22 #include <linux/module.h>
24 #include <linux/pci.h>
29 #define E752X_REVISION " Ver: 2.0.2"
30 #define EDAC_MOD_STR "e752x_edac"
32 static int report_non_memory_errors;
33 static int force_function_unhide;
34 static int sysbus_parity = -1;
36 static struct edac_pci_ctl_info *e752x_pci;
38 #define e752x_printk(level, fmt, arg...) \
39 edac_printk(level, "e752x", fmt, ##arg)
41 #define e752x_mc_printk(mci, level, fmt, arg...) \
42 edac_mc_chipset_printk(mci, level, "e752x", fmt, ##arg)
44 #ifndef PCI_DEVICE_ID_INTEL_7520_0
45 #define PCI_DEVICE_ID_INTEL_7520_0 0x3590
48 #ifndef PCI_DEVICE_ID_INTEL_7520_1_ERR
49 #define PCI_DEVICE_ID_INTEL_7520_1_ERR 0x3591
52 #ifndef PCI_DEVICE_ID_INTEL_7525_0
53 #define PCI_DEVICE_ID_INTEL_7525_0 0x359E
56 #ifndef PCI_DEVICE_ID_INTEL_7525_1_ERR
57 #define PCI_DEVICE_ID_INTEL_7525_1_ERR 0x3593
60 #ifndef PCI_DEVICE_ID_INTEL_7320_0
61 #define PCI_DEVICE_ID_INTEL_7320_0 0x3592
64 #ifndef PCI_DEVICE_ID_INTEL_7320_1_ERR
65 #define PCI_DEVICE_ID_INTEL_7320_1_ERR 0x3593
68 #ifndef PCI_DEVICE_ID_INTEL_3100_0
69 #define PCI_DEVICE_ID_INTEL_3100_0 0x35B0
72 #ifndef PCI_DEVICE_ID_INTEL_3100_1_ERR
73 #define PCI_DEVICE_ID_INTEL_3100_1_ERR 0x35B1
76 #define E752X_NR_CSROWS 8
79 #define E752X_MCHSCRB 0x52
87 #define E752X_DRB 0x60
88 #define E752X_DRA 0x70
100 #define E752X_DRC 0x7C
106 #define E752X_DRM 0x80
107 #define E752X_DDRCSR 0x9A
111 #define E752X_TOLM 0xC4
112 #define E752X_REMAPBASE 0xC6
113 #define E752X_REMAPLIMIT 0xC8
114 #define E752X_REMAPOFFSET 0xCA
117 #define E752X_FERR_GLOBAL 0x40
118 #define E752X_NERR_GLOBAL 0x44
119 #define E752X_HI_FERR 0x50
120 #define E752X_HI_NERR 0x52
121 #define E752X_HI_ERRMASK 0x54
122 #define E752X_HI_SMICMD 0x5A
123 #define E752X_SYSBUS_FERR 0x60
124 #define E752X_SYSBUS_NERR 0x62
125 #define E752X_SYSBUS_ERRMASK 0x64
126 #define E752X_SYSBUS_SMICMD 0x6A
127 #define E752X_BUF_FERR 0x70
128 #define E752X_BUF_NERR 0x72
129 #define E752X_BUF_ERRMASK 0x74
130 #define E752X_BUF_SMICMD 0x7A
131 #define E752X_DRAM_FERR 0x80
132 #define E752X_DRAM_NERR 0x82
133 #define E752X_DRAM_ERRMASK 0x84
134 #define E752X_DRAM_SMICMD 0x8A
135 #define E752X_DRAM_RETR_ADD 0xAC
136 #define E752X_DRAM_SEC1_ADD 0xA0
144 #define E752X_DRAM_SEC2_ADD 0xC8
152 #define E752X_DRAM_DED_ADD 0xA4
160 #define E752X_DRAM_SCRB_ADD 0xA8
168 #define E752X_DRAM_SEC1_SYNDROME 0xC4
170 #define E752X_DRAM_SEC2_SYNDROME 0xC6
172 #define E752X_DEVPRES1 0xF4
175 #define I3100_NSI_FERR 0x48
176 #define I3100_NSI_NERR 0x4C
177 #define I3100_NSI_SMICMD 0x54
178 #define I3100_NSI_EMASK 0x90
181 #define ICH5R_PCI_STAT 0x06
182 #define ICH5R_PCI_2ND_STAT 0x1E
183 #define ICH5R_PCI_BRIDGE_CTL 0x3E
256 .ctl_name =
"E7520"},
260 .ctl_name =
"E7525"},
264 .ctl_name =
"E7320"},
278 #define SDRATE_EOT 0xFFFFFFFF
290 static const struct scrubrate scrubrates_e752x[] = {
299 static const struct scrubrate scrubrates_i3100[] = {
317 if ((page >= 0x100000) && (page < pvt->
remapbase))
326 return pvt->
tolm - 1;
330 u32 sec1_add,
u16 sec1_syndrome)
346 row = ((page >> 1) & 3);
348 "Test row %d Table %d %d %d %d %d %d %d %d\n", row,
354 for (i = 0; i < 8; i++) {
355 if (pvt->
map[i] == row)
365 "row %d not found in remap table\n",
371 channel = !(error_one & 1);
381 u32 sec1_add,
u16 sec1_syndrome,
int *error_found,
387 do_process_ce(mci, error_one, sec1_add, sec1_syndrome);
391 u32 ded_add,
u32 scrb_add)
393 u32 error_2b, block_page;
399 if (error_one & 0x0202) {
407 ((block_page >> 1) & 3) :
415 "e752x UE from Read",
"");
418 if (error_one & 0x0404) {
426 ((block_page >> 1) & 3) :
434 "e752x UE from Scruber",
"");
439 u32 ded_add,
u32 scrb_add,
int *error_found,
445 do_process_ue(mci, error_one, ded_add, scrb_add);
448 static inline void process_ue_no_info_wr(
struct mem_ctl_info *mci,
449 int *error_found,
int handle_error)
459 "e752x UE log memory write",
"");
469 error_1b = retry_add;
477 "CE page 0x%lx, row %d : Memory read retry\n",
478 (
long unsigned int)page, row);
481 static inline void process_ded_retry(
struct mem_ctl_info *mci,
u16 error,
482 u32 retry_add,
int *error_found,
488 do_process_ded_retry(mci, error, retry_add);
491 static inline void process_threshold_ce(
struct mem_ctl_info *mci,
u16 error,
492 int *error_found,
int handle_error)
500 static char *global_message[11] = {
508 "HUB or NS Interface",
516 static char *fatal_message[2] = {
"Non-Fatal ",
"Fatal " };
522 for (i = 0; i < 11; i++) {
523 if (errors & (1 << i)) {
528 if ((i ==
DRAM_ENTRY) || report_non_memory_errors)
530 fatal_message[fatal],
536 static inline void global_error(
int fatal,
u32 errors,
int *error_found,
542 do_global_error(fatal, errors);
545 static char *hub_message[7] = {
546 "HI Address or Command Parity",
"HI Illegal Access",
547 "HI Internal Parity",
"Out of Range Access",
548 "HI Data Parity",
"Enhanced Config Access",
549 "Hub Interface Target Abort"
552 static void do_hub_error(
int fatal,
u8 errors)
556 for (i = 0; i < 7; i++) {
557 if (errors & (1 << i))
559 fatal_message[fatal], hub_message[i]);
563 static inline void hub_error(
int fatal,
u8 errors,
int *error_found,
569 do_hub_error(fatal, errors);
572 #define NSI_FATAL_MASK 0x0c080081
573 #define NSI_NON_FATAL_MASK 0x23a0ba64
574 #define NSI_ERR_MASK (NSI_FATAL_MASK | NSI_NON_FATAL_MASK)
576 static char *nsi_message[30] = {
582 "Correctable Error Message",
583 "Non-Fatal Error Message",
584 "Fatal Error Message",
590 "REPLAY_NUM Rollover",
592 "Replay Timer Timeout",
596 "Data Link Protocol Error",
600 "Completion Timeout",
602 "Unexpected Completion",
606 "Unsupported Request"
609 static void do_nsi_error(
int fatal,
u32 errors)
613 for (i = 0; i < 30; i++) {
614 if (errors & (1 << i))
616 fatal_message[fatal], nsi_message[i]);
620 static inline void nsi_error(
int fatal,
u32 errors,
int *error_found,
626 do_nsi_error(fatal, errors);
629 static char *membuf_message[4] = {
630 "Internal PMWB to DRAM parity",
631 "Internal PMWB to System Bus Parity",
632 "Internal System Bus or IO to PMWB Parity",
633 "Internal DRAM to PMWB Parity"
636 static void do_membuf_error(
u8 errors)
640 for (i = 0; i < 4; i++) {
641 if (errors & (1 << i))
647 static inline void membuf_error(
u8 errors,
int *error_found,
int handle_error)
652 do_membuf_error(errors);
655 static char *sysbus_message[10] = {
656 "Addr or Request Parity",
657 "Data Strobe Glitch",
658 "Addr Strobe Glitch",
661 "Non DRAM Lock Error",
664 "IO Subsystem Parity"
667 static void do_sysbus_error(
int fatal,
u32 errors)
671 for (i = 0; i < 10; i++) {
672 if (errors & (1 << i))
674 fatal_message[fatal], sysbus_message[i]);
678 static inline void sysbus_error(
int fatal,
u32 errors,
int *error_found,
684 do_sysbus_error(fatal, errors);
688 int *error_found,
int handle_error)
700 hub_error(1, stat8 & 0x2b, error_found, handle_error);
703 hub_error(0, stat8 & 0x54, error_found, handle_error);
713 hub_error(1, stat8 & 0x2b, error_found, handle_error);
716 hub_error(0, stat8 & 0x54, error_found, handle_error);
721 int *error_found,
int handle_error)
728 nsi_error(1, stat32 & NSI_FATAL_MASK, error_found,
731 nsi_error(0, stat32 & NSI_NON_FATAL_MASK, error_found,
735 if (stat32 & NSI_ERR_MASK) {
736 if (stat32 & NSI_FATAL_MASK)
737 nsi_error(1, stat32 & NSI_FATAL_MASK, error_found,
740 nsi_error(0, stat32 & NSI_NON_FATAL_MASK, error_found,
746 int *error_found,
int handle_error)
756 error32 = (stat32 >> 16) & 0x3ff;
757 stat32 = stat32 & 0x3ff;
760 sysbus_error(1, stat32 & 0x087, error_found, handle_error);
763 sysbus_error(0, stat32 & 0x378, error_found, handle_error);
766 sysbus_error(1, error32 & 0x087, error_found, handle_error);
769 sysbus_error(0, error32 & 0x378, error_found, handle_error);
773 int *error_found,
int handle_error)
781 membuf_error(stat8, error_found, handle_error);
788 membuf_error(stat8, error_found, handle_error);
796 u16 error_one, error_next;
802 if (error_one & 0x0101)
806 if (error_next & 0x0101)
810 if (error_one & 0x4040)
811 process_ue_no_info_wr(mci, error_found, handle_error);
813 if (error_next & 0x4040)
814 process_ue_no_info_wr(mci, error_found, handle_error);
816 if (error_one & 0x2020)
818 error_found, handle_error);
820 if (error_next & 0x2020)
822 error_found, handle_error);
824 if (error_one & 0x0808)
825 process_threshold_ce(mci, error_one, error_found, handle_error);
827 if (error_next & 0x0808)
828 process_threshold_ce(mci, error_next, error_found,
831 if (error_one & 0x0606)
835 if (error_next & 0x0606)
840 static void e752x_get_error_info(
struct mem_ctl_info *mci,
846 memset(info, 0,
sizeof(*info));
947 static int e752x_process_error_info(
struct mem_ctl_info *mci,
959 global_error(1, error32, &error_found, handle_errors);
962 global_error(0, stat32, &error_found, handle_errors);
968 global_error(1, error32, &error_found, handle_errors);
971 global_error(0, stat32, &error_found, handle_errors);
973 e752x_check_hub_interface(info, &error_found, handle_errors);
974 e752x_check_ns_interface(info, &error_found, handle_errors);
975 e752x_check_sysbus(info, &error_found, handle_errors);
976 e752x_check_membuf(info, &error_found, handle_errors);
977 e752x_check_dram(mci, info, &error_found, handle_errors);
986 e752x_get_error_info(mci, &info);
987 e752x_process_error_info(mci, &info, 1);
999 scrubrates = scrubrates_i3100;
1001 scrubrates = scrubrates_e752x;
1014 pci_write_config_word(pdev,
E752X_MCHSCRB, scrubrates[i].scrubval);
1020 static int get_sdram_scrub_rate(
struct mem_ctl_info *mci)
1029 scrubrates = scrubrates_i3100;
1031 scrubrates = scrubrates_e752x;
1035 scrubval = scrubval & 0x0f;
1038 if (scrubrates[i].scrubval == scrubval)
1043 "Invalid sdram scrub control value: 0x%x\n", scrubval);
1051 static inline int dual_channel_active(
u16 ddrcsr)
1053 return (((ddrcsr >> 12) & 3) == 3);
1073 unsigned long last_cumul_size;
1074 int index, mem_dev, drc_chan;
1078 u32 dra,
drc, cumul_size,
i, nr_pages;
1081 for (index = 0; index < 4; index++) {
1083 pci_read_config_byte(pdev,
E752X_DRA + index, &dra_reg);
1084 dra |= dra_reg << (index * 8);
1086 pci_read_config_dword(pdev,
E752X_DRC, &drc);
1087 drc_chan = dual_channel_active(ddrcsr) ? 1 : 0;
1088 drc_drbg = drc_chan + 1;
1089 drc_ddim = (drc >> 20) & 0x3;
1096 for (last_cumul_size = index = 0; index < mci->
nr_csrows; index++) {
1098 mem_dev = (dra >> (index * 4 + 2)) & 0x3;
1099 csrow = mci->
csrows[remap_csrow_index(mci, index)];
1101 mem_dev = (mem_dev == 2);
1102 pci_read_config_byte(pdev,
E752X_DRB + index, &value);
1104 cumul_size = value << (25 + drc_drbg -
PAGE_SHIFT);
1105 edac_dbg(3,
"(%d) cumul_size 0x%x\n", index, cumul_size);
1106 if (cumul_size == last_cumul_size)
1111 nr_pages = cumul_size - last_cumul_size;
1112 last_cumul_size = cumul_size;
1119 if (drc_chan && mem_dev) {
1131 edac_dbg(3,
"Initializing rank at (%i,%i)\n", index, i);
1133 dimm->
grain = 1 << 12;
1141 static void e752x_init_mem_map_table(
struct pci_dev *pdev,
1150 for (index = 0; index < 8; index += 2) {
1151 pci_read_config_byte(pdev,
E752X_DRB + index, &value);
1153 if (value == last) {
1156 pvt->
map[index + 1] = 0xff;
1164 pci_read_config_byte(pdev,
E752X_DRB + index + 1,
1169 pvt->
map[index + 1] = (value == last) ? 0xff : row;
1177 static int e752x_get_devs(
struct pci_dev *pdev,
int dev_idx,
1191 "vendor %x device 0x%x (broken BIOS?)\n",
1197 e752x_devs[dev_idx].ctl_dev,
1217 static void e752x_init_sysbus_parity_mask(
struct e752x_pvt *pvt)
1224 if (sysbus_parity != -1) {
1225 enable = sysbus_parity;
1226 }
else if (cpu_id[0] && !
strstr(cpu_id,
"Xeon")) {
1228 "supported by CPU, disabling\n");
1238 static void e752x_init_error_reporting_regs(
struct e752x_pvt *pvt)
1252 e752x_init_sysbus_parity_mask(pvt);
1261 static int e752x_probe1(
struct pci_dev *pdev,
int dev_idx)
1280 if (!force_function_unhide && !(stat8 & (1 << 5))) {
1282 "E752x error registers can be safely un-hidden\n");
1291 drc_chan = dual_channel_active(ddrcsr);
1295 layers[0].is_virt_csrow =
true;
1297 layers[1].size = drc_chan + 1;
1298 layers[1].is_virt_csrow =
false;
1315 pvt->
dev_info = &e752x_devs[dev_idx];
1318 if (e752x_get_devs(pdev, dev_idx, pvt)) {
1335 pci_read_config_byte(pdev,
E752X_DRM, &stat8);
1336 pvt->
map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
1338 e752x_init_csrows(mci, pdev, ddrcsr);
1339 e752x_init_mem_map_table(pdev, pvt);
1341 if (dev_idx ==
I3100)
1345 edac_dbg(3,
"tolm, remapbase, remaplimit\n");
1348 pci_read_config_word(pdev,
E752X_TOLM, &pci_data);
1349 pvt->
tolm = ((
u32) pci_data) << 4;
1355 "tolm = %x, remapbase = %x, remaplimit = %x\n",
1362 edac_dbg(3,
"failed edac_mc_add_mc()\n");
1366 e752x_init_error_reporting_regs(pvt);
1367 e752x_get_error_info(mci, &
discard);
1373 "%s(): Unable to create PCI control\n", __func__);
1375 "%s(): PCI error report via EDAC not setup\n",
1447 .probe = e752x_init_one,
1449 .id_table = e752x_pci_tbl,
1452 static int __init e752x_init(
void)
1461 pci_rc = pci_register_driver(&e752x_driver);
1462 return (pci_rc < 0) ? pci_rc : 0;
1465 static void __exit e752x_exit(
void)
1475 MODULE_AUTHOR(
"Linux Networx (http://lnxi.com) Tom Zimmerman\n");
1479 MODULE_PARM_DESC(force_function_unhide,
"if BIOS sets Dev0:Fun1 up as hidden:"
1480 " 1=force unhide and hope BIOS doesn't fight driver for "
1481 "Dev0:Fun1 access");
1488 " 1=enable system bus parity checking, default=auto-detect");
1491 "reporting, 1=enable non-memory error reporting");