From: sashiko-bot@kernel.org
To: "Yang Siyuan" <hsyysy@163.com>
Cc: linux-watchdog@vger.kernel.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] watchdog: sunxi_wdt: stop the watchdog across system suspend
Date: Tue, 17 Nov 2026 09:36:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-218496@kernel.org> (raw)
In-Reply-To: <20261117092036.12192-1-hsyysy@163.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] watchdog: sunxi_wdt: unused function warnings when
CONFIG_PM_SLEEP=n
- [Low] watchdog: sunxi_wdt: redundant running_at_suspend state in
sunxi_wdt_suspend()
--
commit 5093f8c201de1c0caf9e3ec2bb9831935e62dd95
Author: Yang Siyuan <hsyysy@163.com>
watchdog: sunxi_wdt: stop the watchdog across system suspend
This commit adds system sleep PM callbacks to stop the Allwinner watchdog
before suspend and restart it on resume if it was running.
> diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c
> index a6500ebf24bad..23b50cb8d3ebc 100644
> --- a/drivers/watchdog/sunxi_wdt.c
> +++ b/drivers/watchdog/sunxi_wdt.c
> @@ -55,6 +55,7 @@ struct sunxi_wdt_dev {
> struct watchdog_device wdt_dev;
> void __iomem *wdt_base;
> const struct sunxi_wdt_reg *wdt_regs;
> + bool running_at_suspend;
> };
>
> /*
> @@ -225,6 +226,36 @@ static int sunxi_wdt_start(struct watchdog_device *wdt_dev)
> return 0;
> }
>
> +/*
> + * The hardware watchdog has a maximum timeout of 16 seconds. A system
> + * suspend easily lasts longer than that, and the watchdog core only cancels
> + * its ping worker during suspend; it does not stop the timer. Stop the
> + * watchdog explicitly while suspended and re-arm it on resume.
> + */
> +static int sunxi_wdt_suspend(struct device *dev)
> +{
> + struct sunxi_wdt_dev *sunxi_wdt = dev_get_drvdata(dev);
> +
> + sunxi_wdt->running_at_suspend = sunxi_wdt_is_running(&sunxi_wdt->wdt_dev);
> + sunxi_wdt_stop(&sunxi_wdt->wdt_dev);
> +
> + return 0;
> +}
> +
> +static int sunxi_wdt_resume(struct device *dev)
> +{
> + struct sunxi_wdt_dev *sunxi_wdt = dev_get_drvdata(dev);
> +
> + if (sunxi_wdt->running_at_suspend)
> + sunxi_wdt_start(&sunxi_wdt->wdt_dev);
> +
> + return 0;
> +}
[Severity: Low]
Could sunxi_wdt_suspend() and sunxi_wdt_resume() check
watchdog_hw_running(&sunxi_wdt->wdt_dev) instead of tracking
running_at_suspend? Both sunxi_wdt_probe() and the watchdog core already
maintain WDOG_HW_RUNNING in wdt_dev.status, and guarding sunxi_wdt_stop()
with watchdog_hw_running() also avoids reading and writing wdt_mode on
suspend when the watchdog is inactive.
Also, this driver neither sets max_hw_heartbeat_ms nor calls
watchdog_stop_ping_on_suspend(), so the comment's reference to the
watchdog core cancelling its ping worker during suspend does not apply
here.
> +
> +static const struct dev_pm_ops sunxi_wdt_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(sunxi_wdt_suspend, sunxi_wdt_resume)
> +};
> +
> static const struct watchdog_info sunxi_wdt_info = {
[ ... ]
> @@ -348,6 +381,7 @@ static struct platform_driver sunxi_wdt_driver = {
> .driver = {
> .name = DRV_NAME,
> .of_match_table = sunxi_wdt_dt_ids,
> + .pm = &sunxi_wdt_pm_ops,
> },
> };
[Severity: Medium]
Does building with CONFIG_PM_SLEEP=n warn about unused functions for
sunxi_wdt_suspend() and sunxi_wdt_resume()? SET_SYSTEM_SLEEP_PM_OPS()
expands to nothing when CONFIG_PM_SLEEP is disabled, leaving both static
functions unreferenced. Using DEFINE_SIMPLE_DEV_PM_OPS() with
pm_sleep_ptr(&sunxi_wdt_pm_ops) lets the compiler drop the callbacks and
PM ops structure without warnings.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117092036.12192-1-hsyysy@163.com?part=1
next prev parent reply other threads:[~2026-11-17 9:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:20 [PATCH] watchdog: sunxi_wdt: stop the watchdog across system suspend Yang Siyuan
2026-11-17 9:36 ` sashiko-bot [this message]
2026-11-17 10:40 ` [PATCH v2] " Yang Siyuan
2026-11-17 15:51 ` [PATCH] " kernel test robot
2026-11-17 23:18 ` [PATCH v3] " Yang Siyuan
2026-11-18 0:28 ` Guenter Roeck
2026-11-18 0:50 ` [PATCH v4] " Yang Siyuan
2026-11-18 4:24 ` Guenter Roeck
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-218496@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hsyysy@163.com \
--cc=linux-sunxi@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.