Skip to content

Commit a7d550f

Browse files
sverdlinrobherring
authored andcommitted
of: fdt: Honor CONFIG_CMDLINE* even without /chosen node
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" Move CONFIG_CMDLINE handling outside of early_init_dt_scan_chosen() so that cases b and c above result in the same cmdline. Signed-off-by: Alexander Sverdlin <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring <[email protected]>
1 parent 71a7507 commit a7d550f

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

drivers/of/fdt.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,26 +1173,6 @@ int __init early_init_dt_scan_chosen(char *cmdline)
11731173
if (p != NULL && l > 0)
11741174
strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
11751175

1176-
/*
1177-
* CONFIG_CMDLINE is meant to be a default in case nothing else
1178-
* managed to set the command line, unless CONFIG_CMDLINE_FORCE
1179-
* is set in which case we override whatever was found earlier.
1180-
*/
1181-
#ifdef CONFIG_CMDLINE
1182-
#if defined(CONFIG_CMDLINE_EXTEND)
1183-
strlcat(cmdline, " ", COMMAND_LINE_SIZE);
1184-
strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1185-
#elif defined(CONFIG_CMDLINE_FORCE)
1186-
strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1187-
#else
1188-
/* No arguments from boot loader, use kernel's cmdl*/
1189-
if (!((char *)cmdline)[0])
1190-
strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1191-
#endif
1192-
#endif /* CONFIG_CMDLINE */
1193-
1194-
pr_debug("Command line is: %s\n", (char *)cmdline);
1195-
11961176
rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
11971177
if (rng_seed && l > 0) {
11981178
add_bootloader_randomness(rng_seed, l);
@@ -1297,6 +1277,26 @@ void __init early_init_dt_scan_nodes(void)
12971277
if (rc)
12981278
pr_warn("No chosen node found, continuing without\n");
12991279

1280+
/*
1281+
* CONFIG_CMDLINE is meant to be a default in case nothing else
1282+
* managed to set the command line, unless CONFIG_CMDLINE_FORCE
1283+
* is set in which case we override whatever was found earlier.
1284+
*/
1285+
#ifdef CONFIG_CMDLINE
1286+
#if defined(CONFIG_CMDLINE_EXTEND)
1287+
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
1288+
strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1289+
#elif defined(CONFIG_CMDLINE_FORCE)
1290+
strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1291+
#else
1292+
/* No arguments from boot loader, use kernel's cmdl */
1293+
if (!boot_command_line[0])
1294+
strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1295+
#endif
1296+
#endif /* CONFIG_CMDLINE */
1297+
1298+
pr_debug("Command line is: %s\n", boot_command_line);
1299+
13001300
/* Setup memory, calling early_init_dt_add_memory_arch */
13011301
early_init_dt_scan_memory();
13021302

0 commit comments

Comments
 (0)