diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2009-09-21 08:35:51 -0400 |
---|---|---|
committer | Borislav Petkov <borislav.petkov@amd.com> | 2009-10-07 10:50:50 -0400 |
commit | 9d858bb10a9907bbbaffbb4a80a31718d548868c (patch) | |
tree | 6f5f6a61c171a6f4be7ccb447216757d34c6331b /drivers/edac | |
parent | 2cff18c22cfaa88216a5d8c62ea64d1fb575c145 (diff) |
amd64_edac: fix chip select handling
Different processor families support a different number of chip selects.
Handle this in a family-dependent way with the proper values assigned at
init time (see amd64_set_dct_base_and_mask).
Remove _DCSM_COUNT defines since they're used at one place and originate
from public documentation.
CC: Keith Mannthey <kmannth@us.ibm.com>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/amd64_edac.c | 57 | ||||
-rw-r--r-- | drivers/edac/amd64_edac.h | 15 |
2 files changed, 32 insertions, 40 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index ecc86c300e2b..85c308b1fed7 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -189,7 +189,10 @@ static int amd64_get_scrub_rate(struct mem_ctl_info *mci, u32 *bw) | |||
189 | /* Map from a CSROW entry to the mask entry that operates on it */ | 189 | /* Map from a CSROW entry to the mask entry that operates on it */ |
190 | static inline u32 amd64_map_to_dcs_mask(struct amd64_pvt *pvt, int csrow) | 190 | static inline u32 amd64_map_to_dcs_mask(struct amd64_pvt *pvt, int csrow) |
191 | { | 191 | { |
192 | return csrow >> (pvt->num_dcsm >> 3); | 192 | if (boot_cpu_data.x86 == 0xf && pvt->ext_model < OPTERON_CPU_REV_F) |
193 | return csrow; | ||
194 | else | ||
195 | return csrow >> 1; | ||
193 | } | 196 | } |
194 | 197 | ||
195 | /* return the 'base' address the i'th CS entry of the 'dct' DRAM controller */ | 198 | /* return the 'base' address the i'th CS entry of the 'dct' DRAM controller */ |
@@ -374,7 +377,7 @@ static int input_addr_to_csrow(struct mem_ctl_info *mci, u64 input_addr) | |||
374 | * base/mask register pair, test the condition shown near the start of | 377 | * base/mask register pair, test the condition shown near the start of |
375 | * section 3.5.4 (p. 84, BKDG #26094, K8, revA-E). | 378 | * section 3.5.4 (p. 84, BKDG #26094, K8, revA-E). |
376 | */ | 379 | */ |
377 | for (csrow = 0; csrow < CHIPSELECT_COUNT; csrow++) { | 380 | for (csrow = 0; csrow < pvt->cs_count; csrow++) { |
378 | 381 | ||
379 | /* This DRAM chip select is disabled on this node */ | 382 | /* This DRAM chip select is disabled on this node */ |
380 | if ((pvt->dcsb0[csrow] & K8_DCSB_CS_ENABLE) == 0) | 383 | if ((pvt->dcsb0[csrow] & K8_DCSB_CS_ENABLE) == 0) |
@@ -731,7 +734,7 @@ static void find_csrow_limits(struct mem_ctl_info *mci, int csrow, | |||
731 | u64 base, mask; | 734 | u64 base, mask; |
732 | 735 | ||
733 | pvt = mci->pvt_info; | 736 | pvt = mci->pvt_info; |
734 | BUG_ON((csrow < 0) || (csrow >= CHIPSELECT_COUNT)); | 737 | BUG_ON((csrow < 0) || (csrow >= pvt->cs_count)); |
735 | 738 | ||
736 | base = base_from_dct_base(pvt, csrow); | 739 | base = base_from_dct_base(pvt, csrow); |
737 | mask = mask_from_dct_mask(pvt, csrow); | 740 | mask = mask_from_dct_mask(pvt, csrow); |
@@ -959,35 +962,27 @@ err_reg: | |||
959 | */ | 962 | */ |
960 | static void amd64_set_dct_base_and_mask(struct amd64_pvt *pvt) | 963 | static void amd64_set_dct_base_and_mask(struct amd64_pvt *pvt) |
961 | { | 964 | { |
962 | if (pvt->ext_model >= OPTERON_CPU_REV_F) { | 965 | |
966 | if (boot_cpu_data.x86 == 0xf && pvt->ext_model < OPTERON_CPU_REV_F) { | ||
967 | pvt->dcsb_base = REV_E_DCSB_BASE_BITS; | ||
968 | pvt->dcsm_mask = REV_E_DCSM_MASK_BITS; | ||
969 | pvt->dcs_mask_notused = REV_E_DCS_NOTUSED_BITS; | ||
970 | pvt->dcs_shift = REV_E_DCS_SHIFT; | ||
971 | pvt->cs_count = 8; | ||
972 | pvt->num_dcsm = 8; | ||
973 | } else { | ||
963 | pvt->dcsb_base = REV_F_F1Xh_DCSB_BASE_BITS; | 974 | pvt->dcsb_base = REV_F_F1Xh_DCSB_BASE_BITS; |
964 | pvt->dcsm_mask = REV_F_F1Xh_DCSM_MASK_BITS; | 975 | pvt->dcsm_mask = REV_F_F1Xh_DCSM_MASK_BITS; |
965 | pvt->dcs_mask_notused = REV_F_F1Xh_DCS_NOTUSED_BITS; | 976 | pvt->dcs_mask_notused = REV_F_F1Xh_DCS_NOTUSED_BITS; |
966 | pvt->dcs_shift = REV_F_F1Xh_DCS_SHIFT; | 977 | pvt->dcs_shift = REV_F_F1Xh_DCS_SHIFT; |
967 | 978 | ||
968 | switch (boot_cpu_data.x86) { | 979 | if (boot_cpu_data.x86 == 0x11) { |
969 | case 0xf: | 980 | pvt->cs_count = 4; |
970 | pvt->num_dcsm = REV_F_DCSM_COUNT; | 981 | pvt->num_dcsm = 2; |
971 | break; | 982 | } else { |
972 | 983 | pvt->cs_count = 8; | |
973 | case 0x10: | 984 | pvt->num_dcsm = 4; |
974 | pvt->num_dcsm = F10_DCSM_COUNT; | ||
975 | break; | ||
976 | |||
977 | case 0x11: | ||
978 | pvt->num_dcsm = F11_DCSM_COUNT; | ||
979 | break; | ||
980 | |||
981 | default: | ||
982 | amd64_printk(KERN_ERR, "Unsupported family!\n"); | ||
983 | break; | ||
984 | } | 985 | } |
985 | } else { | ||
986 | pvt->dcsb_base = REV_E_DCSB_BASE_BITS; | ||
987 | pvt->dcsm_mask = REV_E_DCSM_MASK_BITS; | ||
988 | pvt->dcs_mask_notused = REV_E_DCS_NOTUSED_BITS; | ||
989 | pvt->dcs_shift = REV_E_DCS_SHIFT; | ||
990 | pvt->num_dcsm = REV_E_DCSM_COUNT; | ||
991 | } | 986 | } |
992 | } | 987 | } |
993 | 988 | ||
@@ -1000,7 +995,7 @@ static void amd64_read_dct_base_mask(struct amd64_pvt *pvt) | |||
1000 | 995 | ||
1001 | amd64_set_dct_base_and_mask(pvt); | 996 | amd64_set_dct_base_and_mask(pvt); |
1002 | 997 | ||
1003 | for (cs = 0; cs < CHIPSELECT_COUNT; cs++) { | 998 | for (cs = 0; cs < pvt->cs_count; cs++) { |
1004 | reg = K8_DCSB0 + (cs * 4); | 999 | reg = K8_DCSB0 + (cs * 4); |
1005 | err = pci_read_config_dword(pvt->dram_f2_ctl, reg, | 1000 | err = pci_read_config_dword(pvt->dram_f2_ctl, reg, |
1006 | &pvt->dcsb0[cs]); | 1001 | &pvt->dcsb0[cs]); |
@@ -1563,7 +1558,7 @@ static int f10_lookup_addr_in_dct(u32 in_addr, u32 nid, u32 cs) | |||
1563 | 1558 | ||
1564 | debugf1("InputAddr=0x%x channelselect=%d\n", in_addr, cs); | 1559 | debugf1("InputAddr=0x%x channelselect=%d\n", in_addr, cs); |
1565 | 1560 | ||
1566 | for (csrow = 0; csrow < CHIPSELECT_COUNT; csrow++) { | 1561 | for (csrow = 0; csrow < pvt->cs_count; csrow++) { |
1567 | 1562 | ||
1568 | cs_base = amd64_get_dct_base(pvt, cs, csrow); | 1563 | cs_base = amd64_get_dct_base(pvt, cs, csrow); |
1569 | if (!(cs_base & K8_DCSB_CS_ENABLE)) | 1564 | if (!(cs_base & K8_DCSB_CS_ENABLE)) |
@@ -2494,7 +2489,7 @@ err_reg: | |||
2494 | * NOTE: CPU Revision Dependent code | 2489 | * NOTE: CPU Revision Dependent code |
2495 | * | 2490 | * |
2496 | * Input: | 2491 | * Input: |
2497 | * @csrow_nr ChipSelect Row Number (0..CHIPSELECT_COUNT-1) | 2492 | * @csrow_nr ChipSelect Row Number (0..pvt->cs_count-1) |
2498 | * k8 private pointer to --> | 2493 | * k8 private pointer to --> |
2499 | * DRAM Bank Address mapping register | 2494 | * DRAM Bank Address mapping register |
2500 | * node_id | 2495 | * node_id |
@@ -2574,7 +2569,7 @@ static int amd64_init_csrows(struct mem_ctl_info *mci) | |||
2574 | (pvt->nbcfg & K8_NBCFG_ECC_ENABLE) ? "Enabled" : "Disabled" | 2569 | (pvt->nbcfg & K8_NBCFG_ECC_ENABLE) ? "Enabled" : "Disabled" |
2575 | ); | 2570 | ); |
2576 | 2571 | ||
2577 | for (i = 0; i < CHIPSELECT_COUNT; i++) { | 2572 | for (i = 0; i < pvt->cs_count; i++) { |
2578 | csrow = &mci->csrows[i]; | 2573 | csrow = &mci->csrows[i]; |
2579 | 2574 | ||
2580 | if ((pvt->dcsb0[i] & K8_DCSB_CS_ENABLE) == 0) { | 2575 | if ((pvt->dcsb0[i] & K8_DCSB_CS_ENABLE) == 0) { |
@@ -2985,7 +2980,7 @@ static int amd64_init_2nd_stage(struct amd64_pvt *pvt) | |||
2985 | goto err_exit; | 2980 | goto err_exit; |
2986 | 2981 | ||
2987 | ret = -ENOMEM; | 2982 | ret = -ENOMEM; |
2988 | mci = edac_mc_alloc(0, CHIPSELECT_COUNT, pvt->channel_count, node_id); | 2983 | mci = edac_mc_alloc(0, pvt->cs_count, pvt->channel_count, node_id); |
2989 | if (!mci) | 2984 | if (!mci) |
2990 | goto err_exit; | 2985 | goto err_exit; |
2991 | 2986 | ||
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index c3f769e017fa..64193927a05a 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h | |||
@@ -144,7 +144,7 @@ | |||
144 | #define OPTERON_CPU_REV_FA 5 | 144 | #define OPTERON_CPU_REV_FA 5 |
145 | 145 | ||
146 | /* Hardware limit on ChipSelect rows per MC and processors per system */ | 146 | /* Hardware limit on ChipSelect rows per MC and processors per system */ |
147 | #define CHIPSELECT_COUNT 8 | 147 | #define MAX_CS_COUNT 8 |
148 | #define DRAM_REG_COUNT 8 | 148 | #define DRAM_REG_COUNT 8 |
149 | 149 | ||
150 | 150 | ||
@@ -195,7 +195,6 @@ | |||
195 | */ | 195 | */ |
196 | #define REV_E_DCSB_BASE_BITS (0xFFE0FE00ULL) | 196 | #define REV_E_DCSB_BASE_BITS (0xFFE0FE00ULL) |
197 | #define REV_E_DCS_SHIFT 4 | 197 | #define REV_E_DCS_SHIFT 4 |
198 | #define REV_E_DCSM_COUNT 8 | ||
199 | 198 | ||
200 | #define REV_F_F1Xh_DCSB_BASE_BITS (0x1FF83FE0ULL) | 199 | #define REV_F_F1Xh_DCSB_BASE_BITS (0x1FF83FE0ULL) |
201 | #define REV_F_F1Xh_DCS_SHIFT 8 | 200 | #define REV_F_F1Xh_DCS_SHIFT 8 |
@@ -206,9 +205,6 @@ | |||
206 | */ | 205 | */ |
207 | #define REV_F_DCSB_BASE_BITS (0x1FF83FE0ULL) | 206 | #define REV_F_DCSB_BASE_BITS (0x1FF83FE0ULL) |
208 | #define REV_F_DCS_SHIFT 8 | 207 | #define REV_F_DCS_SHIFT 8 |
209 | #define REV_F_DCSM_COUNT 4 | ||
210 | #define F10_DCSM_COUNT 4 | ||
211 | #define F11_DCSM_COUNT 2 | ||
212 | 208 | ||
213 | /* DRAM CS Mask Registers */ | 209 | /* DRAM CS Mask Registers */ |
214 | #define K8_DCSM0 0x60 | 210 | #define K8_DCSM0 0x60 |
@@ -447,12 +443,12 @@ struct amd64_pvt { | |||
447 | u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */ | 443 | u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */ |
448 | 444 | ||
449 | /* DRAM CS Base Address Registers F2x[1,0][5C:40] */ | 445 | /* DRAM CS Base Address Registers F2x[1,0][5C:40] */ |
450 | u32 dcsb0[CHIPSELECT_COUNT]; | 446 | u32 dcsb0[MAX_CS_COUNT]; |
451 | u32 dcsb1[CHIPSELECT_COUNT]; | 447 | u32 dcsb1[MAX_CS_COUNT]; |
452 | 448 | ||
453 | /* DRAM CS Mask Registers F2x[1,0][6C:60] */ | 449 | /* DRAM CS Mask Registers F2x[1,0][6C:60] */ |
454 | u32 dcsm0[CHIPSELECT_COUNT]; | 450 | u32 dcsm0[MAX_CS_COUNT]; |
455 | u32 dcsm1[CHIPSELECT_COUNT]; | 451 | u32 dcsm1[MAX_CS_COUNT]; |
456 | 452 | ||
457 | /* | 453 | /* |
458 | * Decoded parts of DRAM BASE and LIMIT Registers | 454 | * Decoded parts of DRAM BASE and LIMIT Registers |
@@ -472,6 +468,7 @@ struct amd64_pvt { | |||
472 | */ | 468 | */ |
473 | u32 dcsb_base; /* DCSB base bits */ | 469 | u32 dcsb_base; /* DCSB base bits */ |
474 | u32 dcsm_mask; /* DCSM mask bits */ | 470 | u32 dcsm_mask; /* DCSM mask bits */ |
471 | u32 cs_count; /* num chip selects (== num DCSB registers) */ | ||
475 | u32 num_dcsm; /* Number of DCSM registers */ | 472 | u32 num_dcsm; /* Number of DCSM registers */ |
476 | u32 dcs_mask_notused; /* DCSM notused mask bits */ | 473 | u32 dcs_mask_notused; /* DCSM notused mask bits */ |
477 | u32 dcs_shift; /* DCSB and DCSM shift value */ | 474 | u32 dcs_shift; /* DCSB and DCSM shift value */ |