* [PATCH v4 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout
@ 2026-08-05 8:54 Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-05 8:54 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm, kernel,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
Faruque Ansari
This series extends the Power State Change Reason Register (PSCRR) [1]
framework to capture two additional reset causes.
1. Kernel panic — a panic notifier writes PSCR_KERNEL_PANIC to NVMEM
before the system resets, so the next boot can distinguish a panic
from other reset causes.
2. Watchdog pretimeout — set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT) is
called from pretimeout_panic(), when the watchdog fire its
pre-reset notification before resetting the system, so the reason gets
saved and we know its was a watchdog timeout that caused the reset.
Changes in v4:
- correct 2/3 patch.
- v3-link: [4]
Changes in v3:
- Update patch 3/3 based on Guenter Roeck's feedback:
* Move set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT) from
watchdog_notify_pretimeout() to pretimeout_panic().
- v2-link: [3]
Changes in v2:
- Split patch 2/2 into two patches as requested by Guenter Roeck:
* Patch 2/3: power/reset — add PSCR_WATCHDOG_PRETIMEOUT and guard
panic notifier against overwriting watchdog reason.
* Patch 3/3: watchdog — hook set_psc_reason() into
watchdog_notify_pretimeout().
- v1-link: [2]
[1] https://lore.kernel.org/all/20260731095959.296056-1-o.rempel@pengutronix.de/
[2] https://lore.kernel.org/all/20260714-pscrr-reboot-reason-v1-0-a09f23b12527@oss.qualcomm.com/
[3] https://lore.kernel.org/lkml/20260722-pscrr-reboot-reason-v2-0-495ba3005953@oss.qualcomm.com/
[4] https://lore.kernel.org/lkml/20260804-pscrr-reboot-reason-v3-0-e706dbfc7465@oss.qualcomm.com/
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
Faruque Ansari (3):
power: reset: pscrr: add kernel panic reason tracking
power: reset: pscrr: add watchdog pretimeout reason tracking
watchdog: pretimeout: update PSC reason in panic pretimeout governor
drivers/power/reset/pscrr/pscrr.c | 30 ++++++++++++++++++++++++++++++
drivers/watchdog/pretimeout_panic.c | 2 ++
include/linux/power/power_on_reason.h | 2 ++
include/linux/reboot.h | 7 +++++++
kernel/reboot.c | 2 ++
5 files changed, 43 insertions(+)
---
base-commit: 551961df5728932d968a4aae534714acfa43f3a1
change-id: 20260803-pscrr-reboot-reason-f1254965ec0d
Best regards,
--
Faruque Ansari <faruque.ansari@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking
2026-08-05 8:54 [PATCH v4 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
@ 2026-08-05 8:54 ` Faruque Ansari
2026-10-07 10:43 ` Daniel Lezcano
2026-08-05 8:54 ` [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 3/3] watchdog: pretimeout: update PSC reason in panic pretimeout governor Faruque Ansari
2 siblings, 1 reply; 8+ messages in thread
From: Faruque Ansari @ 2026-08-05 8:54 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm, kernel,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
Faruque Ansari
Kernel panic resets are not recorded in NVMEM, causing subsequent
boots to report PSCR_UNKNOWN and making post-mortem analysis more
difficult.
Register a panic notifier to preserve the shutdown reason across
panic-triggered resets. Add PSCR_KERNEL_PANIC as a dedicated reset
reason code and its corresponding reason string to identify kernel
panic resets on subsequent boots.
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
drivers/power/reset/pscrr/pscrr.c | 27 +++++++++++++++++++++++++++
include/linux/power/power_on_reason.h | 1 +
include/linux/reboot.h | 3 +++
kernel/reboot.c | 1 +
4 files changed, 32 insertions(+)
diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/pscrr.c
index 6f23f4c4f590..8c45b84059a9 100644
--- a/drivers/power/reset/pscrr/pscrr.c
+++ b/drivers/power/reset/pscrr/pscrr.c
@@ -41,6 +41,7 @@
#include <linux/mutex.h>
#include <linux/notifier.h>
#include <linux/of.h>
+#include <linux/panic_notifier.h>
#include <linux/pscrr.h>
#include <linux/reboot.h>
#include <linux/slab.h>
@@ -519,6 +520,29 @@ static struct notifier_block pscrr_reboot_nb = {
.notifier_call = pscrr_reboot_notifier,
};
+/*
+ * Panic notifier: record that the machine went down through a kernel panic, so
+ * the cause is visible on the next boot. Runs in atomic panic context, so the
+ * provider list is walked without pscrr_lock - providers no longer come or go
+ * once the machine is going down.
+ */
+static int pscrr_panic_notifier(struct notifier_block *nb,
+ unsigned long action, void *unused)
+{
+ struct pscrr_provider_dir *dir;
+
+ set_psc_reason(PSCR_KERNEL_PANIC);
+
+ list_for_each_entry(dir, &pscrr_dirs, node)
+ pscrr_do_record(dir, get_psc_reason());
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block pscrr_panic_nb = {
+ .notifier_call = pscrr_panic_notifier,
+};
+
/*----------------------------------------------------------------------*/
/* Built-in provider: device-tree /chosen/reset-source */
/*----------------------------------------------------------------------*/
@@ -611,6 +635,8 @@ static int __init pscrr_core_init(void)
return ret;
}
+ atomic_notifier_chain_register(&panic_notifier_list, &pscrr_panic_nb);
+
pscrr_register_reset_source();
return 0;
@@ -619,6 +645,7 @@ static int __init pscrr_core_init(void)
static void __exit pscrr_core_exit(void)
{
pscrr_provider_unregister(&pscrr_reset_source_provider);
+ atomic_notifier_chain_unregister(&panic_notifier_list, &pscrr_panic_nb);
unregister_reboot_notifier(&pscrr_reboot_nb);
kobject_put(pscrr_root);
pscrr_root = NULL;
diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
index 13e61ace14f5..8c99bdd75021 100644
--- a/include/linux/power/power_on_reason.h
+++ b/include/linux/power/power_on_reason.h
@@ -20,5 +20,6 @@
#define POWER_ON_REASON_OVER_TEMPERATURE "over temperature"
#define POWER_ON_REASON_EC_PANIC "EC panic"
#define POWER_ON_REASON_EXTERNAL "external reset"
+#define POWER_ON_REASON_KERNEL_PANIC "kernel panic"
#endif /* POWER_ON_REASON_H */
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 13f004ad1066..a117dd5eaecd 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -241,6 +241,8 @@ extern void orderly_reboot(void);
*
* @PSCR_XTAL_FAIL: Reset caused by a crystal oscillator failure.
*
+ * @PSCR_KERNEL_PANIC: Reset that followed a kernel 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.
@@ -264,6 +266,7 @@ enum psc_reason {
PSCR_RESET_BUTTON,
PSCR_CPU_CLK_FAIL,
PSCR_XTAL_FAIL,
+ PSCR_KERNEL_PANIC,
/* Number of reasons */
PSCR_REASON_COUNT,
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 75af5d763465..979ecf3b093c 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1109,6 +1109,7 @@ static const struct psc_reason_desc psc_reason_descs[] = {
[PSCR_RESET_BUTTON] = { "reset-button", POWER_ON_REASON_RST_BTN },
[PSCR_CPU_CLK_FAIL] = { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_FAIL },
[PSCR_XTAL_FAIL] = { "crystal-failure", POWER_ON_REASON_XTAL_FAIL },
+ [PSCR_KERNEL_PANIC] = { "kernel-panic", POWER_ON_REASON_KERNEL_PANIC },
};
/**
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-08-05 8:54 [PATCH v4 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
@ 2026-08-05 8:54 ` Faruque Ansari
2026-10-07 10:54 ` Daniel Lezcano
2026-08-05 8:54 ` [PATCH v4 3/3] watchdog: pretimeout: update PSC reason in panic pretimeout governor Faruque Ansari
2 siblings, 1 reply; 8+ messages in thread
From: Faruque Ansari @ 2026-08-05 8:54 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm, kernel,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
Faruque Ansari
Watchdog pretimeout resets are not recorded with a dedicated reason,
causing subsequent boots to report PSCR_UNKNOWN and making it difficult
to distinguish them from other unexpected resets.
Add PSCR_WATCHDOG_PRETIMEOUT as a dedicated reason code and prevent the
panic notifier from overwriting a watchdog pretimeout reason with
PSCR_KERNEL_PANIC when the pretimeout governor triggers a panic.
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
drivers/power/reset/pscrr/pscrr.c | 11 +++++++----
include/linux/power/power_on_reason.h | 1 +
include/linux/reboot.h | 4 ++++
kernel/reboot.c | 1 +
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/pscrr.c
index 8c45b84059a9..b7e6239e207e 100644
--- a/drivers/power/reset/pscrr/pscrr.c
+++ b/drivers/power/reset/pscrr/pscrr.c
@@ -529,12 +529,15 @@ static struct notifier_block pscrr_reboot_nb = {
static int pscrr_panic_notifier(struct notifier_block *nb,
unsigned long action, void *unused)
{
- struct pscrr_provider_dir *dir;
- set_psc_reason(PSCR_KERNEL_PANIC);
+ /*
+ * Do not overwrite a watchdog pretimeout reason already set by the
+ * pretimeout path before it triggered this panic.
+ */
+ if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
+ set_psc_reason(PSCR_KERNEL_PANIC);
- list_for_each_entry(dir, &pscrr_dirs, node)
- pscrr_do_record(dir, get_psc_reason());
+ pscrr_record_current();
return NOTIFY_DONE;
}
diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
index 8c99bdd75021..8e3889fa43ef 100644
--- a/include/linux/power/power_on_reason.h
+++ b/include/linux/power/power_on_reason.h
@@ -21,5 +21,6 @@
#define POWER_ON_REASON_EC_PANIC "EC panic"
#define POWER_ON_REASON_EXTERNAL "external reset"
#define POWER_ON_REASON_KERNEL_PANIC "kernel panic"
+#define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout"
#endif /* POWER_ON_REASON_H */
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index a117dd5eaecd..6d5ecc6cdc00 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -243,6 +243,9 @@ extern void orderly_reboot(void);
*
* @PSCR_KERNEL_PANIC: Reset that followed a kernel panic.
*
+ * @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog pretimeout fires, before
+ * the pretimeout governor brings the system down.
+ *
* @PSCR_REASON_COUNT: Number of defined power state change reasons. This
* value is useful for range checking and potential future extensions
* while maintaining compatibility.
@@ -267,6 +270,7 @@ enum psc_reason {
PSCR_CPU_CLK_FAIL,
PSCR_XTAL_FAIL,
PSCR_KERNEL_PANIC,
+ PSCR_WATCHDOG_PRETIMEOUT,
/* Number of reasons */
PSCR_REASON_COUNT,
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 979ecf3b093c..fad4ef9681a6 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1110,6 +1110,7 @@ static const struct psc_reason_desc psc_reason_descs[] = {
[PSCR_CPU_CLK_FAIL] = { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_FAIL },
[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 },
};
/**
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] watchdog: pretimeout: update PSC reason in panic pretimeout governor
2026-08-05 8:54 [PATCH v4 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
@ 2026-08-05 8:54 ` Faruque Ansari
2 siblings, 0 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-05 8:54 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm, kernel,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
Faruque Ansari
Update the PSC reset reason by invoking
set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT) from the panic governor's
pretimeout handler before calling panic(), so the reset cause is
committed to persistent storage before the system goes down.
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/watchdog/pretimeout_panic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/watchdog/pretimeout_panic.c b/drivers/watchdog/pretimeout_panic.c
index 8c3ac674dc45..819487b5e6fe 100644
--- a/drivers/watchdog/pretimeout_panic.c
+++ b/drivers/watchdog/pretimeout_panic.c
@@ -5,6 +5,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/watchdog.h>
#include "watchdog_pretimeout.h"
@@ -17,6 +18,7 @@
*/
static void pretimeout_panic(struct watchdog_device *wdd)
{
+ set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT);
panic("watchdog pretimeout event\n");
}
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking
2026-08-05 8:54 ` [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
@ 2026-10-07 10:43 ` Daniel Lezcano
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Lezcano @ 2026-10-07 10:43 UTC (permalink / raw)
To: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Oleksij Rempel,
Srinivas Kandagatla, Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda
On 8/5/26 10:54, Faruque Ansari wrote:
> Kernel panic resets are not recorded in NVMEM, causing subsequent
> boots to report PSCR_UNKNOWN and making post-mortem analysis more
> difficult.
>
> Register a panic notifier to preserve the shutdown reason across
> panic-triggered resets. Add PSCR_KERNEL_PANIC as a dedicated reset
> reason code and its corresponding reason string to identify kernel
> panic resets on subsequent boots.
>
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> ---
Reviewed-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-08-05 8:54 ` [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
@ 2026-10-07 10:54 ` Daniel Lezcano
2026-10-12 11:06 ` Faruque Ansari
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Lezcano @ 2026-10-07 10:54 UTC (permalink / raw)
To: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Oleksij Rempel,
Srinivas Kandagatla, Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda
On 8/5/26 10:54, Faruque Ansari wrote:
> Watchdog pretimeout resets are not recorded with a dedicated reason,
> causing subsequent boots to report PSCR_UNKNOWN and making it difficult
> to distinguish them from other unexpected resets.
>
> Add PSCR_WATCHDOG_PRETIMEOUT as a dedicated reason code and prevent the
> panic notifier from overwriting a watchdog pretimeout reason with
> PSCR_KERNEL_PANIC when the pretimeout governor triggers a panic.
>
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> ---
> drivers/power/reset/pscrr/pscrr.c | 11 +++++++----
> include/linux/power/power_on_reason.h | 1 +
> include/linux/reboot.h | 4 ++++
> kernel/reboot.c | 1 +
> 4 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/reset/pscrr/pscrr.c
> index 8c45b84059a9..b7e6239e207e 100644
> --- a/drivers/power/reset/pscrr/pscrr.c
> +++ b/drivers/power/reset/pscrr/pscrr.c
> @@ -529,12 +529,15 @@ static struct notifier_block pscrr_reboot_nb = {
> static int pscrr_panic_notifier(struct notifier_block *nb,
> unsigned long action, void *unused)
> {
> - struct pscrr_provider_dir *dir;
>
> - set_psc_reason(PSCR_KERNEL_PANIC);
> + /*
> + * Do not overwrite a watchdog pretimeout reason already set by the
> + * pretimeout path before it triggered this panic.
> + */
> + if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
> + set_psc_reason(PSCR_KERNEL_PANIC);
It does not sounds correct.
May be you should move the set_psc_reason() to different places for panic.
I did not explore the panic() function but I would suggest to have
something like:
panic(..., ) --> defaults to PSCR_KERNEL_PANIC
panic_with_pscrr(..., reason)
Then pscrr_panic_notifier() only does the record
> - list_for_each_entry(dir, &pscrr_dirs, node)
> - pscrr_do_record(dir, get_psc_reason());
> + pscrr_record_current();
>
> return NOTIFY_DONE;
> }
> diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
> index 8c99bdd75021..8e3889fa43ef 100644
> --- a/include/linux/power/power_on_reason.h
> +++ b/include/linux/power/power_on_reason.h
> @@ -21,5 +21,6 @@
> #define POWER_ON_REASON_EC_PANIC "EC panic"
> #define POWER_ON_REASON_EXTERNAL "external reset"
> #define POWER_ON_REASON_KERNEL_PANIC "kernel panic"
> +#define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout"
>
> #endif /* POWER_ON_REASON_H */
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index a117dd5eaecd..6d5ecc6cdc00 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -243,6 +243,9 @@ extern void orderly_reboot(void);
> *
> * @PSCR_KERNEL_PANIC: Reset that followed a kernel panic.
> *
> + * @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog pretimeout fires, before
> + * the pretimeout governor brings the system down.
> + *
> * @PSCR_REASON_COUNT: Number of defined power state change reasons. This
> * value is useful for range checking and potential future extensions
> * while maintaining compatibility.
> @@ -267,6 +270,7 @@ enum psc_reason {
> PSCR_CPU_CLK_FAIL,
> PSCR_XTAL_FAIL,
> PSCR_KERNEL_PANIC,
> + PSCR_WATCHDOG_PRETIMEOUT,
>
> /* Number of reasons */
> PSCR_REASON_COUNT,
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index 979ecf3b093c..fad4ef9681a6 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -1110,6 +1110,7 @@ static const struct psc_reason_desc psc_reason_descs[] = {
> [PSCR_CPU_CLK_FAIL] = { "cpu-clock-failure", POWER_ON_REASON_CPU_CLK_FAIL },
> [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 },
> };
>
> /**
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-10-07 10:54 ` Daniel Lezcano
@ 2026-10-12 11:06 ` Faruque Ansari
2026-10-13 10:00 ` Daniel Lezcano
0 siblings, 1 reply; 8+ messages in thread
From: Faruque Ansari @ 2026-10-12 11:06 UTC (permalink / raw)
To: Daniel Lezcano, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Oleksij Rempel,
Srinivas Kandagatla, Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda
Hi Daniel Lezcano,
On 07-Oct-26 4:24 PM, Daniel Lezcano wrote:
> On 8/5/26 10:54, Faruque Ansari wrote:
>> Watchdog pretimeout resets are not recorded with a dedicated
>> reason,
>> causing subsequent boots to report PSCR_UNKNOWN and making it
>> difficult
>> to distinguish them from other unexpected resets.
>>
>> Add PSCR_WATCHDOG_PRETIMEOUT as a dedicated reason code and
>> prevent the
>> panic notifier from overwriting a watchdog pretimeout reason with
>> PSCR_KERNEL_PANIC when the pretimeout governor triggers a panic.
>>
>> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
>> ---
>> drivers/power/reset/pscrr/pscrr.c | 11 +++++++----
>> include/linux/power/power_on_reason.h | 1 +
>> include/linux/reboot.h | 4 ++++
>> kernel/reboot.c | 1 +
>> 4 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/
>> reset/pscrr/pscrr.c
>> index 8c45b84059a9..b7e6239e207e 100644
>> --- a/drivers/power/reset/pscrr/pscrr.c
>> +++ b/drivers/power/reset/pscrr/pscrr.c
>> @@ -529,12 +529,15 @@ static struct notifier_block
>> pscrr_reboot_nb = {
>> static int pscrr_panic_notifier(struct notifier_block *nb,
>> unsigned long action, void *unused)
>> {
>> - struct pscrr_provider_dir *dir;
>> - set_psc_reason(PSCR_KERNEL_PANIC);
>> + /*
>> + * Do not overwrite a watchdog pretimeout reason already
>> set by the
>> + * pretimeout path before it triggered this panic.
>> + */
>> + if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
>> + set_psc_reason(PSCR_KERNEL_PANIC);
>
> It does not sounds correct.
>
> May be you should move the set_psc_reason() to different places
> for panic.
>
> I did not explore the panic() function but I would suggest to
> have something like:
>
> panic(..., ) --> defaults to PSCR_KERNEL_PANIC
>
> panic_with_pscrr(..., reason)
>
> Then pscrr_panic_notifier() only does the record
Thanks for your review.
I agree that handling the kernel panic reason in this notifier
may not be the ideal approach today. However, my intention is to
add userspace crash recording support in the future as well.
Since this notifier already serves as the common point for
recording restart reasons, it seems like the most appropriate
place to handle userspace-triggered reboot reasons when that
support is added.
For consistency, I added the handling for kernel panic and
watchdog reset reasons here as well. While they are not strictly
required for the current use case, this notifier is the most
suitable place to record reboot reasons. Keeping all reboot
reason handling in one place will also make it easier to add
userspace reboot/crash recording support in the future, without
introducing a separate mechanism later.
Thanks,
Faruque Ansari
>
>> - list_for_each_entry(dir, &pscrr_dirs, node)
>> - pscrr_do_record(dir, get_psc_reason());
>> + pscrr_record_current();
>> return NOTIFY_DONE;
>> }
>> diff --git a/include/linux/power/power_on_reason.h b/include/
>> linux/power/power_on_reason.h
>> index 8c99bdd75021..8e3889fa43ef 100644
>> --- a/include/linux/power/power_on_reason.h
>> +++ b/include/linux/power/power_on_reason.h
>> @@ -21,5 +21,6 @@
>> #define POWER_ON_REASON_EC_PANIC "EC panic"
>> #define POWER_ON_REASON_EXTERNAL "external reset"
>> #define POWER_ON_REASON_KERNEL_PANIC "kernel panic"
>> +#define POWER_ON_REASON_WATCHDOG_PRETIMEOUT "watchdog pretimeout"
>> #endif /* POWER_ON_REASON_H */
>> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
>> index a117dd5eaecd..6d5ecc6cdc00 100644
>> --- a/include/linux/reboot.h
>> +++ b/include/linux/reboot.h
>> @@ -243,6 +243,9 @@ extern void orderly_reboot(void);
>> *
>> * @PSCR_KERNEL_PANIC: Reset that followed a kernel panic.
>> *
>> + * @PSCR_WATCHDOG_PRETIMEOUT: Recorded when a watchdog
>> pretimeout fires, before
>> + * the pretimeout governor brings the system down.
>> + *
>> * @PSCR_REASON_COUNT: Number of defined power state change
>> reasons. This
>> * value is useful for range checking and potential future
>> extensions
>> * while maintaining compatibility.
>> @@ -267,6 +270,7 @@ enum psc_reason {
>> PSCR_CPU_CLK_FAIL,
>> PSCR_XTAL_FAIL,
>> PSCR_KERNEL_PANIC,
>> + PSCR_WATCHDOG_PRETIMEOUT,
>> /* Number of reasons */
>> PSCR_REASON_COUNT,
>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>> index 979ecf3b093c..fad4ef9681a6 100644
>> --- a/kernel/reboot.c
>> +++ b/kernel/reboot.c
>> @@ -1110,6 +1110,7 @@ static const struct psc_reason_desc
>> psc_reason_descs[] = {
>> [PSCR_CPU_CLK_FAIL] = { "cpu-clock-failure",
>> POWER_ON_REASON_CPU_CLK_FAIL },
>> [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 },
>> };
>> /**
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-10-12 11:06 ` Faruque Ansari
@ 2026-10-13 10:00 ` Daniel Lezcano
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Lezcano @ 2026-10-13 10:00 UTC (permalink / raw)
To: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Oleksij Rempel,
Srinivas Kandagatla, Daniel Lezcano, Pengutronix Kernel Team
Cc: linux-pm, linux-kernel, linux-watchdog, linux-arm-msm,
Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda
On 10/12/26 13:06, Faruque Ansari wrote:
>
> Hi Daniel Lezcano,
>
> On 07-Oct-26 4:24 PM, Daniel Lezcano wrote:
>> On 8/5/26 10:54, Faruque Ansari wrote:
>>> Watchdog pretimeout resets are not recorded with a dedicated reason,
>>> causing subsequent boots to report PSCR_UNKNOWN and making it difficult
>>> to distinguish them from other unexpected resets.
>>>
>>> Add PSCR_WATCHDOG_PRETIMEOUT as a dedicated reason code and prevent the
>>> panic notifier from overwriting a watchdog pretimeout reason with
>>> PSCR_KERNEL_PANIC when the pretimeout governor triggers a panic.
>>>
>>> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
>>> ---
>>> drivers/power/reset/pscrr/pscrr.c | 11 +++++++----
>>> include/linux/power/power_on_reason.h | 1 +
>>> include/linux/reboot.h | 4 ++++
>>> kernel/reboot.c | 1 +
>>> 4 files changed, 13 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/power/reset/pscrr/pscrr.c b/drivers/power/
>>> reset/pscrr/pscrr.c
>>> index 8c45b84059a9..b7e6239e207e 100644
>>> --- a/drivers/power/reset/pscrr/pscrr.c
>>> +++ b/drivers/power/reset/pscrr/pscrr.c
>>> @@ -529,12 +529,15 @@ static struct notifier_block pscrr_reboot_nb = {
>>> static int pscrr_panic_notifier(struct notifier_block *nb,
>>> unsigned long action, void *unused)
>>> {
>>> - struct pscrr_provider_dir *dir;
>>> - set_psc_reason(PSCR_KERNEL_PANIC);
>>> + /*
>>> + * Do not overwrite a watchdog pretimeout reason already set by the
>>> + * pretimeout path before it triggered this panic.
>>> + */
>>> + if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
>>> + set_psc_reason(PSCR_KERNEL_PANIC);
>>
>> It does not sounds correct.
>>>> May be you should move the set_psc_reason() to different places for
>> panic.
>>
>> I did not explore the panic() function but I would suggest to have
>> something like:
>>
>> panic(..., ) --> defaults to PSCR_KERNEL_PANIC
>>
>> panic_with_pscrr(..., reason)
>>
>> Then pscrr_panic_notifier() only does the record
>
> Thanks for your review.
>
> I agree that handling the kernel panic reason in this notifier may not
> be the ideal approach today. However, my intention is to add userspace
> crash recording support in the future as well. Since this notifier
> already serves as the common point for recording restart reasons, it
> seems like the most appropriate place to handle userspace-triggered
> reboot reasons when that support is added.
>
> For consistency, I added the handling for kernel panic and watchdog
> reset reasons here as well. While they are not strictly required for the
> current use case, this notifier is the most suitable place to record
> reboot reasons. Keeping all reboot reason handling in one place will
> also make it easier to add userspace reboot/crash recording support in
> the future, without introducing a separate mechanism later.
I understand the purpose of the series, but setting the reboot reason
directly from this notifier does not seem like the right approach.
The notifier should be responsible for recording the reason, while
determining and updating that reason should be handled independently, as
it may originate from different execution contexts.
The need to explicitly check for PSCR_WATCHDOG_PRETIMEOUT before setting
PSCR_KERNEL_PANIC illustrates the problem: the notifier now needs to
know about other reboot reasons and their relative priorities.
As more reboot reasons are introduced, this approach will require
additional special cases and become increasingly difficult to maintain.
Wouldn't it make more sense to centralize the reason selection policy,
keeping the notifier focused on recording the selected reason?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-10-13 10:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05 8:54 [PATCH v4 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-08-05 8:54 ` [PATCH v4 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
2026-10-07 10:43 ` Daniel Lezcano
2026-08-05 8:54 ` [PATCH v4 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
2026-10-07 10:54 ` Daniel Lezcano
2026-10-12 11:06 ` Faruque Ansari
2026-10-13 10:00 ` Daniel Lezcano
2026-08-05 8:54 ` [PATCH v4 3/3] watchdog: pretimeout: update PSC reason in panic pretimeout governor Faruque Ansari
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®