diff mbox series

riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb

Message ID PSBPR04MB3991F5AF4EEA354A658A3BAAB1829@PSBPR04MB3991.apcprd04.prod.outlook.com (mailing list archive)
State Changes Requested
Headers show
Series riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb | expand

Commit Message

Wenting Zhang July 8, 2022, 8:09 p.m. UTC
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.

Signed-off-by: Wenting Zhang <zephray@outlook.com>
---
 arch/riscv/kernel/setup.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Conor Dooley July 8, 2022, 8:19 p.m. UTC | #1
Hey Wenting,
I see you've just CC'ed the list but not the maintainers.
If you run get_maintainers in the scripts directory, you'll get
a list spat out of the right people to CC.

On 08/07/2022 21:09, Wenting Zhang wrote:
> 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

You mention a fix. Do you know what commit this fixes?

> 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.
> 
> Signed-off-by: Wenting Zhang <zephray@outlook.com>
> ---
>  arch/riscv/kernel/setup.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index f0f36a4a0e9b..6e8aaa1ff7c7 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -251,10 +251,9 @@ 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");

Running one of the other scripts (checkpatch.pl with the --strict
option) will complain about this:
CHECK: Unbalanced braces around else statement
#41: FILE: arch/riscv/kernel/setup.c:254:
+	} else

Thanks,
Conor.

>  
> -	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);
Conor Dooley July 8, 2022, 10:30 p.m. UTC | #2
On 08/07/2022 21:50, Wenting Zhang wrote:
> 	
> You don't often get email from zephray@outlook.com. Learn why this is important <https://aka.ms/LearnAboutSenderIdentification>
> 	
> 
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> Hi Conor,
> 
> Thanks a lot for your comments. I have configured my git to use
> get_maintainers to populate the TO and CC list, it should work
> better now.

Yea, the new patch looks better - thanks!

> I have also added the Fixes to the commit message, fixed
> the style issue pointed out by the --strict option and sent a new
> patch.

Just FYI, should just also figure out how to send plaintext emails.
If you can't figure out how to do that with outlook. I know
Evolution and Thunderbird are both capable of but might not be
worth installing if you don't intend contributing much.
In the case, you can use the send-email commands from lore to send
replies, eg:
https://lore.kernel.org/all/737467de-c8a9-75e0-3f78-a6ab0860a6e8@microchip.com/#R

Thanks,
Conor.

> 
> Thanks,
> Wenting
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *From:* Conor.Dooley@microchip.com <Conor.Dooley@microchip.com>
> *Sent:* Friday, July 8, 2022 16:19
> *To:* zephray@outlook.com <zephray@outlook.com>; linux-riscv@lists.infradead.org <linux-riscv@lists.infradead.org>
> *Subject:* Re: [PATCH] riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb
>  
> Hey Wenting,
> I see you've just CC'ed the list but not the maintainers.
> If you run get_maintainers in the scripts directory, you'll get
> a list spat out of the right people to CC.
> 
> On 08/07/2022 21:09, Wenting Zhang wrote:
>> 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
> 
> You mention a fix. Do you know what commit this fixes?
> 
>> 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.
>> 
>> Signed-off-by: Wenting Zhang <zephray@outlook.com>
>> ---
>>  arch/riscv/kernel/setup.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
>> index f0f36a4a0e9b..6e8aaa1ff7c7 100644
>> --- a/arch/riscv/kernel/setup.c
>> +++ b/arch/riscv/kernel/setup.c
>> @@ -251,10 +251,9 @@ 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");
> 
> Running one of the other scripts (checkpatch.pl with the --strict
> option) will complain about this:
> CHECK: Unbalanced braces around else statement
> #41: FILE: arch/riscv/kernel/setup.c:254:
> +       } else
> 
> Thanks,
> Conor.
> 
>>  
>> -     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);
diff mbox series

Patch

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index f0f36a4a0e9b..6e8aaa1ff7c7 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -251,10 +251,9 @@  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);