History

watchdog: msc313e: Fix spurious reset on suspend

If the hardware watchdog was started by the bootloader and the device is suspended before userspace opens it, the ping worker (from watchdog core) is frozen and the active hardware timer continues running. This leads to a spurious system reset. Check both watchdog_active() and watchdog_hw_running() when deciding whether to start or stop the watchdog during suspend and resume. Additionally, call watchdog_stop_ping_on_suspend() to ensure the ping worker be correctly paused and restarted during suspend and resume.

Tzung-Bi Shih committed 2 months ago

Commit 4f6817c1 parent 3db2df21 file · +3 −2Browse files

Unified · Split

drivers/watchdog/msc313e_wdt.c+3−2
@@ -156,6 +156,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev) · 155 unmodified lines
156156 watchdog_init_timeout(&priv->wdev, timeout, dev);
157157 watchdog_stop_on_reboot(&priv->wdev);
158158 watchdog_stop_on_unregister(&priv->wdev);
159+ watchdog_stop_ping_on_suspend(&priv->wdev);
159160
160161 ret = devm_watchdog_register_device(dev, &priv->wdev);
161162
@@ -170,7 +171,7 @@ static int __maybe_unused msc313e_wdt_suspend(struct device *dev) · 8 unmodified lines
170171 {
171172 struct msc313e_wdt_priv *priv = dev_get_drvdata(dev);
172173
173− if (watchdog_active(&priv->wdev))
174+ if (watchdog_active(&priv->wdev) || watchdog_hw_running(&priv->wdev))
174175 msc313e_wdt_stop(&priv->wdev);
175176
176177 return 0;
@@ -180,7 +181,7 @@ static int __maybe_unused msc313e_wdt_resume(struct device *dev) · 3 unmodified lines
180181 {
181182 struct msc313e_wdt_priv *priv = dev_get_drvdata(dev);
182183
183− if (watchdog_active(&priv->wdev))
184+ if (watchdog_active(&priv->wdev) || watchdog_hw_running(&priv->wdev))
184185 msc313e_wdt_start(&priv->wdev);
185186
186187 return 0;