Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Li Jun" <lijun01@kylinos.cn>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog
Date: Fri, 11 Sep 2026 03:19:16 +0000	[thread overview]
Message-ID: <20260911031916.A8E051F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911030531.837140-1-lijun01@kylinos.cn>

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

Pre-existing issues:
- [High] wdt_restart() fails to reboot the system if the watchdog counter clock (wdt->clk) was previously disabled.
--

commit 5341b327de5a15d0411852abc081601a0f32ac49
Author: Li Jun <lijun01@kylinos.cn>

watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog

sp805_wdt_suspend() and sp805_wdt_resume() only check watchdog_active(),
when the watchdog is left running by the driver sets WDOG_HW_RUNNING.
This ensures wdt_disable() is called in suspend.

> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
> index c2125f204a137..2ddb754f3b4a1 100644
> --- a/drivers/watchdog/sp805_wdt.c
> +++ b/drivers/watchdog/sp805_wdt.c
> @@ -325,7 +325,8 @@ static int __maybe_unused sp805_wdt_suspend(struct device *dev)
>  {
>  	struct sp805_wdt *wdt = dev_get_drvdata(dev);
>  
> -	if (watchdog_active(&wdt->wdd))
> +	if (watchdog_active(&wdt->wdd) ||
> +	    watchdog_hw_running(&wdt->wdd))
>  		return wdt_disable(&wdt->wdd);
>  
>  	return 0;
>  }

[ ... ]

> @@ -335,7 +336,8 @@ static int __maybe_unused sp805_wdt_resume(struct device *dev)
>  {
>  	struct sp805_wdt *wdt = dev_get_drvdata(dev);
>  
> -	if (watchdog_active(&wdt->wdd))
> +	if (watchdog_active(&wdt->wdd) ||
> +	    watchdog_hw_running(&wdt->wdd))
>  		return wdt_enable(&wdt->wdd);
>  
>  	return 0;
>  }

[Severity: High]
This isn't a bug introduced by this patch, but does wdt_restart() fail to
reboot the system if the watchdog counter clock was previously disabled?

If userspace cleanly stops the watchdog, the core calls wdt_disable() which
disables wdt->clk. If a reboot command is subsequently issued, wdt_restart()
writes to WDTCONTROL to assert RESET_ENABLE:

drivers/watchdog/sp805_wdt.c:wdt_restart() {
        ...
        writel_relaxed(UNLOCK, wdt->base + WDTLOCK);
        writel_relaxed(0, wdt->base + WDTCONTROL);
        writel_relaxed(0, wdt->base + WDTLOAD);
        writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL);
        ...
}

Because the counter clock is disabled, the hardware timer will not count down,
and the hardware reset signal is never generated. Since wdt_restart() returns
0 without re-enabling the clock, does the reboot silently fail and hang the
system?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911030531.837140-1-lijun01@kylinos.cn?part=1

  reply	other threads:[~2026-09-11  3:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  3:05 [PATCH] watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog Li Jun
2026-09-11  3:19 ` sashiko-bot [this message]
2026-09-11  3:39 ` 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=20260911031916.A8E051F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lijun01@kylinos.cn \
    --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