public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@austin.ibm.com>
To: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/6 v5] CPU DLPAR Handling
Date: Wed, 28 Oct 2009 15:59:29 -0500	[thread overview]
Message-ID: <4AE8B0B1.4020102@austin.ibm.com> (raw)
In-Reply-To: <4AE8ADCF.6090104@austin.ibm.com>

Register the pseries specific handler for the powerpc architecture handlers
for the cpu probe and release files.  This also implements the cpu DLPAR
addition and removal of CPUS from the system.

Signed-off-by: Nathan Fontenot <nfont at asutin.ibm.com>
---

Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/dlpar.c	2009-10-28 15:21:49.000000000 -0500
+++ powerpc/arch/powerpc/platforms/pseries/dlpar.c	2009-10-28 15:21:56.000000000 -0500
@@ -1,11 +1,10 @@
 /*
- * dlpar.c - support for dynamic reconfiguration (including PCI
- * Hotplug and Dynamic Logical Partitioning on RPA platforms).
+ * Support for dynamic reconfiguration (including PCI, Memory, and CPU
+ * Hotplug and Dynamic Logical Partitioning on PAPR platforms).
  *
  * Copyright (C) 2009 Nathan Fontenot
  * Copyright (C) 2009 IBM Corporation
  *
- *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version
  * 2 as published by the Free Software Foundation.
@@ -19,7 +18,7 @@
 #include <linux/memory_hotplug.h>
 #include <linux/sysdev.h>
 #include <linux/sysfs.h>
-
+#include <linux/cpu.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
@@ -408,6 +407,80 @@
 	return 0;
 }
 
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+static ssize_t cpu_probe(const char *buf, size_t count)
+{
+	struct device_node *dn;
+	unsigned long drc_index;
+	char *cpu_name;
+	int rc;
+
+	rc = strict_strtoul(buf, 0, &drc_index);
+	if (rc)
+		return -EINVAL;
+
+	rc = acquire_drc(drc_index);
+	if (rc)
+		return -EINVAL;
+
+	dn = configure_connector(drc_index);
+	if (!dn) {
+		release_drc(drc_index);
+		return -EINVAL;
+	}
+
+	/* fixup dn name */
+	cpu_name = kzalloc(strlen(dn->full_name) + strlen("/cpus/") + 1,
+			   GFP_KERNEL);
+	if (!cpu_name) {
+		free_cc_nodes(dn);
+		release_drc(drc_index);
+		return -ENOMEM;
+	}
+
+	sprintf(cpu_name, "/cpus/%s", dn->full_name);
+	kfree(dn->full_name);
+	dn->full_name = cpu_name;
+
+	rc = add_device_tree_nodes(dn);
+	if (rc)
+		release_drc(drc_index);
+
+	return rc ? -EINVAL : count;
+}
+
+static ssize_t cpu_release(const char *buf, size_t count)
+{
+	struct device_node *dn;
+	const u32 *drc_index;
+	int rc;
+
+	dn = of_find_node_by_path(buf);
+	if (!dn)
+		return -EINVAL;
+
+	drc_index = of_get_property(dn, "ibm,my-drc-index", NULL);
+	if (!drc_index) {
+		of_node_put(dn);
+		return -EINVAL;
+	}
+
+	rc = release_drc(*drc_index);
+	if (rc) {
+		of_node_put(dn);
+		return -EINVAL;
+	}
+
+	rc = remove_device_tree_nodes(dn);
+	if (rc)
+		acquire_drc(*drc_index);
+
+	of_node_put(dn);
+	return rc ? -EINVAL : count;
+}
+
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
+
 #ifdef CONFIG_MEMORY_HOTPLUG
 
 static struct property *clone_property(struct property *old_prop)
@@ -591,6 +664,11 @@
 	ppc_md.memory_probe = memory_probe;
 #endif
 
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+	ppc_md.cpu_release = cpu_release;
+	ppc_md.cpu_probe = cpu_probe;
+#endif
+
 	return 0;
 }
 device_initcall(pseries_dlpar_init);

  parent reply	other threads:[~2009-10-28 20:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 20:47 [PATCH 0/6 v5] Kernel handling of Dynamic Logical Partitioning Nathan Fontenot
2009-10-28 20:53 ` [PATCH 1/6 v5] Kernel DLPAR Infrastructure Nathan Fontenot
2009-10-29  3:08   ` Benjamin Herrenschmidt
2009-10-29  3:59     ` Nathan Lynch
2009-11-02 16:27     ` Nathan Fontenot
2009-11-02 16:40       ` Grant Likely
2009-11-02 16:47         ` Nathan Fontenot
2009-11-02 16:56           ` Grant Likely
2009-10-28 20:54 ` [PATCH 2/6 v5] Move of_drconf_cell to prom.h Nathan Fontenot
2009-10-28 20:55 ` [PATCH 3/6 v5] Memory probe/release files Nathan Fontenot
2009-10-29  3:13   ` Benjamin Herrenschmidt
2009-11-02 16:14     ` Nathan Fontenot
2009-10-28 20:57 ` [PATCH 4/6 v5] Memory DLPAR Handling Nathan Fontenot
2009-11-05 18:51   ` Roland Dreier
2009-10-28 20:58 ` [PATCH 5/6 v5] CPU probe/release files Nathan Fontenot
2009-10-29  3:25   ` Benjamin Herrenschmidt
2009-12-18 14:33   ` Andreas Schwab
2009-12-18 16:24     ` Nathan Fontenot
2009-12-18 17:29       ` Andreas Schwab
2009-12-19  8:46     ` Benjamin Herrenschmidt
2009-12-19 10:11       ` Andreas Schwab
2009-12-22  2:17       ` Nathan Fontenot
2009-10-28 20:59 ` Nathan Fontenot [this message]
2009-10-29  3:26   ` [PATCH 6/6 v5] CPU DLPAR Handling Benjamin Herrenschmidt
2009-11-02 16:15     ` 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=4AE8B0B1.4020102@austin.ibm.com \
    --to=nfont@austin.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@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