Commit 977ab257 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: rt@linuxtronix.de
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/20161117183541.8588-17-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 9b377e21
...@@ -703,7 +703,7 @@ static struct device_attribute pa6t_attrs[] = { ...@@ -703,7 +703,7 @@ static struct device_attribute pa6t_attrs[] = {
#endif /* HAS_PPC_PMC_PA6T */ #endif /* HAS_PPC_PMC_PA6T */
#endif /* HAS_PPC_PMC_CLASSIC */ #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 cpu *c = &per_cpu(cpu_devices, cpu);
struct device *s = &c->dev; struct device *s = &c->dev;
...@@ -782,11 +782,12 @@ static void register_cpu_online(unsigned int cpu) ...@@ -782,11 +782,12 @@ static void register_cpu_online(unsigned int cpu)
} }
#endif #endif
cacheinfo_cpu_online(cpu); cacheinfo_cpu_online(cpu);
return 0;
} }
#ifdef CONFIG_HOTPLUG_CPU static int unregister_cpu_online(unsigned int cpu)
static void unregister_cpu_online(unsigned int cpu)
{ {
#ifdef CONFIG_HOTPLUG_CPU
struct cpu *c = &per_cpu(cpu_devices, cpu); struct cpu *c = &per_cpu(cpu_devices, cpu);
struct device *s = &c->dev; struct device *s = &c->dev;
struct device_attribute *attrs, *pmc_attrs; struct device_attribute *attrs, *pmc_attrs;
...@@ -863,6 +864,8 @@ static void unregister_cpu_online(unsigned int cpu) ...@@ -863,6 +864,8 @@ static void unregister_cpu_online(unsigned int cpu)
} }
#endif #endif
cacheinfo_cpu_offline(cpu); cacheinfo_cpu_offline(cpu);
#endif /* CONFIG_HOTPLUG_CPU */
return 0;
} }
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
...@@ -883,32 +886,6 @@ ssize_t arch_cpu_release(const char *buf, size_t count) ...@@ -883,32 +886,6 @@ ssize_t arch_cpu_release(const char *buf, size_t count)
} }
#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ #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); static DEFINE_MUTEX(cpu_mutex);
int cpu_add_dev_attr(struct device_attribute *attr) int cpu_add_dev_attr(struct device_attribute *attr)
...@@ -1023,12 +1000,10 @@ static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL); ...@@ -1023,12 +1000,10 @@ static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL);
static int __init topology_init(void) static int __init topology_init(void)
{ {
int cpu; int cpu, r;
register_nodes(); register_nodes();
cpu_notifier_register_begin();
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct cpu *c = &per_cpu(cpu_devices, cpu); struct cpu *c = &per_cpu(cpu_devices, cpu);
...@@ -1047,15 +1022,10 @@ static int __init topology_init(void) ...@@ -1047,15 +1022,10 @@ static int __init topology_init(void)
device_create_file(&c->dev, &dev_attr_physical_id); device_create_file(&c->dev, &dev_attr_physical_id);
} }
if (cpu_online(cpu))
register_cpu_online(cpu);
} }
r = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powerpc/topology:online",
__register_cpu_notifier(&sysfs_cpu_nb); register_cpu_online, unregister_cpu_online);
WARN_ON(r < 0);
cpu_notifier_register_done();
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
sysfs_create_dscr_default(); sysfs_create_dscr_default();
#endif /* CONFIG_PPC64 */ #endif /* CONFIG_PPC64 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment