Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Intel 5000(P/V/X) class Memory Controllers kernel module |
| 3 | * |
| 4 | * This file may be distributed under the terms of the |
| 5 | * GNU General Public License. |
| 6 | * |
| 7 | * Written by Douglas Thompson Linux Networx (http://lnxi.com) |
| 8 | * norsk5@xmission.com |
| 9 | * |
| 10 | * This module is based on the following document: |
| 11 | * |
| 12 | * Intel 5000X Chipset Memory Controller Hub (MCH) - Datasheet |
| 13 | * http://developer.intel.com/design/chipsets/datashts/313070.htm |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/pci.h> |
| 20 | #include <linux/pci_ids.h> |
| 21 | #include <linux/slab.h> |
Dave Jiang | c0d1217 | 2007-07-19 01:49:46 -0700 | [diff] [blame] | 22 | #include <linux/edac.h> |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 23 | #include <asm/mmzone.h> |
| 24 | |
Douglas Thompson | 20bcb7a | 2007-07-19 01:49:47 -0700 | [diff] [blame] | 25 | #include "edac_core.h" |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * Alter this version for the I5000 module when modifications are made |
| 29 | */ |
Michal Marek | 152ba39 | 2011-04-01 12:41:20 +0200 | [diff] [blame] | 30 | #define I5000_REVISION " Ver: 2.0.12" |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 31 | #define EDAC_MOD_STR "i5000_edac" |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 32 | |
| 33 | #define i5000_printk(level, fmt, arg...) \ |
| 34 | edac_printk(level, "i5000", fmt, ##arg) |
| 35 | |
| 36 | #define i5000_mc_printk(mci, level, fmt, arg...) \ |
| 37 | edac_mc_chipset_printk(mci, level, "i5000", fmt, ##arg) |
| 38 | |
| 39 | #ifndef PCI_DEVICE_ID_INTEL_FBD_0 |
| 40 | #define PCI_DEVICE_ID_INTEL_FBD_0 0x25F5 |
| 41 | #endif |
| 42 | #ifndef PCI_DEVICE_ID_INTEL_FBD_1 |
| 43 | #define PCI_DEVICE_ID_INTEL_FBD_1 0x25F6 |
| 44 | #endif |
| 45 | |
| 46 | /* Device 16, |
| 47 | * Function 0: System Address |
| 48 | * Function 1: Memory Branch Map, Control, Errors Register |
| 49 | * Function 2: FSB Error Registers |
| 50 | * |
| 51 | * All 3 functions of Device 16 (0,1,2) share the SAME DID |
| 52 | */ |
| 53 | #define PCI_DEVICE_ID_INTEL_I5000_DEV16 0x25F0 |
| 54 | |
| 55 | /* OFFSETS for Function 0 */ |
| 56 | |
| 57 | /* OFFSETS for Function 1 */ |
| 58 | #define AMBASE 0x48 |
| 59 | #define MAXCH 0x56 |
| 60 | #define MAXDIMMPERCH 0x57 |
| 61 | #define TOLM 0x6C |
| 62 | #define REDMEMB 0x7C |
| 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) |
| 66 | #define MIR0 0x80 |
| 67 | #define MIR1 0x84 |
| 68 | #define MIR2 0x88 |
| 69 | #define AMIR0 0x8C |
| 70 | #define AMIR1 0x90 |
| 71 | #define AMIR2 0x94 |
| 72 | |
| 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 |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 80 | #define FERR_FAT_MASK (FERR_FAT_M1ERR | \ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 81 | FERR_FAT_M2ERR | \ |
| 82 | FERR_FAT_M3ERR) |
| 83 | |
| 84 | #define FERR_NF_FBD 0xA0 |
| 85 | |
| 86 | /* Thermal and SPD or BFD errors */ |
| 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 |
| 95 | |
| 96 | /* Correctable errors */ |
| 97 | #define FERR_NF_M20ERR 0x00010000 |
| 98 | #define FERR_NF_M19ERR 0x00008000 |
| 99 | #define FERR_NF_M18ERR 0x00004000 |
| 100 | #define FERR_NF_M17ERR 0x00002000 |
| 101 | |
| 102 | /* Non-Retry or redundant Retry errors */ |
| 103 | #define FERR_NF_M16ERR 0x00001000 |
| 104 | #define FERR_NF_M15ERR 0x00000800 |
| 105 | #define FERR_NF_M14ERR 0x00000400 |
| 106 | #define FERR_NF_M13ERR 0x00000200 |
| 107 | |
| 108 | /* Uncorrectable errors */ |
| 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 |
| 118 | |
| 119 | #define FERR_NF_UNCORRECTABLE (FERR_NF_M12ERR | \ |
| 120 | FERR_NF_M11ERR | \ |
| 121 | FERR_NF_M10ERR | \ |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 122 | FERR_NF_M9ERR | \ |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 123 | FERR_NF_M8ERR | \ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 124 | FERR_NF_M7ERR | \ |
| 125 | FERR_NF_M6ERR | \ |
| 126 | FERR_NF_M5ERR | \ |
| 127 | FERR_NF_M4ERR) |
| 128 | #define FERR_NF_CORRECTABLE (FERR_NF_M20ERR | \ |
| 129 | FERR_NF_M19ERR | \ |
| 130 | FERR_NF_M18ERR | \ |
| 131 | FERR_NF_M17ERR) |
| 132 | #define FERR_NF_DIMM_SPARE (FERR_NF_M27ERR | \ |
| 133 | FERR_NF_M28ERR) |
| 134 | #define FERR_NF_THERMAL (FERR_NF_M26ERR | \ |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 135 | FERR_NF_M25ERR | \ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 136 | FERR_NF_M24ERR | \ |
| 137 | FERR_NF_M23ERR) |
| 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 | \ |
| 141 | FERR_NF_M14ERR | \ |
| 142 | FERR_NF_M15ERR) |
| 143 | |
| 144 | #define NERR_NF_FBD 0xA4 |
| 145 | #define FERR_NF_MASK (FERR_NF_UNCORRECTABLE | \ |
| 146 | FERR_NF_CORRECTABLE | \ |
| 147 | FERR_NF_DIMM_SPARE | \ |
| 148 | FERR_NF_THERMAL | \ |
| 149 | FERR_NF_SPD_PROTOCOL | \ |
| 150 | FERR_NF_NORTH_CRC | \ |
| 151 | FERR_NF_NON_RETRY) |
| 152 | |
| 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 |
| 166 | |
| 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 |
| 182 | |
| 183 | #define ENABLE_EMASK_FBD_FATAL_ERRORS (EMASK_FBD_M1ERR | \ |
| 184 | EMASK_FBD_M2ERR | \ |
| 185 | EMASK_FBD_M3ERR) |
| 186 | |
| 187 | #define ENABLE_EMASK_FBD_UNCORRECTABLE (EMASK_FBD_M4ERR | \ |
| 188 | EMASK_FBD_M5ERR | \ |
| 189 | EMASK_FBD_M6ERR | \ |
| 190 | EMASK_FBD_M7ERR | \ |
| 191 | EMASK_FBD_M8ERR | \ |
| 192 | EMASK_FBD_M9ERR | \ |
| 193 | EMASK_FBD_M10ERR | \ |
| 194 | EMASK_FBD_M11ERR | \ |
| 195 | EMASK_FBD_M12ERR) |
| 196 | #define ENABLE_EMASK_FBD_CORRECTABLE (EMASK_FBD_M17ERR | \ |
| 197 | EMASK_FBD_M18ERR | \ |
| 198 | EMASK_FBD_M19ERR | \ |
| 199 | EMASK_FBD_M20ERR) |
| 200 | #define ENABLE_EMASK_FBD_DIMM_SPARE (EMASK_FBD_M27ERR | \ |
| 201 | EMASK_FBD_M28ERR) |
| 202 | #define ENABLE_EMASK_FBD_THERMALS (EMASK_FBD_M26ERR | \ |
| 203 | EMASK_FBD_M25ERR | \ |
| 204 | EMASK_FBD_M24ERR | \ |
| 205 | EMASK_FBD_M23ERR) |
| 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 | \ |
| 209 | EMASK_FBD_M14ERR | \ |
| 210 | EMASK_FBD_M13ERR) |
| 211 | |
| 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) |
| 220 | |
| 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 |
| 238 | #define REDMEMA 0xDC |
| 239 | #define RECMEMA 0xE2 |
| 240 | #define REC_BANK(x) (((x)>>12) & 0x7) |
| 241 | #define REC_RDWR(x) (((x)>>11) & 1) |
| 242 | #define REC_RANK(x) (((x)>>8) & 0x7) |
| 243 | #define RECMEMB 0xE4 |
| 244 | #define REC_CAS(x) (((x)>>16) & 0xFFFFFF) |
| 245 | #define REC_RAS(x) ((x) & 0x7FFF) |
| 246 | #define RECFGLOG 0xE8 |
| 247 | #define RECFBDA 0xEC |
| 248 | #define RECFBDB 0xF0 |
| 249 | #define RECFBDC 0xF4 |
| 250 | #define RECFBDD 0xF8 |
| 251 | #define RECFBDE 0xFC |
| 252 | |
| 253 | /* OFFSETS for Function 2 */ |
| 254 | |
| 255 | /* |
| 256 | * Device 21, |
| 257 | * Function 0: Memory Map Branch 0 |
| 258 | * |
| 259 | * Device 22, |
| 260 | * Function 0: Memory Map Branch 1 |
| 261 | */ |
| 262 | #define PCI_DEVICE_ID_I5000_BRANCH_0 0x25F5 |
| 263 | #define PCI_DEVICE_ID_I5000_BRANCH_1 0x25F6 |
| 264 | |
| 265 | #define AMB_PRESENT_0 0x64 |
| 266 | #define AMB_PRESENT_1 0x66 |
| 267 | #define MTR0 0x80 |
| 268 | #define MTR1 0x84 |
| 269 | #define MTR2 0x88 |
| 270 | #define MTR3 0x8C |
| 271 | |
| 272 | #define NUM_MTRS 4 |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 273 | #define CHANNELS_PER_BRANCH 2 |
| 274 | #define MAX_BRANCHES 2 |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 275 | |
Joe Perches | 7e88185 | 2012-04-28 16:41:46 -0300 | [diff] [blame^] | 276 | /* Defines to extract the various fields from the |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 277 | * MTRx - Memory Technology Registers |
| 278 | */ |
| 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) |
Marisuz Kozlowski | 977c76b | 2007-07-19 01:50:18 -0700 | [diff] [blame] | 284 | #define MTR_DIMM_RANK_ADDR_BITS(mtr) (MTR_DIMM_RANK(mtr) ? 2 : 1) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 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) |
| 289 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 290 | /* enables the report of miscellaneous messages as CE errors - default off */ |
| 291 | static int misc_messages; |
| 292 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 293 | /* Enumeration of supported devices */ |
| 294 | enum i5000_chips { |
| 295 | I5000P = 0, |
| 296 | I5000V = 1, /* future */ |
| 297 | I5000X = 2 /* future */ |
| 298 | }; |
| 299 | |
| 300 | /* Device name and register DID (Device ID) */ |
| 301 | struct i5000_dev_info { |
| 302 | const char *ctl_name; /* name for this device */ |
| 303 | u16 fsb_mapping_errors; /* DID for the branchmap,control */ |
| 304 | }; |
| 305 | |
| 306 | /* Table of devices attributes supported by this driver */ |
| 307 | static const struct i5000_dev_info i5000_devs[] = { |
| 308 | [I5000P] = { |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 309 | .ctl_name = "I5000", |
| 310 | .fsb_mapping_errors = PCI_DEVICE_ID_INTEL_I5000_DEV16, |
| 311 | }, |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | struct i5000_dimm_info { |
| 315 | int megabytes; /* size, 0 means not present */ |
| 316 | int dual_rank; |
| 317 | }; |
| 318 | |
| 319 | #define MAX_CHANNELS 6 /* max possible channels */ |
| 320 | #define MAX_CSROWS (8*2) /* max possible csrows per channel */ |
| 321 | |
| 322 | /* driver private data structure */ |
| 323 | struct i5000_pvt { |
| 324 | struct pci_dev *system_address; /* 16.0 */ |
| 325 | struct pci_dev *branchmap_werrors; /* 16.1 */ |
| 326 | struct pci_dev *fsb_error_regs; /* 16.2 */ |
| 327 | struct pci_dev *branch_0; /* 21.0 */ |
| 328 | struct pci_dev *branch_1; /* 22.0 */ |
| 329 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 330 | u16 tolm; /* top of low memory */ |
| 331 | u64 ambase; /* AMB BAR */ |
| 332 | |
| 333 | u16 mir0, mir1, mir2; |
| 334 | |
| 335 | u16 b0_mtr[NUM_MTRS]; /* Memory Technlogy Reg */ |
| 336 | u16 b0_ambpresent0; /* Branch 0, Channel 0 */ |
| 337 | u16 b0_ambpresent1; /* Brnach 0, Channel 1 */ |
| 338 | |
| 339 | u16 b1_mtr[NUM_MTRS]; /* Memory Technlogy Reg */ |
| 340 | u16 b1_ambpresent0; /* Branch 1, Channel 8 */ |
| 341 | u16 b1_ambpresent1; /* Branch 1, Channel 1 */ |
| 342 | |
Joe Perches | 6f042b5 | 2008-02-03 17:12:34 +0200 | [diff] [blame] | 343 | /* DIMM information matrix, allocating architecture maximums */ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 344 | struct i5000_dimm_info dimm_info[MAX_CSROWS][MAX_CHANNELS]; |
| 345 | |
| 346 | /* Actual values for this controller */ |
| 347 | int maxch; /* Max channels */ |
| 348 | int maxdimmperch; /* Max DIMMs per channel */ |
| 349 | }; |
| 350 | |
| 351 | /* I5000 MCH error information retrieved from Hardware */ |
| 352 | struct i5000_error_info { |
| 353 | |
| 354 | /* These registers are always read from the MC */ |
| 355 | u32 ferr_fat_fbd; /* First Errors Fatal */ |
| 356 | u32 nerr_fat_fbd; /* Next Errors Fatal */ |
| 357 | u32 ferr_nf_fbd; /* First Errors Non-Fatal */ |
| 358 | u32 nerr_nf_fbd; /* Next Errors Non-Fatal */ |
| 359 | |
| 360 | /* These registers are input ONLY if there was a Recoverable Error */ |
| 361 | u32 redmemb; /* Recoverable Mem Data Error log B */ |
| 362 | u16 recmema; /* Recoverable Mem Error log A */ |
| 363 | u32 recmemb; /* Recoverable Mem Error log B */ |
| 364 | |
| 365 | /* These registers are input ONLY if there was a |
| 366 | * Non-Recoverable Error */ |
| 367 | u16 nrecmema; /* Non-Recoverable Mem log A */ |
| 368 | u16 nrecmemb; /* Non-Recoverable Mem log B */ |
| 369 | |
| 370 | }; |
| 371 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 372 | static struct edac_pci_ctl_info *i5000_pci; |
| 373 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 374 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 375 | * i5000_get_error_info Retrieve the hardware error information from |
| 376 | * the hardware and cache it in the 'info' |
| 377 | * structure |
| 378 | */ |
| 379 | static void i5000_get_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 380 | struct i5000_error_info *info) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 381 | { |
| 382 | struct i5000_pvt *pvt; |
| 383 | u32 value; |
| 384 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 385 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 386 | |
| 387 | /* read in the 1st FATAL error register */ |
| 388 | pci_read_config_dword(pvt->branchmap_werrors, FERR_FAT_FBD, &value); |
| 389 | |
| 390 | /* Mask only the bits that the doc says are valid |
| 391 | */ |
| 392 | value &= (FERR_FAT_FBDCHAN | FERR_FAT_MASK); |
| 393 | |
| 394 | /* If there is an error, then read in the */ |
| 395 | /* NEXT FATAL error register and the Memory Error Log Register A */ |
| 396 | if (value & FERR_FAT_MASK) { |
| 397 | info->ferr_fat_fbd = value; |
| 398 | |
| 399 | /* harvest the various error data we need */ |
| 400 | pci_read_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 401 | NERR_FAT_FBD, &info->nerr_fat_fbd); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 402 | pci_read_config_word(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 403 | NRECMEMA, &info->nrecmema); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 404 | pci_read_config_word(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 405 | NRECMEMB, &info->nrecmemb); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 406 | |
| 407 | /* Clear the error bits, by writing them back */ |
| 408 | pci_write_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 409 | FERR_FAT_FBD, value); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 410 | } else { |
| 411 | info->ferr_fat_fbd = 0; |
| 412 | info->nerr_fat_fbd = 0; |
| 413 | info->nrecmema = 0; |
| 414 | info->nrecmemb = 0; |
| 415 | } |
| 416 | |
| 417 | /* read in the 1st NON-FATAL error register */ |
| 418 | pci_read_config_dword(pvt->branchmap_werrors, FERR_NF_FBD, &value); |
| 419 | |
| 420 | /* If there is an error, then read in the 1st NON-FATAL error |
| 421 | * register as well */ |
| 422 | if (value & FERR_NF_MASK) { |
| 423 | info->ferr_nf_fbd = value; |
| 424 | |
| 425 | /* harvest the various error data we need */ |
| 426 | pci_read_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 427 | NERR_NF_FBD, &info->nerr_nf_fbd); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 428 | pci_read_config_word(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 429 | RECMEMA, &info->recmema); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 430 | pci_read_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 431 | RECMEMB, &info->recmemb); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 432 | pci_read_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 433 | REDMEMB, &info->redmemb); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 434 | |
| 435 | /* Clear the error bits, by writing them back */ |
| 436 | pci_write_config_dword(pvt->branchmap_werrors, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 437 | FERR_NF_FBD, value); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 438 | } else { |
| 439 | info->ferr_nf_fbd = 0; |
| 440 | info->nerr_nf_fbd = 0; |
| 441 | info->recmema = 0; |
| 442 | info->recmemb = 0; |
| 443 | info->redmemb = 0; |
| 444 | } |
| 445 | } |
| 446 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 447 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 448 | * i5000_process_fatal_error_info(struct mem_ctl_info *mci, |
| 449 | * struct i5000_error_info *info, |
| 450 | * int handle_errors); |
| 451 | * |
| 452 | * handle the Intel FATAL errors, if any |
| 453 | */ |
| 454 | static void i5000_process_fatal_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 455 | struct i5000_error_info *info, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 456 | int handle_errors) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 457 | { |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 458 | char msg[EDAC_MC_LABEL_LEN + 1 + 160]; |
| 459 | char *specific = NULL; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 460 | u32 allErrors; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 461 | int channel; |
| 462 | int bank; |
| 463 | int rank; |
| 464 | int rdwr; |
| 465 | int ras, cas; |
| 466 | |
| 467 | /* mask off the Error bits that are possible */ |
| 468 | allErrors = (info->ferr_fat_fbd & FERR_FAT_MASK); |
| 469 | if (!allErrors) |
| 470 | return; /* if no error, return now */ |
| 471 | |
Mauro Carvalho Chehab | 486dfb1 | 2012-04-25 11:47:36 -0300 | [diff] [blame] | 472 | channel = EXTRACT_FBDCHAN_INDX(info->ferr_fat_fbd); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 473 | |
| 474 | /* Use the NON-Recoverable macros to extract data */ |
| 475 | bank = NREC_BANK(info->nrecmema); |
| 476 | rank = NREC_RANK(info->nrecmema); |
| 477 | rdwr = NREC_RDWR(info->nrecmema); |
| 478 | ras = NREC_RAS(info->nrecmemb); |
| 479 | cas = NREC_CAS(info->nrecmemb); |
| 480 | |
Mauro Carvalho Chehab | 486dfb1 | 2012-04-25 11:47:36 -0300 | [diff] [blame] | 481 | debugf0("\t\tCSROW= %d Channel= %d " |
| 482 | "(DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", |
| 483 | rank, channel, bank, |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 484 | rdwr ? "Write" : "Read", ras, cas); |
| 485 | |
| 486 | /* Only 1 bit will be on */ |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 487 | switch (allErrors) { |
| 488 | case FERR_FAT_M1ERR: |
| 489 | specific = "Alert on non-redundant retry or fast " |
| 490 | "reset timeout"; |
| 491 | break; |
| 492 | case FERR_FAT_M2ERR: |
| 493 | specific = "Northbound CRC error on non-redundant " |
| 494 | "retry"; |
| 495 | break; |
| 496 | case FERR_FAT_M3ERR: |
Aristeu Rozanski | 8360e81 | 2008-10-15 22:04:32 -0700 | [diff] [blame] | 497 | { |
| 498 | static int done; |
| 499 | |
| 500 | /* |
| 501 | * This error is generated to inform that the intelligent |
| 502 | * throttling is disabled and the temperature passed the |
| 503 | * specified middle point. Since this is something the BIOS |
| 504 | * should take care of, we'll warn only once to avoid |
| 505 | * worthlessly flooding the log. |
| 506 | */ |
| 507 | if (done) |
| 508 | return; |
| 509 | done++; |
| 510 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 511 | specific = ">Tmid Thermal event with intelligent " |
Aristeu Rozanski | 8360e81 | 2008-10-15 22:04:32 -0700 | [diff] [blame] | 512 | "throttling disabled"; |
| 513 | } |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 514 | break; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | /* Form out message */ |
| 518 | snprintf(msg, sizeof(msg), |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 519 | "Bank=%d RAS=%d CAS=%d FATAL Err=0x%x (%s)", |
| 520 | bank, ras, cas, allErrors, specific); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 521 | |
| 522 | /* Call the helper to output message */ |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 523 | edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 0, 0, 0, |
Mauro Carvalho Chehab | 486dfb1 | 2012-04-25 11:47:36 -0300 | [diff] [blame] | 524 | channel >> 1, channel & 1, rank, |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 525 | rdwr ? "Write error" : "Read error", |
| 526 | msg, NULL); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 527 | } |
| 528 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 529 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 530 | * i5000_process_fatal_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 531 | * struct i5000_error_info *info, |
| 532 | * int handle_errors); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 533 | * |
| 534 | * handle the Intel NON-FATAL errors, if any |
| 535 | */ |
| 536 | static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 537 | struct i5000_error_info *info, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 538 | int handle_errors) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 539 | { |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 540 | char msg[EDAC_MC_LABEL_LEN + 1 + 170]; |
| 541 | char *specific = NULL; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 542 | u32 allErrors; |
| 543 | u32 ue_errors; |
| 544 | u32 ce_errors; |
| 545 | u32 misc_errors; |
| 546 | int branch; |
| 547 | int channel; |
| 548 | int bank; |
| 549 | int rank; |
| 550 | int rdwr; |
| 551 | int ras, cas; |
| 552 | |
| 553 | /* mask off the Error bits that are possible */ |
| 554 | allErrors = (info->ferr_nf_fbd & FERR_NF_MASK); |
| 555 | if (!allErrors) |
| 556 | return; /* if no error, return now */ |
| 557 | |
| 558 | /* ONLY ONE of the possible error bits will be set, as per the docs */ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 559 | ue_errors = allErrors & FERR_NF_UNCORRECTABLE; |
| 560 | if (ue_errors) { |
| 561 | debugf0("\tUncorrected bits= 0x%x\n", ue_errors); |
| 562 | |
| 563 | branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); |
Tamas Vincze | 118f3e1 | 2010-01-15 17:01:10 -0800 | [diff] [blame] | 564 | |
| 565 | /* |
| 566 | * According with i5000 datasheet, bit 28 has no significance |
| 567 | * for errors M4Err-M12Err and M17Err-M21Err, on FERR_NF_FBD |
| 568 | */ |
| 569 | channel = branch & 2; |
| 570 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 571 | bank = NREC_BANK(info->nrecmema); |
| 572 | rank = NREC_RANK(info->nrecmema); |
| 573 | rdwr = NREC_RDWR(info->nrecmema); |
| 574 | ras = NREC_RAS(info->nrecmemb); |
| 575 | cas = NREC_CAS(info->nrecmemb); |
| 576 | |
| 577 | debugf0 |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 578 | ("\t\tCSROW= %d Channels= %d,%d (Branch= %d " |
| 579 | "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", |
| 580 | rank, channel, channel + 1, branch >> 1, bank, |
| 581 | rdwr ? "Write" : "Read", ras, cas); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 582 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 583 | switch (ue_errors) { |
| 584 | case FERR_NF_M12ERR: |
| 585 | specific = "Non-Aliased Uncorrectable Patrol Data ECC"; |
| 586 | break; |
| 587 | case FERR_NF_M11ERR: |
| 588 | specific = "Non-Aliased Uncorrectable Spare-Copy " |
| 589 | "Data ECC"; |
| 590 | break; |
| 591 | case FERR_NF_M10ERR: |
| 592 | specific = "Non-Aliased Uncorrectable Mirrored Demand " |
| 593 | "Data ECC"; |
| 594 | break; |
| 595 | case FERR_NF_M9ERR: |
| 596 | specific = "Non-Aliased Uncorrectable Non-Mirrored " |
| 597 | "Demand Data ECC"; |
| 598 | break; |
| 599 | case FERR_NF_M8ERR: |
| 600 | specific = "Aliased Uncorrectable Patrol Data ECC"; |
| 601 | break; |
| 602 | case FERR_NF_M7ERR: |
| 603 | specific = "Aliased Uncorrectable Spare-Copy Data ECC"; |
| 604 | break; |
| 605 | case FERR_NF_M6ERR: |
| 606 | specific = "Aliased Uncorrectable Mirrored Demand " |
| 607 | "Data ECC"; |
| 608 | break; |
| 609 | case FERR_NF_M5ERR: |
| 610 | specific = "Aliased Uncorrectable Non-Mirrored Demand " |
| 611 | "Data ECC"; |
| 612 | break; |
| 613 | case FERR_NF_M4ERR: |
| 614 | specific = "Uncorrectable Data ECC on Replay"; |
| 615 | break; |
| 616 | } |
| 617 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 618 | /* Form out message */ |
| 619 | snprintf(msg, sizeof(msg), |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 620 | "Rank=%d Bank=%d RAS=%d CAS=%d, UE Err=0x%x (%s)", |
| 621 | rank, bank, ras, cas, ue_errors, specific); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 622 | |
| 623 | /* Call the helper to output message */ |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 624 | edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, |
| 625 | channel >> 1, -1, rank, |
| 626 | rdwr ? "Write error" : "Read error", |
| 627 | msg, NULL); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | /* Check correctable errors */ |
| 631 | ce_errors = allErrors & FERR_NF_CORRECTABLE; |
| 632 | if (ce_errors) { |
| 633 | debugf0("\tCorrected bits= 0x%x\n", ce_errors); |
| 634 | |
| 635 | branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); |
| 636 | |
| 637 | channel = 0; |
| 638 | if (REC_ECC_LOCATOR_ODD(info->redmemb)) |
| 639 | channel = 1; |
| 640 | |
| 641 | /* Convert channel to be based from zero, instead of |
| 642 | * from branch base of 0 */ |
| 643 | channel += branch; |
| 644 | |
| 645 | bank = REC_BANK(info->recmema); |
| 646 | rank = REC_RANK(info->recmema); |
| 647 | rdwr = REC_RDWR(info->recmema); |
| 648 | ras = REC_RAS(info->recmemb); |
| 649 | cas = REC_CAS(info->recmemb); |
| 650 | |
| 651 | debugf0("\t\tCSROW= %d Channel= %d (Branch %d " |
| 652 | "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", |
| 653 | rank, channel, branch >> 1, bank, |
| 654 | rdwr ? "Write" : "Read", ras, cas); |
| 655 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 656 | switch (ce_errors) { |
| 657 | case FERR_NF_M17ERR: |
| 658 | specific = "Correctable Non-Mirrored Demand Data ECC"; |
| 659 | break; |
| 660 | case FERR_NF_M18ERR: |
| 661 | specific = "Correctable Mirrored Demand Data ECC"; |
| 662 | break; |
| 663 | case FERR_NF_M19ERR: |
| 664 | specific = "Correctable Spare-Copy Data ECC"; |
| 665 | break; |
| 666 | case FERR_NF_M20ERR: |
| 667 | specific = "Correctable Patrol Data ECC"; |
| 668 | break; |
| 669 | } |
| 670 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 671 | /* Form out message */ |
| 672 | snprintf(msg, sizeof(msg), |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 673 | "Rank=%d Bank=%d RDWR=%s RAS=%d " |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 674 | "CAS=%d, CE Err=0x%x (%s))", branch >> 1, bank, |
| 675 | rdwr ? "Write" : "Read", ras, cas, ce_errors, |
| 676 | specific); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 677 | |
| 678 | /* Call the helper to output message */ |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 679 | edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0, |
| 680 | channel >> 1, channel % 2, rank, |
| 681 | rdwr ? "Write error" : "Read error", |
| 682 | msg, NULL); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 685 | if (!misc_messages) |
| 686 | return; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 687 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 688 | misc_errors = allErrors & (FERR_NF_NON_RETRY | FERR_NF_NORTH_CRC | |
| 689 | FERR_NF_SPD_PROTOCOL | FERR_NF_DIMM_SPARE); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 690 | if (misc_errors) { |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 691 | switch (misc_errors) { |
| 692 | case FERR_NF_M13ERR: |
| 693 | specific = "Non-Retry or Redundant Retry FBD Memory " |
| 694 | "Alert or Redundant Fast Reset Timeout"; |
| 695 | break; |
| 696 | case FERR_NF_M14ERR: |
| 697 | specific = "Non-Retry or Redundant Retry FBD " |
| 698 | "Configuration Alert"; |
| 699 | break; |
| 700 | case FERR_NF_M15ERR: |
| 701 | specific = "Non-Retry or Redundant Retry FBD " |
| 702 | "Northbound CRC error on read data"; |
| 703 | break; |
| 704 | case FERR_NF_M21ERR: |
| 705 | specific = "FBD Northbound CRC error on " |
| 706 | "FBD Sync Status"; |
| 707 | break; |
| 708 | case FERR_NF_M22ERR: |
| 709 | specific = "SPD protocol error"; |
| 710 | break; |
| 711 | case FERR_NF_M27ERR: |
| 712 | specific = "DIMM-spare copy started"; |
| 713 | break; |
| 714 | case FERR_NF_M28ERR: |
| 715 | specific = "DIMM-spare copy completed"; |
| 716 | break; |
| 717 | } |
| 718 | branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 719 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 720 | /* Form out message */ |
| 721 | snprintf(msg, sizeof(msg), |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 722 | "Err=%#x (%s)", misc_errors, specific); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 723 | |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 724 | /* Call the helper to output message */ |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 725 | edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0, |
| 726 | branch >> 1, -1, -1, |
| 727 | "Misc error", msg, NULL); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 728 | } |
| 729 | } |
| 730 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 731 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 732 | * i5000_process_error_info Process the error info that is |
| 733 | * in the 'info' structure, previously retrieved from hardware |
| 734 | */ |
| 735 | static void i5000_process_error_info(struct mem_ctl_info *mci, |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 736 | struct i5000_error_info *info, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 737 | int handle_errors) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 738 | { |
| 739 | /* First handle any fatal errors that occurred */ |
| 740 | i5000_process_fatal_error_info(mci, info, handle_errors); |
| 741 | |
| 742 | /* now handle any non-fatal errors that occurred */ |
| 743 | i5000_process_nonfatal_error_info(mci, info, handle_errors); |
| 744 | } |
| 745 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 746 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 747 | * i5000_clear_error Retrieve any error from the hardware |
| 748 | * but do NOT process that error. |
| 749 | * Used for 'clearing' out of previous errors |
| 750 | * Called by the Core module. |
| 751 | */ |
| 752 | static void i5000_clear_error(struct mem_ctl_info *mci) |
| 753 | { |
| 754 | struct i5000_error_info info; |
| 755 | |
| 756 | i5000_get_error_info(mci, &info); |
| 757 | } |
| 758 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 759 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 760 | * i5000_check_error Retrieve and process errors reported by the |
| 761 | * hardware. Called by the Core module. |
| 762 | */ |
| 763 | static void i5000_check_error(struct mem_ctl_info *mci) |
| 764 | { |
| 765 | struct i5000_error_info info; |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 766 | debugf4("MC%d\n", mci->mc_idx); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 767 | i5000_get_error_info(mci, &info); |
| 768 | i5000_process_error_info(mci, &info, 1); |
| 769 | } |
| 770 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 771 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 772 | * i5000_get_devices Find and perform 'get' operation on the MCH's |
| 773 | * device/functions we want to reference for this driver |
| 774 | * |
| 775 | * Need to 'get' device 16 func 1 and func 2 |
| 776 | */ |
| 777 | static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) |
| 778 | { |
| 779 | //const struct i5000_dev_info *i5000_dev = &i5000_devs[dev_idx]; |
| 780 | struct i5000_pvt *pvt; |
| 781 | struct pci_dev *pdev; |
| 782 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 783 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 784 | |
| 785 | /* Attempt to 'get' the MCH register we want */ |
| 786 | pdev = NULL; |
| 787 | while (1) { |
| 788 | pdev = pci_get_device(PCI_VENDOR_ID_INTEL, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 789 | PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 790 | |
| 791 | /* End of list, leave */ |
| 792 | if (pdev == NULL) { |
| 793 | i5000_printk(KERN_ERR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 794 | "'system address,Process Bus' " |
| 795 | "device not found:" |
| 796 | "vendor 0x%x device 0x%x FUNC 1 " |
| 797 | "(broken BIOS?)\n", |
| 798 | PCI_VENDOR_ID_INTEL, |
| 799 | PCI_DEVICE_ID_INTEL_I5000_DEV16); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 800 | |
| 801 | return 1; |
| 802 | } |
| 803 | |
| 804 | /* Scan for device 16 func 1 */ |
| 805 | if (PCI_FUNC(pdev->devfn) == 1) |
| 806 | break; |
| 807 | } |
| 808 | |
| 809 | pvt->branchmap_werrors = pdev; |
| 810 | |
| 811 | /* Attempt to 'get' the MCH register we want */ |
| 812 | pdev = NULL; |
| 813 | while (1) { |
| 814 | pdev = pci_get_device(PCI_VENDOR_ID_INTEL, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 815 | PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 816 | |
| 817 | if (pdev == NULL) { |
| 818 | i5000_printk(KERN_ERR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 819 | "MC: 'branchmap,control,errors' " |
| 820 | "device not found:" |
| 821 | "vendor 0x%x device 0x%x Func 2 " |
| 822 | "(broken BIOS?)\n", |
| 823 | PCI_VENDOR_ID_INTEL, |
| 824 | PCI_DEVICE_ID_INTEL_I5000_DEV16); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 825 | |
| 826 | pci_dev_put(pvt->branchmap_werrors); |
| 827 | return 1; |
| 828 | } |
| 829 | |
| 830 | /* Scan for device 16 func 1 */ |
| 831 | if (PCI_FUNC(pdev->devfn) == 2) |
| 832 | break; |
| 833 | } |
| 834 | |
| 835 | pvt->fsb_error_regs = pdev; |
| 836 | |
| 837 | debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n", |
| 838 | pci_name(pvt->system_address), |
| 839 | pvt->system_address->vendor, pvt->system_address->device); |
| 840 | debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n", |
| 841 | pci_name(pvt->branchmap_werrors), |
| 842 | pvt->branchmap_werrors->vendor, pvt->branchmap_werrors->device); |
| 843 | debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n", |
| 844 | pci_name(pvt->fsb_error_regs), |
| 845 | pvt->fsb_error_regs->vendor, pvt->fsb_error_regs->device); |
| 846 | |
| 847 | pdev = NULL; |
| 848 | pdev = pci_get_device(PCI_VENDOR_ID_INTEL, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 849 | PCI_DEVICE_ID_I5000_BRANCH_0, pdev); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 850 | |
| 851 | if (pdev == NULL) { |
| 852 | i5000_printk(KERN_ERR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 853 | "MC: 'BRANCH 0' device not found:" |
| 854 | "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n", |
| 855 | PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_I5000_BRANCH_0); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 856 | |
| 857 | pci_dev_put(pvt->branchmap_werrors); |
| 858 | pci_dev_put(pvt->fsb_error_regs); |
| 859 | return 1; |
| 860 | } |
| 861 | |
| 862 | pvt->branch_0 = pdev; |
| 863 | |
| 864 | /* If this device claims to have more than 2 channels then |
| 865 | * fetch Branch 1's information |
| 866 | */ |
| 867 | if (pvt->maxch >= CHANNELS_PER_BRANCH) { |
| 868 | pdev = NULL; |
| 869 | pdev = pci_get_device(PCI_VENDOR_ID_INTEL, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 870 | PCI_DEVICE_ID_I5000_BRANCH_1, pdev); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 871 | |
| 872 | if (pdev == NULL) { |
| 873 | i5000_printk(KERN_ERR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 874 | "MC: 'BRANCH 1' device not found:" |
| 875 | "vendor 0x%x device 0x%x Func 0 " |
| 876 | "(broken BIOS?)\n", |
| 877 | PCI_VENDOR_ID_INTEL, |
| 878 | PCI_DEVICE_ID_I5000_BRANCH_1); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 879 | |
| 880 | pci_dev_put(pvt->branchmap_werrors); |
| 881 | pci_dev_put(pvt->fsb_error_regs); |
| 882 | pci_dev_put(pvt->branch_0); |
| 883 | return 1; |
| 884 | } |
| 885 | |
| 886 | pvt->branch_1 = pdev; |
| 887 | } |
| 888 | |
| 889 | return 0; |
| 890 | } |
| 891 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 892 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 893 | * i5000_put_devices 'put' all the devices that we have |
| 894 | * reserved via 'get' |
| 895 | */ |
| 896 | static void i5000_put_devices(struct mem_ctl_info *mci) |
| 897 | { |
| 898 | struct i5000_pvt *pvt; |
| 899 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 900 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 901 | |
| 902 | pci_dev_put(pvt->branchmap_werrors); /* FUNC 1 */ |
| 903 | pci_dev_put(pvt->fsb_error_regs); /* FUNC 2 */ |
| 904 | pci_dev_put(pvt->branch_0); /* DEV 21 */ |
| 905 | |
| 906 | /* Only if more than 2 channels do we release the second branch */ |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 907 | if (pvt->maxch >= CHANNELS_PER_BRANCH) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 908 | pci_dev_put(pvt->branch_1); /* DEV 22 */ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 909 | } |
| 910 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 911 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 912 | * determine_amb_resent |
| 913 | * |
| 914 | * the information is contained in NUM_MTRS different registers |
| 915 | * determineing which of the NUM_MTRS requires knowing |
| 916 | * which channel is in question |
| 917 | * |
| 918 | * 2 branches, each with 2 channels |
| 919 | * b0_ambpresent0 for channel '0' |
| 920 | * b0_ambpresent1 for channel '1' |
| 921 | * b1_ambpresent0 for channel '2' |
| 922 | * b1_ambpresent1 for channel '3' |
| 923 | */ |
| 924 | static int determine_amb_present_reg(struct i5000_pvt *pvt, int channel) |
| 925 | { |
| 926 | int amb_present; |
| 927 | |
| 928 | if (channel < CHANNELS_PER_BRANCH) { |
| 929 | if (channel & 0x1) |
| 930 | amb_present = pvt->b0_ambpresent1; |
| 931 | else |
| 932 | amb_present = pvt->b0_ambpresent0; |
| 933 | } else { |
| 934 | if (channel & 0x1) |
| 935 | amb_present = pvt->b1_ambpresent1; |
| 936 | else |
| 937 | amb_present = pvt->b1_ambpresent0; |
| 938 | } |
| 939 | |
| 940 | return amb_present; |
| 941 | } |
| 942 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 943 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 944 | * determine_mtr(pvt, csrow, channel) |
| 945 | * |
| 946 | * return the proper MTR register as determine by the csrow and channel desired |
| 947 | */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 948 | static int determine_mtr(struct i5000_pvt *pvt, int slot, int channel) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 949 | { |
| 950 | int mtr; |
| 951 | |
| 952 | if (channel < CHANNELS_PER_BRANCH) |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 953 | mtr = pvt->b0_mtr[slot]; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 954 | else |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 955 | mtr = pvt->b1_mtr[slot]; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 956 | |
| 957 | return mtr; |
| 958 | } |
| 959 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 960 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 961 | */ |
| 962 | static void decode_mtr(int slot_row, u16 mtr) |
| 963 | { |
| 964 | int ans; |
| 965 | |
| 966 | ans = MTR_DIMMS_PRESENT(mtr); |
| 967 | |
| 968 | debugf2("\tMTR%d=0x%x: DIMMs are %s\n", slot_row, mtr, |
| 969 | ans ? "Present" : "NOT Present"); |
| 970 | if (!ans) |
| 971 | return; |
| 972 | |
| 973 | debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr)); |
| 974 | debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr)); |
| 975 | debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANK(mtr) ? "double" : "single"); |
Joe Perches | 7e88185 | 2012-04-28 16:41:46 -0300 | [diff] [blame^] | 976 | debugf2("\t\tNUMROW: %s\n", |
| 977 | MTR_DIMM_ROWS(mtr) == 0 ? "8,192 - 13 rows" : |
| 978 | MTR_DIMM_ROWS(mtr) == 1 ? "16,384 - 14 rows" : |
| 979 | MTR_DIMM_ROWS(mtr) == 2 ? "32,768 - 15 rows" : |
| 980 | "reserved"); |
| 981 | debugf2("\t\tNUMCOL: %s\n", |
| 982 | MTR_DIMM_COLS(mtr) == 0 ? "1,024 - 10 columns" : |
| 983 | MTR_DIMM_COLS(mtr) == 1 ? "2,048 - 11 columns" : |
| 984 | MTR_DIMM_COLS(mtr) == 2 ? "4,096 - 12 columns" : |
| 985 | "reserved"); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 986 | } |
| 987 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 988 | static void handle_channel(struct i5000_pvt *pvt, int slot, int channel, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 989 | struct i5000_dimm_info *dinfo) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 990 | { |
| 991 | int mtr; |
| 992 | int amb_present_reg; |
| 993 | int addrBits; |
| 994 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 995 | mtr = determine_mtr(pvt, slot, channel); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 996 | if (MTR_DIMMS_PRESENT(mtr)) { |
| 997 | amb_present_reg = determine_amb_present_reg(pvt, channel); |
| 998 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 999 | /* Determine if there is a DIMM present in this DIMM slot */ |
| 1000 | if (amb_present_reg) { |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1001 | dinfo->dual_rank = MTR_DIMM_RANK(mtr); |
| 1002 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1003 | /* Start with the number of bits for a Bank |
| 1004 | * on the DRAM */ |
| 1005 | addrBits = MTR_DRAM_BANKS_ADDR_BITS(mtr); |
| 1006 | /* Add the number of ROW bits */ |
| 1007 | addrBits += MTR_DIMM_ROWS_ADDR_BITS(mtr); |
| 1008 | /* add the number of COLUMN bits */ |
| 1009 | addrBits += MTR_DIMM_COLS_ADDR_BITS(mtr); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1010 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1011 | addrBits += 6; /* add 64 bits per DIMM */ |
| 1012 | addrBits -= 20; /* divide by 2^^20 */ |
| 1013 | addrBits -= 3; /* 8 bits per bytes */ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1014 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1015 | dinfo->megabytes = 1 << addrBits; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1020 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1021 | * calculate_dimm_size |
| 1022 | * |
| 1023 | * also will output a DIMM matrix map, if debug is enabled, for viewing |
| 1024 | * how the DIMMs are populated |
| 1025 | */ |
| 1026 | static void calculate_dimm_size(struct i5000_pvt *pvt) |
| 1027 | { |
| 1028 | struct i5000_dimm_info *dinfo; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1029 | int slot, channel, branch; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1030 | char *p, *mem_buffer; |
| 1031 | int space, n; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1032 | |
| 1033 | /* ================= Generate some debug output ================= */ |
| 1034 | space = PAGE_SIZE; |
| 1035 | mem_buffer = p = kmalloc(space, GFP_KERNEL); |
| 1036 | if (p == NULL) { |
| 1037 | i5000_printk(KERN_ERR, "MC: %s:%s() kmalloc() failed\n", |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1038 | __FILE__, __func__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1039 | return; |
| 1040 | } |
| 1041 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1042 | /* Scan all the actual slots |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1043 | * and calculate the information for each DIMM |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1044 | * Start with the highest slot first, to display it first |
| 1045 | * and work toward the 0th slot |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1046 | */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1047 | for (slot = pvt->maxdimmperch - 1; slot >= 0; slot--) { |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1048 | |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1049 | /* on an odd slot, first output a 'boundary' marker, |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1050 | * then reset the message buffer */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1051 | if (slot & 0x1) { |
| 1052 | n = snprintf(p, space, "--------------------------" |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1053 | "--------------------------------"); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1054 | p += n; |
| 1055 | space -= n; |
| 1056 | debugf2("%s\n", mem_buffer); |
| 1057 | p = mem_buffer; |
| 1058 | space = PAGE_SIZE; |
| 1059 | } |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1060 | n = snprintf(p, space, "slot %2d ", slot); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1061 | p += n; |
| 1062 | space -= n; |
| 1063 | |
| 1064 | for (channel = 0; channel < pvt->maxch; channel++) { |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1065 | dinfo = &pvt->dimm_info[slot][channel]; |
| 1066 | handle_channel(pvt, slot, channel, dinfo); |
| 1067 | if (dinfo->megabytes) |
| 1068 | n = snprintf(p, space, "%4d MB %dR| ", |
| 1069 | dinfo->megabytes, dinfo->dual_rank + 1); |
| 1070 | else |
| 1071 | n = snprintf(p, space, "%4d MB | ", 0); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1072 | p += n; |
| 1073 | space -= n; |
| 1074 | } |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1075 | p += n; |
| 1076 | space -= n; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1077 | debugf2("%s\n", mem_buffer); |
| 1078 | p = mem_buffer; |
| 1079 | space = PAGE_SIZE; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | /* Output the last bottom 'boundary' marker */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1083 | n = snprintf(p, space, "--------------------------" |
| 1084 | "--------------------------------"); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1085 | p += n; |
| 1086 | space -= n; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1087 | debugf2("%s\n", mem_buffer); |
| 1088 | p = mem_buffer; |
| 1089 | space = PAGE_SIZE; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1090 | |
| 1091 | /* now output the 'channel' labels */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1092 | n = snprintf(p, space, " "); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1093 | p += n; |
| 1094 | space -= n; |
| 1095 | for (channel = 0; channel < pvt->maxch; channel++) { |
| 1096 | n = snprintf(p, space, "channel %d | ", channel); |
| 1097 | p += n; |
| 1098 | space -= n; |
| 1099 | } |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1100 | debugf2("%s\n", mem_buffer); |
| 1101 | p = mem_buffer; |
| 1102 | space = PAGE_SIZE; |
| 1103 | |
| 1104 | n = snprintf(p, space, " "); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1105 | p += n; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1106 | for (branch = 0; branch < MAX_BRANCHES; branch++) { |
| 1107 | n = snprintf(p, space, " branch %d | ", branch); |
| 1108 | p += n; |
| 1109 | space -= n; |
| 1110 | } |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1111 | |
| 1112 | /* output the last message and free buffer */ |
| 1113 | debugf2("%s\n", mem_buffer); |
| 1114 | kfree(mem_buffer); |
| 1115 | } |
| 1116 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1117 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1118 | * i5000_get_mc_regs read in the necessary registers and |
| 1119 | * cache locally |
| 1120 | * |
| 1121 | * Fills in the private data members |
| 1122 | */ |
| 1123 | static void i5000_get_mc_regs(struct mem_ctl_info *mci) |
| 1124 | { |
| 1125 | struct i5000_pvt *pvt; |
| 1126 | u32 actual_tolm; |
| 1127 | u16 limit; |
| 1128 | int slot_row; |
| 1129 | int maxch; |
| 1130 | int maxdimmperch; |
| 1131 | int way0, way1; |
| 1132 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1133 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1134 | |
| 1135 | pci_read_config_dword(pvt->system_address, AMBASE, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1136 | (u32 *) & pvt->ambase); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1137 | pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32), |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1138 | ((u32 *) & pvt->ambase) + sizeof(u32)); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1139 | |
| 1140 | maxdimmperch = pvt->maxdimmperch; |
| 1141 | maxch = pvt->maxch; |
| 1142 | |
| 1143 | debugf2("AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n", |
| 1144 | (long unsigned int)pvt->ambase, pvt->maxch, pvt->maxdimmperch); |
| 1145 | |
| 1146 | /* Get the Branch Map regs */ |
| 1147 | pci_read_config_word(pvt->branchmap_werrors, TOLM, &pvt->tolm); |
| 1148 | pvt->tolm >>= 12; |
| 1149 | debugf2("\nTOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm, |
| 1150 | pvt->tolm); |
| 1151 | |
| 1152 | actual_tolm = pvt->tolm << 28; |
| 1153 | debugf2("Actual TOLM byte addr=%u (0x%x)\n", actual_tolm, actual_tolm); |
| 1154 | |
| 1155 | pci_read_config_word(pvt->branchmap_werrors, MIR0, &pvt->mir0); |
| 1156 | pci_read_config_word(pvt->branchmap_werrors, MIR1, &pvt->mir1); |
| 1157 | pci_read_config_word(pvt->branchmap_werrors, MIR2, &pvt->mir2); |
| 1158 | |
| 1159 | /* Get the MIR[0-2] regs */ |
| 1160 | limit = (pvt->mir0 >> 4) & 0x0FFF; |
| 1161 | way0 = pvt->mir0 & 0x1; |
| 1162 | way1 = pvt->mir0 & 0x2; |
| 1163 | debugf2("MIR0: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); |
| 1164 | limit = (pvt->mir1 >> 4) & 0x0FFF; |
| 1165 | way0 = pvt->mir1 & 0x1; |
| 1166 | way1 = pvt->mir1 & 0x2; |
| 1167 | debugf2("MIR1: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); |
| 1168 | limit = (pvt->mir2 >> 4) & 0x0FFF; |
| 1169 | way0 = pvt->mir2 & 0x1; |
| 1170 | way1 = pvt->mir2 & 0x2; |
| 1171 | debugf2("MIR2: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); |
| 1172 | |
| 1173 | /* Get the MTR[0-3] regs */ |
| 1174 | for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { |
| 1175 | int where = MTR0 + (slot_row * sizeof(u32)); |
| 1176 | |
| 1177 | pci_read_config_word(pvt->branch_0, where, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1178 | &pvt->b0_mtr[slot_row]); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1179 | |
| 1180 | debugf2("MTR%d where=0x%x B0 value=0x%x\n", slot_row, where, |
| 1181 | pvt->b0_mtr[slot_row]); |
| 1182 | |
| 1183 | if (pvt->maxch >= CHANNELS_PER_BRANCH) { |
| 1184 | pci_read_config_word(pvt->branch_1, where, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1185 | &pvt->b1_mtr[slot_row]); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1186 | debugf2("MTR%d where=0x%x B1 value=0x%x\n", slot_row, |
Keith Mannthey | c2494ac | 2009-10-26 16:50:11 -0700 | [diff] [blame] | 1187 | where, pvt->b1_mtr[slot_row]); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1188 | } else { |
| 1189 | pvt->b1_mtr[slot_row] = 0; |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | /* Read and dump branch 0's MTRs */ |
| 1194 | debugf2("\nMemory Technology Registers:\n"); |
| 1195 | debugf2(" Branch 0:\n"); |
| 1196 | for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { |
| 1197 | decode_mtr(slot_row, pvt->b0_mtr[slot_row]); |
| 1198 | } |
| 1199 | pci_read_config_word(pvt->branch_0, AMB_PRESENT_0, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1200 | &pvt->b0_ambpresent0); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1201 | debugf2("\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0); |
| 1202 | pci_read_config_word(pvt->branch_0, AMB_PRESENT_1, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1203 | &pvt->b0_ambpresent1); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1204 | debugf2("\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1); |
| 1205 | |
| 1206 | /* Only if we have 2 branchs (4 channels) */ |
| 1207 | if (pvt->maxch < CHANNELS_PER_BRANCH) { |
| 1208 | pvt->b1_ambpresent0 = 0; |
| 1209 | pvt->b1_ambpresent1 = 0; |
| 1210 | } else { |
| 1211 | /* Read and dump branch 1's MTRs */ |
| 1212 | debugf2(" Branch 1:\n"); |
| 1213 | for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { |
| 1214 | decode_mtr(slot_row, pvt->b1_mtr[slot_row]); |
| 1215 | } |
| 1216 | pci_read_config_word(pvt->branch_1, AMB_PRESENT_0, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1217 | &pvt->b1_ambpresent0); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1218 | debugf2("\t\tAMB-Branch 1-present0 0x%x:\n", |
| 1219 | pvt->b1_ambpresent0); |
| 1220 | pci_read_config_word(pvt->branch_1, AMB_PRESENT_1, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1221 | &pvt->b1_ambpresent1); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1222 | debugf2("\t\tAMB-Branch 1-present1 0x%x:\n", |
| 1223 | pvt->b1_ambpresent1); |
| 1224 | } |
| 1225 | |
| 1226 | /* Go and determine the size of each DIMM and place in an |
| 1227 | * orderly matrix */ |
| 1228 | calculate_dimm_size(pvt); |
| 1229 | } |
| 1230 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1231 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1232 | * i5000_init_csrows Initialize the 'csrows' table within |
| 1233 | * the mci control structure with the |
| 1234 | * addressing of memory. |
| 1235 | * |
| 1236 | * return: |
| 1237 | * 0 success |
| 1238 | * 1 no actual memory found on this MC |
| 1239 | */ |
| 1240 | static int i5000_init_csrows(struct mem_ctl_info *mci) |
| 1241 | { |
| 1242 | struct i5000_pvt *pvt; |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1243 | struct dimm_info *dimm; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1244 | int empty, channel_count; |
| 1245 | int max_csrows; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1246 | int mtr; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1247 | int csrow_megs; |
| 1248 | int channel; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1249 | int slot; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1250 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1251 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1252 | |
| 1253 | channel_count = pvt->maxch; |
| 1254 | max_csrows = pvt->maxdimmperch * 2; |
| 1255 | |
| 1256 | empty = 1; /* Assume NO memory */ |
| 1257 | |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1258 | /* |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1259 | * FIXME: The memory layout used to map slot/channel into the |
| 1260 | * real memory architecture is weird: branch+slot are "csrows" |
| 1261 | * and channel is channel. That required an extra array (dimm_info) |
| 1262 | * to map the dimms. A good cleanup would be to remove this array, |
| 1263 | * and do a loop here with branch, channel, slot |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1264 | */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1265 | for (slot = 0; slot < max_csrows; slot++) { |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1266 | for (channel = 0; channel < pvt->maxch; channel++) { |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1267 | |
| 1268 | mtr = determine_mtr(pvt, slot, channel); |
| 1269 | |
| 1270 | if (!MTR_DIMMS_PRESENT(mtr)) |
| 1271 | continue; |
| 1272 | |
| 1273 | dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, mci->n_layers, |
| 1274 | channel / MAX_BRANCHES, |
| 1275 | channel % MAX_BRANCHES, slot); |
| 1276 | |
| 1277 | csrow_megs = pvt->dimm_info[slot][channel].megabytes; |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1278 | dimm->grain = 8; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 1279 | |
| 1280 | /* Assume DDR2 for now */ |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1281 | dimm->mtype = MEM_FB_DDR2; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 1282 | |
| 1283 | /* ask what device type on this row */ |
| 1284 | if (MTR_DRAM_WIDTH(mtr)) |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1285 | dimm->dtype = DEV_X8; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 1286 | else |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1287 | dimm->dtype = DEV_X4; |
Mauro Carvalho Chehab | 084a4fc | 2012-01-27 18:38:08 -0300 | [diff] [blame] | 1288 | |
Mauro Carvalho Chehab | a895bf8 | 2012-01-28 09:09:38 -0300 | [diff] [blame] | 1289 | dimm->edac_mode = EDAC_S8ECD8ED; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1290 | dimm->nr_pages = csrow_megs << 8; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1291 | } |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1292 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1293 | empty = 0; |
| 1294 | } |
| 1295 | |
| 1296 | return empty; |
| 1297 | } |
| 1298 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1299 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1300 | * i5000_enable_error_reporting |
| 1301 | * Turn on the memory reporting features of the hardware |
| 1302 | */ |
| 1303 | static void i5000_enable_error_reporting(struct mem_ctl_info *mci) |
| 1304 | { |
| 1305 | struct i5000_pvt *pvt; |
| 1306 | u32 fbd_error_mask; |
| 1307 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1308 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1309 | |
| 1310 | /* Read the FBD Error Mask Register */ |
| 1311 | pci_read_config_dword(pvt->branchmap_werrors, EMASK_FBD, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1312 | &fbd_error_mask); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1313 | |
| 1314 | /* Enable with a '0' */ |
| 1315 | fbd_error_mask &= ~(ENABLE_EMASK_ALL); |
| 1316 | |
| 1317 | pci_write_config_dword(pvt->branchmap_werrors, EMASK_FBD, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1318 | fbd_error_mask); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1319 | } |
| 1320 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1321 | /* |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1322 | * i5000_get_dimm_and_channel_counts(pdev, &nr_csrows, &num_channels) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1323 | * |
| 1324 | * ask the device how many channels are present and how many CSROWS |
| 1325 | * as well |
| 1326 | */ |
| 1327 | static void i5000_get_dimm_and_channel_counts(struct pci_dev *pdev, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1328 | int *num_dimms_per_channel, |
| 1329 | int *num_channels) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1330 | { |
| 1331 | u8 value; |
| 1332 | |
| 1333 | /* Need to retrieve just how many channels and dimms per channel are |
| 1334 | * supported on this memory controller |
| 1335 | */ |
| 1336 | pci_read_config_byte(pdev, MAXDIMMPERCH, &value); |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1337 | *num_dimms_per_channel = (int)value; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1338 | |
| 1339 | pci_read_config_byte(pdev, MAXCH, &value); |
| 1340 | *num_channels = (int)value; |
| 1341 | } |
| 1342 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1343 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1344 | * i5000_probe1 Probe for ONE instance of device to see if it is |
| 1345 | * present. |
| 1346 | * return: |
| 1347 | * 0 for FOUND a device |
| 1348 | * < 0 for error code |
| 1349 | */ |
| 1350 | static int i5000_probe1(struct pci_dev *pdev, int dev_idx) |
| 1351 | { |
| 1352 | struct mem_ctl_info *mci; |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1353 | struct edac_mc_layer layers[3]; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1354 | struct i5000_pvt *pvt; |
| 1355 | int num_channels; |
| 1356 | int num_dimms_per_channel; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1357 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1358 | debugf0("MC: %s(), pdev bus %u dev=0x%x fn=0x%x\n", |
| 1359 | __FILE__, pdev->bus->number, |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1360 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); |
| 1361 | |
| 1362 | /* We only are looking for func 0 of the set */ |
| 1363 | if (PCI_FUNC(pdev->devfn) != 0) |
| 1364 | return -ENODEV; |
| 1365 | |
| 1366 | /* Ask the devices for the number of CSROWS and CHANNELS so |
| 1367 | * that we can calculate the memory resources, etc |
| 1368 | * |
| 1369 | * The Chipset will report what it can handle which will be greater |
| 1370 | * or equal to what the motherboard manufacturer will implement. |
| 1371 | * |
| 1372 | * As we don't have a motherboard identification routine to determine |
| 1373 | * actual number of slots/dimms per channel, we thus utilize the |
| 1374 | * resource as specified by the chipset. Thus, we might have |
| 1375 | * have more DIMMs per channel than actually on the mobo, but this |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1376 | * allows the driver to support up to the chipset max, without |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1377 | * some fancy mobo determination. |
| 1378 | */ |
| 1379 | i5000_get_dimm_and_channel_counts(pdev, &num_dimms_per_channel, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1380 | &num_channels); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1381 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1382 | debugf0("MC: Number of Branches=2 Channels= %d DIMMS= %d\n", |
| 1383 | num_channels, num_dimms_per_channel); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1384 | |
| 1385 | /* allocate a new MC control structure */ |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1386 | |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1387 | layers[0].type = EDAC_MC_LAYER_BRANCH; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1388 | layers[0].size = MAX_BRANCHES; |
| 1389 | layers[0].is_virt_csrow = false; |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1390 | layers[1].type = EDAC_MC_LAYER_CHANNEL; |
Mauro Carvalho Chehab | 64e1fda | 2012-02-24 09:34:54 -0300 | [diff] [blame] | 1391 | layers[1].size = num_channels / MAX_BRANCHES; |
Mauro Carvalho Chehab | 702df64 | 2012-04-16 15:09:46 -0300 | [diff] [blame] | 1392 | layers[1].is_virt_csrow = false; |
| 1393 | layers[2].type = EDAC_MC_LAYER_SLOT; |
| 1394 | layers[2].size = num_dimms_per_channel; |
| 1395 | layers[2].is_virt_csrow = true; |
Mauro Carvalho Chehab | ca0907b | 2012-05-02 14:37:00 -0300 | [diff] [blame] | 1396 | mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(*pvt)); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1397 | if (mci == NULL) |
| 1398 | return -ENOMEM; |
| 1399 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1400 | debugf0("MC: %s(): mci = %p\n", __FILE__, mci); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1401 | |
Mauro Carvalho Chehab | fd68750 | 2012-03-16 07:44:18 -0300 | [diff] [blame] | 1402 | mci->pdev = &pdev->dev; /* record ptr to the generic device */ |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1403 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1404 | pvt = mci->pvt_info; |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1405 | pvt->system_address = pdev; /* Record this device in our private */ |
| 1406 | pvt->maxch = num_channels; |
| 1407 | pvt->maxdimmperch = num_dimms_per_channel; |
| 1408 | |
| 1409 | /* 'get' the pci devices we want to reserve for our use */ |
| 1410 | if (i5000_get_devices(mci, dev_idx)) |
| 1411 | goto fail0; |
| 1412 | |
| 1413 | /* Time to get serious */ |
| 1414 | i5000_get_mc_regs(mci); /* retrieve the hardware registers */ |
| 1415 | |
| 1416 | mci->mc_idx = 0; |
| 1417 | mci->mtype_cap = MEM_FLAG_FB_DDR2; |
| 1418 | mci->edac_ctl_cap = EDAC_FLAG_NONE; |
| 1419 | mci->edac_cap = EDAC_FLAG_NONE; |
| 1420 | mci->mod_name = "i5000_edac.c"; |
| 1421 | mci->mod_ver = I5000_REVISION; |
| 1422 | mci->ctl_name = i5000_devs[dev_idx].ctl_name; |
Dave Jiang | c419270 | 2007-07-19 01:49:47 -0700 | [diff] [blame] | 1423 | mci->dev_name = pci_name(pdev); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1424 | mci->ctl_page_to_phys = NULL; |
| 1425 | |
| 1426 | /* Set the function pointer to an actual operation function */ |
| 1427 | mci->edac_check = i5000_check_error; |
| 1428 | |
| 1429 | /* initialize the MC control structure 'csrows' table |
| 1430 | * with the mapping and control information */ |
| 1431 | if (i5000_init_csrows(mci)) { |
| 1432 | debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n" |
| 1433 | " because i5000_init_csrows() returned nonzero " |
| 1434 | "value\n"); |
| 1435 | mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */ |
| 1436 | } else { |
| 1437 | debugf1("MC: Enable error reporting now\n"); |
| 1438 | i5000_enable_error_reporting(mci); |
| 1439 | } |
| 1440 | |
| 1441 | /* add this new MC control structure to EDAC's list of MCs */ |
Doug Thompson | b8f6f97 | 2007-07-19 01:50:26 -0700 | [diff] [blame] | 1442 | if (edac_mc_add_mc(mci)) { |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1443 | debugf0("MC: %s(): failed edac_mc_add_mc()\n", |
| 1444 | __FILE__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1445 | /* FIXME: perhaps some code should go here that disables error |
| 1446 | * reporting if we just enabled it |
| 1447 | */ |
| 1448 | goto fail1; |
| 1449 | } |
| 1450 | |
| 1451 | i5000_clear_error(mci); |
| 1452 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 1453 | /* allocating generic PCI control info */ |
| 1454 | i5000_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR); |
| 1455 | if (!i5000_pci) { |
| 1456 | printk(KERN_WARNING |
| 1457 | "%s(): Unable to create PCI control\n", |
| 1458 | __func__); |
| 1459 | printk(KERN_WARNING |
| 1460 | "%s(): PCI error report via EDAC not setup\n", |
| 1461 | __func__); |
| 1462 | } |
| 1463 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1464 | return 0; |
| 1465 | |
| 1466 | /* Error exit unwinding stack */ |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1467 | fail1: |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1468 | |
| 1469 | i5000_put_devices(mci); |
| 1470 | |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1471 | fail0: |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1472 | edac_mc_free(mci); |
| 1473 | return -ENODEV; |
| 1474 | } |
| 1475 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1476 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1477 | * i5000_init_one constructor for one instance of device |
| 1478 | * |
| 1479 | * returns: |
| 1480 | * negative on error |
| 1481 | * count (>= 0) |
| 1482 | */ |
| 1483 | static int __devinit i5000_init_one(struct pci_dev *pdev, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1484 | const struct pci_device_id *id) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1485 | { |
| 1486 | int rc; |
| 1487 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1488 | debugf0("MC: %s()\n", __FILE__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1489 | |
| 1490 | /* wake up device */ |
| 1491 | rc = pci_enable_device(pdev); |
Kulikov Vasiliy | 44aa80f | 2010-08-10 18:03:19 -0700 | [diff] [blame] | 1492 | if (rc) |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1493 | return rc; |
| 1494 | |
| 1495 | /* now probe and enable the device */ |
| 1496 | return i5000_probe1(pdev, id->driver_data); |
| 1497 | } |
| 1498 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1499 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1500 | * i5000_remove_one destructor for one instance of device |
| 1501 | * |
| 1502 | */ |
| 1503 | static void __devexit i5000_remove_one(struct pci_dev *pdev) |
| 1504 | { |
| 1505 | struct mem_ctl_info *mci; |
| 1506 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1507 | debugf0("%s()\n", __FILE__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1508 | |
Dave Jiang | 456a2f9 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 1509 | if (i5000_pci) |
| 1510 | edac_pci_release_generic_ctl(i5000_pci); |
| 1511 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1512 | if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL) |
| 1513 | return; |
| 1514 | |
| 1515 | /* retrieve references to resources, and free those resources */ |
| 1516 | i5000_put_devices(mci); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1517 | edac_mc_free(mci); |
| 1518 | } |
| 1519 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1520 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1521 | * pci_device_id table for which devices we are looking for |
| 1522 | * |
| 1523 | * The "E500P" device is the first device supported. |
| 1524 | */ |
Lionel Debroux | 36c46f3 | 2012-02-27 07:41:47 +0100 | [diff] [blame] | 1525 | static DEFINE_PCI_DEVICE_TABLE(i5000_pci_tbl) = { |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1526 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I5000_DEV16), |
| 1527 | .driver_data = I5000P}, |
| 1528 | |
| 1529 | {0,} /* 0 terminated list. */ |
| 1530 | }; |
| 1531 | |
| 1532 | MODULE_DEVICE_TABLE(pci, i5000_pci_tbl); |
| 1533 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1534 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1535 | * i5000_driver pci_driver structure for this module |
| 1536 | * |
| 1537 | */ |
| 1538 | static struct pci_driver i5000_driver = { |
Darrick J. Wong | 57510c2 | 2007-11-14 16:59:58 -0800 | [diff] [blame] | 1539 | .name = KBUILD_BASENAME, |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1540 | .probe = i5000_init_one, |
| 1541 | .remove = __devexit_p(i5000_remove_one), |
| 1542 | .id_table = i5000_pci_tbl, |
| 1543 | }; |
| 1544 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1545 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1546 | * i5000_init Module entry function |
| 1547 | * Try to initialize this module for its devices |
| 1548 | */ |
| 1549 | static int __init i5000_init(void) |
| 1550 | { |
| 1551 | int pci_rc; |
| 1552 | |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1553 | debugf2("MC: %s()\n", __FILE__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1554 | |
Hitoshi Mitake | c3c52bc | 2008-04-29 01:03:18 -0700 | [diff] [blame] | 1555 | /* Ensure that the OPSTATE is set correctly for POLL or NMI */ |
| 1556 | opstate_init(); |
| 1557 | |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1558 | pci_rc = pci_register_driver(&i5000_driver); |
| 1559 | |
| 1560 | return (pci_rc < 0) ? pci_rc : 0; |
| 1561 | } |
| 1562 | |
Douglas Thompson | b2ccaec | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 1563 | /* |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1564 | * i5000_exit() Module exit function |
| 1565 | * Unregister the driver |
| 1566 | */ |
| 1567 | static void __exit i5000_exit(void) |
| 1568 | { |
Mauro Carvalho Chehab | dd23cd6 | 2012-04-29 11:59:14 -0300 | [diff] [blame] | 1569 | debugf2("MC: %s()\n", __FILE__); |
Eric Wollesen | eb60705 | 2007-07-19 01:49:39 -0700 | [diff] [blame] | 1570 | pci_unregister_driver(&i5000_driver); |
| 1571 | } |
| 1572 | |
| 1573 | module_init(i5000_init); |
| 1574 | module_exit(i5000_exit); |
| 1575 | |
| 1576 | MODULE_LICENSE("GPL"); |
| 1577 | MODULE_AUTHOR |
| 1578 | ("Linux Networx (http://lnxi.com) Doug Thompson <norsk5@xmission.com>"); |
| 1579 | MODULE_DESCRIPTION("MC Driver for Intel I5000 memory controllers - " |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 1580 | I5000_REVISION); |
Hitoshi Mitake | c3c52bc | 2008-04-29 01:03:18 -0700 | [diff] [blame] | 1581 | |
Dave Jiang | c0d1217 | 2007-07-19 01:49:46 -0700 | [diff] [blame] | 1582 | module_param(edac_op_state, int, 0444); |
| 1583 | MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); |
Aristeu Rozanski | c066740 | 2008-10-15 22:04:31 -0700 | [diff] [blame] | 1584 | module_param(misc_messages, int, 0444); |
| 1585 | MODULE_PARM_DESC(misc_messages, "Log miscellaneous non fatal messages"); |
| 1586 | |