Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755333AbcKQSkc (ORCPT ); Thu, 17 Nov 2016 13:40:32 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:49682 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754876AbcKQSg0 (ORCPT ); Thu, 17 Nov 2016 13:36:26 -0500 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: rt@linuxtronix.de, Sebastian Andrzej Siewior , Tony Luck , Borislav Petkov , x86@kernel.org, linux-edac@vger.kernel.org, Thomas Gleixner Subject: [PATCH 01/20] x86/mce/therm_throt: Convert to hotplug state machine Date: Thu, 17 Nov 2016 19:35:22 +0100 Message-Id: <20161117183541.8588-2-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161117183541.8588-1-bigeasy@linutronix.de> References: <20161117183541.8588-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 Content-Length: 2973 Lines: 106 Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. Cc: Tony Luck Cc: Borislav Petkov Cc: x86@kernel.org Cc: linux-edac@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/mcheck/therm_throt.c | 53 ++++++++--------------------= ---- include/linux/cpuhotplug.h | 1 + 2 files changed, 13 insertions(+), 41 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu= /mcheck/therm_throt.c index 6b9dc4d18ccc..7f56620735ca 100644 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c @@ -271,58 +271,29 @@ static void thermal_throttle_remove_dev(struct device= *dev) } =20 /* Get notified when a cpu comes on/off. Be hotplug friendly. */ -static int -thermal_throttle_cpu_callback(struct notifier_block *nfb, - unsigned long action, - void *hcpu) +static int thermal_throttle_prepare(unsigned int cpu) { - unsigned int cpu =3D (unsigned long)hcpu; - struct device *dev; - int err =3D 0; + struct device *dev =3D get_cpu_device(cpu); =20 - dev =3D get_cpu_device(cpu); - - switch (action) { - case CPU_UP_PREPARE: - case CPU_UP_PREPARE_FROZEN: - err =3D thermal_throttle_add_dev(dev, cpu); - WARN_ON(err); - break; - case CPU_UP_CANCELED: - case CPU_UP_CANCELED_FROZEN: - case CPU_DEAD: - case CPU_DEAD_FROZEN: - thermal_throttle_remove_dev(dev); - break; - } - return notifier_from_errno(err); + return thermal_throttle_add_dev(dev, cpu); } =20 -static struct notifier_block thermal_throttle_cpu_notifier =3D +static int thermal_throttle_dead(unsigned int cpu) { - .notifier_call =3D thermal_throttle_cpu_callback, -}; + struct device *dev =3D get_cpu_device(cpu); + + thermal_throttle_remove_dev(dev); + return 0; +} =20 static __init int thermal_throttle_init_device(void) { - unsigned int cpu =3D 0; - int err; - if (!atomic_read(&therm_throt_en)) return 0; =20 - cpu_notifier_register_begin(); - - /* connect live CPUs to sysfs */ - for_each_online_cpu(cpu) { - err =3D thermal_throttle_add_dev(get_cpu_device(cpu), cpu); - WARN_ON(err); - } - - __register_hotcpu_notifier(&thermal_throttle_cpu_notifier); - cpu_notifier_register_done(); - - return 0; + return cpuhp_setup_state(CPUHP_X86_THERM_PREPARE, "x86/therm:prepare", + thermal_throttle_prepare, + thermal_throttle_dead); } device_initcall(thermal_throttle_init_device); =20 diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 79b96f647d64..aea6c6a63139 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -59,6 +59,7 @@ enum cpuhp_state { CPUHP_BLK_MQ_PREPARE, CPUHP_NET_FLOW_PREPARE, CPUHP_TOPOLOGY_PREPARE, + CPUHP_X86_THERM_PREPARE, CPUHP_TIMERS_DEAD, CPUHP_NOTF_ERR_INJ_PREPARE, CPUHP_MIPS_SOC_PREPARE, --=20 2.10.2