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

Atish Patra atishp at atishpatra.org
Wed Nov 25 17:21:04 EST 2020


On Wed, Nov 25, 2020 at 3:40 AM Kefeng Wang <wangkefeng.wang at 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 at 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 at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.
Reviewed-by: Atish Patra <atish.patra at wdc.com>

-- 
Regards,
Atish



More information about the linux-riscv mailing list