From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932767AbcKCOvO (ORCPT ); Thu, 3 Nov 2016 10:51:14 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35484 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932318AbcKCOvK (ORCPT ); Thu, 3 Nov 2016 10:51:10 -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 24/25] x86/mcheck: Move CPU_ONLINE to hotplug state machine Date: Thu, 3 Nov 2016 15:50:20 +0100 Message-Id: <20161103145021.28528-25-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 This callback is still partly asymmetrical since the counterpart of mce_device_create is done in CPU_DEAD. On failure we don't undo mce_device_create() doing _but_ it will happen once we move CPU_DEAD to the state machine. 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/kernel/cpu/mcheck/mce.c | 61 ++++++++++++++++--------------------= ---- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/= mce.c index 596a7128a46b..b1770ebcb8de 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -2487,18 +2487,6 @@ mce_cpu_callback(struct notifier_block *nfb, unsigne= d long action, void *hcpu) unsigned int cpu =3D (unsigned long)hcpu; =20 switch (action & ~CPU_TASKS_FROZEN) { - case CPU_ONLINE: - mce_device_create(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_dead) threshold_cpu_callback_dead(cpu); @@ -2514,6 +2502,22 @@ mce_cpu_callback(struct notifier_block *nfb, unsigne= d long action, void *hcpu) return NOTIFY_OK; } =20 +static int mce_cpu_online(unsigned int cpu) +{ + int ret; + + mce_device_create(cpu); + if (!threshold_cpu_callback_online) + return 0; + + ret =3D threshold_cpu_callback_online(cpu); + if (ret) { + mce_device_remove(cpu); + return ret; + } + return 0; +} + static int mce_cpu_down_dying(unsigned int cpu) { struct timer_list *t =3D this_cpu_ptr(&mce_timer); @@ -2547,8 +2551,8 @@ static __init void mce_init_banks(void) =20 static __init int mcheck_init_device(void) { + enum cpuhp_state hp_online; int err; - int i =3D 0; =20 if (!mce_available(&boot_cpu_data)) { err =3D -EIO; @@ -2580,22 +2584,13 @@ static __init int mcheck_init_device(void) mcheck_cpu_starting, mce_cpu_down_dying); if (err) goto err_init_pool; + err =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/mce:online", + mce_cpu_online, NULL); + if (err < 0) + goto err_hp_online; + hp_online =3D err; =20 cpu_notifier_register_begin(); - for_each_online_cpu(i) { - err =3D mce_device_create(i); - if (err) { - /* - * Register notifier anyway (and do not unreg it) so - * that we don't leave undeleted timers, see notifier - * callback above. - */ - __register_hotcpu_notifier(&mce_cpu_notifier); - cpu_notifier_register_done(); - goto err_device_create; - } - } - __register_hotcpu_notifier(&mce_cpu_notifier); cpu_notifier_register_done(); =20 @@ -2610,17 +2605,9 @@ static __init int mcheck_init_device(void) =20 err_register: unregister_syscore_ops(&mce_syscore_ops); + cpuhp_remove_state(hp_online); =20 -err_device_create: - /* - * We didn't keep track of which devices were created above, but - * even if we had, the set of online cpus might have changed. - * Play safe and remove for every possible cpu, since - * mce_device_remove() will do the right thing. - */ - for_each_possible_cpu(i) - mce_device_remove(i); - +err_hp_online: cpuhp_remove_state(CPUHP_AP_X86_MCE_STARTING); =20 err_init_pool: --=20 2.10.2