[PATCH 14/19] ppc64: Move iSeries memory limit logic into device tree

Michael Ellerman michael at ellerman.id.au
Tue Jul 26 18:58:42 EST 2005


Move the iSeries specific memory limit logic earlier so we can put it into
the device tree. Unfortunately this means we have to parse the command line
twice (once in iSeries_early_setup() and once in setup_system()), I might clean
that up later.

---

 arch/ppc64/kernel/iSeries_setup.c |   48 ++++++++++++++++++++++----------------
 arch/ppc64/kernel/setup.c         |   17 -------------
 2 files changed, 29 insertions(+), 36 deletions(-)

Index: work/arch/ppc64/kernel/iSeries_setup.c
===================================================================
--- work.orig/arch/ppc64/kernel/iSeries_setup.c
+++ work/arch/ppc64/kernel/iSeries_setup.c
@@ -313,8 +313,6 @@ static void __init iSeries_get_cmdline(v
 
 static void __init iSeries_init_early(void)
 {
-	extern unsigned long memory_limit;
-
 	DBG(" -> iSeries_init_early()\n");
 
 	ppcdbg_initialize();
@@ -358,23 +356,6 @@ static void __init iSeries_init_early(vo
 	 */
 	iommu_init_early_iSeries();
 
-	iSeries_get_cmdline();
-
-	/* Save unparsed command line copy for /proc/cmdline */
-	strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
-
-	/* Parse early parameters, in particular mem=x */
-	parse_early_param();
-
-	if (memory_limit) {
-		if (memory_limit < systemcfg->physicalMemorySize)
-			systemcfg->physicalMemorySize = memory_limit;
-		else {
-			printk("Ignoring mem=%lu >= ram_top.\n", memory_limit);
-			memory_limit = 0;
-		}
-	}
-
 	/* Initialize machine-dependency vectors */
 #ifdef CONFIG_SMP
 	smp_init_iSeries();
@@ -917,6 +898,19 @@ static int iseries_dedicated_idle(void)
 	return 0;
 }
 
+static unsigned long iseries_memory_limit;
+
+static int __init early_parsemem(char *p)
+{
+	if (!p)
+		return 0;
+
+	iseries_memory_limit = ALIGN(memparse(p, &p), PAGE_SIZE);
+
+	return 0;
+}
+early_param("mem", early_parsemem);
+
 #ifndef CONFIG_PCI
 void __init iSeries_init_IRQ(void) { }
 #endif
@@ -1097,6 +1091,10 @@ void build_flat_dt(struct iseries_flat_d
 	/* /chosen */
 	dt_start_node(dt, "/chosen");
 	dt_prop_u32(dt, "linux,platform", PLATFORM_ISERIES_LPAR);
+	dt_prop_str(dt, "bootargs", cmd_line);
+	if (iseries_memory_limit)
+		dt_prop_u64(dt, "linux,memory-limit", iseries_memory_limit);
+
 	dt_end_node(dt);
 
 	dt_end_node(dt);
@@ -1116,6 +1114,18 @@ void __init iSeries_early_setup(void)
 	 */
 	build_iSeries_Memory_Map();
 
+	iSeries_get_cmdline();
+
+	/* Save unparsed command line copy for /proc/cmdline */
+	strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
+
+	/* Parse early parameters, in particular mem=x */
+	parse_early_param();
+
+	if (iseries_memory_limit &&
+			iseries_memory_limit < systemcfg->physicalMemorySize)
+		systemcfg->physicalMemorySize = iseries_memory_limit;
+
 	build_flat_dt(&iseries_dt);
 	early_init_devtree(&iseries_dt);
 
Index: work/arch/ppc64/kernel/setup.c
===================================================================
--- work.orig/arch/ppc64/kernel/setup.c
+++ work/arch/ppc64/kernel/setup.c
@@ -812,23 +812,6 @@ unsigned long memory_limit;
 unsigned long tce_alloc_start;
 unsigned long tce_alloc_end;
 
-#ifdef CONFIG_PPC_ISERIES
-/*
- * On iSeries we just parse the mem=X option from the command line.
- * On pSeries it's a bit more complicated, see prom_init_mem()
- */
-static int __init early_parsemem(char *p)
-{
-	if (!p)
-		return 0;
-
-	memory_limit = ALIGN(memparse(p, &p), PAGE_SIZE);
-
-	return 0;
-}
-early_param("mem", early_parsemem);
-#endif /* CONFIG_PPC_ISERIES */
-
 #ifdef CONFIG_PPC_MULTIPLATFORM
 static int __init set_preferred_console(void)
 {



More information about the Linuxppc64-dev mailing list