From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v7] watchdog: Add ARM TWD (MPCore private) watchdog driver
Date: Sat, 21 Nov 2026 11:00:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-226965@kernel.org> (raw)
In-Reply-To: <20261121-arm-twd-wdt-v7-1-7757144dcf48@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] watchdog: arm_twd_wdt: stale deadline in twd_wdt_resume()
causes reset
--
commit 233fd28bdb50f0195aee9760c111c785c11b011f
Author: Fil Dunsky <filipp.dunsky@gmail.com>
watchdog: Add ARM TWD (MPCore private) watchdog driver
This commit adds a watchdog driver for the ARM11 MPCore, Cortex-A5, and
Cortex-A9 MPCore private (TWD) watchdog, using the CPU0 watchdog as the
system watchdog.
> diff --git a/drivers/watchdog/arm_twd_wdt.c b/drivers/watchdog/arm_twd_wdt.c
> new file mode 100644
> index 0000000000000..6d16c461f6553
> --- /dev/null
> +++ b/drivers/watchdog/arm_twd_wdt.c
> @@ -0,0 +1,678 @@
[ ... ]
> +static u32 twd_wdt_ticks(struct twd_wdt *wdt)
> +{
> + s64 left = atomic64_read(&wdt->expires) - ktime_get_ns();
> + u64 ticks;
> +
> + if (left <= 0)
> + return 1;
> +
> + ticks = mul_u64_u64_div_u64(READ_ONCE(wdt->rate), left,
> + (u64)NSEC_PER_SEC * (TWD_WDT_PRESCALE + 1));
> +
> + return clamp_t(u64, ticks, 1, U32_MAX);
> +}
[ ... ]
> +/*
> + * Stop the hardware for system sleep while the core stops its ping worker.
> + * These callbacks retain the deadline; core PM keepalives can refresh it
> + * before suspend and after resume.
> + */
> +static int twd_wdt_suspend(struct device *dev)
> +{
> + struct twd_wdt *wdt = dev_get_drvdata(dev);
> +
> + guard(mutex)(&wdt->lock);
> +
> + wdt->resume_armed = wdt->armed;
> + /* Keep CPU PM from restoring the watchdog while it is suspended. */
> + smp_store_release(&wdt->armed, false);
> + if (wdt->resume_armed)
> + twd_wdt_call(wdt, twd_wdt_cpu_stop);
> +
> + return 0;
> +}
> +
> +static int twd_wdt_resume(struct device *dev)
> +{
> + struct twd_wdt *wdt = dev_get_drvdata(dev);
> +
> + guard(mutex)(&wdt->lock);
> +
> + if (wdt->resume_armed) {
> + /* Publish the saved deadline before allowing CPU PM to restore it. */
> + smp_store_release(&wdt->armed, true);
> + twd_wdt_call(wdt, twd_wdt_cpu_start);
> + wdt->resume_armed = false;
> + }
> +
> + return 0;
> +}
[Severity: Medium]
Can retaining the absolute monotonic timestamp in wdt->expires across
suspend cause an immediate watchdog reset in twd_wdt_resume()?
twd_wdt_suspend() stops the hardware counter without recording the
remaining time until wdt->expires. Whenever ktime_get_ns() continues to
advance while the watchdog is suspended (for example during
suspend-to-idle on platforms without cpuidle enter_s2idle to freeze
timekeeping, or across slow device suspend/resume and hibernation stages),
ktime_get_ns() can pass wdt->expires before dpm_resume() runs
twd_wdt_resume().
Because twd_wdt_resume() runs before the PM_POST_SUSPEND notifier calls
watchdog_dev_resume() to issue a post-resume ping, twd_wdt_cpu_start() ->
twd_wdt_ticks() sees left <= 0 and loads TWD_WDT_LOAD with 1 tick,
resetting the system immediately. Saving the remaining delta in
twd_wdt_suspend() and recomputing wdt->expires from ktime_get_ns() in
twd_wdt_resume() would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-arm-twd-wdt-v7-1-7757144dcf48@gmail.com?part=1
prev parent reply other threads:[~2026-11-21 11:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 10:31 [PATCH v7] watchdog: Add ARM TWD (MPCore private) watchdog driver Fil Dunsky via B4 Relay
2026-11-21 11:00 ` sashiko-bot [this message]
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=sashiko-outbox-226965@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=filipp.dunsky@gmail.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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