From: Rob Herring <robh@kernel.org>
To: Geoff Levand <geoff@infradead.org>,
Alexander Sverdlin <alexander.sverdlin@gmail.com>,
Frank Rowand <frowand.list@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2
Date: Tue, 03 Jan 2023 12:00:32 -0600 [thread overview]
Message-ID: <20230103-dt-cmdline-fix-v1-2-7038e88b18b6@kernel.org> (raw)
In-Reply-To: <20230103-dt-cmdline-fix-v1-0-7038e88b18b6@kernel.org>
I do not read a strict requirement on /chosen node in either ePAPR or in
Documentation/devicetree. Help text for CONFIG_CMDLINE and
CONFIG_CMDLINE_EXTEND doesn't make their behavior explicitly dependent on
the presence of /chosen or the presense of /chosen/bootargs.
However the early check for /chosen and bailing out in
early_init_dt_scan_chosen() skips CONFIG_CMDLINE handling which is not
really related to /chosen node or the particular method of passing cmdline
from bootloader.
This leads to counterintuitive combinations (assuming
CONFIG_CMDLINE_EXTEND=y):
a) bootargs="foo", CONFIG_CMDLINE="bar" => cmdline=="foo bar"
b) /chosen missing, CONFIG_CMDLINE="bar" => cmdline==""
c) bootargs="", CONFIG_CMDLINE="bar" => cmdline==" bar"
Rework early_init_dt_scan_chosen() so that the cmdline config options are
always handled.
[commit msg written by Alexander Sverdlin]
Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/of/fdt.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7b571a631639..4b94bb52671e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1161,18 +1161,32 @@ int __init early_init_dt_scan_chosen(char *cmdline)
if (node < 0)
node = fdt_path_offset(fdt, "/chosen@0");
if (node < 0)
- return -ENOENT;
+ /* Handle the cmdline config options even if no /chosen node */
+ goto handle_cmdline;
chosen_node_offset = node;
early_init_dt_check_for_initrd(node);
early_init_dt_check_for_elfcorehdr(node);
+ rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
+ if (rng_seed && l > 0) {
+ add_bootloader_randomness(rng_seed, l);
+
+ /* try to clear seed so it won't be found. */
+ fdt_nop_property(initial_boot_params, node, "rng-seed");
+
+ /* update CRC check value */
+ of_fdt_crc32 = crc32_be(~0, initial_boot_params,
+ fdt_totalsize(initial_boot_params));
+ }
+
/* Retrieve command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0)
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
+handle_cmdline:
/*
* CONFIG_CMDLINE is meant to be a default in case nothing else
* managed to set the command line, unless CONFIG_CMDLINE_FORCE
@@ -1193,18 +1207,6 @@ int __init early_init_dt_scan_chosen(char *cmdline)
pr_debug("Command line is: %s\n", (char *)cmdline);
- rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
- if (rng_seed && l > 0) {
- add_bootloader_randomness(rng_seed, l);
-
- /* try to clear seed so it won't be found. */
- fdt_nop_property(initial_boot_params, node, "rng-seed");
-
- /* update CRC check value */
- of_fdt_crc32 = crc32_be(~0, initial_boot_params,
- fdt_totalsize(initial_boot_params));
- }
-
return 0;
}
--
2.39.0
next prev parent reply other threads:[~2023-01-03 18:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 18:00 [PATCH 0/2] of: Fix handling CONFIG_CMDLINE* even without /chosen node Rob Herring
2023-01-03 18:00 ` [PATCH 1/2] Revert "of: fdt: Honor CONFIG_CMDLINE* even without /chosen node" Rob Herring
2023-01-03 18:00 ` Rob Herring [this message]
2023-01-04 1:31 ` [PATCH 0/2] of: Fix handling CONFIG_CMDLINE* even without /chosen node Geoff Levand
2023-01-04 9:48 ` Alexander Sverdlin
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=20230103-dt-cmdline-fix-v1-2-7038e88b18b6@kernel.org \
--to=robh@kernel.org \
--cc=alexander.sverdlin@gmail.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=geoff@infradead.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).