Skip to contentSkip to conversation

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

PATCH In review Kefeng Wang 3 participants 4 messages Nov 25, 2020 – Jan 9, 2021 RISC-V

lore
Share & tools
lore
#0 lore raw

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

Add the machine name to kernel boot-up log, and install the machine name to stack dump for DT boot mode.

---

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(-)
arch/riscv/kernel/setup.c +8 -1
index c424cc6dd833..901ac0c680dd 100644
@@ -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
Signature · 7 lines
2.26.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v1 1/1
#1 lore raw
Quoted 48 lines · Kefeng Wang

Add the machine name to kernel boot-up log, and install the machine name to stack dump for DT boot mode.

---

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(-)
arch/riscv/kernel/setup.c +8 -2
index c424cc6dd833..901ac0c680dd 100644
@@ -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

Quoted 4 lines

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Signature · 7 lines
Regards,
Atish

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw
In reply to Kefeng Wang

Hi Palmer,  kindly ping..

Quoted 33 lines · Kefeng Wang

Add the machine name to kernel boot-up log, and install the machine name to stack dump for DT boot mode.

---

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(-)
arch/riscv/kernel/setup.c +2 -1
index c424cc6dd833..901ac0c680dd 100644
@@ -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();

arch/riscv/kernel/setup.c static DEFINE_PER_CPU(struct cpu, cpu_devices); · line 68

Quoted 10 lines
arch/riscv/kernel/setup.c +6 -0
+
+		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

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#3 lore raw
Quoted 44 lines · On Mon, 14 Dec 2020 03:31:03 PST (-0800), [email protected] wrote:

Hi Palmer,  kindly ping..

Quoted 41 lines · Kefeng Wang

Add the machine name to kernel boot-up log, and install the machine name to stack dump for DT boot mode.

---

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(-)
arch/riscv/kernel/setup.c +8 -1
index c424cc6dd833..901ac0c680dd 100644
@@ -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;
+	}
 
Quoted 2 lines

arch/riscv/kernel/setup.c static DEFINE_PER_CPU(struct cpu, cpu_devices); · line 68

Quoted 2 lines
arch/riscv/kernel/setup.c +0 -0
  	pr_err("No DTB passed to the kernel\n");
  #ifdef CONFIG_CMDLINE_FORCE

Thanks, this is on for-next.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv