Commit | Line | Data |
---|---|---|
b70ef010 | 1 | #include <linux/module.h> |
888ab8e6 BP |
2 | #include <linux/slab.h> |
3 | ||
47ca08a4 | 4 | #include "mce_amd.h" |
b52401ce | 5 | |
888ab8e6 BP |
6 | static struct amd_decoder_ops *fam_ops; |
7 | ||
549d042d | 8 | static bool report_gart_errors; |
7cfd4a87 | 9 | static void (*nb_bus_decoder)(int node_id, struct mce *m, u32 nbcfg); |
549d042d BP |
10 | |
11 | void amd_report_gart_errors(bool v) | |
12 | { | |
13 | report_gart_errors = v; | |
14 | } | |
15 | EXPORT_SYMBOL_GPL(amd_report_gart_errors); | |
16 | ||
7cfd4a87 | 17 | void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32)) |
549d042d BP |
18 | { |
19 | nb_bus_decoder = f; | |
20 | } | |
21 | EXPORT_SYMBOL_GPL(amd_register_ecc_decoder); | |
22 | ||
7cfd4a87 | 23 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32)) |
549d042d BP |
24 | { |
25 | if (nb_bus_decoder) { | |
26 | WARN_ON(nb_bus_decoder != f); | |
27 | ||
28 | nb_bus_decoder = NULL; | |
29 | } | |
30 | } | |
31 | EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder); | |
32 | ||
b52401ce DT |
33 | /* |
34 | * string representation for the different MCA reported error types, see F3x48 | |
35 | * or MSR0000_0411. | |
36 | */ | |
6337583d BP |
37 | |
38 | /* transaction type */ | |
39 | const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" }; | |
b70ef010 | 40 | EXPORT_SYMBOL_GPL(tt_msgs); |
b52401ce | 41 | |
6337583d BP |
42 | /* cache level */ |
43 | const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" }; | |
b70ef010 | 44 | EXPORT_SYMBOL_GPL(ll_msgs); |
b52401ce | 45 | |
6337583d | 46 | /* memory transaction type */ |
b52401ce | 47 | const char *rrrr_msgs[] = { |
6337583d | 48 | "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP" |
b52401ce | 49 | }; |
b70ef010 | 50 | EXPORT_SYMBOL_GPL(rrrr_msgs); |
b52401ce | 51 | |
6337583d BP |
52 | /* participating processor */ |
53 | const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" }; | |
b70ef010 | 54 | EXPORT_SYMBOL_GPL(pp_msgs); |
b52401ce | 55 | |
6337583d BP |
56 | /* request timeout */ |
57 | const char *to_msgs[] = { "no timeout", "timed out" }; | |
b70ef010 | 58 | EXPORT_SYMBOL_GPL(to_msgs); |
b52401ce | 59 | |
6337583d BP |
60 | /* memory or i/o */ |
61 | const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" }; | |
b70ef010 | 62 | EXPORT_SYMBOL_GPL(ii_msgs); |
b52401ce | 63 | |
1c43f2e2 BP |
64 | /* |
65 | * Map the 4 or 5 (family-specific) bits of Extended Error code to the | |
66 | * string table. | |
67 | */ | |
68 | const char *ext_msgs[] = { | |
69 | "K8 ECC error", /* 0_0000b */ | |
70 | "CRC error on link", /* 0_0001b */ | |
71 | "Sync error packets on link", /* 0_0010b */ | |
72 | "Master Abort during link operation", /* 0_0011b */ | |
73 | "Target Abort during link operation", /* 0_0100b */ | |
74 | "Invalid GART PTE entry during table walk", /* 0_0101b */ | |
75 | "Unsupported atomic RMW command received", /* 0_0110b */ | |
76 | "WDT error: NB transaction timeout", /* 0_0111b */ | |
77 | "ECC/ChipKill ECC error", /* 0_1000b */ | |
78 | "SVM DEV Error", /* 0_1001b */ | |
79 | "Link Data error", /* 0_1010b */ | |
80 | "Link/L3/Probe Filter Protocol error", /* 0_1011b */ | |
81 | "NB Internal Arrays Parity error", /* 0_1100b */ | |
82 | "DRAM Address/Control Parity error", /* 0_1101b */ | |
83 | "Link Transmission error", /* 0_1110b */ | |
84 | "GART/DEV Table Walk Data error" /* 0_1111b */ | |
85 | "Res 0x100 error", /* 1_0000b */ | |
86 | "Res 0x101 error", /* 1_0001b */ | |
87 | "Res 0x102 error", /* 1_0010b */ | |
88 | "Res 0x103 error", /* 1_0011b */ | |
89 | "Res 0x104 error", /* 1_0100b */ | |
90 | "Res 0x105 error", /* 1_0101b */ | |
91 | "Res 0x106 error", /* 1_0110b */ | |
92 | "Res 0x107 error", /* 1_0111b */ | |
93 | "Res 0x108 error", /* 1_1000b */ | |
94 | "Res 0x109 error", /* 1_1001b */ | |
95 | "Res 0x10A error", /* 1_1010b */ | |
96 | "Res 0x10B error", /* 1_1011b */ | |
97 | "ECC error in L3 Cache Data", /* 1_1100b */ | |
98 | "L3 Cache Tag error", /* 1_1101b */ | |
99 | "L3 Cache LRU Parity error", /* 1_1110b */ | |
100 | "Probe Filter error" /* 1_1111b */ | |
b52401ce | 101 | }; |
b70ef010 | 102 | EXPORT_SYMBOL_GPL(ext_msgs); |
549d042d | 103 | |
888ab8e6 | 104 | static bool f10h_dc_mce(u16 ec) |
51966241 | 105 | { |
888ab8e6 BP |
106 | u8 r4 = (ec >> 4) & 0xf; |
107 | bool ret = false; | |
51966241 | 108 | |
888ab8e6 BP |
109 | if (r4 == R4_GEN) { |
110 | pr_cont("during data scrub.\n"); | |
111 | return true; | |
112 | } | |
51966241 | 113 | |
888ab8e6 BP |
114 | if (MEM_ERROR(ec)) { |
115 | u8 ll = ec & 0x3; | |
116 | ret = true; | |
51966241 | 117 | |
888ab8e6 BP |
118 | if (ll == LL_L2) |
119 | pr_cont("during L1 linefill from L2.\n"); | |
120 | else if (ll == LL_L1) | |
121 | pr_cont("Data/Tag %s error.\n", RRRR_MSG(ec)); | |
122 | else | |
123 | ret = false; | |
124 | } | |
125 | return ret; | |
126 | } | |
51966241 | 127 | |
888ab8e6 BP |
128 | static bool k8_dc_mce(u16 ec) |
129 | { | |
130 | if (BUS_ERROR(ec)) { | |
131 | pr_cont("during system linefill.\n"); | |
132 | return true; | |
133 | } | |
51966241 | 134 | |
888ab8e6 BP |
135 | return f10h_dc_mce(ec); |
136 | } | |
137 | ||
138 | static bool f14h_dc_mce(u16 ec) | |
139 | { | |
140 | u8 r4 = (ec >> 4) & 0xf; | |
141 | u8 ll = ec & 0x3; | |
142 | u8 tt = (ec >> 2) & 0x3; | |
143 | u8 ii = tt; | |
144 | bool ret = true; | |
145 | ||
146 | if (MEM_ERROR(ec)) { | |
147 | ||
148 | if (tt != TT_DATA || ll != LL_L1) | |
149 | return false; | |
150 | ||
151 | switch (r4) { | |
152 | case R4_DRD: | |
153 | case R4_DWR: | |
154 | pr_cont("Data/Tag parity error due to %s.\n", | |
155 | (r4 == R4_DRD ? "load/hw prf" : "store")); | |
156 | break; | |
157 | case R4_EVICT: | |
158 | pr_cont("Copyback parity error on a tag miss.\n"); | |
159 | break; | |
160 | case R4_SNOOP: | |
161 | pr_cont("Tag parity error during snoop.\n"); | |
162 | break; | |
163 | default: | |
164 | ret = false; | |
165 | } | |
166 | } else if (BUS_ERROR(ec)) { | |
167 | ||
168 | if ((ii != II_MEM && ii != II_IO) || ll != LL_LG) | |
169 | return false; | |
170 | ||
171 | pr_cont("System read data error on a "); | |
172 | ||
173 | switch (r4) { | |
174 | case R4_RD: | |
175 | pr_cont("TLB reload.\n"); | |
176 | break; | |
177 | case R4_DWR: | |
178 | pr_cont("store.\n"); | |
179 | break; | |
180 | case R4_DRD: | |
181 | pr_cont("load.\n"); | |
182 | break; | |
183 | default: | |
184 | ret = false; | |
185 | } | |
186 | } else { | |
187 | ret = false; | |
188 | } | |
189 | ||
190 | return ret; | |
191 | } | |
192 | ||
193 | static void amd_decode_dc_mce(struct mce *m) | |
194 | { | |
195 | u16 ec = m->status & 0xffff; | |
196 | u8 xec = (m->status >> 16) & 0xf; | |
197 | ||
198 | pr_emerg(HW_ERR "Data Cache Error: "); | |
199 | ||
200 | /* TLB error signatures are the same across families */ | |
201 | if (TLB_ERROR(ec)) { | |
202 | u8 tt = (ec >> 2) & 0x3; | |
203 | ||
204 | if (tt == TT_DATA) { | |
205 | pr_cont("%s TLB %s.\n", LL_MSG(ec), | |
206 | (xec ? "multimatch" : "parity error")); | |
207 | return; | |
208 | } | |
51966241 BP |
209 | else |
210 | goto wrong_dc_mce; | |
888ab8e6 BP |
211 | } |
212 | ||
213 | if (!fam_ops->dc_mce(ec)) | |
51966241 BP |
214 | goto wrong_dc_mce; |
215 | ||
216 | return; | |
217 | ||
218 | wrong_dc_mce: | |
c9f281fd | 219 | pr_emerg(HW_ERR "Corrupted DC MCE info?\n"); |
51966241 BP |
220 | } |
221 | ||
dd53bce4 | 222 | static bool k8_ic_mce(u16 ec) |
ab5535e7 | 223 | { |
dd53bce4 BP |
224 | u8 ll = ec & 0x3; |
225 | u8 r4 = (ec >> 4) & 0xf; | |
226 | bool ret = true; | |
ab5535e7 | 227 | |
dd53bce4 BP |
228 | if (!MEM_ERROR(ec)) |
229 | return false; | |
ab5535e7 | 230 | |
dd53bce4 BP |
231 | if (ll == 0x2) |
232 | pr_cont("during a linefill from L2.\n"); | |
233 | else if (ll == 0x1) { | |
234 | switch (r4) { | |
235 | case R4_IRD: | |
236 | pr_cont("Parity error during data load.\n"); | |
237 | break; | |
ab5535e7 | 238 | |
dd53bce4 BP |
239 | case R4_EVICT: |
240 | pr_cont("Copyback Parity/Victim error.\n"); | |
241 | break; | |
242 | ||
243 | case R4_SNOOP: | |
244 | pr_cont("Tag Snoop error.\n"); | |
245 | break; | |
246 | ||
247 | default: | |
248 | ret = false; | |
249 | break; | |
250 | } | |
ab5535e7 | 251 | } else |
dd53bce4 | 252 | ret = false; |
ab5535e7 | 253 | |
dd53bce4 BP |
254 | return ret; |
255 | } | |
256 | ||
257 | static bool f14h_ic_mce(u16 ec) | |
258 | { | |
259 | u8 ll = ec & 0x3; | |
260 | u8 tt = (ec >> 2) & 0x3; | |
261 | u8 r4 = (ec >> 4) & 0xf; | |
262 | bool ret = true; | |
ab5535e7 | 263 | |
dd53bce4 BP |
264 | if (MEM_ERROR(ec)) { |
265 | if (tt != 0 || ll != 1) | |
266 | ret = false; | |
267 | ||
268 | if (r4 == R4_IRD) | |
269 | pr_cont("Data/tag array parity error for a tag hit.\n"); | |
270 | else if (r4 == R4_SNOOP) | |
271 | pr_cont("Tag error during snoop/victimization.\n"); | |
272 | else | |
273 | ret = false; | |
274 | } | |
275 | return ret; | |
276 | } | |
277 | ||
278 | static void amd_decode_ic_mce(struct mce *m) | |
279 | { | |
280 | u16 ec = m->status & 0xffff; | |
281 | u8 xec = (m->status >> 16) & 0xf; | |
282 | ||
283 | pr_emerg(HW_ERR "Instruction Cache Error: "); | |
284 | ||
285 | if (TLB_ERROR(ec)) | |
286 | pr_cont("%s TLB %s.\n", LL_MSG(ec), | |
287 | (xec ? "multimatch" : "parity error")); | |
288 | else if (BUS_ERROR(ec)) { | |
289 | bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT(58))); | |
290 | ||
291 | pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read")); | |
292 | } else if (fam_ops->ic_mce(ec)) | |
293 | ; | |
294 | else | |
295 | pr_emerg(HW_ERR "Corrupted IC MCE info?\n"); | |
ab5535e7 BP |
296 | } |
297 | ||
7cfd4a87 | 298 | static void amd_decode_bu_mce(struct mce *m) |
56cad2d6 | 299 | { |
7cfd4a87 BP |
300 | u32 ec = m->status & 0xffff; |
301 | u32 xec = (m->status >> 16) & 0xf; | |
56cad2d6 | 302 | |
c9f281fd | 303 | pr_emerg(HW_ERR "Bus Unit Error"); |
56cad2d6 BP |
304 | |
305 | if (xec == 0x1) | |
306 | pr_cont(" in the write data buffers.\n"); | |
307 | else if (xec == 0x3) | |
308 | pr_cont(" in the victim data buffers.\n"); | |
309 | else if (xec == 0x2 && MEM_ERROR(ec)) | |
310 | pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec)); | |
311 | else if (xec == 0x0) { | |
312 | if (TLB_ERROR(ec)) | |
313 | pr_cont(": %s error in a Page Descriptor Cache or " | |
314 | "Guest TLB.\n", TT_MSG(ec)); | |
315 | else if (BUS_ERROR(ec)) | |
316 | pr_cont(": %s/ECC error in data read from NB: %s.\n", | |
317 | RRRR_MSG(ec), PP_MSG(ec)); | |
318 | else if (MEM_ERROR(ec)) { | |
319 | u8 rrrr = (ec >> 4) & 0xf; | |
320 | ||
321 | if (rrrr >= 0x7) | |
322 | pr_cont(": %s error during data copyback.\n", | |
323 | RRRR_MSG(ec)); | |
324 | else if (rrrr <= 0x1) | |
325 | pr_cont(": %s parity/ECC error during data " | |
326 | "access from L2.\n", RRRR_MSG(ec)); | |
327 | else | |
328 | goto wrong_bu_mce; | |
329 | } else | |
330 | goto wrong_bu_mce; | |
331 | } else | |
332 | goto wrong_bu_mce; | |
333 | ||
334 | return; | |
335 | ||
336 | wrong_bu_mce: | |
c9f281fd | 337 | pr_emerg(HW_ERR "Corrupted BU MCE info?\n"); |
56cad2d6 BP |
338 | } |
339 | ||
7cfd4a87 | 340 | static void amd_decode_ls_mce(struct mce *m) |
f9350efd | 341 | { |
ded50623 BP |
342 | u16 ec = m->status & 0xffff; |
343 | u8 xec = (m->status >> 16) & 0xf; | |
344 | ||
345 | if (boot_cpu_data.x86 == 0x14) { | |
346 | pr_emerg("You shouldn't be seeing an LS MCE on this cpu family," | |
347 | " please report on LKML.\n"); | |
348 | return; | |
349 | } | |
f9350efd | 350 | |
c9f281fd | 351 | pr_emerg(HW_ERR "Load Store Error"); |
f9350efd BP |
352 | |
353 | if (xec == 0x0) { | |
ded50623 | 354 | u8 r4 = (ec >> 4) & 0xf; |
f9350efd | 355 | |
ded50623 | 356 | if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR)) |
f9350efd BP |
357 | goto wrong_ls_mce; |
358 | ||
359 | pr_cont(" during %s.\n", RRRR_MSG(ec)); | |
ded50623 BP |
360 | } else |
361 | goto wrong_ls_mce; | |
362 | ||
f9350efd BP |
363 | return; |
364 | ||
365 | wrong_ls_mce: | |
c9f281fd | 366 | pr_emerg(HW_ERR "Corrupted LS MCE info?\n"); |
f9350efd BP |
367 | } |
368 | ||
7cfd4a87 | 369 | void amd_decode_nb_mce(int node_id, struct mce *m, u32 nbcfg) |
549d042d | 370 | { |
7cfd4a87 BP |
371 | u32 ec = m->status & 0xffff; |
372 | u32 nbsh = (u32)(m->status >> 32); | |
373 | u32 nbsl = (u32)m->status; | |
549d042d | 374 | |
256f7276 BP |
375 | /* |
376 | * GART TLB error reporting is disabled by default. Bail out early. | |
377 | */ | |
378 | if (TLB_ERROR(ec) && !report_gart_errors) | |
379 | return; | |
380 | ||
c9f281fd | 381 | pr_emerg(HW_ERR "Northbridge Error, node %d", node_id); |
549d042d BP |
382 | |
383 | /* | |
384 | * F10h, revD can disable ErrCpu[3:0] so check that first and also the | |
385 | * value encoding has changed so interpret those differently | |
386 | */ | |
387 | if ((boot_cpu_data.x86 == 0x10) && | |
cec7924f | 388 | (boot_cpu_data.x86_model > 7)) { |
7cfd4a87 BP |
389 | if (nbsh & K8_NBSH_ERR_CPU_VAL) |
390 | pr_cont(", core: %u\n", (u8)(nbsh & 0xf)); | |
549d042d | 391 | } else { |
7cfd4a87 | 392 | u8 assoc_cpus = nbsh & 0xf; |
5b89d2f9 BP |
393 | |
394 | if (assoc_cpus > 0) | |
395 | pr_cont(", core: %d", fls(assoc_cpus) - 1); | |
396 | ||
397 | pr_cont("\n"); | |
549d042d BP |
398 | } |
399 | ||
7cfd4a87 | 400 | pr_emerg(HW_ERR "%s.\n", EXT_ERR_MSG(nbsl)); |
d93cc222 BP |
401 | |
402 | if (BUS_ERROR(ec) && nb_bus_decoder) | |
7cfd4a87 | 403 | nb_bus_decoder(node_id, m, nbcfg); |
d93cc222 BP |
404 | } |
405 | EXPORT_SYMBOL_GPL(amd_decode_nb_mce); | |
406 | ||
7cfd4a87 | 407 | static void amd_decode_fr_mce(struct mce *m) |
53bd5fed BP |
408 | { |
409 | /* we have only one error signature so match all fields at once. */ | |
7cfd4a87 | 410 | if ((m->status & 0xffff) == 0x0f0f) |
c9f281fd | 411 | pr_emerg(HW_ERR " FR Error: CPU Watchdog timer expire.\n"); |
53bd5fed | 412 | else |
c9f281fd | 413 | pr_emerg(HW_ERR "Corrupted FR MCE info?\n"); |
53bd5fed BP |
414 | } |
415 | ||
6337583d | 416 | static inline void amd_decode_err_code(u16 ec) |
d93cc222 | 417 | { |
549d042d | 418 | if (TLB_ERROR(ec)) { |
c9f281fd | 419 | pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n", |
549d042d BP |
420 | TT_MSG(ec), LL_MSG(ec)); |
421 | } else if (MEM_ERROR(ec)) { | |
6337583d | 422 | pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n", |
549d042d BP |
423 | RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); |
424 | } else if (BUS_ERROR(ec)) { | |
6337583d | 425 | pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, " |
d93cc222 BP |
426 | "Participating Processor: %s\n", |
427 | RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), | |
428 | PP_MSG(ec)); | |
429 | } else | |
c9f281fd | 430 | pr_emerg(HW_ERR "Huh? Unknown MCE error 0x%x\n", ec); |
549d042d | 431 | } |
549d042d | 432 | |
9cdeb404 | 433 | int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) |
549d042d | 434 | { |
fb253195 | 435 | struct mce *m = (struct mce *)data; |
b69b29de | 436 | int node, ecc; |
549d042d | 437 | |
c9f281fd | 438 | pr_emerg(HW_ERR "MC%d_STATUS: ", m->bank); |
549d042d | 439 | |
37b7370a | 440 | pr_cont("%sorrected error, other errors lost: %s, " |
b69b29de BP |
441 | "CPU context corrupt: %s", |
442 | ((m->status & MCI_STATUS_UC) ? "Unc" : "C"), | |
37b7370a | 443 | ((m->status & MCI_STATUS_OVER) ? "yes" : "no"), |
b69b29de | 444 | ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); |
549d042d | 445 | |
b69b29de | 446 | /* do the two bits[14:13] together */ |
35d824b2 | 447 | ecc = (m->status >> 45) & 0x3; |
b69b29de BP |
448 | if (ecc) |
449 | pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); | |
450 | ||
451 | pr_cont("\n"); | |
452 | ||
51966241 BP |
453 | switch (m->bank) { |
454 | case 0: | |
7cfd4a87 | 455 | amd_decode_dc_mce(m); |
51966241 | 456 | break; |
d93cc222 | 457 | |
ab5535e7 | 458 | case 1: |
7cfd4a87 | 459 | amd_decode_ic_mce(m); |
ab5535e7 BP |
460 | break; |
461 | ||
56cad2d6 | 462 | case 2: |
7cfd4a87 | 463 | amd_decode_bu_mce(m); |
56cad2d6 BP |
464 | break; |
465 | ||
f9350efd | 466 | case 3: |
7cfd4a87 | 467 | amd_decode_ls_mce(m); |
f9350efd BP |
468 | break; |
469 | ||
51966241 | 470 | case 4: |
7cfd4a87 BP |
471 | node = amd_get_nb_id(m->extcpu); |
472 | amd_decode_nb_mce(node, m, 0); | |
51966241 BP |
473 | break; |
474 | ||
53bd5fed | 475 | case 5: |
7cfd4a87 | 476 | amd_decode_fr_mce(m); |
53bd5fed BP |
477 | break; |
478 | ||
51966241 BP |
479 | default: |
480 | break; | |
b69b29de | 481 | } |
51966241 BP |
482 | |
483 | amd_decode_err_code(m->status & 0xffff); | |
fb253195 BP |
484 | |
485 | return NOTIFY_STOP; | |
549d042d | 486 | } |
9cdeb404 | 487 | EXPORT_SYMBOL_GPL(amd_decode_mce); |
f436f8bb | 488 | |
fb253195 BP |
489 | static struct notifier_block amd_mce_dec_nb = { |
490 | .notifier_call = amd_decode_mce, | |
491 | }; | |
492 | ||
f436f8bb IM |
493 | static int __init mce_amd_init(void) |
494 | { | |
495 | /* | |
e045c291 | 496 | * We can decode MCEs for K8, F10h and F11h CPUs: |
f436f8bb | 497 | */ |
e045c291 BP |
498 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
499 | return 0; | |
500 | ||
501 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) | |
502 | return 0; | |
503 | ||
888ab8e6 BP |
504 | fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL); |
505 | if (!fam_ops) | |
506 | return -ENOMEM; | |
507 | ||
508 | switch (boot_cpu_data.x86) { | |
509 | case 0xf: | |
510 | fam_ops->dc_mce = k8_dc_mce; | |
dd53bce4 | 511 | fam_ops->ic_mce = k8_ic_mce; |
888ab8e6 BP |
512 | break; |
513 | ||
514 | case 0x10: | |
515 | fam_ops->dc_mce = f10h_dc_mce; | |
dd53bce4 | 516 | fam_ops->ic_mce = k8_ic_mce; |
888ab8e6 BP |
517 | break; |
518 | ||
519 | case 0x14: | |
520 | fam_ops->dc_mce = f14h_dc_mce; | |
dd53bce4 | 521 | fam_ops->ic_mce = f14h_ic_mce; |
888ab8e6 BP |
522 | break; |
523 | ||
524 | default: | |
525 | printk(KERN_WARNING "Huh? What family is that: %d?!\n", | |
526 | boot_cpu_data.x86); | |
527 | kfree(fam_ops); | |
528 | return -EINVAL; | |
529 | } | |
530 | ||
e045c291 | 531 | atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
f436f8bb IM |
532 | |
533 | return 0; | |
534 | } | |
535 | early_initcall(mce_amd_init); | |
0d18b2e3 BP |
536 | |
537 | #ifdef MODULE | |
538 | static void __exit mce_amd_exit(void) | |
539 | { | |
fb253195 | 540 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
888ab8e6 | 541 | kfree(fam_ops); |
0d18b2e3 BP |
542 | } |
543 | ||
544 | MODULE_DESCRIPTION("AMD MCE decoder"); | |
545 | MODULE_ALIAS("edac-mce-amd"); | |
546 | MODULE_LICENSE("GPL"); | |
547 | module_exit(mce_amd_exit); | |
548 | #endif |