MIPS: allow keeping the dtb command line
Subsystems (4)
v2 cover MIPS: allow keeping the dtb command line
Currently MIPS kernel code overwrites any bootargs from devicetree unconditionally with the arcscmdline. Several targets work around this by copying the devicetree bootargs into the arcscmdline after parsing the device tree.
This patchset adds a new kernel option for keeping the devicetree bootargs, then removes the workarounds and lets the targets instead make use of that option.
Since some targets use OF but don't make use of the devicetree bootargs, treat them like non-OF enabled targets and only use the prom commandline.
Changes v1 -> v2:
* Fix ATh79 -> ATH79
Jonas Gorski (3):
MIPS: use USE_OF as the guard for appended dtb
MIPS: make the kernel arguments from dtb available
MIPS: make MIPS_CMDLINE_DTB default
arch/mips/Kconfig | 21 ++++++++++++++++++++- arch/mips/bmips/setup.c | 1 - arch/mips/kernel/setup.c | 24 +++++++++++++++++------- arch/mips/lantiq/prom.c | 2 -- arch/mips/netlogic/xlp/dt.c | 1 - arch/mips/pistachio/init.c | 1 - arch/mips/ralink/of.c | 2 -- 7 files changed, 37 insertions(+), 15 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/3 MIPS: use USE_OF as the guard for appended dtb
Since OF is now a user selectable symbol, the choice for appended dtb support should only be visible when USE_OF is selected, as this indicates actual machine support for device tree in MIPS.
---
v1 -> v2:
* no changes
arch/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Kconfig +1 -1
@@ -2700,7 +2700,7 @@ config BUILTIN_DTB bool choice - prompt "Kernel appended dtb support" if OF + prompt "Kernel appended dtb support" if USE_OF default MIPS_NO_APPENDED_DTB config MIPS_NO_APPENDED_DTB
Signature · 1 line
2.1.4
PATCH v2 2/3 MIPS: make the kernel arguments from dtb available
In reply to Jonas GorskiSimilar to how arm allows using selecting between bootloader arguments, dtb arguments and both, allow to select them on mips. But since we have less control over the place of the dtb do not modify it but instead use the boot_command_line for merging them.
The default is "use bootloader arguments" to keep the current behaviour as default.
---
v1 -> v2:
* no changes
arch/mips/Kconfig | 16 ++++++++++++++++ arch/mips/kernel/setup.c | 24 +++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
arch/mips/Kconfig +16 -0
@@ -2744,6 +2744,22 @@ choice if you don't intend to always append a DTB. endchoice +choice + prompt "Kernel command line type" if !CMDLINE_OVERRIDE + default MIPS_CMDLINE_FROM_BOOTLOADER + + config MIPS_CMDLINE_FROM_DTB + depends on USE_OF + bool "Dtb kernel arguments if available" + + config MIPS_CMDLINE_DTB_EXTEND + depends on USE_OF + bool "Extend dtb kernel arguments with bootloader arguments" + + config MIPS_CMDLINE_FROM_BOOTLOADER + bool "Bootloader kernel arguments if available" +endchoice + endmenu config LOCKDEP_SUPPORT
arch/mips/kernel/setup.c +17 -7
@@ -617,6 +617,10 @@ static void __init request_crashkernel(struct resource *res) }#endif /* !defined(CONFIG_KEXEC) */ +#define USE_PROM_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER) +#define USE_DTB_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB) +#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_EXTEND) +static void __init arch_mem_init (char **cmdline_p) {struct memblock_region *reg;
@@ -641,18 +645,24 @@ static void __init arch_mem_init(char **cmdline_p)pr_info ("Determined physical RAM map:\n" );print_memory_map (); -#ifdef CONFIG_CMDLINE_BOOL -#ifdef CONFIG_CMDLINE_OVERRIDE +#if defined(CONFIG_CMDLINE_BOOL ) && defined(CONFIG_CMDLINE_OVERRIDE )strlcpy (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE );#else +if ((USE_PROM_CMDLINE && arcs_cmdline[0 ]) || + (USE_DTB_CMDLINE && !boot_command_line[0 ])) +strlcpy (boot_command_line, arcs_cmdline,COMMAND_LINE_SIZE ); + +if (EXTEND_WITH_PROM && arcs_cmdline[0 ]) { +strlcat (boot_command_line," " ,COMMAND_LINE_SIZE ); +strlcat (boot_command_line, arcs_cmdline,COMMAND_LINE_SIZE ); + } + +#if defined(CONFIG_CMDLINE_BOOL )if (builtin_cmdline[0 ]) { -strlcat (arcs_cmdline," " ,COMMAND_LINE_SIZE ); -strlcat (arcs_cmdline, builtin_cmdline,COMMAND_LINE_SIZE ); +strlcat (boot_command_line," " ,COMMAND_LINE_SIZE ); +strlcat (boot_command_line, builtin_cmdline,COMMAND_LINE_SIZE ); } -strlcpy (boot_command_line, arcs_cmdline,COMMAND_LINE_SIZE );#endif -#else -strlcpy (boot_command_line, arcs_cmdline,COMMAND_LINE_SIZE );#endif strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE );
Signature · 1 line
2.1.4
PATCH v2 3/3 MIPS: make MIPS_CMDLINE_DTB default
In reply to Jonas GorskiSeval of-enabled machines (bmips, lantiq, xlp, pistachio, ralink) copied the arguments from dtb to arcs_command_line to prevent the kernel from overwriting them.
Since there is now an option to keep the dtb arguments, default to the new option remove the "backup" to arcs_command_line in case of USE_OF is enabled, except for those platforms that still take the bootloader arguments or do not use any at all.
---
v1 -> v2:
* ATh79 -> ATH79
arch/mips/Kconfig | 3 +++ arch/mips/bmips/setup.c | 1 - arch/mips/lantiq/prom.c | 2 -- arch/mips/netlogic/xlp/dt.c | 1 - arch/mips/pistachio/init.c | 1 - arch/mips/ralink/of.c | 2 -- 6 files changed, 3 insertions(+), 7 deletions(-)
arch/mips/Kconfig +3 -0
@@ -2746,6 +2746,9 @@ endchoice choice prompt "Kernel command line type" if !CMDLINE_OVERRIDE + default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \ + !MIPS_MALTA && !MIPS_SEAD3 && \ + !CAVIUM_OCTEON_SOC default MIPS_CMDLINE_FROM_BOOTLOADER config MIPS_CMDLINE_FROM_DTB
arch/mips/bmips/setup.c +0 -1
@@ -157,7 +157,6 @@ void __init plat_mem_setup(void)panic ("no dtb found" );__dt_setup_arch (dtb); -strlcpy (arcs_cmdline, boot_command_line,COMMAND_LINE_SIZE );for (q = bmips_quirk_list; q->quirk_fn; q++) { if (of_flat_dt_is_compatible(of_get_flat_dt_root(),
arch/mips/lantiq/prom.c +0 -2
@@ -77,8 +77,6 @@ void __init plat_mem_setup(void)* parsed resulting in our memory appearing */ __dt_setup_arch (__dtb_start); - -strlcpy (arcs_cmdline, boot_command_line,COMMAND_LINE_SIZE ); }void __init device_tree_init (void )
arch/mips/netlogic/xlp/dt.c +0 -1
@@ -87,7 +87,6 @@ void __init *xlp_dt_init(void *fdtp)void __init xlp_early_init_devtree (void ) {__dt_setup_arch (xlp_fdt_blob); -strlcpy (arcs_cmdline, boot_command_line,COMMAND_LINE_SIZE ); }void __init device_tree_init (void )
arch/mips/pistachio/init.c +0 -1
@@ -58,7 +58,6 @@ void __init plat_mem_setup(void)panic ("Device-tree not present" );__dt_setup_arch ((void *)fw_arg1); -strlcpy (arcs_cmdline, boot_command_line,COMMAND_LINE_SIZE );plat_setup_iocoherency (); }
arch/mips/ralink/of.c +0 -2
@@ -74,8 +74,6 @@ void __init plat_mem_setup(void)*/ __dt_setup_arch (__dtb_start); -strlcpy (arcs_cmdline, boot_command_line,COMMAND_LINE_SIZE ); -of_scan_flat_dt (early_init_dt_find_memory,NULL );if (memory_dtb)of_scan_flat_dt (early_init_dt_scan_memory,NULL );
Signature · 1 line
2.1.4