blob: 33985aa613569b31e2ed992cffe7b6a6ab39ce85 [file] [log] [blame]
Borislav Petkovb70ef012009-06-25 19:32:38 +02001#include <linux/module.h>
Borislav Petkov888ab8e2010-08-18 15:11:35 +02002#include <linux/slab.h>
3
Borislav Petkov47ca08a2010-09-27 15:30:39 +02004#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02005
Borislav Petkov888ab8e2010-08-18 15:11:35 +02006static struct amd_decoder_ops *fam_ops;
7
Borislav Petkov549d0422009-07-24 13:51:42 +02008static bool report_gart_errors;
Borislav Petkov7cfd4a82010-09-01 14:45:20 +02009static void (*nb_bus_decoder)(int node_id, struct mce *m, u32 nbcfg);
Borislav Petkov549d0422009-07-24 13:51:42 +020010
11void amd_report_gart_errors(bool v)
12{
13 report_gart_errors = v;
14}
15EXPORT_SYMBOL_GPL(amd_report_gart_errors);
16
Borislav Petkov7cfd4a82010-09-01 14:45:20 +020017void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32))
Borislav Petkov549d0422009-07-24 13:51:42 +020018{
19 nb_bus_decoder = f;
20}
21EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
22
Borislav Petkov7cfd4a82010-09-01 14:45:20 +020023void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32))
Borislav Petkov549d0422009-07-24 13:51:42 +020024{
25 if (nb_bus_decoder) {
26 WARN_ON(nb_bus_decoder != f);
27
28 nb_bus_decoder = NULL;
29 }
30}
31EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
32
Doug Thompsonb52401ce2009-05-06 17:57:20 +020033/*
34 * string representation for the different MCA reported error types, see F3x48
35 * or MSR0000_0411.
36 */
Borislav Petkov63375832010-09-06 18:13:39 +020037
38/* transaction type */
39const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020040EXPORT_SYMBOL_GPL(tt_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020041
Borislav Petkov63375832010-09-06 18:13:39 +020042/* cache level */
43const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020044EXPORT_SYMBOL_GPL(ll_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020045
Borislav Petkov63375832010-09-06 18:13:39 +020046/* memory transaction type */
Doug Thompsonb52401ce2009-05-06 17:57:20 +020047const char *rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020048 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020049};
Borislav Petkovb70ef012009-06-25 19:32:38 +020050EXPORT_SYMBOL_GPL(rrrr_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020051
Borislav Petkov63375832010-09-06 18:13:39 +020052/* participating processor */
53const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020054EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020055
Borislav Petkov63375832010-09-06 18:13:39 +020056/* request timeout */
57const char *to_msgs[] = { "no timeout", "timed out" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020058EXPORT_SYMBOL_GPL(to_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020059
Borislav Petkov63375832010-09-06 18:13:39 +020060/* memory or i/o */
61const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020062EXPORT_SYMBOL_GPL(ii_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020063
Borislav Petkov1c43f2e2009-07-23 15:47:51 +020064/*
65 * Map the 4 or 5 (family-specific) bits of Extended Error code to the
66 * string table.
67 */
68const 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 */
Doug Thompsonb52401ce2009-05-06 17:57:20 +0200101};
Borislav Petkovb70ef012009-06-25 19:32:38 +0200102EXPORT_SYMBOL_GPL(ext_msgs);
Borislav Petkov549d0422009-07-24 13:51:42 +0200103
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200104static bool f10h_dc_mce(u16 ec)
105{
106 u8 r4 = (ec >> 4) & 0xf;
107 bool ret = false;
108
109 if (r4 == R4_GEN) {
110 pr_cont("during data scrub.\n");
111 return true;
112 }
113
114 if (MEM_ERROR(ec)) {
115 u8 ll = ec & 0x3;
116 ret = true;
117
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}
127
128static bool k8_dc_mce(u16 ec)
129{
130 if (BUS_ERROR(ec)) {
131 pr_cont("during system linefill.\n");
132 return true;
133 }
134
135 return f10h_dc_mce(ec);
136}
137
138static 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
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200193static void amd_decode_dc_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200194{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200195 u16 ec = m->status & 0xffff;
196 u8 xec = (m->status >> 16) & 0xf;
Borislav Petkov51966242009-07-28 13:50:43 +0200197
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200198 pr_emerg(HW_ERR "Data Cache Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200199
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200200 /* TLB error signatures are the same across families */
201 if (TLB_ERROR(ec)) {
202 u8 tt = (ec >> 2) & 0x3;
Borislav Petkov51966242009-07-28 13:50:43 +0200203
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200204 if (tt == TT_DATA) {
205 pr_cont("%s TLB %s.\n", LL_MSG(ec),
206 (xec ? "multimatch" : "parity error"));
207 return;
208 }
Borislav Petkov51966242009-07-28 13:50:43 +0200209 else
210 goto wrong_dc_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200211 }
212
213 if (!fam_ops->dc_mce(ec))
Borislav Petkov51966242009-07-28 13:50:43 +0200214 goto wrong_dc_mce;
215
216 return;
217
218wrong_dc_mce:
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200219 pr_emerg(HW_ERR "Corrupted DC MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200220}
221
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200222static void amd_decode_ic_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200223{
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200224 u32 ec = m->status & 0xffff;
225 u32 xec = (m->status >> 16) & 0xf;
Borislav Petkovab5535e2009-07-28 14:06:26 +0200226
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200227 pr_emerg(HW_ERR "Instruction Cache Error");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200228
229 if (xec == 1 && TLB_ERROR(ec))
230 pr_cont(": %s TLB multimatch.\n", LL_MSG(ec));
231 else if (xec == 0) {
232 if (TLB_ERROR(ec))
233 pr_cont(": %s TLB Parity error.\n", LL_MSG(ec));
234 else if (BUS_ERROR(ec)) {
235 if (boot_cpu_data.x86 == 0xf &&
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200236 (m->status & BIT(58)))
Borislav Petkovab5535e2009-07-28 14:06:26 +0200237 pr_cont(" during system linefill.\n");
238 else
239 pr_cont(" during attempted NB data read.\n");
240 } else if (MEM_ERROR(ec)) {
241 u8 ll = ec & 0x3;
242 u8 rrrr = (ec >> 4) & 0xf;
243
244 if (ll == 0x2)
245 pr_cont(" during a linefill from L2.\n");
246 else if (ll == 0x1) {
247
248 switch (rrrr) {
249 case 0x5:
250 pr_cont(": Parity error during "
251 "data load.\n");
252 break;
253
254 case 0x7:
255 pr_cont(": Copyback Parity/Victim"
256 " error.\n");
257 break;
258
259 case 0x8:
260 pr_cont(": Tag Snoop error.\n");
261 break;
262
263 default:
264 goto wrong_ic_mce;
265 break;
266 }
267 }
268 } else
269 goto wrong_ic_mce;
270 } else
271 goto wrong_ic_mce;
272
273 return;
274
275wrong_ic_mce:
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200276 pr_emerg(HW_ERR "Corrupted IC MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200277}
278
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200279static void amd_decode_bu_mce(struct mce *m)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200280{
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200281 u32 ec = m->status & 0xffff;
282 u32 xec = (m->status >> 16) & 0xf;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200283
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200284 pr_emerg(HW_ERR "Bus Unit Error");
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200285
286 if (xec == 0x1)
287 pr_cont(" in the write data buffers.\n");
288 else if (xec == 0x3)
289 pr_cont(" in the victim data buffers.\n");
290 else if (xec == 0x2 && MEM_ERROR(ec))
291 pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec));
292 else if (xec == 0x0) {
293 if (TLB_ERROR(ec))
294 pr_cont(": %s error in a Page Descriptor Cache or "
295 "Guest TLB.\n", TT_MSG(ec));
296 else if (BUS_ERROR(ec))
297 pr_cont(": %s/ECC error in data read from NB: %s.\n",
298 RRRR_MSG(ec), PP_MSG(ec));
299 else if (MEM_ERROR(ec)) {
300 u8 rrrr = (ec >> 4) & 0xf;
301
302 if (rrrr >= 0x7)
303 pr_cont(": %s error during data copyback.\n",
304 RRRR_MSG(ec));
305 else if (rrrr <= 0x1)
306 pr_cont(": %s parity/ECC error during data "
307 "access from L2.\n", RRRR_MSG(ec));
308 else
309 goto wrong_bu_mce;
310 } else
311 goto wrong_bu_mce;
312 } else
313 goto wrong_bu_mce;
314
315 return;
316
317wrong_bu_mce:
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200318 pr_emerg(HW_ERR "Corrupted BU MCE info?\n");
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200319}
320
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200321static void amd_decode_ls_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200322{
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200323 u32 ec = m->status & 0xffff;
324 u32 xec = (m->status >> 16) & 0xf;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200325
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200326 pr_emerg(HW_ERR "Load Store Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200327
328 if (xec == 0x0) {
329 u8 rrrr = (ec >> 4) & 0xf;
330
331 if (!BUS_ERROR(ec) || (rrrr != 0x3 && rrrr != 0x4))
332 goto wrong_ls_mce;
333
334 pr_cont(" during %s.\n", RRRR_MSG(ec));
335 }
336 return;
337
338wrong_ls_mce:
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200339 pr_emerg(HW_ERR "Corrupted LS MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200340}
341
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200342void amd_decode_nb_mce(int node_id, struct mce *m, u32 nbcfg)
Borislav Petkov549d0422009-07-24 13:51:42 +0200343{
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200344 u32 ec = m->status & 0xffff;
345 u32 nbsh = (u32)(m->status >> 32);
346 u32 nbsl = (u32)m->status;
Borislav Petkov549d0422009-07-24 13:51:42 +0200347
Borislav Petkov256f7272009-12-15 16:03:53 +0100348 /*
349 * GART TLB error reporting is disabled by default. Bail out early.
350 */
351 if (TLB_ERROR(ec) && !report_gart_errors)
352 return;
353
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200354 pr_emerg(HW_ERR "Northbridge Error, node %d", node_id);
Borislav Petkov549d0422009-07-24 13:51:42 +0200355
356 /*
357 * F10h, revD can disable ErrCpu[3:0] so check that first and also the
358 * value encoding has changed so interpret those differently
359 */
360 if ((boot_cpu_data.x86 == 0x10) &&
Borislav Petkovcec79242009-10-27 19:12:02 +0100361 (boot_cpu_data.x86_model > 7)) {
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200362 if (nbsh & K8_NBSH_ERR_CPU_VAL)
363 pr_cont(", core: %u\n", (u8)(nbsh & 0xf));
Borislav Petkov549d0422009-07-24 13:51:42 +0200364 } else {
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200365 u8 assoc_cpus = nbsh & 0xf;
Borislav Petkov5b89d2f2010-03-09 20:38:48 +0100366
367 if (assoc_cpus > 0)
368 pr_cont(", core: %d", fls(assoc_cpus) - 1);
369
370 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +0200371 }
372
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200373 pr_emerg(HW_ERR "%s.\n", EXT_ERR_MSG(nbsl));
Borislav Petkovd93cc222009-07-28 10:56:15 +0200374
375 if (BUS_ERROR(ec) && nb_bus_decoder)
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200376 nb_bus_decoder(node_id, m, nbcfg);
Borislav Petkovd93cc222009-07-28 10:56:15 +0200377}
378EXPORT_SYMBOL_GPL(amd_decode_nb_mce);
379
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200380static void amd_decode_fr_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200381{
382 /* we have only one error signature so match all fields at once. */
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200383 if ((m->status & 0xffff) == 0x0f0f)
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200384 pr_emerg(HW_ERR " FR Error: CPU Watchdog timer expire.\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200385 else
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200386 pr_emerg(HW_ERR "Corrupted FR MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200387}
388
Borislav Petkov63375832010-09-06 18:13:39 +0200389static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +0200390{
Borislav Petkov549d0422009-07-24 13:51:42 +0200391 if (TLB_ERROR(ec)) {
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200392 pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n",
Borislav Petkov549d0422009-07-24 13:51:42 +0200393 TT_MSG(ec), LL_MSG(ec));
394 } else if (MEM_ERROR(ec)) {
Borislav Petkov63375832010-09-06 18:13:39 +0200395 pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n",
Borislav Petkov549d0422009-07-24 13:51:42 +0200396 RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec));
397 } else if (BUS_ERROR(ec)) {
Borislav Petkov63375832010-09-06 18:13:39 +0200398 pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, "
Borislav Petkovd93cc222009-07-28 10:56:15 +0200399 "Participating Processor: %s\n",
400 RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec),
401 PP_MSG(ec));
402 } else
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200403 pr_emerg(HW_ERR "Huh? Unknown MCE error 0x%x\n", ec);
Borislav Petkov549d0422009-07-24 13:51:42 +0200404}
Borislav Petkov549d0422009-07-24 13:51:42 +0200405
Borislav Petkov9cdeb402010-09-02 18:33:24 +0200406int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +0200407{
Borislav Petkovfb253192009-10-07 13:20:38 +0200408 struct mce *m = (struct mce *)data;
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200409 int node, ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +0200410
Borislav Petkovc9f281f2010-08-18 18:21:42 +0200411 pr_emerg(HW_ERR "MC%d_STATUS: ", m->bank);
Borislav Petkov549d0422009-07-24 13:51:42 +0200412
Borislav Petkov37b73702010-08-24 18:21:42 +0200413 pr_cont("%sorrected error, other errors lost: %s, "
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200414 "CPU context corrupt: %s",
415 ((m->status & MCI_STATUS_UC) ? "Unc" : "C"),
Borislav Petkov37b73702010-08-24 18:21:42 +0200416 ((m->status & MCI_STATUS_OVER) ? "yes" : "no"),
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200417 ((m->status & MCI_STATUS_PCC) ? "yes" : "no"));
Borislav Petkov549d0422009-07-24 13:51:42 +0200418
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200419 /* do the two bits[14:13] together */
Borislav Petkov35d824b2010-04-30 15:19:02 +0200420 ecc = (m->status >> 45) & 0x3;
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200421 if (ecc)
422 pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U"));
423
424 pr_cont("\n");
425
Borislav Petkov51966242009-07-28 13:50:43 +0200426 switch (m->bank) {
427 case 0:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200428 amd_decode_dc_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +0200429 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +0200430
Borislav Petkovab5535e2009-07-28 14:06:26 +0200431 case 1:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200432 amd_decode_ic_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200433 break;
434
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200435 case 2:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200436 amd_decode_bu_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200437 break;
438
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200439 case 3:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200440 amd_decode_ls_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200441 break;
442
Borislav Petkov51966242009-07-28 13:50:43 +0200443 case 4:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200444 node = amd_get_nb_id(m->extcpu);
445 amd_decode_nb_mce(node, m, 0);
Borislav Petkov51966242009-07-28 13:50:43 +0200446 break;
447
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200448 case 5:
Borislav Petkov7cfd4a82010-09-01 14:45:20 +0200449 amd_decode_fr_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200450 break;
451
Borislav Petkov51966242009-07-28 13:50:43 +0200452 default:
453 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200454 }
Borislav Petkov51966242009-07-28 13:50:43 +0200455
456 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +0200457
458 return NOTIFY_STOP;
Borislav Petkov549d0422009-07-24 13:51:42 +0200459}
Borislav Petkov9cdeb402010-09-02 18:33:24 +0200460EXPORT_SYMBOL_GPL(amd_decode_mce);
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200461
Borislav Petkovfb253192009-10-07 13:20:38 +0200462static struct notifier_block amd_mce_dec_nb = {
463 .notifier_call = amd_decode_mce,
464};
465
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200466static int __init mce_amd_init(void)
467{
468 /*
Borislav Petkove045c292010-08-06 18:55:45 +0200469 * We can decode MCEs for K8, F10h and F11h CPUs:
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200470 */
Borislav Petkove045c292010-08-06 18:55:45 +0200471 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
472 return 0;
473
474 if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11)
475 return 0;
476
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200477 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
478 if (!fam_ops)
479 return -ENOMEM;
480
481 switch (boot_cpu_data.x86) {
482 case 0xf:
483 fam_ops->dc_mce = k8_dc_mce;
484 break;
485
486 case 0x10:
487 fam_ops->dc_mce = f10h_dc_mce;
488 break;
489
490 case 0x14:
491 fam_ops->dc_mce = f14h_dc_mce;
492 break;
493
494 default:
495 printk(KERN_WARNING "Huh? What family is that: %d?!\n",
496 boot_cpu_data.x86);
497 kfree(fam_ops);
498 return -EINVAL;
499 }
500
Borislav Petkove045c292010-08-06 18:55:45 +0200501 atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200502
503 return 0;
504}
505early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +0200506
507#ifdef MODULE
508static void __exit mce_amd_exit(void)
509{
Borislav Petkovfb253192009-10-07 13:20:38 +0200510 atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200511 kfree(fam_ops);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +0200512}
513
514MODULE_DESCRIPTION("AMD MCE decoder");
515MODULE_ALIAS("edac-mce-amd");
516MODULE_LICENSE("GPL");
517module_exit(mce_amd_exit);
518#endif