x86/ras, EDAC, acpi: Assign MCE notifier handlers a priority
authorBorislav Petkov <bp@suse.de>
Mon, 23 Jan 2017 18:35:14 +0000 (19:35 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 24 Jan 2017 08:14:57 +0000 (09:14 +0100)
Assign all notifiers on the MCE decode chain a priority so that they get
called in the correct order.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20170123183514.13356-10-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/mce.h
arch/x86/kernel/cpu/mcheck/mce.c
drivers/acpi/acpi_extlog.c
drivers/acpi/nfit/mce.c
drivers/edac/i7core_edac.c
drivers/edac/mce_amd.c
drivers/edac/sb_edac.c
drivers/edac/skx_edac.c

index 528f6ec897cbf3aee51d039a11f5a65882382147..e63873683d4a3a79b625699ebf66419d7e2d1de0 100644 (file)
@@ -189,6 +189,15 @@ extern struct mce_vendor_flags mce_flags;
 
 extern struct mca_config mca_cfg;
 extern struct mca_msr_regs msr_ops;
+
+enum mce_notifier_prios {
+       MCE_PRIO_SRAO           = INT_MAX,
+       MCE_PRIO_EXTLOG         = INT_MAX - 1,
+       MCE_PRIO_NFIT           = INT_MAX - 2,
+       MCE_PRIO_EDAC           = INT_MAX - 3,
+       MCE_PRIO_LOWEST         = 0,
+};
+
 extern void mce_register_decode_chain(struct notifier_block *nb);
 extern void mce_unregister_decode_chain(struct notifier_block *nb);
 
index 0fef5406f0eb9bec5dbad3c419c5d58cd14c8800..e39bbc0e7c8bbe51dfae0f07b02df2e9c726323a 100644 (file)
@@ -216,9 +216,7 @@ void mce_register_decode_chain(struct notifier_block *nb)
 {
        atomic_inc(&num_notifiers);
 
-       /* Ensure SRAO notifier has the highest priority in the decode chain. */
-       if (nb != &mce_srao_nb && nb->priority == INT_MAX)
-               nb->priority -= 1;
+       WARN_ON(nb->priority > MCE_PRIO_LOWEST && nb->priority < MCE_PRIO_EDAC);
 
        atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
 }
@@ -582,7 +580,7 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
 }
 static struct notifier_block mce_srao_nb = {
        .notifier_call  = srao_decode_notifier,
-       .priority = INT_MAX,
+       .priority       = MCE_PRIO_SRAO,
 };
 
 static int mce_default_notifier(struct notifier_block *nb, unsigned long val,
@@ -608,7 +606,7 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,
 static struct notifier_block mce_default_nb = {
        .notifier_call  = mce_default_notifier,
        /* lowest prio, we want it to run last. */
-       .priority       = 0,
+       .priority       = MCE_PRIO_LOWEST,
 };
 
 /*
index b3842ffc19ba20a210bec8dd8dc5f56cf9119de9..a15270a806fcab41bae160937cb09c11515056f2 100644 (file)
@@ -212,6 +212,7 @@ static bool __init extlog_get_l1addr(void)
 }
 static struct notifier_block extlog_mce_dec = {
        .notifier_call  = extlog_print,
+       .priority       = MCE_PRIO_EXTLOG,
 };
 
 static int __init extlog_init(void)
index e5ce81c38eed4bbeea0bcbc380c77ba66d0b097c..3ba1c3472cf9e293ae70fd7cdc649eeb96abf1a0 100644 (file)
@@ -90,6 +90,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
 
 static struct notifier_block nfit_mce_dec = {
        .notifier_call  = nfit_handle_mce,
+       .priority       = MCE_PRIO_NFIT,
 };
 
 void nfit_mce_register(void)
index 69b5adead0ad63e1ff5ea89a589715c5921f3c49..75ad847593b79561dd469273f93109fe68be573a 100644 (file)
@@ -1835,6 +1835,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,
 
 static struct notifier_block i7_mce_dec = {
        .notifier_call  = i7core_mce_check_error,
+       .priority       = MCE_PRIO_EDAC,
 };
 
 struct memdev_dmi_entry {
index ecad750fd09052de59597c1a5768e5f78e4a96ed..0d9bc25543d8234f7676e4d201da97a9ffe8330f 100644 (file)
@@ -1054,6 +1054,7 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
 
 static struct notifier_block amd_mce_dec_nb = {
        .notifier_call  = amd_decode_mce,
+       .priority       = MCE_PRIO_EDAC,
 };
 
 static int __init mce_amd_init(void)
index 54ae6dc45ab2216343b0c542765537889332a0fb..c585a014dd3d556a37d9c220391dab1bc65d54fc 100644 (file)
@@ -3136,7 +3136,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,
 }
 
 static struct notifier_block sbridge_mce_dec = {
-       .notifier_call      = sbridge_mce_check_error,
+       .notifier_call  = sbridge_mce_check_error,
+       .priority       = MCE_PRIO_EDAC,
 };
 
 /****************************************************************************
index 79ef675e4d6f0525478d9980477e6a42c18d5b33..1159dba4671fef926afce7164cd278faf23c2e24 100644 (file)
@@ -1007,7 +1007,8 @@ static int skx_mce_check_error(struct notifier_block *nb, unsigned long val,
 }
 
 static struct notifier_block skx_mce_dec = {
-       .notifier_call = skx_mce_check_error,
+       .notifier_call  = skx_mce_check_error,
+       .priority       = MCE_PRIO_EDAC,
 };
 
 static void skx_remove(void)