* [PATCH v2 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout
@ 2026-07-22 15:12 Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Faruque Ansari @ 2026-07-22 15:12 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano
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,
linux-arm-msm, 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 watchdog_notify_pretimeout(), 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.
[1] https://lore.kernel.org/lkml/20250618120255.3141862-1-o.rempel@pengutronix.de/
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().
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: record PSC reason on watchdog pretimeout
drivers/power/reset/pscrr.c | 37 ++++++++++++++++++++++++++++++++++
drivers/watchdog/watchdog_pretimeout.c | 3 +++
include/linux/power/power_on_reason.h | 2 ++
include/linux/reboot.h | 2 ++
kernel/reboot.c | 2 ++
5 files changed, 46 insertions(+)
---
base-commit: 7715d20f91523e0189ba9d8813f03971229d5e90
change-id: 20260721-pscrr-reboot-reason-2432962a9c4d
Best regards,
--
Faruque Ansari <faruque.ansari@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] power: reset: pscrr: add kernel panic reason tracking
2026-07-22 15:12 [PATCH v2 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
@ 2026-07-22 15:13 ` Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout Faruque Ansari
2 siblings, 0 replies; 7+ messages in thread
From: Faruque Ansari @ 2026-07-22 15:13 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano
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,
linux-arm-msm, 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.c | 32 ++++++++++++++++++++++++++++++++
include/linux/power/power_on_reason.h | 1 +
include/linux/reboot.h | 1 +
kernel/reboot.c | 1 +
4 files changed, 35 insertions(+)
diff --git a/drivers/power/reset/pscrr.c b/drivers/power/reset/pscrr.c
index 92e8ef97421c..b5906f127e88 100644
--- a/drivers/power/reset/pscrr.c
+++ b/drivers/power/reset/pscrr.c
@@ -60,6 +60,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
+#include <linux/panic_notifier.h>
#include <linux/power/power_on_reason.h>
#include <linux/pscrr.h>
#include <linux/reboot.h>
@@ -78,6 +79,7 @@ struct pscrr_core {
/* Kobject for sysfs */
struct kobject *kobj;
struct notifier_block reboot_nb;
+ struct notifier_block panic_nb;
};
static struct pscrr_core g_pscrr = {
@@ -136,6 +138,30 @@ static int pscrr_reboot_notifier(struct notifier_block *nb,
return NOTIFY_OK;
}
+static int pscrr_panic_notifier(struct notifier_block *nb,
+ unsigned long action, void *unused)
+{
+ int ret;
+ struct pscrr_backend *backend;
+
+ backend = g_pscrr.backend;
+
+ if (!backend || !backend->ops || !backend->ops->write_reason)
+ return NOTIFY_OK;
+
+ set_psc_reason(PSCR_KERNEL_PANIC);
+ ret = backend->ops->write_reason(get_psc_reason());
+ if (ret)
+ pr_err("PSCRR: Failed to store reason %d (%s) at panic, err=%pe\n",
+ get_psc_reason(), psc_reason_to_str(get_psc_reason()),
+ ERR_PTR(ret));
+ else
+ pr_debug("PSCRR: Stored reason %d (%s) at panic.\n",
+ get_psc_reason(), psc_reason_to_str(get_psc_reason()));
+
+ return NOTIFY_OK;
+}
+
/*----------------------------------------------------------------------*/
/* Sysfs Interface */
/*----------------------------------------------------------------------*/
@@ -349,6 +375,10 @@ int pscrr_core_init(const struct pscrr_backend_ops *ops)
goto err_free;
}
+ /* Setup the panic notifier to persist reason on kernel panic */
+ g_pscrr.panic_nb.notifier_call = pscrr_panic_notifier;
+ atomic_notifier_chain_register(&panic_notifier_list, &g_pscrr.panic_nb);
+
/* Create a kobject and sysfs group under /sys/kernel/pscrr */
g_pscrr.kobj = kobject_create_and_add("pscrr", kernel_kobj);
if (!g_pscrr.kobj) {
@@ -371,6 +401,7 @@ int pscrr_core_init(const struct pscrr_backend_ops *ops)
err_kobj_put:
kobject_put(g_pscrr.kobj);
err_unreg_reboot:
+ atomic_notifier_chain_unregister(&panic_notifier_list, &g_pscrr.panic_nb);
unregister_reboot_notifier(&g_pscrr.reboot_nb);
err_free:
kfree(g_pscrr.backend);
@@ -391,6 +422,7 @@ void pscrr_core_exit(void)
kobject_put(g_pscrr.kobj);
}
+ atomic_notifier_chain_unregister(&panic_notifier_list, &g_pscrr.panic_nb);
unregister_reboot_notifier(&g_pscrr.reboot_nb);
kfree(g_pscrr.backend);
diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
index bf9501792696..4ac1bdfdc211 100644
--- a/include/linux/power/power_on_reason.h
+++ b/include/linux/power/power_on_reason.h
@@ -19,5 +19,6 @@
#define POWER_ON_REASON_REGULATOR_FAILURE "regulator failure"
#define POWER_ON_REASON_OVER_TEMPERATURE "over temperature"
#define POWER_ON_REASON_EC_PANIC "EC panic"
+#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 6477910c6a9e..a492b1652038 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -236,6 +236,7 @@ enum psc_reason {
PSCR_REGULATOR_FAILURE,
PSCR_OVER_TEMPERATURE,
PSCR_EC_PANIC,
+ PSCR_KERNEL_PANIC,
/* Number of reasons */
PSCR_REASON_COUNT,
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 61e0027b7550..f1df52f8773a 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1065,6 +1065,7 @@ static const char * const pscr_reason_strs[] = {
[PSCR_REGULATOR_FAILURE] = POWER_ON_REASON_REGULATOR_FAILURE,
[PSCR_OVER_TEMPERATURE] = POWER_ON_REASON_OVER_TEMPERATURE,
[PSCR_EC_PANIC] = POWER_ON_REASON_EC_PANIC,
+ [PSCR_KERNEL_PANIC] = POWER_ON_REASON_KERNEL_PANIC,
};
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-07-22 15:12 [PATCH v2 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
@ 2026-07-22 15:13 ` Faruque Ansari
2026-07-30 4:49 ` Matti Vaittinen
2026-07-22 15:13 ` [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout Faruque Ansari
2 siblings, 1 reply; 7+ messages in thread
From: Faruque Ansari @ 2026-07-22 15:13 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano
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,
linux-arm-msm, Faruque Ansari
Watchdog pretimeout resets are not recorded with a dedicated reset
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 reset 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.c | 7 ++++++-
include/linux/power/power_on_reason.h | 1 +
include/linux/reboot.h | 1 +
kernel/reboot.c | 1 +
4 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/power/reset/pscrr.c b/drivers/power/reset/pscrr.c
index b5906f127e88..5b107c62fe82 100644
--- a/drivers/power/reset/pscrr.c
+++ b/drivers/power/reset/pscrr.c
@@ -149,7 +149,12 @@ static int pscrr_panic_notifier(struct notifier_block *nb,
if (!backend || !backend->ops || !backend->ops->write_reason)
return NOTIFY_OK;
- set_psc_reason(PSCR_KERNEL_PANIC);
+ /*
+ * Do not overwrite a previously recorded watchdog pretimeout reason
+ * during panic handling.
+ */
+ if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
+ set_psc_reason(PSCR_KERNEL_PANIC);
ret = backend->ops->write_reason(get_psc_reason());
if (ret)
pr_err("PSCRR: Failed to store reason %d (%s) at panic, err=%pe\n",
diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h
index 4ac1bdfdc211..c5846c0ccde4 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_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 a492b1652038..fccbffc9dbef 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -237,6 +237,7 @@ enum psc_reason {
PSCR_OVER_TEMPERATURE,
PSCR_EC_PANIC,
PSCR_KERNEL_PANIC,
+ PSCR_WATCHDOG_PRETIMEOUT,
/* Number of reasons */
PSCR_REASON_COUNT,
diff --git a/kernel/reboot.c b/kernel/reboot.c
index f1df52f8773a..629002a951c2 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1066,6 +1066,7 @@ static const char * const pscr_reason_strs[] = {
[PSCR_OVER_TEMPERATURE] = POWER_ON_REASON_OVER_TEMPERATURE,
[PSCR_EC_PANIC] = POWER_ON_REASON_EC_PANIC,
[PSCR_KERNEL_PANIC] = POWER_ON_REASON_KERNEL_PANIC,
+ [PSCR_WATCHDOG_PRETIMEOUT] = POWER_ON_REASON_WATCHDOG_PRETIMEOUT,
};
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout
2026-07-22 15:12 [PATCH v2 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
@ 2026-07-22 15:13 ` Faruque Ansari
2026-07-30 5:03 ` Guenter Roeck
2 siblings, 1 reply; 7+ messages in thread
From: Faruque Ansari @ 2026-07-22 15:13 UTC (permalink / raw)
To: Sebastian Reichel, Wim Van Sebroeck, Guenter Roeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano
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,
linux-arm-msm, Faruque Ansari
Update the PSC reset reason by invoking set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT)
from watchdog_notify_pretimeout() before either the panic or noop governor
runs, so the reset cause is committed to persistent storage before the
system goes down.
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
drivers/watchdog/watchdog_pretimeout.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c
index 02e09b9e396d..ea48d4eca4aa 100644
--- a/drivers/watchdog/watchdog_pretimeout.c
+++ b/drivers/watchdog/watchdog_pretimeout.c
@@ -4,6 +4,7 @@
*/
#include <linux/list.h>
+#include <linux/reboot.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
@@ -103,6 +104,8 @@ void watchdog_notify_pretimeout(struct watchdog_device *wdd)
{
unsigned long flags;
+ set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT);
+
spin_lock_irqsave(&pretimeout_lock, flags);
if (!wdd->gov) {
spin_unlock_irqrestore(&pretimeout_lock, flags);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-07-22 15:13 ` [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
@ 2026-07-30 4:49 ` Matti Vaittinen
2026-07-30 5:24 ` Oleksij Rempel
0 siblings, 1 reply; 7+ messages in thread
From: Matti Vaittinen @ 2026-07-30 4:49 UTC (permalink / raw)
To: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Oleksij Rempel,
Srinivas Kandagatla, Daniel Lezcano
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, Ahmad Fatoum,
Andrew Morton, avaneesh.dwivedi, Umang Chheda, linux-arm-msm
On 22/07/2026 18:13, Faruque Ansari wrote:
> Watchdog pretimeout resets are not recorded with a dedicated reset
> 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 reset 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.c | 7 ++++++-
> include/linux/power/power_on_reason.h | 1 +
> include/linux/reboot.h | 1 +
> kernel/reboot.c | 1 +
> 4 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/reset/pscrr.c b/drivers/power/reset/pscrr.c
> index b5906f127e88..5b107c62fe82 100644
> --- a/drivers/power/reset/pscrr.c
> +++ b/drivers/power/reset/pscrr.c
> @@ -149,7 +149,12 @@ static int pscrr_panic_notifier(struct notifier_block *nb,
> if (!backend || !backend->ops || !backend->ops->write_reason)
> return NOTIFY_OK;
>
> - set_psc_reason(PSCR_KERNEL_PANIC);
> + /*
> + * Do not overwrite a previously recorded watchdog pretimeout reason
> + * during panic handling.
> + */
> + if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
> + set_psc_reason(PSCR_KERNEL_PANIC);
Hi Faruque,
I like the idea of adding WDG pretimeout resets in pscrr. I am just
wondering what makes WDG reason so special, that it shouldn't be
overwritten while other reasons can be? Can this notifier be called (now
or in the future) so, that there are other reasons getting overwritten?
For some reason I think the PSCRR was designed to be able to store
multiple reasons(?) Could you just add one more instead of overwriting
existing - or should the check be more generic (to ensure the reason is
only set if there is nothing to overwrite).
If I am just completely lost (which happens), could you then improve the
comment a bit to explain why WDG timeout is special and shouldn't be
overwritten. The checking code itself is quite self-explatonary ;)
Anyways, I am happy to see the PSCRR being worked on! Thanks!
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout
2026-07-22 15:13 ` [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout Faruque Ansari
@ 2026-07-30 5:03 ` Guenter Roeck
0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2026-07-30 5:03 UTC (permalink / raw)
To: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck, Benson Leung,
Tzung-Bi Shih, Oleksij Rempel, Srinivas Kandagatla,
Daniel Lezcano
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,
linux-arm-msm
On 7/22/26 08:13, Faruque Ansari wrote:
> Update the PSC reset reason by invoking set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT)
> from watchdog_notify_pretimeout() before either the panic or noop governor
> runs, so the reset cause is committed to persistent storage before the
> system goes down.
>
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> ---
> drivers/watchdog/watchdog_pretimeout.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c
> index 02e09b9e396d..ea48d4eca4aa 100644
> --- a/drivers/watchdog/watchdog_pretimeout.c
> +++ b/drivers/watchdog/watchdog_pretimeout.c
> @@ -4,6 +4,7 @@
> */
>
> #include <linux/list.h>
> +#include <linux/reboot.h>
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> #include <linux/string.h>
> @@ -103,6 +104,8 @@ void watchdog_notify_pretimeout(struct watchdog_device *wdd)
> {
> unsigned long flags;
>
> + set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT);
> +
A call to watchdog_notify_pretimeout() does not necessarily reset the system.
It only resets the system if the panic governor is active. Given that,
I think this is a bit misleading. If the "noop" governor is active and the
system crashes later due to a completely unrelated panic, the restart reason
will be wrongly logged as pretimeout.
Guenter
> spin_lock_irqsave(&pretimeout_lock, flags);
> if (!wdd->gov) {
> spin_unlock_irqrestore(&pretimeout_lock, flags);
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout reason tracking
2026-07-30 4:49 ` Matti Vaittinen
@ 2026-07-30 5:24 ` Oleksij Rempel
0 siblings, 0 replies; 7+ messages in thread
From: Oleksij Rempel @ 2026-07-30 5:24 UTC (permalink / raw)
To: Matti Vaittinen
Cc: Faruque Ansari, Sebastian Reichel, Wim Van Sebroeck,
Guenter Roeck, Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla,
Daniel Lezcano, 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, Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi,
Umang Chheda, linux-arm-msm
Hi Matti,
On Thu, Jul 30, 2026 at 07:49:41AM +0300, Matti Vaittinen wrote:
> On 22/07/2026 18:13, Faruque Ansari wrote:
> > Watchdog pretimeout resets are not recorded with a dedicated reset
> > 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 reset 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.c | 7 ++++++-
> > include/linux/power/power_on_reason.h | 1 +
> > include/linux/reboot.h | 1 +
> > kernel/reboot.c | 1 +
> > 4 files changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/power/reset/pscrr.c b/drivers/power/reset/pscrr.c
> > index b5906f127e88..5b107c62fe82 100644
> > --- a/drivers/power/reset/pscrr.c
> > +++ b/drivers/power/reset/pscrr.c
> > @@ -149,7 +149,12 @@ static int pscrr_panic_notifier(struct notifier_block *nb,
> > if (!backend || !backend->ops || !backend->ops->write_reason)
> > return NOTIFY_OK;
> > - set_psc_reason(PSCR_KERNEL_PANIC);
> > + /*
> > + * Do not overwrite a previously recorded watchdog pretimeout reason
> > + * during panic handling.
> > + */
> > + if (get_psc_reason() != PSCR_WATCHDOG_PRETIMEOUT)
> > + set_psc_reason(PSCR_KERNEL_PANIC);
>
> Hi Faruque,
>
> I like the idea of adding WDG pretimeout resets in pscrr. I am just
> wondering what makes WDG reason so special, that it shouldn't be overwritten
> while other reasons can be? Can this notifier be called (now or in the
> future) so, that there are other reasons getting overwritten? For some
> reason I think the PSCRR was designed to be able to store multiple
> reasons(?)
It depends on the backed. A simple nvmem cell, would be able to hold
only one reason.
> Could you just add one more instead of overwriting existing - or
> should the check be more generic (to ensure the reason is only set if there
> is nothing to overwrite).
So, depending on the backed, we will have different policies. For
example, with one slot storage, we need to decided what to store:
first one or the last one.
In most cases, the initial one is most interesting. But, if we are
debugging system reset/reboot behavior, the last one.
>
> If I am just completely lost (which happens), could you then improve the
> comment a bit to explain why WDG timeout is special and shouldn't be
> overwritten. The checking code itself is quite self-explatonary ;)
Good question. I included this patch to my refactoring, but didn't had
strong opinion haw to handle it. I guess, after introducing record
policy, this issue will be partially addressed:
https://github.com/olerem/linux-2.6/blob/v7.2/topic/pscr/Documentation/ABI/testing/sysfs-kernel-pscrr#L95
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-30 5:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22 15:12 [PATCH v2 0/3] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 1/3] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
2026-07-22 15:13 ` [PATCH v2 2/3] power: reset: pscrr: add watchdog pretimeout " Faruque Ansari
2026-07-30 4:49 ` Matti Vaittinen
2026-07-30 5:24 ` Oleksij Rempel
2026-07-22 15:13 ` [PATCH v2 3/3] watchdog: pretimeout: record PSC reason on watchdog pretimeout Faruque Ansari
2026-07-30 5:03 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox