linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
@ 2006-02-24 16:54 Kumar Gala
  2006-02-24 21:04 ` Segher Boessenkool
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Kumar Gala @ 2006-02-24 16:54 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linux-kernel, linuxppc-dev, Linus Torvalds

mem= command line option was being ignored in arch/powerpc if we were not
a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The initial
command line extraction and parsing needed to be moved earlier in the boot
process and have code to actual parse mem= and do something about it.

Also, fixed a compile warning in the file.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

---
commit 625f68c82bae16c53f684c5512b0176c243c6068
tree 5657155434c9a44fa9ee3e0329756e354daf4845
parent 820ac48b82821c6d38747ea49f98aeca05ca2e2b
author Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 11:03:12 -0600
committer Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 11:03:12 -0600

 arch/powerpc/kernel/prom.c |   54 +++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 294832a..6dbd217 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -816,8 +816,6 @@ void __init unflatten_device_tree(void)
 {
 	unsigned long start, mem, size;
 	struct device_node **allnextp = &allnodes;
-	char *p = NULL;
-	int l = 0;
 
 	DBG(" -> unflatten_device_tree()\n");
 
@@ -857,19 +855,6 @@ void __init unflatten_device_tree(void)
 	if (of_chosen == NULL)
 		of_chosen = of_find_node_by_path("/chosen@0");
 
-	/* Retreive command line */
-	if (of_chosen != NULL) {
-		p = (char *)get_property(of_chosen, "bootargs", &l);
-		if (p != NULL && l > 0)
-			strlcpy(cmd_line, p, min(l, COMMAND_LINE_SIZE));
-	}
-#ifdef CONFIG_CMDLINE
-	if (l == 0 || (l == 1 && (*p) == 0))
-		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-	DBG("Command line is: %s\n", cmd_line);
-
 	DBG(" <- unflatten_device_tree()\n");
 }
 
@@ -940,6 +925,8 @@ static int __init early_init_dt_scan_cho
 {
 	u32 *prop;
 	unsigned long *lprop;
+	unsigned long l;
+	char *p;
 
 	DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
 
@@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
                crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
 
+	/* Retreive command line */
+ 	p = of_get_flat_dt_prop(node, "bootargs", &l);
+	if (p != NULL && l > 0)
+		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
+
+#ifdef CONFIG_CMDLINE
+	if (l == 0 || (l == 1 && (*p) == 0))
+		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif /* CONFIG_CMDLINE */
+
+	DBG("Command line is: %s\n", cmd_line);
+
+	if (strstr(cmd_line, "mem=")) {
+		char *p, *q;
+		unsigned long maxmem = 0;
+
+		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
+			q = p + 4;
+			if (p > cmd_line && p[-1] != ' ')
+				continue;
+			maxmem = simple_strtoul(q, &q, 0);
+			if (*q == 'k' || *q == 'K') {
+				maxmem <<= 10;
+				++q;
+			} else if (*q == 'm' || *q == 'M') {
+				maxmem <<= 20;
+				++q;
+			} else if (*q == 'g' || *q == 'G') {
+				maxmem <<= 30;
+				++q;
+			}
+		}
+		memory_limit = maxmem;
+	}
+
 	/* break now */
 	return 1;
 }
@@ -1124,7 +1146,7 @@ static void __init early_reserve_mem(voi
 			size_32 = *(reserve_map_32++);
 			if (size_32 == 0)
 				break;
-			DBG("reserving: %lx -> %lx\n", base_32, size_32);
+			DBG("reserving: %x -> %x\n", base_32, size_32);
 			lmb_reserve(base_32, size_32);
 		}
 		return;


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
@ 2006-02-24 21:04 ` Segher Boessenkool
  2006-02-24 22:27 ` Michael Ellerman
  2006-02-26 20:38 ` Dave Hansen
  2 siblings, 0 replies; 10+ messages in thread
From: Segher Boessenkool @ 2006-02-24 21:04 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Paul Mackerras, linuxppc-dev, Linus Torvalds, linux-kernel

I can confirm this works on systems with "real" OF, too.  Furthermore,
the patch looks sane to me.

Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

> mem= command line option was being ignored in arch/powerpc if we were 
> not
> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The 
> initial
> command line extraction and parsing needed to be moved earlier in the 
> boot
> process and have code to actual parse mem= and do something about it.
>
> Also, fixed a compile warning in the file.
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>
> ---
> commit 625f68c82bae16c53f684c5512b0176c243c6068
> tree 5657155434c9a44fa9ee3e0329756e354daf4845
> parent 820ac48b82821c6d38747ea49f98aeca05ca2e2b
> author Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 
> 11:03:12 -0600
> committer Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 
> 11:03:12 -0600
>
>  arch/powerpc/kernel/prom.c |   54 
> +++++++++++++++++++++++++++++++-------------
>  1 files changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 294832a..6dbd217 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -816,8 +816,6 @@ void __init unflatten_device_tree(void)
>  {
>  	unsigned long start, mem, size;
>  	struct device_node **allnextp = &allnodes;
> -	char *p = NULL;
> -	int l = 0;
>
>  	DBG(" -> unflatten_device_tree()\n");
>
> @@ -857,19 +855,6 @@ void __init unflatten_device_tree(void)
>  	if (of_chosen == NULL)
>  		of_chosen = of_find_node_by_path("/chosen@0");
>
> -	/* Retreive command line */
> -	if (of_chosen != NULL) {
> -		p = (char *)get_property(of_chosen, "bootargs", &l);
> -		if (p != NULL && l > 0)
> -			strlcpy(cmd_line, p, min(l, COMMAND_LINE_SIZE));
> -	}
> -#ifdef CONFIG_CMDLINE
> -	if (l == 0 || (l == 1 && (*p) == 0))
> -		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#endif /* CONFIG_CMDLINE */
> -
> -	DBG("Command line is: %s\n", cmd_line);
> -
>  	DBG(" <- unflatten_device_tree()\n");
>  }
>
> @@ -940,6 +925,8 @@ static int __init early_init_dt_scan_cho
>  {
>  	u32 *prop;
>  	unsigned long *lprop;
> +	unsigned long l;
> +	char *p;
>
>  	DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
>
> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
>                 crashk_res.end = crashk_res.start + *lprop - 1;
>  #endif
>
> +	/* Retreive command line */
> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
> +	if (p != NULL && l > 0)
> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
> +
> +#ifdef CONFIG_CMDLINE
> +	if (l == 0 || (l == 1 && (*p) == 0))
> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#endif /* CONFIG_CMDLINE */
> +
> +	DBG("Command line is: %s\n", cmd_line);
> +
> +	if (strstr(cmd_line, "mem=")) {
> +		char *p, *q;
> +		unsigned long maxmem = 0;
> +
> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> +			q = p + 4;
> +			if (p > cmd_line && p[-1] != ' ')
> +				continue;
> +			maxmem = simple_strtoul(q, &q, 0);
> +			if (*q == 'k' || *q == 'K') {
> +				maxmem <<= 10;
> +				++q;
> +			} else if (*q == 'm' || *q == 'M') {
> +				maxmem <<= 20;
> +				++q;
> +			} else if (*q == 'g' || *q == 'G') {
> +				maxmem <<= 30;
> +				++q;
> +			}
> +		}
> +		memory_limit = maxmem;
> +	}
> +
>  	/* break now */
>  	return 1;
>  }
> @@ -1124,7 +1146,7 @@ static void __init early_reserve_mem(voi
>  			size_32 = *(reserve_map_32++);
>  			if (size_32 == 0)
>  				break;
> -			DBG("reserving: %lx -> %lx\n", base_32, size_32);
> +			DBG("reserving: %x -> %x\n", base_32, size_32);
>  			lmb_reserve(base_32, size_32);
>  		}
>  		return;
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
  2006-02-24 21:04 ` Segher Boessenkool
@ 2006-02-24 22:27 ` Michael Ellerman
  2006-02-24 22:43   ` Kumar Gala
  2006-02-26 20:38 ` Dave Hansen
  2 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2006-02-24 22:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Kumar Gala, Paul Mackerras, Linus Torvalds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]

Hi Kumar,

On Sat, 25 Feb 2006 03:54, Kumar Gala wrote:
> mem= command line option was being ignored in arch/powerpc if we were not
> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The initial
> command line extraction and parsing needed to be moved earlier in the boot
> process and have code to actual parse mem= and do something about it.

> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
>                 crashk_res.end = crashk_res.start + *lprop - 1;
>  #endif
>
> +	/* Retreive command line */
> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
> +	if (p != NULL && l > 0)
> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
> +
> +#ifdef CONFIG_CMDLINE
> +	if (l == 0 || (l == 1 && (*p) == 0))
> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#endif /* CONFIG_CMDLINE */
> +
> +	DBG("Command line is: %s\n", cmd_line);
> +
> +	if (strstr(cmd_line, "mem=")) {
> +		char *p, *q;
> +		unsigned long maxmem = 0;
> +
> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> +			q = p + 4;
> +			if (p > cmd_line && p[-1] != ' ')
> +				continue;
> +			maxmem = simple_strtoul(q, &q, 0);
> +			if (*q == 'k' || *q == 'K') {
> +				maxmem <<= 10;
> +				++q;
> +			} else if (*q == 'm' || *q == 'M') {
> +				maxmem <<= 20;
> +				++q;
> +			} else if (*q == 'g' || *q == 'G') {
> +				maxmem <<= 30;
> +				++q;
> +			}
> +		}
> +		memory_limit = maxmem;
> +	}
> +

Why not make the mem= parsing an early_param() handler and then call 
parse_early_param() here?

And I think a switch would be easier to read for the K/M/G handling.

cheers

-- 
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 22:27 ` Michael Ellerman
@ 2006-02-24 22:43   ` Kumar Gala
  2006-02-24 23:14     ` [PATCH][UPDATE] " Kumar Gala
  2006-02-24 23:25     ` [PATCH] " Michael Ellerman
  0 siblings, 2 replies; 10+ messages in thread
From: Kumar Gala @ 2006-02-24 22:43 UTC (permalink / raw)
  To: michael; +Cc: linuxppc-dev, Paul Mackerras, Linus Torvalds, linux-kernel


On Feb 24, 2006, at 4:27 PM, Michael Ellerman wrote:

> Hi Kumar,
>
> On Sat, 25 Feb 2006 03:54, Kumar Gala wrote:
>> mem= command line option was being ignored in arch/powerpc if we  
>> were not
>> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The  
>> initial
>> command line extraction and parsing needed to be moved earlier in  
>> the boot
>> process and have code to actual parse mem= and do something about it.
>
>> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
>>                 crashk_res.end = crashk_res.start + *lprop - 1;
>>  #endif
>>
>> +	/* Retreive command line */
>> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
>> +	if (p != NULL && l > 0)
>> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
>> +
>> +#ifdef CONFIG_CMDLINE
>> +	if (l == 0 || (l == 1 && (*p) == 0))
>> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>> +#endif /* CONFIG_CMDLINE */
>> +
>> +	DBG("Command line is: %s\n", cmd_line);
>> +
>> +	if (strstr(cmd_line, "mem=")) {
>> +		char *p, *q;
>> +		unsigned long maxmem = 0;
>> +
>> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
>> +			q = p + 4;
>> +			if (p > cmd_line && p[-1] != ' ')
>> +				continue;
>> +			maxmem = simple_strtoul(q, &q, 0);
>> +			if (*q == 'k' || *q == 'K') {
>> +				maxmem <<= 10;
>> +				++q;
>> +			} else if (*q == 'm' || *q == 'M') {
>> +				maxmem <<= 20;
>> +				++q;
>> +			} else if (*q == 'g' || *q == 'G') {
>> +				maxmem <<= 30;
>> +				++q;
>> +			}
>> +		}
>> +		memory_limit = maxmem;
>> +	}
>> +
>
> Why not make the mem= parsing an early_param() handler and then call
> parse_early_param() here?

This would put constraints on the early_param()'s that I dont think  
we should impose.

> And I think a switch would be easier to read for the K/M/G handling.

I should probably use memparse() now that I've found it :)

- k

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH][UPDATE] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 22:43   ` Kumar Gala
@ 2006-02-24 23:14     ` Kumar Gala
  2006-02-24 23:25     ` [PATCH] " Michael Ellerman
  1 sibling, 0 replies; 10+ messages in thread
From: Kumar Gala @ 2006-02-24 23:14 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Linus Torvalds, linux-kernel

mem= command line option was being ignored in arch/powerpc if we were not
a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The initial
command line extraction and parsing needed to be moved earlier in the boot
process and have code to actual parse mem= and do something about it.

Also, fixed a compile warning in the file.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

---
commit a49869ffbf01f3998523357c85f7b55a6d064cda
tree efd39700c07ac02cb6216ebf8d6d0d2adf7be36a
parent 820ac48b82821c6d38747ea49f98aeca05ca2e2b
author Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 17:08:54 -0600
committer Kumar Gala <galak@kernel.crashing.org> Fri, 24 Feb 2006 17:08:54 -0600

 arch/powerpc/kernel/prom.c |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 294832a..670654b 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -816,8 +816,6 @@ void __init unflatten_device_tree(void)
 {
 	unsigned long start, mem, size;
 	struct device_node **allnextp = &allnodes;
-	char *p = NULL;
-	int l = 0;
 
 	DBG(" -> unflatten_device_tree()\n");
 
@@ -857,19 +855,6 @@ void __init unflatten_device_tree(void)
 	if (of_chosen == NULL)
 		of_chosen = of_find_node_by_path("/chosen@0");
 
-	/* Retreive command line */
-	if (of_chosen != NULL) {
-		p = (char *)get_property(of_chosen, "bootargs", &l);
-		if (p != NULL && l > 0)
-			strlcpy(cmd_line, p, min(l, COMMAND_LINE_SIZE));
-	}
-#ifdef CONFIG_CMDLINE
-	if (l == 0 || (l == 1 && (*p) == 0))
-		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-	DBG("Command line is: %s\n", cmd_line);
-
 	DBG(" <- unflatten_device_tree()\n");
 }
 
@@ -940,6 +925,8 @@ static int __init early_init_dt_scan_cho
 {
 	u32 *prop;
 	unsigned long *lprop;
+	unsigned long l;
+	char *p;
 
 	DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
 
@@ -1004,6 +991,29 @@ static int __init early_init_dt_scan_cho
                crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
 
+	/* Retreive command line */
+ 	p = of_get_flat_dt_prop(node, "bootargs", &l);
+	if (p != NULL && l > 0)
+		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
+
+#ifdef CONFIG_CMDLINE
+	if (l == 0 || (l == 1 && (*p) == 0))
+		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif /* CONFIG_CMDLINE */
+
+	DBG("Command line is: %s\n", cmd_line);
+
+	if (strstr(cmd_line, "mem=")) {
+		char *p, *q;
+
+		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
+			q = p + 4;
+			if (p > cmd_line && p[-1] != ' ')
+				continue;
+			memory_limit = memparse(q, &q);
+		}
+	}
+
 	/* break now */
 	return 1;
 }
@@ -1124,7 +1134,7 @@ static void __init early_reserve_mem(voi
 			size_32 = *(reserve_map_32++);
 			if (size_32 == 0)
 				break;
-			DBG("reserving: %lx -> %lx\n", base_32, size_32);
+			DBG("reserving: %x -> %x\n", base_32, size_32);
 			lmb_reserve(base_32, size_32);
 		}
 		return;


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 23:25     ` [PATCH] " Michael Ellerman
@ 2006-02-24 23:18       ` Kumar Gala
  2006-02-25  0:12         ` Michael Ellerman
  0 siblings, 1 reply; 10+ messages in thread
From: Kumar Gala @ 2006-02-24 23:18 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, Linus Torvalds, linux-kernel

On Sat, 25 Feb 2006, Michael Ellerman wrote:

> On Sat, 25 Feb 2006 09:43, Kumar Gala wrote:
> > On Feb 24, 2006, at 4:27 PM, Michael Ellerman wrote:
> > > Hi Kumar,
> > >
> > > On Sat, 25 Feb 2006 03:54, Kumar Gala wrote:
> > >> mem= command line option was being ignored in arch/powerpc if we
> > >> were not
> > >> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The
> > >> initial
> > >> command line extraction and parsing needed to be moved earlier in
> > >> the boot
> > >> process and have code to actual parse mem= and do something about it.
> > >>
> > >> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
> > >>                 crashk_res.end = crashk_res.start + *lprop - 1;
> > >>  #endif
> > >>
> > >> +	/* Retreive command line */
> > >> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
> > >> +	if (p != NULL && l > 0)
> > >> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
> > >> +
> > >> +#ifdef CONFIG_CMDLINE
> > >> +	if (l == 0 || (l == 1 && (*p) == 0))
> > >> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> > >> +#endif /* CONFIG_CMDLINE */
> > >> +
> > >> +	DBG("Command line is: %s\n", cmd_line);
> > >> +
> > >> +	if (strstr(cmd_line, "mem=")) {
> > >> +		char *p, *q;
> > >> +		unsigned long maxmem = 0;
> > >> +
> > >> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> > >> +			q = p + 4;
> > >> +			if (p > cmd_line && p[-1] != ' ')
> > >> +				continue;
> > >> +			maxmem = simple_strtoul(q, &q, 0);
> > >> +			if (*q == 'k' || *q == 'K') {
> > >> +				maxmem <<= 10;
> > >> +				++q;
> > >> +			} else if (*q == 'm' || *q == 'M') {
> > >> +				maxmem <<= 20;
> > >> +				++q;
> > >> +			} else if (*q == 'g' || *q == 'G') {
> > >> +				maxmem <<= 30;
> > >> +				++q;
> > >> +			}
> > >> +		}
> > >> +		memory_limit = maxmem;
> > >> +	}
> > >> +
> > >
> > > Why not make the mem= parsing an early_param() handler and then call
> > > parse_early_param() here?
> >
> > This would put constraints on the early_param()'s that I dont think
> > we should impose.
> 
> All they should really be doing is parsing the string and setting some 
> variables, so that seems reasonable to me. Is there anything in particular?

If you ever had to do some memory allocation as part of the parsing that 
might be an issue, since we haven't setup the LMB at that point.

- kumar


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 22:43   ` Kumar Gala
  2006-02-24 23:14     ` [PATCH][UPDATE] " Kumar Gala
@ 2006-02-24 23:25     ` Michael Ellerman
  2006-02-24 23:18       ` Kumar Gala
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2006-02-24 23:25 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Paul Mackerras, Linus Torvalds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]

On Sat, 25 Feb 2006 09:43, Kumar Gala wrote:
> On Feb 24, 2006, at 4:27 PM, Michael Ellerman wrote:
> > Hi Kumar,
> >
> > On Sat, 25 Feb 2006 03:54, Kumar Gala wrote:
> >> mem= command line option was being ignored in arch/powerpc if we
> >> were not
> >> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The
> >> initial
> >> command line extraction and parsing needed to be moved earlier in
> >> the boot
> >> process and have code to actual parse mem= and do something about it.
> >>
> >> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
> >>                 crashk_res.end = crashk_res.start + *lprop - 1;
> >>  #endif
> >>
> >> +	/* Retreive command line */
> >> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
> >> +	if (p != NULL && l > 0)
> >> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
> >> +
> >> +#ifdef CONFIG_CMDLINE
> >> +	if (l == 0 || (l == 1 && (*p) == 0))
> >> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> >> +#endif /* CONFIG_CMDLINE */
> >> +
> >> +	DBG("Command line is: %s\n", cmd_line);
> >> +
> >> +	if (strstr(cmd_line, "mem=")) {
> >> +		char *p, *q;
> >> +		unsigned long maxmem = 0;
> >> +
> >> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> >> +			q = p + 4;
> >> +			if (p > cmd_line && p[-1] != ' ')
> >> +				continue;
> >> +			maxmem = simple_strtoul(q, &q, 0);
> >> +			if (*q == 'k' || *q == 'K') {
> >> +				maxmem <<= 10;
> >> +				++q;
> >> +			} else if (*q == 'm' || *q == 'M') {
> >> +				maxmem <<= 20;
> >> +				++q;
> >> +			} else if (*q == 'g' || *q == 'G') {
> >> +				maxmem <<= 30;
> >> +				++q;
> >> +			}
> >> +		}
> >> +		memory_limit = maxmem;
> >> +	}
> >> +
> >
> > Why not make the mem= parsing an early_param() handler and then call
> > parse_early_param() here?
>
> This would put constraints on the early_param()'s that I dont think
> we should impose.

All they should really be doing is parsing the string and setting some 
variables, so that seems reasonable to me. Is there anything in particular?

> > And I think a switch would be easier to read for the K/M/G handling.
>
> I should probably use memparse() now that I've found it :)

Even better.

cheers

-- 
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 23:18       ` Kumar Gala
@ 2006-02-25  0:12         ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2006-02-25  0:12 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Kumar Gala, Linus Torvalds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3048 bytes --]

On Sat, 25 Feb 2006 10:18, Kumar Gala wrote:
> On Sat, 25 Feb 2006, Michael Ellerman wrote:
> > On Sat, 25 Feb 2006 09:43, Kumar Gala wrote:
> > > On Feb 24, 2006, at 4:27 PM, Michael Ellerman wrote:
> > > > Hi Kumar,
> > > >
> > > > On Sat, 25 Feb 2006 03:54, Kumar Gala wrote:
> > > >> mem= command line option was being ignored in arch/powerpc if we
> > > >> were not
> > > >> a CONFIG_MULTIPLATFORM (which is handled via prom_init stub). The
> > > >> initial
> > > >> command line extraction and parsing needed to be moved earlier in
> > > >> the boot
> > > >> process and have code to actual parse mem= and do something about
> > > >> it.
> > > >>
> > > >> @@ -1004,6 +991,41 @@ static int __init early_init_dt_scan_cho
> > > >>                 crashk_res.end = crashk_res.start + *lprop - 1;
> > > >>  #endif
> > > >>
> > > >> +	/* Retreive command line */
> > > >> + 	p = of_get_flat_dt_prop(node, "bootargs", &l);
> > > >> +	if (p != NULL && l > 0)
> > > >> +		strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
> > > >> +
> > > >> +#ifdef CONFIG_CMDLINE
> > > >> +	if (l == 0 || (l == 1 && (*p) == 0))
> > > >> +		strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> > > >> +#endif /* CONFIG_CMDLINE */
> > > >> +
> > > >> +	DBG("Command line is: %s\n", cmd_line);
> > > >> +
> > > >> +	if (strstr(cmd_line, "mem=")) {
> > > >> +		char *p, *q;
> > > >> +		unsigned long maxmem = 0;
> > > >> +
> > > >> +		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> > > >> +			q = p + 4;
> > > >> +			if (p > cmd_line && p[-1] != ' ')
> > > >> +				continue;
> > > >> +			maxmem = simple_strtoul(q, &q, 0);
> > > >> +			if (*q == 'k' || *q == 'K') {
> > > >> +				maxmem <<= 10;
> > > >> +				++q;
> > > >> +			} else if (*q == 'm' || *q == 'M') {
> > > >> +				maxmem <<= 20;
> > > >> +				++q;
> > > >> +			} else if (*q == 'g' || *q == 'G') {
> > > >> +				maxmem <<= 30;
> > > >> +				++q;
> > > >> +			}
> > > >> +		}
> > > >> +		memory_limit = maxmem;
> > > >> +	}
> > > >> +
> > > >
> > > > Why not make the mem= parsing an early_param() handler and then call
> > > > parse_early_param() here?
> > >
> > > This would put constraints on the early_param()'s that I dont think
> > > we should impose.
> >
> > All they should really be doing is parsing the string and setting some
> > variables, so that seems reasonable to me. Is there anything in
> > particular?
>
> If you ever had to do some memory allocation as part of the parsing that
> might be an issue, since we haven't setup the LMB at that point.

Sure, but I think it's reasonable to say "don't allocate memory in an 
early_param handler", it is an _early_ param after all. But I guess we'll 
have to agree to disagree until someone else chimes in with an opinion :)

cheers

-- 
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
  2006-02-24 21:04 ` Segher Boessenkool
  2006-02-24 22:27 ` Michael Ellerman
@ 2006-02-26 20:38 ` Dave Hansen
  2006-02-27 16:12   ` Kumar Gala
  2 siblings, 1 reply; 10+ messages in thread
From: Dave Hansen @ 2006-02-26 20:38 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Paul Mackerras, linuxppc-dev, Linus Torvalds, linux-kernel

On Fri, 2006-02-24 at 10:54 -0600, Kumar Gala wrote:
> +       if (strstr(cmd_line, "mem=")) {
> +               char *p, *q;
> +               unsigned long maxmem = 0;
> +
> +               for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> +                       q = p + 4;
> +                       if (p > cmd_line && p[-1] != ' ')
> +                               continue;
> +                       maxmem = simple_strtoul(q, &q, 0);
> +                       if (*q == 'k' || *q == 'K') {
> +                               maxmem <<= 10;
> +                               ++q;
> +                       } else if (*q == 'm' || *q == 'M') {
> +                               maxmem <<= 20;
> +                               ++q;
> +                       } else if (*q == 'g' || *q == 'G') {
> +                               maxmem <<= 30;
> +                               ++q;
> +                       }
> +               }
> +               memory_limit = maxmem;
> +       } 

You may want to check out lib/cmdline.c's memparse() function.  I think
it does this for you.

-- Dave


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
  2006-02-26 20:38 ` Dave Hansen
@ 2006-02-27 16:12   ` Kumar Gala
  0 siblings, 0 replies; 10+ messages in thread
From: Kumar Gala @ 2006-02-27 16:12 UTC (permalink / raw)
  To: Dave Hansen; +Cc: Paul Mackerras, linuxppc-dev, Linus Torvalds, linux-kernel


On Feb 26, 2006, at 2:38 PM, Dave Hansen wrote:

> On Fri, 2006-02-24 at 10:54 -0600, Kumar Gala wrote:
>> +       if (strstr(cmd_line, "mem=")) {
>> +               char *p, *q;
>> +               unsigned long maxmem = 0;
>> +
>> +               for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
>> +                       q = p + 4;
>> +                       if (p > cmd_line && p[-1] != ' ')
>> +                               continue;
>> +                       maxmem = simple_strtoul(q, &q, 0);
>> +                       if (*q == 'k' || *q == 'K') {
>> +                               maxmem <<= 10;
>> +                               ++q;
>> +                       } else if (*q == 'm' || *q == 'M') {
>> +                               maxmem <<= 20;
>> +                               ++q;
>> +                       } else if (*q == 'g' || *q == 'G') {
>> +                               maxmem <<= 30;
>> +                               ++q;
>> +                       }
>> +               }
>> +               memory_limit = maxmem;
>> +       }
>
> You may want to check out lib/cmdline.c's memparse() function.  I  
> think
> it does this for you.

Yeah, found it after I sent the patch.  Since Linus applied this  
version, I'll provide Paul a version that changes this code to use  
memparse for post 2.6.16.

- kumar

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-02-27 16:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
2006-02-24 21:04 ` Segher Boessenkool
2006-02-24 22:27 ` Michael Ellerman
2006-02-24 22:43   ` Kumar Gala
2006-02-24 23:14     ` [PATCH][UPDATE] " Kumar Gala
2006-02-24 23:25     ` [PATCH] " Michael Ellerman
2006-02-24 23:18       ` Kumar Gala
2006-02-25  0:12         ` Michael Ellerman
2006-02-26 20:38 ` Dave Hansen
2006-02-27 16:12   ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).