From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758058AbcKCOvS (ORCPT ); Thu, 3 Nov 2016 10:51:18 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35480 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932766AbcKCOvO (ORCPT ); Thu, 3 Nov 2016 10:51:14 -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 23/25] x86/mcheck: Make CPU_DOWN_PREPARE the counter part of CPU_STARTING Date: Thu, 3 Nov 2016 15:50:19 +0100 Message-Id: <20161103145021.28528-24-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 previous patch moved mcheck_cpu_init() out of identify_cpu() and put it as the first CPU hotplug callback which is invoked on the target CPU during bring up. It enables MCE and starts the MCE timer. If a CPU goes down then those two things have to be reverted and this happens currently in CPU_DOWN_PREPARE. This is not symmetrical because CPU_DOWN_PREPARE is the counterpart of CPU_ONLINE. Usually CPU_DOWN_FAILED and CPU_ONLINE can do the same thing but not in this case since here (in CPU_DOWN_FAILED) it tries to revert what was done in CPU_DOWN_PREPARE. To make this simpler make CPU_DOWN_PREPARE the counterpart of mcheck_cpu_starting() and just disable MCE and stop the timer. With this change the callback is symmetrical again and we don't need CPU_DOWN_FAILED including mce_reenable_cpu(). smp_call_function_single() can be dropped because it is already invoked on the proper CPU and interrupts are disabled at this point. 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 | 44 +++++++++++-------------------------= ---- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/= mce.c index 72af9db8526d..596a7128a46b 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -2469,43 +2469,22 @@ static void mce_device_remove(unsigned int cpu) } =20 /* Make sure there are no machine checks on offlined CPUs. */ -static void mce_disable_cpu(void *h) +static void mce_disable_cpu(void) { - unsigned long action =3D *(unsigned long *)h; - if (!mce_available(raw_cpu_ptr(&cpu_info))) return; =20 - if (!(action & CPU_TASKS_FROZEN)) + if (!cpuhp_tasks_frozen) cmci_clear(); =20 vendor_disable_error_reporting(); } =20 -static void mce_reenable_cpu(void *h) -{ - unsigned long action =3D *(unsigned long *)h; - int i; - - if (!mce_available(raw_cpu_ptr(&cpu_info))) - return; - - if (!(action & CPU_TASKS_FROZEN)) - cmci_reenable(); - for (i =3D 0; i < mca_cfg.banks; i++) { - struct mce_bank *b =3D &mce_banks[i]; - - if (b->init) - wrmsrl(msr_ops.ctl(i), b->ctl); - } -} - /* Get notified when a cpu comes on/off. Be hotplug friendly. */ static int mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *h= cpu) { unsigned int cpu =3D (unsigned long)hcpu; - struct timer_list *t =3D &per_cpu(mce_timer, cpu); =20 switch (action & ~CPU_TASKS_FROZEN) { case CPU_ONLINE: @@ -2530,19 +2509,20 @@ mce_cpu_callback(struct notifier_block *nfb, unsign= ed long action, void *hcpu) if (!(action & CPU_TASKS_FROZEN)) cmci_rediscover(); break; - case CPU_DOWN_PREPARE: - smp_call_function_single(cpu, mce_disable_cpu, &action, 1); - del_timer_sync(t); - break; - case CPU_DOWN_FAILED: - smp_call_function_single(cpu, mce_reenable_cpu, &action, 1); - mce_start_timer(cpu, t); - break; } =20 return NOTIFY_OK; } =20 +static int mce_cpu_down_dying(unsigned int cpu) +{ + struct timer_list *t =3D this_cpu_ptr(&mce_timer); + + mce_disable_cpu(); + del_timer_sync(t); + return 0; +} + static struct notifier_block mce_cpu_notifier =3D { .notifier_call =3D mce_cpu_callback, }; @@ -2597,7 +2577,7 @@ static __init int mcheck_init_device(void) goto err_init_pool; =20 err =3D cpuhp_setup_state(CPUHP_AP_X86_MCE_STARTING, "x86/mce:starting", - mcheck_cpu_starting, NULL); + mcheck_cpu_starting, mce_cpu_down_dying); if (err) goto err_init_pool; =20 --=20 2.10.2