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 3/6 v5] Memory probe/release files
Date: Wed, 28 Oct 2009 15:55:57 -0500	[thread overview]
Message-ID: <4AE8AFDD.6030504@austin.ibm.com> (raw)
In-Reply-To: <4AE8ADCF.6090104@austin.ibm.com>

This patch creates the release sysfs file for memory and updates the
exisiting probe file so both make arch-specific callouts to handle removing
and adding memory to the system.  This also creates the powerpc specific stubs
for handling the arch callouts.

The creation and use of these files are governed by the exisitng
CONFIG_ARCH_MEMORY_PROBE and new CONFIG_ARCH_MEMORY_RELEASE config options.

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

Index: powerpc/arch/powerpc/mm/mem.c
===================================================================
--- powerpc.orig/arch/powerpc/mm/mem.c	2009-10-28 15:20:36.000000000 -0500
+++ powerpc/arch/powerpc/mm/mem.c	2009-10-28 15:21:47.000000000 -0500
@@ -110,6 +110,26 @@
 
 #ifdef CONFIG_MEMORY_HOTPLUG
 
+#ifdef CONFIG_ARCH_MEMORY_RELEASE
+int arch_memory_release(const char *buf, size_t count)
+{
+	if (ppc_md.memory_release)
+		return ppc_md.memory_release(buf, count);
+
+	return -EINVAL;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MEMORY_PROBE
+int arch_memory_probe(u64 phys_addr)
+{
+	if (ppc_md.memory_probe)
+		return ppc_md.memory_probe(phys_addr);
+
+	return -EINVAL;
+}
+#endif
+
 #ifdef CONFIG_NUMA
 int memory_add_physaddr_to_nid(u64 start)
 {
Index: powerpc/drivers/base/memory.c
===================================================================
--- powerpc.orig/drivers/base/memory.c	2009-10-28 15:20:36.000000000 -0500
+++ powerpc/drivers/base/memory.c	2009-10-28 15:21:47.000000000 -0500
@@ -319,6 +319,10 @@
 
 	phys_addr = simple_strtoull(buf, NULL, 0);
 
+	ret = arch_memory_probe(phys_addr);
+	if (ret)
+		return ret;
+
 	nid = memory_add_physaddr_to_nid(phys_addr);
 	ret = add_memory(nid, phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);
 
@@ -328,19 +332,35 @@
 	return count;
 }
 static CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store);
+#endif
 
-static int memory_probe_init(void)
+#ifdef CONFIG_ARCH_MEMORY_RELEASE
+static ssize_t
+memory_release_store(struct class *class, const char *buf, size_t count)
 {
-	return sysfs_create_file(&memory_sysdev_class.kset.kobj,
-				&class_attr_probe.attr);
+	return arch_memory_release(buf, count);
 }
-#else
-static inline int memory_probe_init(void)
+static CLASS_ATTR(release, S_IWUSR, NULL, memory_release_store);
+#endif
+
+static int memory_probe_release_init(void)
 {
-	return 0;
-}
+	int rc = 0;
+
+#ifdef CONFIG_ARCH_MEMORY_PROBE
+	rc = sysfs_create_file(&memory_sysdev_class.kset.kobj,
+			       &class_attr_probe.attr);
+#endif
+
+#ifdef CONFIG_ARCH_MEMORY_RELEASE
+	if (!rc)
+		rc = sysfs_create_file(&memory_sysdev_class.kset.kobj,
+				       &class_attr_release.attr);
 #endif
 
+	return rc;
+}
+
 /*
  * Note that phys_device is optional.  It is here to allow for
  * differentiation between which *physical* devices each
@@ -470,7 +490,7 @@
 			ret = err;
 	}
 
-	err = memory_probe_init();
+	err = memory_probe_release_init();
 	if (!ret)
 		ret = err;
 	err = block_size_init();
Index: powerpc/arch/powerpc/include/asm/machdep.h
===================================================================
--- powerpc.orig/arch/powerpc/include/asm/machdep.h	2009-10-28 15:20:36.000000000 -0500
+++ powerpc/arch/powerpc/include/asm/machdep.h	2009-10-28 15:21:47.000000000 -0500
@@ -266,6 +266,14 @@
 	void (*suspend_disable_irqs)(void);
 	void (*suspend_enable_irqs)(void);
 #endif
+
+#ifdef CONFIG_ARCH_MEMORY_RELEASE
+	int (*memory_release)(const char *, size_t);
+#endif
+#ifdef CONFIG_ARCH_MEMORY_PROBE
+	int (*memory_probe)(u64);
+#endif
+
 };
 
 extern void e500_idle(void);
Index: powerpc/arch/powerpc/Kconfig
===================================================================
--- powerpc.orig/arch/powerpc/Kconfig	2009-10-28 15:20:36.000000000 -0500
+++ powerpc/arch/powerpc/Kconfig	2009-10-28 15:21:47.000000000 -0500
@@ -414,6 +414,10 @@
 	def_bool y
 	depends on MEMORY_HOTPLUG
 
+config ARCH_MEMORY_RELEASE
+	def_bool y
+	depends on MEMORY_HOTPLUG
+
 # Some NUMA nodes have memory ranges that span
 # other nodes.  Even though a pfn is valid and
 # between a node's start and end pfns, it may not
Index: powerpc/include/linux/memory_hotplug.h
===================================================================
--- powerpc.orig/include/linux/memory_hotplug.h	2009-10-28 15:20:36.000000000 -0500
+++ powerpc/include/linux/memory_hotplug.h	2009-10-28 15:21:47.000000000 -0500
@@ -86,6 +86,14 @@
 }
 #endif
 
+#ifdef CONFIG_ARCH_MEMORY_RELEASE
+extern int arch_memory_release(const char *, size_t);
+#endif
+
+#ifdef CONFIG_ARCH_MEMORY_PROBE
+extern int arch_memory_probe(u64);
+#endif
+
 #ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION
 /*
  * For supporting node-hotadd, we have to allocate a new pgdat.

  parent reply	other threads:[~2009-10-28 20:55 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 ` Nathan Fontenot [this message]
2009-10-29  3:13   ` [PATCH 3/6 v5] Memory probe/release files 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 ` [PATCH 6/6 v5] CPU DLPAR Handling Nathan Fontenot
2009-10-29  3:26   ` 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=4AE8AFDD.6030504@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