mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] riscv: sbi: Pass system failure reset reason on panic
@ 2026-11-30 11:06 Joshua Yeong
  0 siblings, 0 replies; only message in thread
From: Joshua Yeong @ 2026-11-30 11:06 UTC (permalink / raw)
  To: pjw, palmer, aou; +Cc: alex, rkrcmar, linux-riscv, linux-kernel, Joshua Yeong

A restart from panic() is sent to the SBI SRST extension with reset
reason NONE, the same as a normal reboot, so firmware cannot tell a
panic reboot apart from a requested one.

Pass SBI_SRST_RESET_REASON_SYS_FAILURE when the restart is requested
while a panic is in progress.

Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
---
 arch/riscv/kernel/sbi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index af1ccea222f1d..e44f23c5ded8d 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -8,6 +8,7 @@
 #include <linux/bits.h>
 #include <linux/init.h>
 #include <linux/mm.h>
+#include <linux/panic.h>
 #include <linux/pm.h>
 #include <linux/reboot.h>
 #include <asm/sbi.h>
@@ -515,10 +516,16 @@ static void sbi_srst_reset(unsigned long type, unsigned long reason)
 static int sbi_srst_reboot(struct notifier_block *this,
 			   unsigned long mode, void *cmd)
 {
+	unsigned long reason = SBI_SRST_RESET_REASON_NONE;
+
+	/* Restart requested from panic() */
+	if (panic_in_progress())
+		reason = SBI_SRST_RESET_REASON_SYS_FAILURE;
+
 	sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
 		       SBI_SRST_RESET_TYPE_WARM_REBOOT :
 		       SBI_SRST_RESET_TYPE_COLD_REBOOT,
-		       SBI_SRST_RESET_REASON_NONE);
+		       reason);
 	return NOTIFY_DONE;
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 11:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 11:06 [PATCH] riscv: sbi: Pass system failure reset reason on panic Joshua Yeong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®