Skip to content

Commit 73ba859

Browse files
author
Borislav Petkov
committed
amd64_edac: Add a fix for Erratum 505
When accessing the scrub rate control register (F3x58) on F15h, the DRAM controller selector (F1x10C[DctCfgSel]) has to point to DCT0 so that the scrub rate configuration can take effect. See Erratum 505 in the AMD F15h revision guide for more details. Signed-off-by: Borislav Petkov <[email protected]>
1 parent b0b07a2 commit 73ba859

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

drivers/edac/amd64_edac.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,30 @@ static int f10_read_dct_pci_cfg(struct amd64_pvt *pvt, int addr, u32 *val,
114114
return __amd64_read_pci_cfg_dword(pvt->F2, addr, val, func);
115115
}
116116

117+
/*
118+
* Select DCT to which PCI cfg accesses are routed
119+
*/
120+
static void f15h_select_dct(struct amd64_pvt *pvt, u8 dct)
121+
{
122+
u32 reg = 0;
123+
124+
amd64_read_pci_cfg(pvt->F1, DCT_CFG_SEL, &reg);
125+
reg &= 0xfffffffe;
126+
reg |= dct;
127+
amd64_write_pci_cfg(pvt->F1, DCT_CFG_SEL, reg);
128+
}
129+
117130
static int f15_read_dct_pci_cfg(struct amd64_pvt *pvt, int addr, u32 *val,
118131
const char *func)
119132
{
120-
u32 reg = 0;
121133
u8 dct = 0;
122134

123135
if (addr >= 0x140 && addr <= 0x1a0) {
124136
dct = 1;
125137
addr -= 0x100;
126138
}
127139

128-
amd64_read_pci_cfg(pvt->F1, DCT_CFG_SEL, &reg);
129-
reg &= 0xfffffffe;
130-
reg |= dct;
131-
amd64_write_pci_cfg(pvt->F1, DCT_CFG_SEL, reg);
140+
f15h_select_dct(pvt, dct);
132141

133142
return __amd64_read_pci_cfg_dword(pvt->F2, addr, val, func);
134143
}
@@ -198,6 +207,10 @@ static int amd64_set_scrub_rate(struct mem_ctl_info *mci, u32 bw)
198207
if (boot_cpu_data.x86 == 0xf)
199208
min_scrubrate = 0x0;
200209

210+
/* F15h Erratum #505 */
211+
if (boot_cpu_data.x86 == 0x15)
212+
f15h_select_dct(pvt, 0);
213+
201214
return __amd64_set_scrub_rate(pvt->F3, bw, min_scrubrate);
202215
}
203216

@@ -207,6 +220,10 @@ static int amd64_get_scrub_rate(struct mem_ctl_info *mci)
207220
u32 scrubval = 0;
208221
int i, retval = -EINVAL;
209222

223+
/* F15h Erratum #505 */
224+
if (boot_cpu_data.x86 == 0x15)
225+
f15h_select_dct(pvt, 0);
226+
210227
amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval);
211228

212229
scrubval = scrubval & 0x001F;

0 commit comments

Comments
 (0)