Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Triet Hoang" <triet.hoang.dev@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 6/8] watchdog: pm8916_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Date: Mon, 14 Sep 2026 09:33:07 +0000	[thread overview]
Message-ID: <20260914093308.251281F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914085451.891675-7-triet.hoang.dev@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The watchdog will trigger a system hard-reset during suspend if it was started by the bootloader but has not been opened by userspace.
--

commit b8ef3a1624c2c7748578b550a5051929133ba830
Author: Triet Hoang <triet.hoang.dev@gmail.com>

watchdog: pm8916_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Convert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS()
and pm_ptr().

> diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c
> index 007ed139ab965..b97c132de3216 100644
> --- a/drivers/watchdog/pm8916_wdt.c
> +++ b/drivers/watchdog/pm8916_wdt.c
[ ... ]
> -static int __maybe_unused pm8916_wdt_suspend(struct device *dev)
> +static int pm8916_wdt_suspend(struct device *dev)
>  {
>  	struct pm8916_wdt *wdt = dev_get_drvdata(dev);

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential problem
in how pm8916_wdt_suspend() handles the hardware watchdog.

Could this trigger a system hard-reset during sleep?

Looking at the rest of pm8916_wdt_suspend(), it only stops the watchdog
if it is active:

	if (watchdog_active(&wdt->wdev))
		return pm8916_wdt_stop(&wdt->wdev);

If the bootloader enables the hardware watchdog, the driver's probe function
detects this and sets WDOG_HW_RUNNING. However, if the system suspends before
userspace opens the watchdog device, WDOG_ACTIVE will not be set.

Since watchdog_dev_suspend() pauses its background ping worker thread during
suspend, and pm8916_wdt_suspend() only checks watchdog_active(), the
hardware watchdog is never stopped.

Would it make sense to check both watchdog_active() and watchdog_hw_running()
to ensure we stop the hardware timer before sleep?

[ ... ]
> -static int __maybe_unused pm8916_wdt_resume(struct device *dev)
> +static int pm8916_wdt_resume(struct device *dev)
>  {
>  	struct pm8916_wdt *wdt = dev_get_drvdata(dev);

[Severity: High]
This is also a pre-existing issue, but the resume path also fails to restart
the watchdog if it was previously kept running by the kernel without an
active userspace owner:

	if (watchdog_active(&wdt->wdev))
		return pm8916_wdt_start(&wdt->wdev);

Would we need to check watchdog_hw_running() here as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914085451.891675-1-triet.hoang.dev@gmail.com?part=6

  reply	other threads:[~2026-09-14  9:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  8:54 [PATCH v2 0/8] watchdog: Convert drivers to DEFINE_SIMPLE_DEV_PM_OPS() Triet Hoang
2026-09-14  8:54 ` [PATCH v2 1/8] watchdog: cadence_wdt: Convert " Triet Hoang
2026-09-16  3:28   ` Tzung-Bi Shih
2026-09-16  4:54     ` Triet Hoang
2026-09-14  8:54 ` [PATCH v2 2/8] watchdog: da9062: " Triet Hoang
2026-09-14  8:54 ` [PATCH v2 3/8] watchdog: keembay_wdt: " Triet Hoang
2026-09-14  9:11   ` sashiko-bot
2026-09-14  9:21   ` Triet Hoang
2026-09-14  8:54 ` [PATCH v2 4/8] watchdog: msc313e_wdt: " Triet Hoang
2026-09-14  9:20   ` sashiko-bot
2026-09-16  3:35     ` Tzung-Bi Shih
2026-09-14  8:54 ` [PATCH v2 5/8] watchdog: of_xilinx_wdt: " Triet Hoang
2026-09-14  8:54 ` [PATCH v2 6/8] watchdog: pm8916_wdt: " Triet Hoang
2026-09-14  9:33   ` sashiko-bot [this message]
2026-09-14  8:54 ` [PATCH v2 7/8] watchdog: sp805_wdt: " Triet Hoang
2026-09-14  8:54 ` [PATCH v2 8/8] watchdog: stmp3xxx_rtc_wdt: " Triet Hoang

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=20260914093308.251281F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=triet.hoang.dev@gmail.com \
    /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