From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 2/6] pseries: Factor out common cpu hotplug code
Date: Mon, 22 Jun 2015 15:58:12 -0500 [thread overview]
Message-ID: <558876E4.9080707@linux.vnet.ibm.com> (raw)
In-Reply-To: <558875FF.2040000@linux.vnet.ibm.com>
Re-factor the cpu hotplug code to support cpu hotplug completely in
the kernel and using the existing sysfs probe/release interface. Move
pieces of the existing cpu hotplug code that will be common to both
interfaces into common routines. This patch does not introduce any
functional changes.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/hotplug-cpu.c | 83 ++++++++++++++------------
1 file changed, 46 insertions(+), 37 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index c55cdbc..f58d902 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -340,8 +340,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;
@@ -383,26 +381,16 @@ out:
}
-static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
+static ssize_t dlpar_cpu_add(struct device_node *parent, u32 drc_index)
{
- struct device_node *dn, *parent;
- u32 drc_index;
+ struct device_node *dn;
int rc;
- rc = kstrtou32(buf, 0, &drc_index);
- if (rc)
- return -EINVAL;
-
rc = dlpar_acquire_drc(drc_index);
if (rc)
return -EINVAL;
- parent = of_find_node_by_path("/cpus");
- if (!parent)
- return -ENODEV;
-
dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent);
- of_node_put(parent);
if (!dn)
return -EINVAL;
@@ -414,10 +402,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)
@@ -476,6 +461,47 @@ 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)
+{
+ struct device_node *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;
+
+ rc = dlpar_cpu_add(parent, drc_index);
+ of_node_put(parent);
+
+ return rc ? rc : count;
+}
+
static ssize_t dlpar_cpu_release(const char *buf, size_t count)
{
struct device_node *dn;
@@ -492,27 +518,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 */
next prev parent reply other threads:[~2015-06-22 20:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 20:54 [PATCH 0/6] pseries: Move CPU dlpar into the kernel Nathan Fontenot
2015-06-22 20:56 ` [PATCH 1/6] pseries: Consolidate CPU hotplug code to hotplug-cpu.c Nathan Fontenot
2015-06-22 20:58 ` Nathan Fontenot [this message]
2015-06-22 20:59 ` [PATCH 3/6] pseries: Update CPU hotplug error recovery Nathan Fontenot
2015-07-21 4:46 ` [3/6] " Michael Ellerman
2015-07-21 19:14 ` Nathan Fontenot
2015-07-22 1:14 ` Michael Ellerman
2015-06-22 21:00 ` [PATCH 4/6] pseries: Add CPU dlpar remove functionality Nathan Fontenot
2015-07-21 9:27 ` [4/6] " Michael Ellerman
2015-07-21 21:34 ` Nathan Fontenot
2015-07-22 1:11 ` Michael Ellerman
2015-07-22 15:42 ` Nathan Fontenot
2015-07-21 9:46 ` Michael Ellerman
2015-06-22 21:01 ` [PATCH 5/6] pseries: Add CPU dlpar add functionality Nathan Fontenot
2015-06-22 21:02 ` [PATCH 6/6] pseries: Enable kernel CPU dlpar from sysfs Nathan Fontenot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=558876E4.9080707@linux.vnet.ibm.com \
--to=nfont@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).