* [PATCH] watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog
@ 2026-09-11 3:05 Li Jun
2026-09-11 3:19 ` sashiko-bot
2026-09-11 3:39 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Li Jun @ 2026-09-11 3:05 UTC (permalink / raw)
To: lijun01, wim, linux, linux-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 in sp805_wdt_probe() but userspace never opens the
device, so WDOG_ACTIVE remains cleared, the wdt_disable() will not be
executed in sp805_wdt_suspend. In this case, the suspend callback is
a no-op and the watchdog keeps counting during system suspend,
leading to an unexpected system reset.
Check WDOG_HW_RUNNING and wdt->wdd,can fix this issue.
Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
drivers/watchdog/sp805_wdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index c2125f204a13..2ddb754f3b4a 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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog
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
2026-09-11 3:39 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-11 3:19 UTC (permalink / raw)
To: Li Jun; +Cc: linux-watchdog
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] watchdog: sp805_wdt: fix suspend/resume handling of HW_RUNNING watchdog
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
@ 2026-09-11 3:39 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-09-11 3:39 UTC (permalink / raw)
To: Li Jun; +Cc: wim, linux-watchdog
On Fri, Sep 11, 2026 at 11:05:31AM +0800, Li Jun wrote:
> sp805_wdt_suspend() and sp805_wdt_resume() only check watchdog_active(),
> when the watchdog is left running by the driver sets
> WDOG_HW_RUNNING in sp805_wdt_probe() but userspace never opens the
> device, so WDOG_ACTIVE remains cleared, the wdt_disable() will not be
> executed in sp805_wdt_suspend. In this case, the suspend callback is
> a no-op and the watchdog keeps counting during system suspend,
> leading to an unexpected system reset.
> Check WDOG_HW_RUNNING and wdt->wdd,can fix this issue.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-11 3:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-09-11 3:39 ` Guenter Roeck
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.