2022-07-08 20:53:56

by Wenting Zhang

[permalink] [raw]
Subject: [PATCH v2] riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb

When CONFIG_CMDLINE_FORCE is enabled, cmdline provided by
CONFIG_CMDLINE are always used. This allows CONFIG_CMDLINE to be
used regardless of the result of device tree scanning.

This especially fixes the case where a device tree without the
chosen node is supplied to the kernel. In such cases,
early_init_dt_scan would return true. But inside
early_init_dt_scan_chosen, the cmdline won't be updated as there
is no chosen node in the device tree. As a result, CONFIG_CMDLINE
is not copied into boot_command_line even if CONFIG_CMDLINE_FORCE
is enabled. This commit allows properly update boot_command_line
in this situation.

Fixes: 8fd6e05c7463 ("arch: riscv: support kernel command line forcing when no DTB passed")
Signed-off-by: Wenting Zhang <[email protected]>
---

ChangeLog:

v2: Add fixes in commit message; fix code style

arch/riscv/kernel/setup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index f0f36a4a0e9b..061cf8db3156 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -251,10 +251,10 @@ static void __init parse_dtb(void)
pr_info("Machine model: %s\n", name);
dump_stack_set_arch_desc("%s (DT)", name);
}
- return;
+ } else {
+ pr_err("No DTB passed to the kernel\n");
}

- pr_err("No DTB passed to the kernel\n");
#ifdef CONFIG_CMDLINE_FORCE
strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
pr_info("Forcing kernel command line to: %s\n", boot_command_line);
--
2.34.1


2022-10-10 15:28:53

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH v2] riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb

Wenting Zhang <[email protected]> writes:

> When CONFIG_CMDLINE_FORCE is enabled, cmdline provided by
> CONFIG_CMDLINE are always used. This allows CONFIG_CMDLINE to be
> used regardless of the result of device tree scanning.
>
> This especially fixes the case where a device tree without the
> chosen node is supplied to the kernel. In such cases,
> early_init_dt_scan would return true. But inside
> early_init_dt_scan_chosen, the cmdline won't be updated as there
> is no chosen node in the device tree. As a result, CONFIG_CMDLINE
> is not copied into boot_command_line even if CONFIG_CMDLINE_FORCE
> is enabled. This commit allows properly update boot_command_line
> in this situation.
>
> Fixes: 8fd6e05c7463 ("arch: riscv: support kernel command line forcing when no DTB passed")
> Signed-off-by: Wenting Zhang <[email protected]>

Reviewed-by: Björn Töpel <[email protected]>

2022-10-11 13:19:24

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2] riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb

On Mon, Oct 10, 2022 at 05:10:33PM +0200, Bj?rn T?pel wrote:
> Wenting Zhang <[email protected]> writes:
>
> > When CONFIG_CMDLINE_FORCE is enabled, cmdline provided by
> > CONFIG_CMDLINE are always used. This allows CONFIG_CMDLINE to be
> > used regardless of the result of device tree scanning.
> >
> > This especially fixes the case where a device tree without the
> > chosen node is supplied to the kernel. In such cases,
> > early_init_dt_scan would return true. But inside
> > early_init_dt_scan_chosen, the cmdline won't be updated as there
> > is no chosen node in the device tree. As a result, CONFIG_CMDLINE
> > is not copied into boot_command_line even if CONFIG_CMDLINE_FORCE
> > is enabled. This commit allows properly update boot_command_line
> > in this situation.
> >
> > Fixes: 8fd6e05c7463 ("arch: riscv: support kernel command line forcing when no DTB passed")
> > Signed-off-by: Wenting Zhang <[email protected]>
>
> Reviewed-by: Bj?rn T?pel <[email protected]>

I noticed that the version of this patch that I had left un-archived in
patchwork was not the correct one. I then realised I gave a "LGTM" type
thing in reponse to the v1, about the v2 but nothing on v2 itself.

Reviewed-by: Conor Dooley <[email protected]>

Thanks,
Conor.