From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 5/6] pseries: Add CPU dlpar add functionality
Date: Mon, 22 Jun 2015 16:01:48 -0500 [thread overview]
Message-ID: <558877BC.5030903@linux.vnet.ibm.com> (raw)
In-Reply-To: <558875FF.2040000@linux.vnet.ibm.com>
Add the ability to hotplug add cpus via rtas hotplug events by either
specifying the drc index of the CPU to add, or providing a count of the
number of CPUs to add.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/hotplug-cpu.c | 76 ++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 49b7196..a5d4c89 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -673,6 +673,74 @@ static int dlpar_cpu_remove_by_count(struct device_node *parent,
return rc;
}
+static int dlpar_cpu_add_by_count(struct device_node *parent, u32 cpus_to_add)
+{
+ struct dr_cpu *dr_cpus;
+ int dr_cpus_added = 0;
+ int dr_cpus_available = 0;
+ int dr_cpus_possible;
+ int i, rc;
+
+ pr_info("Attempting to hot-add %d CPUs\n", cpus_to_add);
+
+ dr_cpus = get_dlpar_cpus(parent);
+ if (!dr_cpus) {
+ pr_info("Could not gather dr CPU info\n");
+ return -EINVAL;
+ }
+
+ dr_cpus_possible = dlpar_cpus_possible(parent);
+
+ for (i = 0; i < dr_cpus_possible; i++) {
+ if (!dr_cpus[i].present)
+ dr_cpus_available++;
+ }
+
+ /* Validate the available CPUs to add. */
+ if (cpus_to_add > dr_cpus_available) {
+ pr_err("Insufficient CPUs (%d) to satisfy add request\n",
+ dr_cpus_available);
+ kfree(dr_cpus);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < dr_cpus_possible; i++) {
+ if (dr_cpus_added == cpus_to_add)
+ break;
+
+ if (dr_cpus[i].present)
+ continue;
+
+ rc = dlpar_cpu_add(parent, dr_cpus[i].drc_index);
+ if (!rc) {
+ dr_cpus_added++;
+ dr_cpus[i].modified = true;
+ }
+ }
+
+ if (dr_cpus_added < cpus_to_add) {
+ pr_err("CPU hot-add failed, removing any added CPUs\n");
+
+ for (i = 0; i < dr_cpus_possible; i++) {
+ if (!dr_cpus[i].modified)
+ continue;
+
+ rc = dlpar_cpu_remove_by_index(parent,
+ dr_cpus[i].drc_index);
+ if (rc)
+ pr_info("Failed to remove added CPU (%x)\n",
+ dr_cpus[i].drc_index);
+ }
+
+ rc = -EINVAL;
+ } else {
+ rc = 0;
+ }
+
+ kfree(dr_cpus);
+ return rc;
+}
+
int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
{
struct device_node *parent;
@@ -697,6 +765,14 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
else
rc = -EINVAL;
break;
+ case PSERIES_HP_ELOG_ACTION_ADD:
+ if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
+ rc = dlpar_cpu_add_by_count(parent, count);
+ else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
+ rc = dlpar_cpu_add(parent, drc_index);
+ else
+ rc = -EINVAL;
+ break;
default:
pr_err("Invalid action (%d) specified\n", hp_elog->action);
rc = -EINVAL;
next prev parent reply other threads:[~2015-06-22 21:01 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 ` [PATCH 2/6] pseries: Factor out common cpu hotplug code Nathan Fontenot
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 ` Nathan Fontenot [this message]
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=558877BC.5030903@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.