From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754918AbcKUPxx (ORCPT ); Mon, 21 Nov 2016 10:53:53 -0500 Received: from terminus.zytor.com ([198.137.202.10]:40564 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078AbcKUPxw (ORCPT ); Mon, 21 Nov 2016 10:53:52 -0500 Date: Mon, 21 Nov 2016 07:53:29 -0800 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, bigeasy@linutronix.de, paulus@samba.org, mingo@kernel.org, linux-kernel@vger.kernel.org, benh@kernel.crashing.org, mpe@ellerman.id.au Reply-To: bigeasy@linutronix.de, hpa@zytor.com, paulus@samba.org, mingo@kernel.org, tglx@linutronix.de, mpe@ellerman.id.au, linux-kernel@vger.kernel.org, benh@kernel.crashing.org In-Reply-To: <20161117183541.8588-17-bigeasy@linutronix.de> References: <20161117183541.8588-17-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] powerpc/sysfs: Convert to hotplug state machine Git-Commit-ID: 2e261004c45e0641492053c7c8ec523569b73eb3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2e261004c45e0641492053c7c8ec523569b73eb3 Gitweb: http://git.kernel.org/tip/2e261004c45e0641492053c7c8ec523569b73eb3 Author: Sebastian Andrzej Siewior AuthorDate: Thu, 17 Nov 2016 19:35:37 +0100 Committer: Thomas Gleixner CommitDate: Mon, 21 Nov 2016 16:37:08 +0100 powerpc/sysfs: Convert to hotplug state machine Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. The previous convention of keeping the files around until the CPU is dead has not been preserved as there is no point to keep them available when the cpu is going down. This makes the hotplug call symmetric. Signed-off-by: Sebastian Andrzej Siewior Cc: Benjamin Herrenschmidt Cc: rt@linuxtronix.de Cc: Paul Mackerras Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/20161117183541.8588-17-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner --- arch/powerpc/kernel/sysfs.c | 50 +++++++++------------------------------------ 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index c4f1d1f..c1fb255 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -703,7 +703,7 @@ static struct device_attribute pa6t_attrs[] = { #endif /* HAS_PPC_PMC_PA6T */ #endif /* HAS_PPC_PMC_CLASSIC */ -static void register_cpu_online(unsigned int cpu) +static int register_cpu_online(unsigned int cpu) { struct cpu *c = &per_cpu(cpu_devices, cpu); struct device *s = &c->dev; @@ -782,11 +782,12 @@ static void register_cpu_online(unsigned int cpu) } #endif cacheinfo_cpu_online(cpu); + return 0; } -#ifdef CONFIG_HOTPLUG_CPU -static void unregister_cpu_online(unsigned int cpu) +static int unregister_cpu_online(unsigned int cpu) { +#ifdef CONFIG_HOTPLUG_CPU struct cpu *c = &per_cpu(cpu_devices, cpu); struct device *s = &c->dev; struct device_attribute *attrs, *pmc_attrs; @@ -863,6 +864,8 @@ static void unregister_cpu_online(unsigned int cpu) } #endif cacheinfo_cpu_offline(cpu); +#endif /* CONFIG_HOTPLUG_CPU */ + return 0; } #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE @@ -883,32 +886,6 @@ ssize_t arch_cpu_release(const char *buf, size_t count) } #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ -#endif /* CONFIG_HOTPLUG_CPU */ - -static int sysfs_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) -{ - unsigned int cpu = (unsigned int)(long)hcpu; - - switch (action) { - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - register_cpu_online(cpu); - break; -#ifdef CONFIG_HOTPLUG_CPU - case CPU_DEAD: - case CPU_DEAD_FROZEN: - unregister_cpu_online(cpu); - break; -#endif - } - return NOTIFY_OK; -} - -static struct notifier_block sysfs_cpu_nb = { - .notifier_call = sysfs_cpu_notify, -}; - static DEFINE_MUTEX(cpu_mutex); int cpu_add_dev_attr(struct device_attribute *attr) @@ -1023,12 +1000,10 @@ static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL); static int __init topology_init(void) { - int cpu; + int cpu, r; register_nodes(); - cpu_notifier_register_begin(); - for_each_possible_cpu(cpu) { struct cpu *c = &per_cpu(cpu_devices, cpu); @@ -1047,15 +1022,10 @@ static int __init topology_init(void) device_create_file(&c->dev, &dev_attr_physical_id); } - - if (cpu_online(cpu)) - register_cpu_online(cpu); } - - __register_cpu_notifier(&sysfs_cpu_nb); - - cpu_notifier_register_done(); - + r = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powerpc/topology:online", + register_cpu_online, unregister_cpu_online); + WARN_ON(r < 0); #ifdef CONFIG_PPC64 sysfs_create_dscr_default(); #endif /* CONFIG_PPC64 */