[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20161103145021.28528-22-bigeasy@linutronix.de>
Date: Thu, 3 Nov 2016 15:50:17 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: rt@...utronix.de,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Tony Luck <tony.luck@...el.com>,
Borislav Petkov <bp@...en8.de>, linux-edac@...r.kernel.org,
x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 21/25] x86/mcheck: Split threshold_cpu_callback into two callbacks
The threshold_cpu_callback callbacks looks like one of the notifier and
its arguments are almost the same. Split this out and have one ONLINE
and one DEAD callback. This will come handy later once the main code
gets changed to use the callback mechanism.
Also, handle threshold_cpu_callback_online() return value so we don't
continue if the function fails.
Cc: Tony Luck <tony.luck@...el.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: linux-edac@...r.kernel.org
Cc: x86@...nel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
arch/x86/include/asm/mce.h | 3 ++-
arch/x86/kernel/cpu/mcheck/mce.c | 18 +++++++++++++-----
arch/x86/kernel/cpu/mcheck/mce_amd.c | 24 ++++--------------------
3 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 9bd7ff5ffbcc..978be74a12c1 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -295,7 +295,8 @@ void do_machine_check(struct pt_regs *, long);
*/
extern void (*mce_threshold_vector)(void);
-extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
+extern int (*threshold_cpu_callback_online)(unsigned int cpu);
+extern int (*threshold_cpu_callback_dead)(unsigned int cpu);
/* Deferred error interrupt handler */
extern void (*deferred_error_int_vector)(void);
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index e9ffd6d9e32d..79b5ad9570ca 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2255,7 +2255,8 @@ static struct bus_type mce_subsys = {
DEFINE_PER_CPU(struct device *, mce_device);
-void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
+int (*threshold_cpu_callback_online)(unsigned int cpu);
+int (*threshold_cpu_callback_dead)(unsigned int cpu);
static inline struct mce_bank *attr_to_bank(struct device_attribute *attr)
{
@@ -2513,12 +2514,19 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
mce_device_create(cpu);
- if (threshold_cpu_callback)
- threshold_cpu_callback(action, cpu);
+ if (threshold_cpu_callback_online) {
+ int ret;
+
+ ret = threshold_cpu_callback_online(cpu);
+ if (ret) {
+ mce_device_remove(cpu);
+ return NOTIFY_BAD;
+ }
+ }
break;
case CPU_DEAD:
- if (threshold_cpu_callback)
- threshold_cpu_callback(action, cpu);
+ if (threshold_cpu_callback_dead)
+ threshold_cpu_callback_dead(cpu);
mce_device_remove(cpu);
mce_intel_hcpu_update(cpu);
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 3e529fd747f8..a99ae03f8c03 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -1077,7 +1077,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
per_cpu(threshold_banks, cpu)[bank] = NULL;
}
-static void threshold_remove_device(unsigned int cpu)
+static int threshold_remove_device(unsigned int cpu)
{
unsigned int bank;
@@ -1088,6 +1088,7 @@ static void threshold_remove_device(unsigned int cpu)
}
kfree(per_cpu(threshold_banks, cpu));
per_cpu(threshold_banks, cpu) = NULL;
+ return 0;
}
/* create dir/files for all valid threshold banks */
@@ -1120,24 +1121,6 @@ static int threshold_create_device(unsigned int cpu)
return err;
}
-/* get notified when a cpu comes on/off */
-static void
-amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
-{
- switch (action) {
- case CPU_ONLINE:
- case CPU_ONLINE_FROZEN:
- threshold_create_device(cpu);
- break;
- case CPU_DEAD:
- case CPU_DEAD_FROZEN:
- threshold_remove_device(cpu);
- break;
- default:
- break;
- }
-}
-
static __init int threshold_init_device(void)
{
unsigned lcpu = 0;
@@ -1149,7 +1132,8 @@ static __init int threshold_init_device(void)
if (err)
return err;
}
- threshold_cpu_callback = amd_64_threshold_cpu_callback;
+ threshold_cpu_callback_online = threshold_create_device;
+ threshold_cpu_callback_dead = threshold_remove_device;
return 0;
}
--
2.10.2
Powered by blists - more mailing lists