From: Michael Ellerman <michael@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Cc: Linus Torvalds <torvalds@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
Date: Sat, 25 Feb 2006 09:27:32 +1100 [thread overview]
Message-ID: <200602250927.36954.michael@ellerman.id.au> (raw)
In-Reply-To: <Pine.LNX.4.44.0602241054090.2981-100000@gate.crashing.org>
[-- 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 --]
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <michael@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Cc: Kumar Gala <galak@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Linus Torvalds <torvalds@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
Date: Sat, 25 Feb 2006 09:27:32 +1100 [thread overview]
Message-ID: <200602250927.36954.michael@ellerman.id.au> (raw)
In-Reply-To: <Pine.LNX.4.44.0602241054090.2981-100000@gate.crashing.org>
[-- 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 --]
next prev parent reply other threads:[~2006-02-24 22:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
2006-02-24 16:54 ` Kumar Gala
2006-02-24 21:04 ` Segher Boessenkool
2006-02-24 21:04 ` Segher Boessenkool
2006-02-24 22:27 ` Michael Ellerman [this message]
2006-02-24 22:27 ` Michael Ellerman
2006-02-24 22:43 ` Kumar Gala
2006-02-24 22:43 ` Kumar Gala
2006-02-24 23:14 ` [PATCH][UPDATE] " Kumar Gala
2006-02-24 23:14 ` Kumar Gala
2006-02-24 23:25 ` [PATCH] " Michael Ellerman
2006-02-24 23:25 ` Michael Ellerman
2006-02-24 23:18 ` Kumar Gala
2006-02-24 23:18 ` Kumar Gala
2006-02-25 0:12 ` Michael Ellerman
2006-02-25 0:12 ` Michael Ellerman
2006-02-26 20:38 ` Dave Hansen
2006-02-26 20:38 ` Dave Hansen
2006-02-27 16:12 ` Kumar Gala
2006-02-27 16:12 ` Kumar Gala
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=200602250927.36954.michael@ellerman.id.au \
--to=michael@ellerman.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.