Skip to content

Commit f08e457

Browse files
author
Borislav Petkov
committed
amd64_edac: Factor in CC6 save area
F15h and later use a portion of DRAM as a CC6 storage area. BIOS programs D18F1x[17C:140,7C:40] DRAM Base/Limit accordingly by subtracting the storage area from the DRAM limit setting. However, in order for edac to consider that part of DRAM too, we need to include it into the per-node range. Signed-off-by: Borislav Petkov <[email protected]>
1 parent f030ddf commit f08e457

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

drivers/edac/amd64_edac.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,19 +944,45 @@ static u64 get_error_address(struct mce *m)
944944

945945
static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range)
946946
{
947+
struct cpuinfo_x86 *c = &boot_cpu_data;
947948
int off = range << 3;
948949

949950
amd64_read_pci_cfg(pvt->F1, DRAM_BASE_LO + off, &pvt->ranges[range].base.lo);
950951
amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_LO + off, &pvt->ranges[range].lim.lo);
951952

952-
if (boot_cpu_data.x86 == 0xf)
953+
if (c->x86 == 0xf)
953954
return;
954955

955956
if (!dram_rw(pvt, range))
956957
return;
957958

958959
amd64_read_pci_cfg(pvt->F1, DRAM_BASE_HI + off, &pvt->ranges[range].base.hi);
959960
amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_HI + off, &pvt->ranges[range].lim.hi);
961+
962+
/* Factor in CC6 save area by reading dst node's limit reg */
963+
if (c->x86 == 0x15) {
964+
struct pci_dev *f1 = NULL;
965+
u8 nid = dram_dst_node(pvt, range);
966+
u32 llim;
967+
968+
f1 = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0x18 + nid, 1));
969+
if (WARN_ON(!f1))
970+
return;
971+
972+
amd64_read_pci_cfg(f1, DRAM_LOCAL_NODE_LIM, &llim);
973+
974+
pvt->ranges[range].lim.lo &= GENMASK(0, 15);
975+
976+
/* {[39:27],111b} */
977+
pvt->ranges[range].lim.lo |= ((llim & 0x1fff) << 3 | 0x7) << 16;
978+
979+
pvt->ranges[range].lim.hi &= GENMASK(0, 7);
980+
981+
/* [47:40] */
982+
pvt->ranges[range].lim.hi |= llim >> 13;
983+
984+
pci_dev_put(f1);
985+
}
960986
}
961987

962988
static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,

drivers/edac/amd64_edac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@
196196

197197
#define DCT_CFG_SEL 0x10C
198198

199+
#define DRAM_LOCAL_NODE_LIM 0x124
200+
199201
#define DRAM_BASE_HI 0x140
200202
#define DRAM_LIMIT_HI 0x144
201203

0 commit comments

Comments
 (0)