[PATCH v5 4/5] power: reset: pscrr: add kernel watchdog reason tracking

From: Faruque Ansari

Date: Mon Nov 23 2026 - 02:06:20 EST


Kernel watchdog events are not recorded with dedicated reset
reason codes.

Add PSCR_KERNEL_WATCHDOG_HARDLOCKUP and PSCR_KERNEL_WATCHDOG_SOFTLOCKUP
as dedicated reason codes to record hard and soft lockup events
detected by the kernel watchdog on subsequent boots.

Signed-off-by: Faruque Ansari <faruque.ansari@xxxxxxxxxxxxxxxx>
---
include/linux/power/power_on_reason.h | 2 ++
include/linux/reboot.h | 10 ++++++++++
kernel/reboot.c | 2 ++
kernel/watchdog.c | 9 +++++++--
4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
index 8e3889fa43ef..9bcce23c81e9 100644
--- a/include/linux/power/power_on_reason.h
+++ b/include/linux/power/power_on_reason.h
@@ -22,5 +22,7 @@
#define POWER_ON_REASON_EXTERNAL "external reset"
#define POWER_ON_REASON_KERNEL_PANIC "kernel panic"
#define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout"
+#define POWER_ON_REASON_HARD_LOCKUP "hard lockup"
+#define POWER_ON_REASON_SOFT_LOCKUP "soft lockup"

#endif /* POWER_ON_REASON_H */
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 6d5ecc6cdc00..45e64bcad37e 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -246,6 +246,14 @@ extern void orderly_reboot(void);
* @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog pretimeout fires, before
* the pretimeout governor brings the system down.
*
+ * @PSCR_KERNEL_WATCHDOG_HARDLOCKUP: Reset that followed a hard lockup detected
+ * by the kernel's NMI watchdog (kernel/watchdog.c), before it escalated to
+ * panic.
+ *
+ * @PSCR_KERNEL_WATCHDOG_SOFTLOCKUP: Reset that followed a soft lockup (hung
+ * task) detected by the kernel's softlockup watchdog, before it
+ * escalated to panic.
+ *
* @PSCR_REASON_COUNT: Number of defined power state change reasons. This
* value is useful for range checking and potential future extensions
* while maintaining compatibility.
@@ -271,6 +279,8 @@ enum psc_reason {
PSCR_XTAL_FAIL,
PSCR_KERNEL_PANIC,
PSCR_WATCHDOG_PRETIMEOUT,
+ PSCR_KERNEL_WATCHDOG_HARDLOCKUP,
+ PSCR_KERNEL_WATCHDOG_SOFTLOCKUP,

/* Number of reasons */
PSCR_REASON_COUNT,
diff --git a/kernel/reboot.c b/kernel/reboot.c
index fad4ef9681a6..b748153d18cc 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1111,6 +1111,8 @@ static const struct psc_reason_desc psc_reason_descs[] = {
[PSCR_XTAL_FAIL] = { "crystal-failure", POWER_ON_REASON_XTAL_FAIL },
[PSCR_KERNEL_PANIC] = { "kernel-panic", POWER_ON_REASON_KERNEL_PANIC },
[PSCR_WATCHDOG_PRETIMEOUT] = { "watchdog-pretimeout", POWER_ON_REASON_WATCHDOG_PRETIMEOUT },
+ [PSCR_KERNEL_WATCHDOG_HARDLOCKUP] = { "hardlockup", POWER_ON_REASON_HARD_LOCKUP },
+ [PSCR_KERNEL_WATCHDOG_SOFTLOCKUP] = { "softlockup", POWER_ON_REASON_SOFT_LOCKUP },
};

/**
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index e5134ad7b663..e05ae3cc583f 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/nmi.h>
+#include <linux/reboot.h>
#include <linux/stop_machine.h>
#include <linux/sysctl.h>
#include <linux/tick.h>
@@ -287,8 +288,10 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
}

sys_info(hardlockup_si_mask & ~SYS_INFO_ALL_BT);
- if (hardlockup_panic)
+ if (hardlockup_panic) {
+ set_psc_reason(PSCR_KERNEL_WATCHDOG_HARDLOCKUP);
nmi_panic(regs, "Hard LOCKUP");
+ }

per_cpu(watchdog_hardlockup_warned, cpu) = true;
}
@@ -903,8 +906,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
sys_info(softlockup_si_mask & ~SYS_INFO_ALL_BT);
thresh_count = duration / get_softlockup_thresh();

- if (softlockup_panic && thresh_count >= softlockup_panic)
+ if (softlockup_panic && thresh_count >= softlockup_panic) {
+ set_psc_reason(PSCR_KERNEL_WATCHDOG_SOFTLOCKUP);
panic("softlockup: hung tasks");
+ }
}

return HRTIMER_RESTART;

--
2.34.1