From: Joshua Yeong <joshua.yeong@starfivetech.com>
To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu
Cc: alex@ghiti.fr, rkrcmar@ventanamicro.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Joshua Yeong <joshua.yeong@starfivetech.com>
Subject: [PATCH] riscv: sbi: Pass system failure reset reason on panic
Date: Mon, 30 Nov 2026 19:06:43 +0800 [thread overview]
Message-ID: <20261130110643.2414998-1-joshua.yeong@starfivetech.com> (raw)
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
reply other threads:[~2026-11-30 11:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130110643.2414998-1-joshua.yeong@starfivetech.com \
--to=joshua.yeong@starfivetech.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rkrcmar@ventanamicro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®