edac_mce_amd.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #include <linux/module.h>
  2. #include "edac_mce_amd.h"
  3. static bool report_gart_errors;
  4. static void (*nb_bus_decoder)(int node_id, struct err_regs *regs);
  5. void amd_report_gart_errors(bool v)
  6. {
  7. report_gart_errors = v;
  8. }
  9. EXPORT_SYMBOL_GPL(amd_report_gart_errors);
  10. void amd_register_ecc_decoder(void (*f)(int, struct err_regs *))
  11. {
  12. nb_bus_decoder = f;
  13. }
  14. EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
  15. void amd_unregister_ecc_decoder(void (*f)(int, struct err_regs *))
  16. {
  17. if (nb_bus_decoder) {
  18. WARN_ON(nb_bus_decoder != f);
  19. nb_bus_decoder = NULL;
  20. }
  21. }
  22. EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
  23. /*
  24. * string representation for the different MCA reported error types, see F3x48
  25. * or MSR0000_0411.
  26. */
  27. const char *tt_msgs[] = { /* transaction type */
  28. "instruction",
  29. "data",
  30. "generic",
  31. "reserved"
  32. };
  33. EXPORT_SYMBOL_GPL(tt_msgs);
  34. const char *ll_msgs[] = { /* cache level */
  35. "L0",
  36. "L1",
  37. "L2",
  38. "L3/generic"
  39. };
  40. EXPORT_SYMBOL_GPL(ll_msgs);
  41. const char *rrrr_msgs[] = {
  42. "generic",
  43. "generic read",
  44. "generic write",
  45. "data read",
  46. "data write",
  47. "inst fetch",
  48. "prefetch",
  49. "evict",
  50. "snoop",
  51. "reserved RRRR= 9",
  52. "reserved RRRR= 10",
  53. "reserved RRRR= 11",
  54. "reserved RRRR= 12",
  55. "reserved RRRR= 13",
  56. "reserved RRRR= 14",
  57. "reserved RRRR= 15"
  58. };
  59. EXPORT_SYMBOL_GPL(rrrr_msgs);
  60. const char *pp_msgs[] = { /* participating processor */
  61. "local node originated (SRC)",
  62. "local node responded to request (RES)",
  63. "local node observed as 3rd party (OBS)",
  64. "generic"
  65. };
  66. EXPORT_SYMBOL_GPL(pp_msgs);
  67. const char *to_msgs[] = {
  68. "no timeout",
  69. "timed out"
  70. };
  71. EXPORT_SYMBOL_GPL(to_msgs);
  72. const char *ii_msgs[] = { /* memory or i/o */
  73. "mem access",
  74. "reserved",
  75. "i/o access",
  76. "generic"
  77. };
  78. EXPORT_SYMBOL_GPL(ii_msgs);
  79. /*
  80. * Map the 4 or 5 (family-specific) bits of Extended Error code to the
  81. * string table.
  82. */
  83. const char *ext_msgs[] = {
  84. "K8 ECC error", /* 0_0000b */
  85. "CRC error on link", /* 0_0001b */
  86. "Sync error packets on link", /* 0_0010b */
  87. "Master Abort during link operation", /* 0_0011b */
  88. "Target Abort during link operation", /* 0_0100b */
  89. "Invalid GART PTE entry during table walk", /* 0_0101b */
  90. "Unsupported atomic RMW command received", /* 0_0110b */
  91. "WDT error: NB transaction timeout", /* 0_0111b */
  92. "ECC/ChipKill ECC error", /* 0_1000b */
  93. "SVM DEV Error", /* 0_1001b */
  94. "Link Data error", /* 0_1010b */
  95. "Link/L3/Probe Filter Protocol error", /* 0_1011b */
  96. "NB Internal Arrays Parity error", /* 0_1100b */
  97. "DRAM Address/Control Parity error", /* 0_1101b */
  98. "Link Transmission error", /* 0_1110b */
  99. "GART/DEV Table Walk Data error" /* 0_1111b */
  100. "Res 0x100 error", /* 1_0000b */
  101. "Res 0x101 error", /* 1_0001b */
  102. "Res 0x102 error", /* 1_0010b */
  103. "Res 0x103 error", /* 1_0011b */
  104. "Res 0x104 error", /* 1_0100b */
  105. "Res 0x105 error", /* 1_0101b */
  106. "Res 0x106 error", /* 1_0110b */
  107. "Res 0x107 error", /* 1_0111b */
  108. "Res 0x108 error", /* 1_1000b */
  109. "Res 0x109 error", /* 1_1001b */
  110. "Res 0x10A error", /* 1_1010b */
  111. "Res 0x10B error", /* 1_1011b */
  112. "ECC error in L3 Cache Data", /* 1_1100b */
  113. "L3 Cache Tag error", /* 1_1101b */
  114. "L3 Cache LRU Parity error", /* 1_1110b */
  115. "Probe Filter error" /* 1_1111b */
  116. };
  117. EXPORT_SYMBOL_GPL(ext_msgs);
  118. void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
  119. {
  120. u32 ec = ERROR_CODE(regs->nbsl);
  121. u32 xec = EXT_ERROR_CODE(regs->nbsl);
  122. if (!handle_errors)
  123. return;
  124. pr_emerg(" Northbridge Error, node %d", node_id);
  125. /*
  126. * F10h, revD can disable ErrCpu[3:0] so check that first and also the
  127. * value encoding has changed so interpret those differently
  128. */
  129. if ((boot_cpu_data.x86 == 0x10) &&
  130. (boot_cpu_data.x86_model > 8)) {
  131. if (regs->nbsh & K8_NBSH_ERR_CPU_VAL)
  132. pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf));
  133. } else {
  134. pr_cont(", core: %d\n", ilog2((regs->nbsh & 0xf)));
  135. }
  136. pr_emerg("%s.\n", EXT_ERR_MSG(xec));
  137. if (BUS_ERROR(ec) && nb_bus_decoder)
  138. nb_bus_decoder(node_id, regs);
  139. }
  140. EXPORT_SYMBOL_GPL(amd_decode_nb_mce);
  141. static inline void amd_decode_err_code(unsigned int ec)
  142. {
  143. if (TLB_ERROR(ec)) {
  144. /*
  145. * GART errors are intended to help graphics driver developers
  146. * to detect bad GART PTEs. It is recommended by AMD to disable
  147. * GART table walk error reporting by default[1] (currently
  148. * being disabled in mce_cpu_quirks()) and according to the
  149. * comment in mce_cpu_quirks(), such GART errors can be
  150. * incorrectly triggered. We may see these errors anyway and
  151. * unless requested by the user, they won't be reported.
  152. *
  153. * [1] section 13.10.1 on BIOS and Kernel Developers Guide for
  154. * AMD NPT family 0Fh processors
  155. */
  156. if (!report_gart_errors)
  157. return;
  158. pr_emerg(" Transaction: %s, Cache Level %s\n",
  159. TT_MSG(ec), LL_MSG(ec));
  160. } else if (MEM_ERROR(ec)) {
  161. pr_emerg(" Transaction: %s, Type: %s, Cache Level: %s",
  162. RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec));
  163. } else if (BUS_ERROR(ec)) {
  164. pr_emerg(" Transaction type: %s(%s), %s, Cache Level: %s, "
  165. "Participating Processor: %s\n",
  166. RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec),
  167. PP_MSG(ec));
  168. } else
  169. pr_warning("Huh? Unknown MCE error 0x%x\n", ec);
  170. }
  171. void decode_mce(struct mce *m)
  172. {
  173. struct err_regs regs;
  174. int node, ecc;
  175. pr_emerg("MC%d_STATUS: ", m->bank);
  176. pr_cont("%sorrected error, report: %s, MiscV: %svalid, "
  177. "CPU context corrupt: %s",
  178. ((m->status & MCI_STATUS_UC) ? "Unc" : "C"),
  179. ((m->status & MCI_STATUS_EN) ? "yes" : "no"),
  180. ((m->status & MCI_STATUS_MISCV) ? "" : "in"),
  181. ((m->status & MCI_STATUS_PCC) ? "yes" : "no"));
  182. /* do the two bits[14:13] together */
  183. ecc = m->status & (3ULL << 45);
  184. if (ecc)
  185. pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U"));
  186. pr_cont("\n");
  187. amd_decode_err_code(m->status & 0xffff);
  188. if (m->bank == 4) {
  189. regs.nbsl = (u32) m->status;
  190. regs.nbsh = (u32)(m->status >> 32);
  191. regs.nbeal = (u32) m->addr;
  192. regs.nbeah = (u32)(m->addr >> 32);
  193. node = per_cpu(cpu_llc_id, m->extcpu);
  194. amd_decode_nb_mce(node, &regs, 1);
  195. }
  196. }