From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932609AbcKCOvK (ORCPT ); Thu, 3 Nov 2016 10:51:10 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35470 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932318AbcKCOvG (ORCPT ); Thu, 3 Nov 2016 10:51:06 -0400 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: rt@linutronix.de, Sebastian Andrzej Siewior , Tony Luck , Borislav Petkov , linux-edac@vger.kernel.org, x86@kernel.org, Thomas Gleixner Subject: [PATCH 21/25] x86/mcheck: Split threshold_cpu_callback into two callbacks Date: Thu, 3 Nov 2016 15:50:17 +0100 Message-Id: <20161103145021.28528-22-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161103145021.28528-1-bigeasy@linutronix.de> References: <20161103145021.28528-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Borislav Petkov Cc: linux-edac@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- 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); */ =20 extern void (*mce_threshold_vector)(void); -extern void (*threshold_cpu_callback)(unsigned long action, unsigned int c= pu); +extern int (*threshold_cpu_callback_online)(unsigned int cpu); +extern int (*threshold_cpu_callback_dead)(unsigned int cpu); =20 /* 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 =3D { =20 DEFINE_PER_CPU(struct device *, mce_device); =20 -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); =20 static inline struct mce_bank *attr_to_bank(struct device_attribute *attr) { @@ -2513,12 +2514,19 @@ mce_cpu_callback(struct notifier_block *nfb, unsign= ed 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 =3D 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); =20 diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mch= eck/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, i= nt bank) per_cpu(threshold_banks, cpu)[bank] =3D NULL; } =20 -static void threshold_remove_device(unsigned int cpu) +static int threshold_remove_device(unsigned int cpu) { unsigned int bank; =20 @@ -1088,6 +1088,7 @@ static void threshold_remove_device(unsigned int cpu) } kfree(per_cpu(threshold_banks, cpu)); per_cpu(threshold_banks, cpu) =3D NULL; + return 0; } =20 /* create dir/files for all valid threshold banks */ @@ -1120,24 +1121,6 @@ static int threshold_create_device(unsigned int cpu) return err; } =20 -/* 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 =3D 0; @@ -1149,7 +1132,8 @@ static __init int threshold_init_device(void) if (err) return err; } - threshold_cpu_callback =3D amd_64_threshold_cpu_callback; + threshold_cpu_callback_online =3D threshold_create_device; + threshold_cpu_callback_dead =3D threshold_remove_device; =20 return 0; } --=20 2.10.2