diff mbox series

riscv: Add machine name to kernel boot log and stack dump output

Message ID 20201125114415.94912-1-wangkefeng.wang@huawei.com (mailing list archive)
State New, archived
Headers show
Series riscv: Add machine name to kernel boot log and stack dump output | expand

Commit Message

Kefeng Wang Nov. 25, 2020, 11:44 a.m. UTC
Add the machine name to kernel boot-up log, and install
the machine name to stack dump for DT boot mode.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---

Here is the message after patched,

root@(none):~# dmesg |grep "Machine model"
[    0.000000] Machine model: riscv-virtio,qemu

root@(none):~# echo c > /proc/sysrq-trigger 
[ 1519.475346] sysrq: Trigger a crash
[ 1519.476004] Kernel panic - not syncing: sysrq triggered crash
[ 1519.476480] CPU: 0 PID: 64 Comm: sh Not tainted 5.10.0-rc5 #246
[ 1519.476877] Hardware name: riscv-virtio,qemu (DT)
[ 1519.477169] Call Trace:
...

 arch/riscv/kernel/setup.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Atish Patra Nov. 25, 2020, 10:21 p.m. UTC | #1
On Wed, Nov 25, 2020 at 3:40 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Add the machine name to kernel boot-up log, and install
> the machine name to stack dump for DT boot mode.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>
> Here is the message after patched,
>
> root@(none):~# dmesg |grep "Machine model"
> [    0.000000] Machine model: riscv-virtio,qemu
>
> root@(none):~# echo c > /proc/sysrq-trigger
> [ 1519.475346] sysrq: Trigger a crash
> [ 1519.476004] Kernel panic - not syncing: sysrq triggered crash
> [ 1519.476480] CPU: 0 PID: 64 Comm: sh Not tainted 5.10.0-rc5 #246
> [ 1519.476877] Hardware name: riscv-virtio,qemu (DT)
> [ 1519.477169] Call Trace:
> ...
>
>  arch/riscv/kernel/setup.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index c424cc6dd833..901ac0c680dd 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -54,8 +54,15 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
>  static void __init parse_dtb(void)
>  {
>         /* Early scan of device tree from init memory */
> -       if (early_init_dt_scan(dtb_early_va))
> +       if (early_init_dt_scan(dtb_early_va)) {
> +               const char *name = of_flat_dt_get_machine_name();
> +
> +               if (name) {
> +                       pr_info("Machine model: %s\n", name);
> +                       dump_stack_set_arch_desc("%s (DT)", name);
> +               }
>                 return;
> +       }
>
>         pr_err("No DTB passed to the kernel\n");
>  #ifdef CONFIG_CMDLINE_FORCE
> --
> 2.26.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Kefeng Wang Dec. 14, 2020, 11:31 a.m. UTC | #2
Hi Palmer,  kindly ping..

On 2020/11/25 19:44, Kefeng Wang wrote:
> Add the machine name to kernel boot-up log, and install
> the machine name to stack dump for DT boot mode.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>
> Here is the message after patched,
>
> root@(none):~# dmesg |grep "Machine model"
> [    0.000000] Machine model: riscv-virtio,qemu
>
> root@(none):~# echo c > /proc/sysrq-trigger
> [ 1519.475346] sysrq: Trigger a crash
> [ 1519.476004] Kernel panic - not syncing: sysrq triggered crash
> [ 1519.476480] CPU: 0 PID: 64 Comm: sh Not tainted 5.10.0-rc5 #246
> [ 1519.476877] Hardware name: riscv-virtio,qemu (DT)
> [ 1519.477169] Call Trace:
> ...
>
>   arch/riscv/kernel/setup.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index c424cc6dd833..901ac0c680dd 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -54,8 +54,15 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
>   static void __init parse_dtb(void)
>   {
>   	/* Early scan of device tree from init memory */
> -	if (early_init_dt_scan(dtb_early_va))
> +	if (early_init_dt_scan(dtb_early_va)) {
> +		const char *name = of_flat_dt_get_machine_name();
> +
> +		if (name) {
> +			pr_info("Machine model: %s\n", name);
> +			dump_stack_set_arch_desc("%s (DT)", name);
> +		}
>   		return;
> +	}
>   
>   	pr_err("No DTB passed to the kernel\n");
>   #ifdef CONFIG_CMDLINE_FORCE
Palmer Dabbelt Jan. 9, 2021, 10:21 p.m. UTC | #3
On Mon, 14 Dec 2020 03:31:03 PST (-0800), wangkefeng.wang@huawei.com wrote:
> Hi Palmer,  kindly ping..
>
> On 2020/11/25 19:44, Kefeng Wang wrote:
>> Add the machine name to kernel boot-up log, and install
>> the machine name to stack dump for DT boot mode.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>
>> Here is the message after patched,
>>
>> root@(none):~# dmesg |grep "Machine model"
>> [    0.000000] Machine model: riscv-virtio,qemu
>>
>> root@(none):~# echo c > /proc/sysrq-trigger
>> [ 1519.475346] sysrq: Trigger a crash
>> [ 1519.476004] Kernel panic - not syncing: sysrq triggered crash
>> [ 1519.476480] CPU: 0 PID: 64 Comm: sh Not tainted 5.10.0-rc5 #246
>> [ 1519.476877] Hardware name: riscv-virtio,qemu (DT)
>> [ 1519.477169] Call Trace:
>> ...
>>
>>   arch/riscv/kernel/setup.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
>> index c424cc6dd833..901ac0c680dd 100644
>> --- a/arch/riscv/kernel/setup.c
>> +++ b/arch/riscv/kernel/setup.c
>> @@ -54,8 +54,15 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
>>   static void __init parse_dtb(void)
>>   {
>>   	/* Early scan of device tree from init memory */
>> -	if (early_init_dt_scan(dtb_early_va))
>> +	if (early_init_dt_scan(dtb_early_va)) {
>> +		const char *name = of_flat_dt_get_machine_name();
>> +
>> +		if (name) {
>> +			pr_info("Machine model: %s\n", name);
>> +			dump_stack_set_arch_desc("%s (DT)", name);
>> +		}
>>   		return;
>> +	}
>>
>>   	pr_err("No DTB passed to the kernel\n");
>>   #ifdef CONFIG_CMDLINE_FORCE

Thanks, this is on for-next.
diff mbox series

Patch

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index c424cc6dd833..901ac0c680dd 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -54,8 +54,15 @@  static DEFINE_PER_CPU(struct cpu, cpu_devices);
 static void __init parse_dtb(void)
 {
 	/* Early scan of device tree from init memory */
-	if (early_init_dt_scan(dtb_early_va))
+	if (early_init_dt_scan(dtb_early_va)) {
+		const char *name = of_flat_dt_get_machine_name();
+
+		if (name) {
+			pr_info("Machine model: %s\n", name);
+			dump_stack_set_arch_desc("%s (DT)", name);
+		}
 		return;
+	}
 
 	pr_err("No DTB passed to the kernel\n");
 #ifdef CONFIG_CMDLINE_FORCE