17 #include <linux/module.h>
19 #include <linux/pci.h>
21 #include <linux/slab.h>
23 #include <asm/mmzone.h>
30 #define I5000_REVISION " Ver: 2.0.12"
31 #define EDAC_MOD_STR "i5000_edac"
33 #define i5000_printk(level, fmt, arg...) \
34 edac_printk(level, "i5000", fmt, ##arg)
36 #define i5000_mc_printk(mci, level, fmt, arg...) \
37 edac_mc_chipset_printk(mci, level, "i5000", fmt, ##arg)
39 #ifndef PCI_DEVICE_ID_INTEL_FBD_0
40 #define PCI_DEVICE_ID_INTEL_FBD_0 0x25F5
42 #ifndef PCI_DEVICE_ID_INTEL_FBD_1
43 #define PCI_DEVICE_ID_INTEL_FBD_1 0x25F6
53 #define PCI_DEVICE_ID_INTEL_I5000_DEV16 0x25F0
60 #define MAXDIMMPERCH 0x57
63 #define RED_ECC_LOCATOR(x) ((x) & 0x3FFFF)
64 #define REC_ECC_LOCATOR_EVEN(x) ((x) & 0x001FF)
65 #define REC_ECC_LOCATOR_ODD(x) ((x) & 0x3FE00)
73 #define FERR_FAT_FBD 0x98
74 #define NERR_FAT_FBD 0x9C
75 #define EXTRACT_FBDCHAN_INDX(x) (((x)>>28) & 0x3)
76 #define FERR_FAT_FBDCHAN 0x30000000
77 #define FERR_FAT_M3ERR 0x00000004
78 #define FERR_FAT_M2ERR 0x00000002
79 #define FERR_FAT_M1ERR 0x00000001
80 #define FERR_FAT_MASK (FERR_FAT_M1ERR | \
84 #define FERR_NF_FBD 0xA0
87 #define FERR_NF_M28ERR 0x01000000
88 #define FERR_NF_M27ERR 0x00800000
89 #define FERR_NF_M26ERR 0x00400000
90 #define FERR_NF_M25ERR 0x00200000
91 #define FERR_NF_M24ERR 0x00100000
92 #define FERR_NF_M23ERR 0x00080000
93 #define FERR_NF_M22ERR 0x00040000
94 #define FERR_NF_M21ERR 0x00020000
97 #define FERR_NF_M20ERR 0x00010000
98 #define FERR_NF_M19ERR 0x00008000
99 #define FERR_NF_M18ERR 0x00004000
100 #define FERR_NF_M17ERR 0x00002000
103 #define FERR_NF_M16ERR 0x00001000
104 #define FERR_NF_M15ERR 0x00000800
105 #define FERR_NF_M14ERR 0x00000400
106 #define FERR_NF_M13ERR 0x00000200
109 #define FERR_NF_M12ERR 0x00000100
110 #define FERR_NF_M11ERR 0x00000080
111 #define FERR_NF_M10ERR 0x00000040
112 #define FERR_NF_M9ERR 0x00000020
113 #define FERR_NF_M8ERR 0x00000010
114 #define FERR_NF_M7ERR 0x00000008
115 #define FERR_NF_M6ERR 0x00000004
116 #define FERR_NF_M5ERR 0x00000002
117 #define FERR_NF_M4ERR 0x00000001
119 #define FERR_NF_UNCORRECTABLE (FERR_NF_M12ERR | \
128 #define FERR_NF_CORRECTABLE (FERR_NF_M20ERR | \
132 #define FERR_NF_DIMM_SPARE (FERR_NF_M27ERR | \
134 #define FERR_NF_THERMAL (FERR_NF_M26ERR | \
138 #define FERR_NF_SPD_PROTOCOL (FERR_NF_M22ERR)
139 #define FERR_NF_NORTH_CRC (FERR_NF_M21ERR)
140 #define FERR_NF_NON_RETRY (FERR_NF_M13ERR | \
144 #define NERR_NF_FBD 0xA4
145 #define FERR_NF_MASK (FERR_NF_UNCORRECTABLE | \
146 FERR_NF_CORRECTABLE | \
147 FERR_NF_DIMM_SPARE | \
149 FERR_NF_SPD_PROTOCOL | \
150 FERR_NF_NORTH_CRC | \
153 #define EMASK_FBD 0xA8
154 #define EMASK_FBD_M28ERR 0x08000000
155 #define EMASK_FBD_M27ERR 0x04000000
156 #define EMASK_FBD_M26ERR 0x02000000
157 #define EMASK_FBD_M25ERR 0x01000000
158 #define EMASK_FBD_M24ERR 0x00800000
159 #define EMASK_FBD_M23ERR 0x00400000
160 #define EMASK_FBD_M22ERR 0x00200000
161 #define EMASK_FBD_M21ERR 0x00100000
162 #define EMASK_FBD_M20ERR 0x00080000
163 #define EMASK_FBD_M19ERR 0x00040000
164 #define EMASK_FBD_M18ERR 0x00020000
165 #define EMASK_FBD_M17ERR 0x00010000
167 #define EMASK_FBD_M15ERR 0x00004000
168 #define EMASK_FBD_M14ERR 0x00002000
169 #define EMASK_FBD_M13ERR 0x00001000
170 #define EMASK_FBD_M12ERR 0x00000800
171 #define EMASK_FBD_M11ERR 0x00000400
172 #define EMASK_FBD_M10ERR 0x00000200
173 #define EMASK_FBD_M9ERR 0x00000100
174 #define EMASK_FBD_M8ERR 0x00000080
175 #define EMASK_FBD_M7ERR 0x00000040
176 #define EMASK_FBD_M6ERR 0x00000020
177 #define EMASK_FBD_M5ERR 0x00000010
178 #define EMASK_FBD_M4ERR 0x00000008
179 #define EMASK_FBD_M3ERR 0x00000004
180 #define EMASK_FBD_M2ERR 0x00000002
181 #define EMASK_FBD_M1ERR 0x00000001
183 #define ENABLE_EMASK_FBD_FATAL_ERRORS (EMASK_FBD_M1ERR | \
187 #define ENABLE_EMASK_FBD_UNCORRECTABLE (EMASK_FBD_M4ERR | \
196 #define ENABLE_EMASK_FBD_CORRECTABLE (EMASK_FBD_M17ERR | \
200 #define ENABLE_EMASK_FBD_DIMM_SPARE (EMASK_FBD_M27ERR | \
202 #define ENABLE_EMASK_FBD_THERMALS (EMASK_FBD_M26ERR | \
206 #define ENABLE_EMASK_FBD_SPD_PROTOCOL (EMASK_FBD_M22ERR)
207 #define ENABLE_EMASK_FBD_NORTH_CRC (EMASK_FBD_M21ERR)
208 #define ENABLE_EMASK_FBD_NON_RETRY (EMASK_FBD_M15ERR | \
212 #define ENABLE_EMASK_ALL (ENABLE_EMASK_FBD_NON_RETRY | \
213 ENABLE_EMASK_FBD_NORTH_CRC | \
214 ENABLE_EMASK_FBD_SPD_PROTOCOL | \
215 ENABLE_EMASK_FBD_THERMALS | \
216 ENABLE_EMASK_FBD_DIMM_SPARE | \
217 ENABLE_EMASK_FBD_FATAL_ERRORS | \
218 ENABLE_EMASK_FBD_CORRECTABLE | \
219 ENABLE_EMASK_FBD_UNCORRECTABLE)
221 #define ERR0_FBD 0xAC
222 #define ERR1_FBD 0xB0
223 #define ERR2_FBD 0xB4
224 #define MCERR_FBD 0xB8
225 #define NRECMEMA 0xBE
226 #define NREC_BANK(x) (((x)>>12) & 0x7)
227 #define NREC_RDWR(x) (((x)>>11) & 1)
228 #define NREC_RANK(x) (((x)>>8) & 0x7)
229 #define NRECMEMB 0xC0
230 #define NREC_CAS(x) (((x)>>16) & 0xFFFFFF)
231 #define NREC_RAS(x) ((x) & 0x7FFF)
232 #define NRECFGLOG 0xC4
233 #define NREEECFBDA 0xC8
234 #define NREEECFBDB 0xCC
235 #define NREEECFBDC 0xD0
236 #define NREEECFBDD 0xD4
237 #define NREEECFBDE 0xD8
240 #define REC_BANK(x) (((x)>>12) & 0x7)
241 #define REC_RDWR(x) (((x)>>11) & 1)
242 #define REC_RANK(x) (((x)>>8) & 0x7)
244 #define REC_CAS(x) (((x)>>16) & 0xFFFFFF)
245 #define REC_RAS(x) ((x) & 0x7FFF)
246 #define RECFGLOG 0xE8
262 #define PCI_DEVICE_ID_I5000_BRANCH_0 0x25F5
263 #define PCI_DEVICE_ID_I5000_BRANCH_1 0x25F6
265 #define AMB_PRESENT_0 0x64
266 #define AMB_PRESENT_1 0x66
273 #define CHANNELS_PER_BRANCH 2
274 #define MAX_BRANCHES 2
279 #define MTR_DIMMS_PRESENT(mtr) ((mtr) & (0x1 << 8))
280 #define MTR_DRAM_WIDTH(mtr) ((((mtr) >> 6) & 0x1) ? 8 : 4)
281 #define MTR_DRAM_BANKS(mtr) ((((mtr) >> 5) & 0x1) ? 8 : 4)
282 #define MTR_DRAM_BANKS_ADDR_BITS(mtr) ((MTR_DRAM_BANKS(mtr) == 8) ? 3 : 2)
283 #define MTR_DIMM_RANK(mtr) (((mtr) >> 4) & 0x1)
284 #define MTR_DIMM_RANK_ADDR_BITS(mtr) (MTR_DIMM_RANK(mtr) ? 2 : 1)
285 #define MTR_DIMM_ROWS(mtr) (((mtr) >> 2) & 0x3)
286 #define MTR_DIMM_ROWS_ADDR_BITS(mtr) (MTR_DIMM_ROWS(mtr) + 13)
287 #define MTR_DIMM_COLS(mtr) ((mtr) & 0x3)
288 #define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10)
291 static int misc_messages;
319 #define MAX_CHANNELS 6
320 #define MAX_CSROWS (8*2)
378 static struct edac_pci_ctl_info *i5000_pci;
460 static void i5000_process_fatal_error_info(
struct mem_ctl_info *mci,
465 char *specific =
NULL;
487 edac_dbg(0,
"\t\tCSROW= %d Channel= %d (DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
489 rdwr ?
"Write" :
"Read", ras, cas);
494 specific =
"Alert on non-redundant retry or fast "
498 specific =
"Northbound CRC error on non-redundant "
516 specific =
">Tmid Thermal event with intelligent "
517 "throttling disabled";
524 "Bank=%d RAS=%d CAS=%d FATAL Err=0x%x (%s)",
525 bank, ras, cas, allErrors, specific);
529 channel >> 1, channel & 1, rank,
530 rdwr ?
"Write error" :
"Read error",
541 static void i5000_process_nonfatal_error_info(
struct mem_ctl_info *mci,
546 char *specific =
NULL;
566 edac_dbg(0,
"\tUncorrected bits= 0x%x\n", ue_errors);
574 channel = branch & 2;
582 edac_dbg(0,
"\t\tCSROW= %d Channels= %d,%d (Branch= %d DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
583 rank, channel, channel + 1, branch >> 1, bank,
584 rdwr ?
"Write" :
"Read", ras, cas);
588 specific =
"Non-Aliased Uncorrectable Patrol Data ECC";
591 specific =
"Non-Aliased Uncorrectable Spare-Copy "
595 specific =
"Non-Aliased Uncorrectable Mirrored Demand "
599 specific =
"Non-Aliased Uncorrectable Non-Mirrored "
603 specific =
"Aliased Uncorrectable Patrol Data ECC";
606 specific =
"Aliased Uncorrectable Spare-Copy Data ECC";
609 specific =
"Aliased Uncorrectable Mirrored Demand "
613 specific =
"Aliased Uncorrectable Non-Mirrored Demand "
617 specific =
"Uncorrectable Data ECC on Replay";
623 "Rank=%d Bank=%d RAS=%d CAS=%d, UE Err=0x%x (%s)",
624 rank, bank, ras, cas, ue_errors, specific);
628 channel >> 1, -1, rank,
629 rdwr ?
"Write error" :
"Read error",
636 edac_dbg(0,
"\tCorrected bits= 0x%x\n", ce_errors);
654 edac_dbg(0,
"\t\tCSROW= %d Channel= %d (Branch %d DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
655 rank, channel, branch >> 1, bank,
656 rdwr ?
"Write" :
"Read", ras, cas);
660 specific =
"Correctable Non-Mirrored Demand Data ECC";
663 specific =
"Correctable Mirrored Demand Data ECC";
666 specific =
"Correctable Spare-Copy Data ECC";
669 specific =
"Correctable Patrol Data ECC";
675 "Rank=%d Bank=%d RDWR=%s RAS=%d "
676 "CAS=%d, CE Err=0x%x (%s))", branch >> 1, bank,
677 rdwr ?
"Write" :
"Read", ras, cas, ce_errors,
682 channel >> 1, channel % 2, rank,
683 rdwr ?
"Write error" :
"Read error",
693 switch (misc_errors) {
695 specific =
"Non-Retry or Redundant Retry FBD Memory "
696 "Alert or Redundant Fast Reset Timeout";
699 specific =
"Non-Retry or Redundant Retry FBD "
700 "Configuration Alert";
703 specific =
"Non-Retry or Redundant Retry FBD "
704 "Northbound CRC error on read data";
707 specific =
"FBD Northbound CRC error on "
711 specific =
"SPD protocol error";
714 specific =
"DIMM-spare copy started";
717 specific =
"DIMM-spare copy completed";
724 "Err=%#x (%s)", misc_errors, specific);
737 static void i5000_process_error_info(
struct mem_ctl_info *mci,
742 i5000_process_fatal_error_info(mci, info, handle_errors);
745 i5000_process_nonfatal_error_info(mci, info, handle_errors);
758 i5000_get_error_info(mci, &info);
769 i5000_get_error_info(mci, &info);
770 i5000_process_error_info(mci, &info, 1);
779 static int i5000_get_devices(
struct mem_ctl_info *mci,
int dev_idx)
796 "'system address,Process Bus' "
798 "vendor 0x%x device 0x%x FUNC 1 "
821 "MC: 'branchmap,control,errors' "
823 "vendor 0x%x device 0x%x Func 2 "
839 edac_dbg(1,
"System Address, processor bus- PCI Bus ID: %s %x:%x\n",
842 edac_dbg(1,
"Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
846 edac_dbg(1,
"FSB Error Regs - PCI Bus ID: %s %x:%x\n",
856 "MC: 'BRANCH 0' device not found:"
857 "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n",
877 "MC: 'BRANCH 1' device not found:"
878 "vendor 0x%x device 0x%x Func 0 "
927 static int determine_amb_present_reg(
struct i5000_pvt *pvt,
int channel)
951 static int determine_mtr(
struct i5000_pvt *pvt,
int slot,
int channel)
965 static void decode_mtr(
int slot_row,
u16 mtr)
971 edac_dbg(2,
"\tMTR%d=0x%x: DIMMs are %sPresent\n",
972 slot_row, mtr, ans ?
"" :
"NOT ");
992 static void handle_channel(
struct i5000_pvt *pvt,
int slot,
int channel,
999 mtr = determine_mtr(pvt, slot, channel);
1001 amb_present_reg = determine_amb_present_reg(pvt, channel);
1004 if (amb_present_reg) {
1034 static void calculate_dimm_size(
struct i5000_pvt *pvt)
1038 char *
p, *mem_buffer;
1046 __FILE__, __func__);
1055 for (slot = pvt->
maxdimmperch - 1; slot >= 0; slot--) {
1060 n =
snprintf(p, space,
"--------------------------"
1061 "--------------------------------");
1068 n =
snprintf(p, space,
"slot %2d ", slot);
1072 for (channel = 0; channel < pvt->
maxch; channel++) {
1074 handle_channel(pvt, slot, channel, dinfo);
1076 n =
snprintf(p, space,
"%4d MB %dR| ",
1079 n =
snprintf(p, space,
"%4d MB | ", 0);
1091 n =
snprintf(p, space,
"--------------------------"
1092 "--------------------------------");
1103 for (channel = 0; channel < pvt->
maxch; channel++) {
1104 n =
snprintf(p, space,
"channel %d | ", channel);
1115 n =
snprintf(p, space,
" branch %d | ", branch);
1131 static void i5000_get_mc_regs(
struct mem_ctl_info *mci)
1151 edac_dbg(2,
"AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n",
1157 edac_dbg(2,
"TOLM (number of 256M regions) =%u (0x%x)\n",
1160 actual_tolm = pvt->
tolm << 28;
1161 edac_dbg(2,
"Actual TOLM byte addr=%u (0x%x)\n",
1162 actual_tolm, actual_tolm);
1169 limit = (pvt->
mir0 >> 4) & 0x0FFF;
1170 way0 = pvt->
mir0 & 0x1;
1171 way1 = pvt->
mir0 & 0x2;
1172 edac_dbg(2,
"MIR0: limit= 0x%x WAY1= %u WAY0= %x\n",
1174 limit = (pvt->
mir1 >> 4) & 0x0FFF;
1175 way0 = pvt->
mir1 & 0x1;
1176 way1 = pvt->
mir1 & 0x2;
1177 edac_dbg(2,
"MIR1: limit= 0x%x WAY1= %u WAY0= %x\n",
1179 limit = (pvt->
mir2 >> 4) & 0x0FFF;
1180 way0 = pvt->
mir2 & 0x1;
1181 way1 = pvt->
mir2 & 0x2;
1182 edac_dbg(2,
"MIR2: limit= 0x%x WAY1= %u WAY0= %x\n",
1186 for (slot_row = 0; slot_row <
NUM_MTRS; slot_row++) {
1187 int where =
MTR0 + (slot_row *
sizeof(
u32));
1189 pci_read_config_word(pvt->
branch_0, where,
1192 edac_dbg(2,
"MTR%d where=0x%x B0 value=0x%x\n",
1193 slot_row, where, pvt->
b0_mtr[slot_row]);
1196 pci_read_config_word(pvt->
branch_1, where,
1198 edac_dbg(2,
"MTR%d where=0x%x B1 value=0x%x\n",
1199 slot_row, where, pvt->
b1_mtr[slot_row]);
1201 pvt->
b1_mtr[slot_row] = 0;
1206 edac_dbg(2,
"Memory Technology Registers:\n");
1208 for (slot_row = 0; slot_row <
NUM_MTRS; slot_row++) {
1209 decode_mtr(slot_row, pvt->
b0_mtr[slot_row]);
1225 for (slot_row = 0; slot_row <
NUM_MTRS; slot_row++) {
1226 decode_mtr(slot_row, pvt->
b1_mtr[slot_row]);
1230 edac_dbg(2,
"\t\tAMB-Branch 1-present0 0x%x:\n",
1234 edac_dbg(2,
"\t\tAMB-Branch 1-present1 0x%x:\n",
1240 calculate_dimm_size(pvt);
1265 channel_count = pvt->
maxch;
1277 for (slot = 0; slot < max_csrows; slot++) {
1278 for (channel = 0; channel < pvt->
maxch; channel++) {
1280 mtr = determine_mtr(pvt, slot, channel);
1315 static void i5000_enable_error_reporting(
struct mem_ctl_info *mci)
1339 static void i5000_get_dimm_and_channel_counts(
struct pci_dev *pdev,
1340 int *num_dimms_per_channel,
1349 *num_dimms_per_channel = (
int)value;
1351 pci_read_config_byte(pdev,
MAXCH, &value);
1352 *num_channels = (
int)value;
1362 static int i5000_probe1(
struct pci_dev *pdev,
int dev_idx)
1368 int num_dimms_per_channel;
1370 edac_dbg(0,
"MC: pdev bus %u dev=0x%x fn=0x%x\n",
1391 i5000_get_dimm_and_channel_counts(pdev, &num_dimms_per_channel,
1394 edac_dbg(0,
"MC: Number of Branches=2 Channels= %d DIMMS= %d\n",
1395 num_channels, num_dimms_per_channel);
1401 layers[0].is_virt_csrow =
false;
1404 layers[1].is_virt_csrow =
false;
1406 layers[2].size = num_dimms_per_channel;
1407 layers[2].is_virt_csrow =
true;
1412 edac_dbg(0,
"MC: mci = %p\n", mci);
1422 if (i5000_get_devices(mci, dev_idx))
1426 i5000_get_mc_regs(mci);
1443 if (i5000_init_csrows(mci)) {
1444 edac_dbg(0,
"MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i5000_init_csrows() returned nonzero value\n");
1447 edac_dbg(1,
"MC: Enable error reporting now\n");
1448 i5000_enable_error_reporting(mci);
1453 edac_dbg(0,
"MC: failed edac_mc_add_mc()\n");
1460 i5000_clear_error(mci);
1466 "%s(): Unable to create PCI control\n",
1469 "%s(): PCI error report via EDAC not setup\n",
1478 i5000_put_devices(mci);
1525 i5000_put_devices(mci);
1548 .name = KBUILD_BASENAME,
1549 .probe = i5000_init_one,
1551 .id_table = i5000_pci_tbl,
1558 static int __init i5000_init(
void)
1567 pci_rc = pci_register_driver(&i5000_driver);
1569 return (pci_rc < 0) ? pci_rc : 0;
1576 static void __exit i5000_exit(
void)