From: Guenter Roeck <linux@roeck-us.net>
To: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
Cc: Sebastian Reichel <sre@kernel.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Srinivas Kandagatla <srini@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org, linux-arm-msm@vger.org,
kernel@pengutronix.de, avaneesh.dwivedi@oss.qualcomm.com,
Umang Chheda <umang.chheda@oss.qualcomm.com>
Subject: Re: [PATCH 2/2] watchdog: pscrr: add watchdog pretimeout reason tracking
Date: Mon, 20 Jul 2026 09:39:08 -0700 [thread overview]
Message-ID: <5c824be9-59d8-4acb-a2a3-784182ba3c8c@roeck-us.net> (raw)
In-Reply-To: <20260714-pscrr-reboot-reason-v1-2-a09f23b12527@oss.qualcomm.com>
On Tue, Jul 14, 2026 at 03:22:35PM +0530, Faruque Ansari wrote:
> A watchdog pretimeout fires before the actual reset, giving the kernel
> a brief window to record what happened. Without this change that
> window goes unused and the next boot sees PSCR_UNKNOWN, making it
> impossible to tell a watchdog-driven reset from any other cause.
>
> Call set_psc_reason(PSCR_WATCHDOG_PRETIMEOUT) at the top of
> watchdog_notify_pretimeout() so the reason is recorded as soon as the
> pretimeout is signalled, before any governor action runs.
>
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> ---
> drivers/power/reset/pscrr.c | 3 ++-
> drivers/watchdog/watchdog_pretimeout.c | 3 +++
> include/linux/power/power_on_reason.h | 1 +
> include/linux/reboot.h | 1 +
> kernel/reboot.c | 1 +
This is a cross-subsystem change. As far as I can see it would
be easy to split it into two patches. Please do that.
Guenter
> 5 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/reset/pscrr.c b/drivers/power/reset/pscrr.c
> index b5906f127e88..36642cf9f27c 100644
> --- a/drivers/power/reset/pscrr.c
> +++ b/drivers/power/reset/pscrr.c
> @@ -149,7 +149,8 @@ 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);
> + 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/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);
> 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,
> };
>
> /**
next prev parent reply other threads:[~2026-07-20 16:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 9:52 [PATCH 0/2] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Faruque Ansari
2026-07-14 9:52 ` [PATCH 1/2] power: reset: pscrr: add kernel panic reason tracking Faruque Ansari
2026-07-14 9:52 ` [PATCH 2/2] watchdog: pscrr: add watchdog pretimeout " Faruque Ansari
2026-07-20 16:39 ` Guenter Roeck [this message]
2026-07-21 11:05 ` Faruque Ansari
2026-07-15 6:20 ` [PATCH 0/2] power: reset: pscrr: record reset cause on panic and watchdog pretimeout Oleksij Rempel
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=5c824be9-59d8-4acb-a2a3-784182ba3c8c@roeck-us.net \
--to=linux@roeck-us.net \
--cc=avaneesh.dwivedi@oss.qualcomm.com \
--cc=bleung@chromium.org \
--cc=daniel.lezcano@kernel.org \
--cc=faruque.ansari@oss.qualcomm.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-msm@vger.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=sre@kernel.org \
--cc=srini@kernel.org \
--cc=tzungbi@kernel.org \
--cc=umang.chheda@oss.qualcomm.com \
--cc=wim@linux-watchdog.org \
/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®