diff options
author | Nathan Fontenot <nfont@linux.vnet.ibm.com> | 2015-12-16 14:51:26 -0600 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-12-17 22:41:01 +1100 |
commit | d98389f375329b7a37d0e9211a1216d9141d7a5f (patch) | |
tree | 06f70c905f414156eb6f1b6bd94c02cad39417f1 /arch/powerpc/platforms | |
parent | 183deeea5871a6f750ec64ab1cff85fb089d38df (diff) | |
download | op-kernel-dev-d98389f375329b7a37d0e9211a1216d9141d7a5f.zip op-kernel-dev-d98389f375329b7a37d0e9211a1216d9141d7a5f.tar.gz |
powerpc/pseries: Factor out common cpu hotplug code
Re-factor the cpu hotplug code to support doing cpu hotplug completely in
the kernel and using the existing sysfs probe/release interfaces. This
patch pulls out pieces of existing cpu hotplug code into common routines,
dlpar_cpu_add() and dlpar_cpu_remove(), to be used by both interfaces.
There are no functional changes introduced.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/pseries/hotplug-cpu.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index 66d8c2c..6fb28cf 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -335,8 +335,6 @@ static void pseries_remove_processor(struct device_node *np) cpu_maps_update_done(); } -#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE - static int dlpar_online_cpu(struct device_node *dn) { int rc = 0; @@ -404,16 +402,11 @@ static bool dlpar_cpu_exists(struct device_node *parent, u32 drc_index) return found; } -static ssize_t dlpar_cpu_probe(const char *buf, size_t count) +static ssize_t dlpar_cpu_add(u32 drc_index) { struct device_node *dn, *parent; - u32 drc_index; int rc; - rc = kstrtou32(buf, 0, &drc_index); - if (rc) - return -EINVAL; - parent = of_find_node_by_path("/cpus"); if (!parent) return -ENODEV; @@ -444,10 +437,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count) } rc = dlpar_online_cpu(dn); - if (rc) - return rc; - - return count; + return rc; } static int dlpar_offline_cpu(struct device_node *dn) @@ -506,6 +496,41 @@ out: } +static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) +{ + int rc; + + rc = dlpar_offline_cpu(dn); + if (rc) + return -EINVAL; + + rc = dlpar_release_drc(drc_index); + if (rc) + return rc; + + rc = dlpar_detach_node(dn); + if (rc) + dlpar_acquire_drc(drc_index); + + return rc; +} + +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE + +static ssize_t dlpar_cpu_probe(const char *buf, size_t count) +{ + u32 drc_index; + int rc; + + rc = kstrtou32(buf, 0, &drc_index); + if (rc) + return -EINVAL; + + rc = dlpar_cpu_add(drc_index); + + return rc ? rc : count; +} + static ssize_t dlpar_cpu_release(const char *buf, size_t count) { struct device_node *dn; @@ -522,27 +547,10 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } - rc = dlpar_offline_cpu(dn); - if (rc) { - of_node_put(dn); - return -EINVAL; - } - - rc = dlpar_release_drc(drc_index); - if (rc) { - of_node_put(dn); - return rc; - } - - rc = dlpar_detach_node(dn); - if (rc) { - dlpar_acquire_drc(drc_index); - return rc; - } - + rc = dlpar_cpu_remove(dn, drc_index); of_node_put(dn); - return count; + return rc ? rc : count; } #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ |