aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-11-11 11:29:13 -0500
committerBorislav Petkov <borislav.petkov@amd.com>2011-03-17 09:46:12 -0400
commitbc21fa578742924aa129a493657f797c13d34ad2 (patch)
tree8a1803ed8a9d045e291af441e400d9811a490ad4
parent7f19bf755ced6fa16dbf118c0eff60586760496b (diff)
amd64_edac: Cleanup DHAR handling
Adjust to F15h, simplify code, fixup macros. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
-rw-r--r--drivers/edac/amd64_edac.c36
-rw-r--r--drivers/edac/amd64_edac.h11
2 files changed, 23 insertions, 24 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 683fd3c716a0..62b4ae9eb337 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -487,9 +487,9 @@ int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
487 return 1; 487 return 1;
488 } 488 }
489 489
490 /* only valid for Fam10h */ 490 /* valid for Fam10h and above */
491 if (boot_cpu_data.x86 == 0x10 && 491 if (boot_cpu_data.x86 >= 0x10 &&
492 (pvt->dhar & F10_DRAM_MEM_HOIST_VALID) == 0) { 492 (pvt->dhar & DRAM_MEM_HOIST_VALID) == 0) {
493 debugf1(" Dram Memory Hoisting is DISABLED on this system\n"); 493 debugf1(" Dram Memory Hoisting is DISABLED on this system\n");
494 return 1; 494 return 1;
495 } 495 }
@@ -518,15 +518,15 @@ int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
518 * addresses in the hole so that they start at 0x100000000. 518 * addresses in the hole so that they start at 0x100000000.
519 */ 519 */
520 520
521 base = dhar_base(pvt->dhar); 521 base = dhar_base(pvt);
522 522
523 *hole_base = base; 523 *hole_base = base;
524 *hole_size = (0x1ull << 32) - base; 524 *hole_size = (0x1ull << 32) - base;
525 525
526 if (boot_cpu_data.x86 > 0xf) 526 if (boot_cpu_data.x86 > 0xf)
527 *hole_offset = f10_dhar_offset(pvt->dhar); 527 *hole_offset = f10_dhar_offset(pvt);
528 else 528 else
529 *hole_offset = k8_dhar_offset(pvt->dhar); 529 *hole_offset = k8_dhar_offset(pvt);
530 530
531 debugf1(" DHAR info for node %d base 0x%lx offset 0x%lx size 0x%lx\n", 531 debugf1(" DHAR info for node %d base 0x%lx offset 0x%lx size 0x%lx\n",
532 pvt->mc_node_id, (unsigned long)*hole_base, 532 pvt->mc_node_id, (unsigned long)*hole_base,
@@ -884,10 +884,9 @@ static void dump_misc_regs(struct amd64_pvt *pvt)
884 884
885 debugf1("F1xF0 (DRAM Hole Address): 0x%08x, base: 0x%08x, " 885 debugf1("F1xF0 (DRAM Hole Address): 0x%08x, base: 0x%08x, "
886 "offset: 0x%08x\n", 886 "offset: 0x%08x\n",
887 pvt->dhar, 887 pvt->dhar, dhar_base(pvt),
888 dhar_base(pvt->dhar), 888 (boot_cpu_data.x86 == 0xf) ? k8_dhar_offset(pvt)
889 (boot_cpu_data.x86 == 0xf) ? k8_dhar_offset(pvt->dhar) 889 : f10_dhar_offset(pvt));
890 : f10_dhar_offset(pvt->dhar));
891 890
892 debugf1(" DramHoleValid: %s\n", 891 debugf1(" DramHoleValid: %s\n",
893 (pvt->dhar & DHAR_VALID) ? "yes" : "no"); 892 (pvt->dhar & DHAR_VALID) ? "yes" : "no");
@@ -1316,7 +1315,7 @@ static inline u32 f10_map_intlv_en_to_shift(u32 intlv_en)
1316static inline u64 f10_get_base_addr_offset(u64 sys_addr, int hi_range_sel, 1315static inline u64 f10_get_base_addr_offset(u64 sys_addr, int hi_range_sel,
1317 u32 dct_sel_base_addr, 1316 u32 dct_sel_base_addr,
1318 u64 dct_sel_base_off, 1317 u64 dct_sel_base_off,
1319 u32 hole_valid, u32 hole_off, 1318 u32 hole_valid, u64 hole_off,
1320 u64 dram_base) 1319 u64 dram_base)
1321{ 1320{
1322 u64 chan_off; 1321 u64 chan_off;
@@ -1324,12 +1323,12 @@ static inline u64 f10_get_base_addr_offset(u64 sys_addr, int hi_range_sel,
1324 if (hi_range_sel) { 1323 if (hi_range_sel) {
1325 if (!(dct_sel_base_addr & 0xFFFF0000) && 1324 if (!(dct_sel_base_addr & 0xFFFF0000) &&
1326 hole_valid && (sys_addr >= 0x100000000ULL)) 1325 hole_valid && (sys_addr >= 0x100000000ULL))
1327 chan_off = hole_off << 16; 1326 chan_off = hole_off;
1328 else 1327 else
1329 chan_off = dct_sel_base_off; 1328 chan_off = dct_sel_base_off;
1330 } else { 1329 } else {
1331 if (hole_valid && (sys_addr >= 0x100000000ULL)) 1330 if (hole_valid && (sys_addr >= 0x100000000ULL))
1332 chan_off = hole_off << 16; 1331 chan_off = hole_off;
1333 else 1332 else
1334 chan_off = dram_base & 0xFFFFF8000000ULL; 1333 chan_off = dram_base & 0xFFFFF8000000ULL;
1335 } 1334 }
@@ -1435,7 +1434,8 @@ static int f10_match_to_this_node(struct amd64_pvt *pvt, int range,
1435 u64 sys_addr, int *nid, int *chan_sel) 1434 u64 sys_addr, int *nid, int *chan_sel)
1436{ 1435{
1437 int cs_found = -EINVAL, high_range = 0; 1436 int cs_found = -EINVAL, high_range = 0;
1438 u32 intlv_shift, hole_off; 1437 u32 intlv_shift;
1438 u64 hole_off;
1439 u32 hole_valid, tmp, dct_sel_base, channel; 1439 u32 hole_valid, tmp, dct_sel_base, channel;
1440 u64 chan_addr, dct_sel_base_off; 1440 u64 chan_addr, dct_sel_base_off;
1441 1441
@@ -1451,11 +1451,11 @@ static int f10_match_to_this_node(struct amd64_pvt *pvt, int range,
1451 * This assumes that one node's DHAR is the same as all the other 1451 * This assumes that one node's DHAR is the same as all the other
1452 * nodes' DHAR. 1452 * nodes' DHAR.
1453 */ 1453 */
1454 hole_off = (pvt->dhar & 0x0000FF80); 1454 hole_off = f10_dhar_offset(pvt);
1455 hole_valid = (pvt->dhar & 0x1); 1455 hole_valid = (pvt->dhar & DHAR_VALID);
1456 dct_sel_base_off = (pvt->dct_sel_hi & 0xFFFFFC00) << 16; 1456 dct_sel_base_off = (pvt->dct_sel_hi & 0xFFFFFC00) << 16;
1457 1457
1458 debugf1(" HoleOffset=0x%x HoleValid=0x%x IntlvSel=0x%x\n", 1458 debugf1(" HoleOffset=0x%016llx HoleValid=%d IntlvSel=0x%x\n",
1459 hole_off, hole_valid, intlv_sel); 1459 hole_off, hole_valid, intlv_sel);
1460 1460
1461 if (intlv_en && 1461 if (intlv_en &&
@@ -2051,7 +2051,7 @@ static void read_mc_regs(struct amd64_pvt *pvt)
2051 2051
2052 read_dct_base_mask(pvt); 2052 read_dct_base_mask(pvt);
2053 2053
2054 amd64_read_pci_cfg(pvt->F1, K8_DHAR, &pvt->dhar); 2054 amd64_read_pci_cfg(pvt->F1, DHAR, &pvt->dhar);
2055 amd64_read_dbam_reg(pvt); 2055 amd64_read_dbam_reg(pvt);
2056 2056
2057 amd64_read_pci_cfg(pvt->F3, F10_ONLINE_SPARE, &pvt->online_spare); 2057 amd64_read_pci_cfg(pvt->F3, F10_ONLINE_SPARE, &pvt->online_spare);
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 93af3575e427..a2bc9a650fff 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -175,20 +175,19 @@
175#define dram_intlv_sel(pvt, i) ((pvt->ranges[i].lim.lo >> 8) & 0x7) 175#define dram_intlv_sel(pvt, i) ((pvt->ranges[i].lim.lo >> 8) & 0x7)
176#define dram_dst_node(pvt, i) (pvt->ranges[i].lim.lo & 0x7) 176#define dram_dst_node(pvt, i) (pvt->ranges[i].lim.lo & 0x7)
177 177
178#define K8_DHAR 0xf0 178#define DHAR 0xf0
179
180#define DHAR_VALID BIT(0) 179#define DHAR_VALID BIT(0)
181#define F10_DRAM_MEM_HOIST_VALID BIT(1) 180#define DRAM_MEM_HOIST_VALID BIT(1)
182 181
183#define DHAR_BASE_MASK 0xff000000 182#define DHAR_BASE_MASK 0xff000000
184#define dhar_base(dhar) (dhar & DHAR_BASE_MASK) 183#define dhar_base(pvt) ((pvt)->dhar & DHAR_BASE_MASK)
185 184
186#define K8_DHAR_OFFSET_MASK 0x0000ff00 185#define K8_DHAR_OFFSET_MASK 0x0000ff00
187#define k8_dhar_offset(dhar) ((dhar & K8_DHAR_OFFSET_MASK) << 16) 186#define k8_dhar_offset(pvt) (((pvt)->dhar & K8_DHAR_OFFSET_MASK) << 16)
188 187
189#define F10_DHAR_OFFSET_MASK 0x0000ff80 188#define F10_DHAR_OFFSET_MASK 0x0000ff80
190 /* NOTE: Extra mask bit vs K8 */ 189 /* NOTE: Extra mask bit vs K8 */
191#define f10_dhar_offset(dhar) ((dhar & F10_DHAR_OFFSET_MASK) << 16) 190#define f10_dhar_offset(pvt) (((pvt)->dhar & F10_DHAR_OFFSET_MASK) << 16)
192 191
193#define DCT_CFG_SEL 0x10C 192#define DCT_CFG_SEL 0x10C
194 193