[PATCH 12/12] powerpc: Add support for "linux, usable-memory" on memory nodes

Michael Ellerman michael at ellerman.id.au
Tue Nov 8 00:07:16 EST 2005


Milton has proposed that we should support a "linux,usable-memory" property
on memory nodes which describes, in preference to "reg", the regions of memory
Linux should use.

This facility is required for kdump, to inform the second kernel which memory
it should use. A future patch may also recast mem=x support in terms of these
properties.

Patch-by: Haren Myneni <haren at us.ibm.com>

 arch/powerpc/kernel/prom.c |   15 ++++++++++-----
 arch/powerpc/mm/numa.c     |   38 +++++++++++++++++++++++++++++---------
 2 files changed, 39 insertions(+), 14 deletions(-)

Index: kexec/arch/powerpc/kernel/prom.c
===================================================================
--- kexec.orig/arch/powerpc/kernel/prom.c
+++ kexec/arch/powerpc/kernel/prom.c
@@ -574,7 +574,10 @@ static int __init interpret_root_props(s
 	unsigned int *rp;
 	int rpsize = (naddrc + nsizec) * sizeof(unsigned int);
 
-	rp = (unsigned int *) get_property(np, "reg", &l);
+	rp = (unsigned int *) get_property(np, "linux,usable-memory", &l);
+	if (rp == NULL)
+		rp = (unsigned int *) get_property(np, "reg", &l);
+
 	if (rp != 0 && l >= rpsize) {
 		i = 0;
 		adr = (struct address_range *) (*mem_start);
@@ -1292,10 +1295,12 @@ static int __init early_init_dt_scan_mem
 	if (type == NULL || strcmp(type, "memory") != 0)
 		return 0;
 
-	reg = (cell_t *)get_flat_dt_prop(node, "reg", &l);
-	if (reg == NULL)
-		return 0;
-
+	reg = (cell_t *)get_flat_dt_prop(node, "linux,usable-memory", &l);
+	if (reg == NULL) {
+		reg = (cell_t *)get_flat_dt_prop(node, "reg", &l);
+		if (reg == NULL)
+			return 0;
+	}
 	endp = reg + (l / sizeof(cell_t));
 
 	DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",
Index: kexec/arch/powerpc/mm/numa.c
===================================================================
--- kexec.orig/arch/powerpc/mm/numa.c
+++ kexec/arch/powerpc/mm/numa.c
@@ -22,6 +22,8 @@
 #include <asm/abs_addr.h>
 #include <asm/system.h>
 
+#include <linux/kexec.h>
+
 static int numa_enabled = 1;
 
 static int numa_debug;
@@ -376,9 +378,15 @@ static int __init parse_numa_properties(
 		unsigned int *memcell_buf;
 		unsigned int len;
 
-		memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
-		if (!memcell_buf || len <= 0)
-			continue;
+		memcell_buf = (unsigned int *)get_property(memory,
+			"linux,usable-memory", &len);
+		if (!memcell_buf || len <= 0) {
+			memcell_buf =
+				(unsigned int *)get_property(memory, "reg",
+					&len);
+			if (!memcell_buf || len <= 0)
+				continue;
+		}
 
 		ranges = memory->n_addrs;
 new_range:
@@ -636,9 +644,15 @@ void __init do_init_bootmem(void)
 			unsigned int *memcell_buf;
 			unsigned int len;
 
-			memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
-			if (!memcell_buf || len <= 0)
-				continue;
+			memcell_buf = (unsigned int *)get_property(memory,
+				"linux,usable-memory", &len);
+			if (!memcell_buf || len <= 0) {
+				memcell_buf =
+					(unsigned int *)get_property(memory,
+						"reg", &len);
+				if (!memcell_buf || len <= 0)
+					continue;
+			}
 
 			ranges = memory->n_addrs;	/* ranges in cell */
 new_range:
@@ -706,9 +720,15 @@ new_range:
 			unsigned int *memcell_buf;
 			unsigned int len;
 
-			memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
-			if (!memcell_buf || len <= 0)
-				continue;
+			memcell_buf = (unsigned int *)get_property(memory,
+				"linux,usable-memory", &len);
+			if (!memcell_buf || len <= 0) {
+				memcell_buf =
+					(unsigned int *)get_property(memory,
+					"reg", &len);
+				if (!memcell_buf || len <= 0)
+					continue;
+			}
 
 			ranges = memory->n_addrs;	/* ranges in cell */
 new_range2:



More information about the Linuxppc64-dev mailing list