arch: riscv: support kernel command line forcing when no DTB passed
PATCH 1/1 arch: riscv: support kernel command line forcing when no DTB passed
CONFIG_CMDLINE_FORCE doesn't work on RISC-V when no DTB is passed into the kernel. This is because the code that forces the kernel command line only runs if a valid DTB is present at boot. During debugging, it's useful to have the ability to force kernel command lines even when no DTB is present. This patch adds support for doing so.
---
Applies on v4.20-rc7.
arch/riscv/kernel/setup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/riscv/kernel/setup.c +8 -1
@@ -171,7 +171,14 @@ asmlinkage void __init setup_vm(void)void __init parse_dtb (unsigned int hartid,void *dtb) { -early_init_dt_scan (__va (dtb)); +if (!early_init_dt_scan (__va (dtb))) +return ; + +pr_err ("No DTB passed to the kernel\n" ); +#ifdef CONFIG_CMDLINE_FORCE +strlcpy (boot_command_line,CONFIG_CMDLINE ,COMMAND_LINE_SIZE ); +pr_info ("Forcing kernel command line to: %s\n" , boot_command_line); +#endif }static void __init setup_bootmem (void )
Signature · 1 line
2.20.0
Quoted 6 lines · Paul Walmsley
CONFIG_CMDLINE_FORCEdoesn't work on RISC-V when no DTB is passed into the kernel. This is because the code that forces the kernel command line only runs if a valid DTB is present at boot. During debugging, it's useful to have the ability to force kernel command lines even when no DTB is present. This patch adds support for doing so.
This looks fine to me:
I just wish all this command line magic could be moved to common code somewhere instead of being reinvented badly in every port..
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
arch/riscv/kernel/setup.c asmlinkage void __init setup_vm(void) · line 177
Quoted 13 lines · Paul Walmsley
arch/riscv/kernel/setup.c +4
-1@@ -171,7 +171,14 @@ asmlinkage void __init setup_vm(void)void __init parse_dtb (unsigned int hartid,void *dtb) { -early_init_dt_scan (__va (dtb)); +if (!early_init_dt_scan (__va (dtb))) +return ; + +pr_err ("No DTB passed to the kernel\n" );
Isn't that backwards? early_init_dt_scan returns true if it found a DTB.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Quoted 8 lines · Andreas Schwab
Quoted 6 lines · Paul Walmsley
arch/riscv/kernel/setup.c +0
-0@@ -171,7 +171,14 @@ asmlinkage void __init setup_vm(void)
Quoted 10 lines
arch/riscv/kernel/setup.c asmlinkage void __init setup_vm(void) · line 177
Quoted 7 lines
arch/riscv/kernel/setup.c +4
-1void __init parse_dtb (unsigned int hartid,void *dtb) { -early_init_dt_scan (__va (dtb)); +if (!early_init_dt_scan (__va (dtb))) +return ; + +pr_err ("No DTB passed to the kernel\n" );Isn't that backwards?
early_init_dt_scanreturns true if it found a DTB.
Yes, it's backwards. Thanks for the catch. Looks like I sent an older version of the patch.
- Paul
PATCH 1/1 arch: riscv: fix logic error in parse_dtb
In reply to Paul WalmsleyThe function early_init_dt_scan returns true if a DTB was detected.
--- arch/riscv/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/setup.c +1 -1
@@ -140,7 +140,7 @@ asmlinkage void __init setup_vm(void)void __init parse_dtb (unsigned int hartid,void *dtb) { -if (!early_init_dt_scan (__va (dtb))) +if (early_init_dt_scan (__va (dtb)))return ;pr_err ("No DTB passed to the kernel\n" );
Signature · 6 lines
2.20.1 -- Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Re: [PATCH] arch: riscv: fix logic error in parse_dtb
Quoted 14 lines · Andreas Schwab
The function
early_init_dt_scanreturns true if a DTB was detected.Fixes 8fd6e05c7463 ("arch: riscv: support kernel command line forcing when no DTB passed")Signed-off-by Andreas Schwab <[email protected]>--- arch/riscv/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/setup.c +0
-0
arch/riscv/kernel/setup.c asmlinkage void __init setup_vm(void) · line 146
Quoted 8 lines
arch/riscv/kernel/setup.c +1
-1@@ -140,7 +140,7 @@ asmlinkage void __init setup_vm(void)void __init parse_dtb (unsigned int hartid,void *dtb) { -if (!early_init_dt_scan (__va (dtb))) +if (early_init_dt_scan (__va (dtb)))return ;pr_err ("No DTB passed to the kernel\n" );
Good catch. I was surprised to see "No DTB passed.." message with rc5.
Regards,
Atish
Re: [PATCH] arch: riscv: fix logic error in parse_dtb
In reply to Andreas SchwabQuoted 23 lines · Andreas Schwab
The function
early_init_dt_scanreturns true if a DTB was detected.Fixes 8fd6e05c7463 ("arch: riscv: support kernel command line forcing when no DTB passed")Signed-off-by Andreas Schwab <[email protected]>--- arch/riscv/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/setup.c +1
-1@@ -140,7 +140,7 @@ asmlinkage void __init setup_vm(void)void __init parse_dtb (unsigned int hartid,void *dtb) { -if (!early_init_dt_scan (__va (dtb))) +if (early_init_dt_scan (__va (dtb)))return ;pr_err ("No DTB passed to the kernel\n" );Signature · 1 line
2.20.1
- Paul