From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v6] watchdog: Add ARM TWD (MPCore private) watchdog driver
Date: Wed, 18 Nov 2026 17:17:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-221636@kernel.org> (raw)
In-Reply-To: <20261118-arm-twd-wdt-v6-1-ce5c85b45c63@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] watchdog: arm_twd_wdt: deadline overwritten on suspend/resume
by PM ping
--
commit 8603b686668545855ad05ceff3a65c5bccb1efde
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 private (TWD) watchdog, using CPU0's watchdog as the system
watchdog and preserving the expiration deadline across clock rate changes,
CPU idle power down and system suspend/resume.
> diff --git a/drivers/watchdog/arm_twd_wdt.c b/drivers/watchdog/arm_twd_wdt.c
> new file mode 100644
> index 0000000000000..84e56ab8beea7
> --- /dev/null
> +++ b/drivers/watchdog/arm_twd_wdt.c
[ ... ]
> +static int twd_wdt_ping(struct watchdog_device *wdd)
> +{
> + struct twd_wdt *wdt = watchdog_get_drvdata(wdd);
> +
> + guard(mutex)(&wdt->lock);
> +
> + if (!wdt->armed)
> + return 0;
> +
> + atomic64_set(&wdt->expires, ktime_get_ns() +
> + (s64)wdd->timeout * NSEC_PER_SEC);
> + twd_wdt_call(wdt, twd_wdt_cpu_ping);
> +
> + return 0;
> +}
[ ... ]
> + watchdog_stop_on_reboot(&wdt->wdd);
> + watchdog_stop_on_unregister(&wdt->wdd);
> + watchdog_stop_ping_on_suspend(&wdt->wdd);
> + watchdog_set_drvdata(&wdt->wdd, wdt);
[ ... ]
> +/* The watchdog loses its state in suspend, set it up again at 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]
Does calling watchdog_stop_ping_on_suspend() cause wdt->expires to be
overwritten with a full timeout on suspend and resume instead of preserving
the saved deadline?
watchdog_stop_ping_on_suspend() registers watchdog_pm_notifier(), which
calls watchdog_dev_suspend() -> __watchdog_ping() -> twd_wdt_ping() at
PM_SUSPEND_PREPARE before twd_wdt_suspend() clears wdt->armed, and calls
watchdog_dev_resume() -> __watchdog_ping() -> twd_wdt_ping() at
PM_POST_SUSPEND after twd_wdt_resume() sets wdt->armed back to true.
Whenever the watchdog is active (or boot-running before open_deadline),
both calls run while wdt->armed is true, resetting wdt->expires to
ktime_get_ns() + wdd->timeout * NSEC_PER_SEC and reloading the counter with
a full timeout.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-arm-twd-wdt-v6-1-ce5c85b45c63@gmail.com?part=1
prev parent reply other threads:[~2026-11-18 17:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 16:59 [PATCH v6] watchdog: Add ARM TWD (MPCore private) watchdog driver Fil Dunsky via B4 Relay
2026-11-18 17:17 ` 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-221636@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