Skip to content

Commit 2024972

Browse files
KanjiMonsterralfbaechle
authored andcommitted
MIPS: Make the kernel arguments from dtb available
Similar 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. Signed-off-by: Jonas Gorski <jogo@openwrt.org> Cc: linux-mips@linux-mips.org Cc: Kevin Cernekee <cernekee@gmail.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: John Crispin <blogic@openwrt.org> Cc: Ganesan Ramalingam <ganesanr@broadcom.com> Cc: Jayachandran C <jchandra@broadcom.com> Cc: Andrew Bresticker <abrestic@chromium.org> Cc: James Hartley <james.hartley@imgtec.com> Patchwork: https://patchwork.linux-mips.org/patch/11284/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 5b24d52 commit 2024972

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

arch/mips/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,6 +2749,22 @@ choice
27492749
if you don't intend to always append a DTB.
27502750
endchoice
27512751

2752+
choice
2753+
prompt "Kernel command line type" if !CMDLINE_OVERRIDE
2754+
default MIPS_CMDLINE_FROM_BOOTLOADER
2755+
2756+
config MIPS_CMDLINE_FROM_DTB
2757+
depends on USE_OF
2758+
bool "Dtb kernel arguments if available"
2759+
2760+
config MIPS_CMDLINE_DTB_EXTEND
2761+
depends on USE_OF
2762+
bool "Extend dtb kernel arguments with bootloader arguments"
2763+
2764+
config MIPS_CMDLINE_FROM_BOOTLOADER
2765+
bool "Bootloader kernel arguments if available"
2766+
endchoice
2767+
27522768
endmenu
27532769

27542770
config LOCKDEP_SUPPORT

arch/mips/kernel/setup.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ static void __init request_crashkernel(struct resource *res)
617617
}
618618
#endif /* !defined(CONFIG_KEXEC) */
619619

620+
#define USE_PROM_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER)
621+
#define USE_DTB_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)
622+
#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_EXTEND)
623+
620624
static void __init arch_mem_init(char **cmdline_p)
621625
{
622626
struct memblock_region *reg;
@@ -641,18 +645,24 @@ static void __init arch_mem_init(char **cmdline_p)
641645
pr_info("Determined physical RAM map:\n");
642646
print_memory_map();
643647

644-
#ifdef CONFIG_CMDLINE_BOOL
645-
#ifdef CONFIG_CMDLINE_OVERRIDE
648+
#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE)
646649
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
647650
#else
651+
if ((USE_PROM_CMDLINE && arcs_cmdline[0]) ||
652+
(USE_DTB_CMDLINE && !boot_command_line[0]))
653+
strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
654+
655+
if (EXTEND_WITH_PROM && arcs_cmdline[0]) {
656+
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
657+
strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
658+
}
659+
660+
#if defined(CONFIG_CMDLINE_BOOL)
648661
if (builtin_cmdline[0]) {
649-
strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
650-
strlcat(arcs_cmdline, builtin_cmdline, COMMAND_LINE_SIZE);
662+
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
663+
strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
651664
}
652-
strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
653665
#endif
654-
#else
655-
strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
656666
#endif
657667
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
658668

0 commit comments

Comments
 (0)