21 #include <linux/module.h>
23 #include <linux/pci.h>
25 #include <linux/slab.h>
34 #define I7300_REVISION " Ver: 1.0.0"
36 #define EDAC_MOD_STR "i7300_edac"
38 #define i7300_printk(level, fmt, arg...) \
39 edac_printk(level, "i7300", fmt, ##arg)
41 #define i7300_mc_printk(mci, level, fmt, arg...) \
42 edac_mc_chipset_printk(mci, level, "i7300", fmt, ##arg)
64 #define MAX_BRANCHES 2
65 #define MAX_CH_PER_BRANCH 2
66 #define MAX_CHANNELS (MAX_CH_PER_BRANCH * MAX_BRANCHES)
69 #define to_channel(ch, branch) ((((branch)) << 1) | (ch))
71 #define to_csrow(slot, ch, branch) \
72 (to_channel(ch, branch) | ((slot) << 2))
118 static struct edac_pci_ctl_info *i7300_pci;
133 #define MAXDIMMPERCH 0x57
136 #define MC_SETTINGS 0x40
137 #define IS_MIRRORED(mc) ((mc) & (1 << 16))
138 #define IS_ECC_ENABLED(mc) ((mc) & (1 << 5))
139 #define IS_RETRY_ENABLED(mc) ((mc) & (1 << 31))
140 #define IS_SCRBALGO_ENHANCED(mc) ((mc) & (1 << 8))
142 #define MC_SETTINGS_A 0x58
143 #define IS_SINGLE_MODE(mca) ((mca) & (1 << 14))
162 #define AMBPRESENT_0 0x64
163 #define AMBPRESENT_1 0x66
166 0x80, 0x84, 0x88, 0x8c,
167 0x82, 0x86, 0x8a, 0x8e
174 #define MTR_DIMMS_PRESENT(mtr) ((mtr) & (1 << 8))
175 #define MTR_DIMMS_ETHROTTLE(mtr) ((mtr) & (1 << 7))
176 #define MTR_DRAM_WIDTH(mtr) (((mtr) & (1 << 6)) ? 8 : 4)
177 #define MTR_DRAM_BANKS(mtr) (((mtr) & (1 << 5)) ? 8 : 4)
178 #define MTR_DIMM_RANKS(mtr) (((mtr) & (1 << 4)) ? 1 : 0)
179 #define MTR_DIMM_ROWS(mtr) (((mtr) >> 2) & 0x3)
180 #define MTR_DRAM_BANKS_ADDR_BITS 2
181 #define MTR_DIMM_ROWS_ADDR_BITS(mtr) (MTR_DIMM_ROWS(mtr) + 13)
182 #define MTR_DIMM_COLS(mtr) ((mtr) & 0x3)
183 #define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10)
192 #define FERR_FAT_FBD 0x98
193 static const char *ferr_fat_fbd_name[] = {
194 [22] =
"Non-Redundant Fast Reset Timeout",
195 [2] =
">Tmid Thermal event with intelligent throttling disabled",
196 [1] =
"Memory or FBD configuration CRC read error",
197 [0] =
"Memory Write error on non-redundant retry or "
198 "FBD configuration Write error on retry",
200 #define GET_FBD_FAT_IDX(fbderr) (((fbderr) >> 28) & 3)
201 #define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 22))
203 #define FERR_NF_FBD 0xa0
204 static const char *ferr_nf_fbd_name[] = {
205 [24] =
"DIMM-Spare Copy Completed",
206 [23] =
"DIMM-Spare Copy Initiated",
207 [22] =
"Redundant Fast Reset Timeout",
208 [21] =
"Memory Write error on redundant retry",
209 [18] =
"SPD protocol Error",
210 [17] =
"FBD Northbound parity error on FBD Sync Status",
211 [16] =
"Correctable Patrol Data ECC",
212 [15] =
"Correctable Resilver- or Spare-Copy Data ECC",
213 [14] =
"Correctable Mirrored Demand Data ECC",
214 [13] =
"Correctable Non-Mirrored Demand Data ECC",
215 [11] =
"Memory or FBD configuration CRC read error",
216 [10] =
"FBD Configuration Write error on first attempt",
217 [9] =
"Memory Write error on first attempt",
218 [8] =
"Non-Aliased Uncorrectable Patrol Data ECC",
219 [7] =
"Non-Aliased Uncorrectable Resilver- or Spare-Copy Data ECC",
220 [6] =
"Non-Aliased Uncorrectable Mirrored Demand Data ECC",
221 [5] =
"Non-Aliased Uncorrectable Non-Mirrored Demand Data ECC",
222 [4] =
"Aliased Uncorrectable Patrol Data ECC",
223 [3] =
"Aliased Uncorrectable Resilver- or Spare-Copy Data ECC",
224 [2] =
"Aliased Uncorrectable Mirrored Demand Data ECC",
225 [1] =
"Aliased Uncorrectable Non-Mirrored Demand Data ECC",
226 [0] =
"Uncorrectable Data ECC on Replay",
228 #define GET_FBD_NF_IDX(fbderr) (((fbderr) >> 28) & 3)
229 #define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\
230 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\
231 (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\
232 (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\
233 (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\
236 #define EMASK_FBD 0xa8
237 #define EMASK_FBD_ERR_MASK ((1 << 27) | (1 << 26) | (1 << 25) | (1 << 24) |\
238 (1 << 22) | (1 << 21) | (1 << 20) | (1 << 19) |\
239 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 14) |\
240 (1 << 13) | (1 << 12) | (1 << 11) | (1 << 10) |\
241 (1 << 9) | (1 << 8) | (1 << 7) | (1 << 6) |\
242 (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) |\
249 #define FERR_GLOBAL_HI 0x48
250 static const char *ferr_global_hi_name[] = {
251 [3] =
"FSB 3 Fatal Error",
252 [2] =
"FSB 2 Fatal Error",
253 [1] =
"FSB 1 Fatal Error",
254 [0] =
"FSB 0 Fatal Error",
256 #define ferr_global_hi_is_fatal(errno) 1
258 #define FERR_GLOBAL_LO 0x40
259 static const char *ferr_global_lo_name[] = {
260 [31] =
"Internal MCH Fatal Error",
261 [30] =
"Intel QuickData Technology Device Fatal Error",
262 [29] =
"FSB1 Fatal Error",
263 [28] =
"FSB0 Fatal Error",
264 [27] =
"FBD Channel 3 Fatal Error",
265 [26] =
"FBD Channel 2 Fatal Error",
266 [25] =
"FBD Channel 1 Fatal Error",
267 [24] =
"FBD Channel 0 Fatal Error",
268 [23] =
"PCI Express Device 7Fatal Error",
269 [22] =
"PCI Express Device 6 Fatal Error",
270 [21] =
"PCI Express Device 5 Fatal Error",
271 [20] =
"PCI Express Device 4 Fatal Error",
272 [19] =
"PCI Express Device 3 Fatal Error",
273 [18] =
"PCI Express Device 2 Fatal Error",
274 [17] =
"PCI Express Device 1 Fatal Error",
275 [16] =
"ESI Fatal Error",
276 [15] =
"Internal MCH Non-Fatal Error",
277 [14] =
"Intel QuickData Technology Device Non Fatal Error",
278 [13] =
"FSB1 Non-Fatal Error",
279 [12] =
"FSB 0 Non-Fatal Error",
280 [11] =
"FBD Channel 3 Non-Fatal Error",
281 [10] =
"FBD Channel 2 Non-Fatal Error",
282 [9] =
"FBD Channel 1 Non-Fatal Error",
283 [8] =
"FBD Channel 0 Non-Fatal Error",
284 [7] =
"PCI Express Device 7 Non-Fatal Error",
285 [6] =
"PCI Express Device 6 Non-Fatal Error",
286 [5] =
"PCI Express Device 5 Non-Fatal Error",
287 [4] =
"PCI Express Device 4 Non-Fatal Error",
288 [3] =
"PCI Express Device 3 Non-Fatal Error",
289 [2] =
"PCI Express Device 2 Non-Fatal Error",
290 [1] =
"PCI Express Device 1 Non-Fatal Error",
291 [0] =
"ESI Non-Fatal Error",
293 #define ferr_global_lo_is_fatal(errno) ((errno < 16) ? 0 : 1)
295 #define NRECMEMA 0xbe
296 #define NRECMEMA_BANK(v) (((v) >> 12) & 7)
297 #define NRECMEMA_RANK(v) (((v) >> 8) & 15)
299 #define NRECMEMB 0xc0
300 #define NRECMEMB_IS_WR(v) ((v) & (1 << 31))
301 #define NRECMEMB_CAS(v) (((v) >> 16) & 0x1fff)
302 #define NRECMEMB_RAS(v) ((v) & 0xffff)
307 #define IS_SECOND_CH(v) ((v) * (1 << 17))
310 #define RECMEMA_BANK(v) (((v) >> 12) & 7)
311 #define RECMEMA_RANK(v) (((v) >> 8) & 15)
314 #define RECMEMB_IS_WR(v) ((v) & (1 << 31))
315 #define RECMEMB_CAS(v) (((v) >> 16) & 0x1fff)
316 #define RECMEMB_RAS(v) ((v) & 0xffff)
334 static const char *get_err_from_table(
const char *
table[],
int size,
int pos)
345 #define GET_ERR_FROM_TABLE(table, pos) \
346 get_err_from_table(table, ARRAY_SIZE(table), pos)
357 u32 errnum, error_reg;
359 const char *specific;
400 is_fatal ?
"Fatal" :
"NOT fatal", specific);
418 const char *specific;
449 "Bank=%d RAS=%d CAS=%d Err=0x%lx (%s))",
450 bank, ras, cas, errors, specific);
454 is_wr ?
"Write error" :
"Read error",
485 channel = (branch << 1);
495 "DRAM-Bank=%d RAS=%d CAS=%d, Err=0x%lx (%s))",
496 bank, ras, cas, errors, specific);
500 branch >> 1, channel % 2, rank,
501 is_wr ?
"Write error" :
"Read error",
513 i7300_process_error_global(mci);
514 i7300_process_fbd_error(mci);
558 static void i7300_enable_error_reporting(
struct mem_ctl_info *mci)
587 static int decode_mtr(
struct i7300_pvt *pvt,
588 int slot,
int ch,
int branch,
599 edac_dbg(2,
"\tMTR%d CH%d: DIMMs are %sPresent (mtr)\n",
600 slot, channel, ans ?
"" :
"NOT ");
624 edac_dbg(2,
"\t\tELECTRICAL THROTTLING is %s\n",
656 edac_dbg(2,
"\t\tECC code is 8-byte-over-32-byte SECDED+ code\n");
658 edac_dbg(2,
"\t\tECC code is on Lockstep mode\n");
667 edac_dbg(2,
"\t\tScrub algorithm for x8 is on %s mode\n",
669 "enhanced" :
"normal");
684 static void print_dimm_size(
struct i7300_pvt *pvt)
686 #ifdef CONFIG_EDAC_DEBUG
699 n =
snprintf(p, space,
"channel %d | ", channel);
706 n =
snprintf(p, space,
"-------------------------------"
707 "------------------------------");
714 for (slot = 0; slot <
MAX_SLOTS; slot++) {
715 n =
snprintf(p, space,
"csrow/SLOT %d ", slot);
731 n =
snprintf(p, space,
"-------------------------------"
732 "------------------------------");
758 edac_dbg(2,
"Memory Technology Registers:\n");
767 edac_dbg(2,
"\t\tAMB-present CH%d = 0x%x:\n",
774 edac_dbg(2,
"\t\tAMB-present CH%d = 0x%x:\n",
779 for (slot = 0; slot <
MAX_SLOTS; slot++) {
780 int where = mtr_regs[
slot];
784 &pvt->
mtr[slot][branch]);
793 mtr = decode_mtr(pvt, slot, ch, branch,
814 static void decode_mir(
int mir_no,
u16 mir[
MAX_MIR])
817 edac_dbg(2,
"MIR%d: limit= 0x%x Branch(es) that participate: %s %s\n",
819 (mir[mir_no] >> 4) & 0xfff,
820 (mir[mir_no] & 1) ?
"B0" :
"",
821 (mir[mir_no] & 2) ?
"B1" :
"");
846 edac_dbg(2,
"TOLM (number of 256M regions) =%u (0x%x)\n",
849 actual_tolm = (
u32) ((1000
l * pvt->
tolm) >> (30 - 28));
850 edac_dbg(2,
"Actual TOLM byte addr=%u.%03u GB (0x%x)\n",
851 actual_tolm/1000, actual_tolm % 1000, pvt->
tolm << 28);
860 edac_dbg(0,
"Memory controller operating on single mode\n");
862 edac_dbg(0,
"Memory controller operating on %smirrored mode\n",
865 edac_dbg(0,
"Error detection is %s\n",
880 decode_mir(i, pvt->
mir);
882 rc = i7300_init_csrows(mci);
888 print_dimm_size(pvt);
942 "'system address,Process Bus' "
944 "vendor 0x%x device 0x%x ERR funcs "
962 edac_dbg(1,
"System Address, processor bus- PCI Bus ID: %s %x:%x\n",
966 edac_dbg(1,
"Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
970 edac_dbg(1,
"FSB Error Regs - PCI Bus ID: %s %x:%x\n",
980 "MC: 'BRANCH 0' device not found:"
981 "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n",
991 "MC: 'BRANCH 1' device not found:"
992 "vendor 0x%x device 0x%x Func 0 "
1002 i7300_put_devices(mci);
1024 edac_dbg(0,
"MC: pdev bus %u dev=0x%x fn=0x%x\n",
1035 layers[0].is_virt_csrow =
false;
1038 layers[1].is_virt_csrow =
true;
1041 layers[2].is_virt_csrow =
true;
1046 edac_dbg(0,
"MC: mci = %p\n", mci);
1060 if (i7300_get_devices(mci))
1078 if (i7300_get_mc_regs(mci)) {
1079 edac_dbg(0,
"MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i7300_init_csrows() returned nonzero value\n");
1082 edac_dbg(1,
"MC: Enable error reporting now\n");
1083 i7300_enable_error_reporting(mci);
1088 edac_dbg(0,
"MC: failed edac_mc_add_mc()\n");
1095 i7300_clear_error(mci);
1101 "%s(): Unable to create PCI control\n",
1104 "%s(): PCI error report via EDAC not setup\n",
1113 i7300_put_devices(mci);
1142 i7300_put_devices(mci);
1164 .name =
"i7300_edac",
1165 .probe = i7300_init_one,
1167 .id_table = i7300_pci_tbl,
1173 static int __init i7300_init(
void)
1182 pci_rc = pci_register_driver(&i7300_driver);
1184 return (pci_rc < 0) ? pci_rc : 0;
1190 static void __exit i7300_exit(
void)