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 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>
Link: https://patch.msgid.link/20260911030531.837140-1-lijun01@kylinos.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Li Jun 2026-09-11 11:05:31 +08:00 committed by Guenter Roeck
parent 17908f8997
commit 1c81d4a5cd

View File

@ -325,7 +325,8 @@ static int 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 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;