EDAC, MCE: Add F15h CU MCE decoder
[cascardo/linux.git] / drivers / edac / mce_amd.c
index c018109..7eb2706 100644 (file)
@@ -5,6 +5,7 @@
 
 static struct amd_decoder_ops *fam_ops;
 
+static u8 xec_mask      = 0xf;
 static u8 nb_err_cpumask = 0xf;
 
 static bool report_gart_errors;
@@ -74,7 +75,44 @@ static const char *f10h_nb_mce_desc[] = {
        "ECC Error in the Probe Filter directory"
 };
 
-static bool f12h_dc_mce(u16 ec)
+static const char * const f15h_ic_mce_desc[] = {
+       "UC during a demand linefill from L2",
+       "Parity error during data load from IC",
+       "Parity error for IC valid bit",
+       "Main tag parity error",
+       "Parity error in prediction queue",
+       "PFB data/address parity error",
+       "Parity error in the branch status reg",
+       "PFB promotion address error",
+       "Tag error during probe/victimization",
+       "Parity error for IC probe tag valid bit",
+       "PFB non-cacheable bit parity error",
+       "PFB valid bit parity error",                   /* xec = 0xd */
+       "patch RAM",                                    /* xec = 010 */
+       "uop queue",
+       "insn buffer",
+       "predecode buffer",
+       "fetch address FIFO"
+};
+
+static const char * const f15h_cu_mce_desc[] = {
+       "Fill ECC error on data fills",                 /* xec = 0x4 */
+       "Fill parity error on insn fills",
+       "Prefetcher request FIFO parity error",
+       "PRQ address parity error",
+       "PRQ data parity error",
+       "WCC Tag ECC error",
+       "WCC Data ECC error",
+       "WCB Data parity error",
+       "VB Data/ECC error",
+       "L2 Tag ECC error",                             /* xec = 0x10 */
+       "Hard L2 Tag ECC error",
+       "Multiple hits on L2 tag",
+       "XAB parity error",
+       "PRB address parity error"
+};
+
+static bool f12h_dc_mce(u16 ec, u8 xec)
 {
        bool ret = false;
 
@@ -92,7 +130,7 @@ static bool f12h_dc_mce(u16 ec)
        return ret;
 }
 
-static bool f10h_dc_mce(u16 ec)
+static bool f10h_dc_mce(u16 ec, u8 xec)
 {
        u8 r4  = (ec >> 4) & 0xf;
        u8 ll  = ec & 0x3;
@@ -101,20 +139,20 @@ static bool f10h_dc_mce(u16 ec)
                pr_cont("during data scrub.\n");
                return true;
        }
-       return f12h_dc_mce(ec);
+       return f12h_dc_mce(ec, xec);
 }
 
-static bool k8_dc_mce(u16 ec)
+static bool k8_dc_mce(u16 ec, u8 xec)
 {
        if (BUS_ERROR(ec)) {
                pr_cont("during system linefill.\n");
                return true;
        }
 
-       return f10h_dc_mce(ec);
+       return f10h_dc_mce(ec, xec);
 }
 
-static bool f14h_dc_mce(u16 ec)
+static bool f14h_dc_mce(u16 ec, u8 xec)
 {
        u8 r4    = (ec >> 4) & 0xf;
        u8 ll    = ec & 0x3;
@@ -169,10 +207,58 @@ static bool f14h_dc_mce(u16 ec)
        return ret;
 }
 
+static bool f15h_dc_mce(u16 ec, u8 xec)
+{
+       bool ret = true;
+
+       if (MEM_ERROR(ec)) {
+
+               switch (xec) {
+               case 0x0:
+                       pr_cont("Data Array access error.\n");
+                       break;
+
+               case 0x1:
+                       pr_cont("UC error during a linefill from L2/NB.\n");
+                       break;
+
+               case 0x2:
+               case 0x11:
+                       pr_cont("STQ access error.\n");
+                       break;
+
+               case 0x3:
+                       pr_cont("SCB access error.\n");
+                       break;
+
+               case 0x10:
+                       pr_cont("Tag error.\n");
+                       break;
+
+               case 0x12:
+                       pr_cont("LDQ access error.\n");
+                       break;
+
+               default:
+                       ret = false;
+               }
+       } else if (BUS_ERROR(ec)) {
+
+               if (!xec)
+                       pr_cont("during system linefill.\n");
+               else
+                       pr_cont(" Internal %s condition.\n",
+                               ((xec == 1) ? "livelock" : "deadlock"));
+       } else
+               ret = false;
+
+       return ret;
+}
+
 static void amd_decode_dc_mce(struct mce *m)
 {
        u16 ec = m->status & 0xffff;
-       u8 xec = (m->status >> 16) & 0xf;
+       u8 xec = (m->status >> 16) & xec_mask;
 
        pr_emerg(HW_ERR "Data Cache Error: ");
 
@@ -182,23 +268,17 @@ static void amd_decode_dc_mce(struct mce *m)
 
                if (tt == TT_DATA) {
                        pr_cont("%s TLB %s.\n", LL_MSG(ec),
-                               (xec ? "multimatch" : "parity error"));
+                               ((xec == 2) ? "locked miss"
+                                           : (xec ? "multimatch" : "parity")));
                        return;
                }
-               else
-                       goto wrong_dc_mce;
-       }
-
-       if (!fam_ops->dc_mce(ec))
-               goto wrong_dc_mce;
-
-       return;
-
-wrong_dc_mce:
-       pr_emerg(HW_ERR "Corrupted DC MCE info?\n");
+       } else if (fam_ops->dc_mce(ec, xec))
+               ;
+       else
+               pr_emerg(HW_ERR "Corrupted DC MCE info?\n");
 }
 
-static bool k8_ic_mce(u16 ec)
+static bool k8_ic_mce(u16 ec, u8 xec)
 {
        u8 ll    = ec & 0x3;
        u8 r4    = (ec >> 4) & 0xf;
@@ -233,7 +313,7 @@ static bool k8_ic_mce(u16 ec)
        return ret;
 }
 
-static bool f14h_ic_mce(u16 ec)
+static bool f14h_ic_mce(u16 ec, u8 xec)
 {
        u8 ll    = ec & 0x3;
        u8 tt    = (ec >> 2) & 0x3;
@@ -254,10 +334,36 @@ static bool f14h_ic_mce(u16 ec)
        return ret;
 }
 
+static bool f15h_ic_mce(u16 ec, u8 xec)
+{
+       bool ret = true;
+
+       if (!MEM_ERROR(ec))
+               return false;
+
+       switch (xec) {
+       case 0x0 ... 0xa:
+               pr_cont("%s.\n", f15h_ic_mce_desc[xec]);
+               break;
+
+       case 0xd:
+               pr_cont("%s.\n", f15h_ic_mce_desc[xec-2]);
+               break;
+
+       case 0x10 ... 0x14:
+               pr_cont("Decoder %s parity error.\n", f15h_ic_mce_desc[xec-4]);
+               break;
+
+       default:
+               ret = false;
+       }
+       return ret;
+}
+
 static void amd_decode_ic_mce(struct mce *m)
 {
        u16 ec = m->status & 0xffff;
-       u8 xec = (m->status >> 16) & 0xf;
+       u8 xec = (m->status >> 16) & xec_mask;
 
        pr_emerg(HW_ERR "Instruction Cache Error: ");
 
@@ -268,7 +374,7 @@ static void amd_decode_ic_mce(struct mce *m)
                bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
 
                pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
-       } else if (fam_ops->ic_mce(ec))
+       } else if (fam_ops->ic_mce(ec, xec))
                ;
        else
                pr_emerg(HW_ERR "Corrupted IC MCE info?\n");
@@ -277,7 +383,7 @@ static void amd_decode_ic_mce(struct mce *m)
 static void amd_decode_bu_mce(struct mce *m)
 {
        u32 ec = m->status & 0xffff;
-       u32 xec = (m->status >> 16) & 0xf;
+       u32 xec = (m->status >> 16) & xec_mask;
 
        pr_emerg(HW_ERR "Bus Unit Error");
 
@@ -316,10 +422,50 @@ wrong_bu_mce:
        pr_emerg(HW_ERR "Corrupted BU MCE info?\n");
 }
 
+static void amd_decode_cu_mce(struct mce *m)
+{
+       u16 ec = m->status & 0xffff;
+       u8 xec = (m->status >> 16) & xec_mask;
+
+       pr_emerg(HW_ERR "Combined Unit Error: ");
+
+       if (TLB_ERROR(ec)) {
+               if (xec == 0x0)
+                       pr_cont("Data parity TLB read error.\n");
+               else if (xec == 0x1)
+                       pr_cont("Poison data provided for TLB fill.\n");
+               else
+                       goto wrong_cu_mce;
+       } else if (BUS_ERROR(ec)) {
+               if (xec > 2)
+                       goto wrong_cu_mce;
+
+               pr_cont("Error during attempted NB data read.\n");
+       } else if (MEM_ERROR(ec)) {
+               switch (xec) {
+               case 0x4 ... 0xc:
+                       pr_cont("%s.\n", f15h_cu_mce_desc[xec - 0x4]);
+                       break;
+
+               case 0x10 ... 0x14:
+                       pr_cont("%s.\n", f15h_cu_mce_desc[xec - 0x7]);
+                       break;
+
+               default:
+                       goto wrong_cu_mce;
+               }
+       }
+
+       return;
+
+wrong_cu_mce:
+       pr_emerg(HW_ERR "Corrupted CU MCE info?\n");
+}
+
 static void amd_decode_ls_mce(struct mce *m)
 {
        u16 ec = m->status & 0xffff;
-       u8 xec = (m->status >> 16) & 0xf;
+       u8 xec = (m->status >> 16) & xec_mask;
 
        if (boot_cpu_data.x86 == 0x14) {
                pr_emerg("You shouldn't be seeing an LS MCE on this cpu family,"
@@ -576,7 +722,10 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
                break;
 
        case 2:
-               amd_decode_bu_mce(m);
+               if (boot_cpu_data.x86 == 0x15)
+                       amd_decode_cu_mce(m);
+               else
+                       amd_decode_bu_mce(m);
                break;
 
        case 3:
@@ -651,6 +800,12 @@ static int __init mce_amd_init(void)
                fam_ops->nb_mce = nb_noop_mce;
                break;
 
+       case 0x15:
+               xec_mask = 0x1f;
+               fam_ops->dc_mce = f15h_dc_mce;
+               fam_ops->ic_mce = f15h_ic_mce;
+               break;
+
        default:
                printk(KERN_WARNING "Huh? What family is that: %d?!\n",
                                    boot_cpu_data.x86);