aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorKen Sloat <ksloat@aampglobal.com>2019-06-14 12:53:22 +0000
committerWim Van Sebroeck <wim@linux-watchdog.org>2019-07-08 20:35:12 +0200
commit8d209eb0b167ac6998ef330150a3960032a31c50 (patch)
tree922e45a5f5f7db2f07754d0052b386cdef878e73 /drivers/watchdog
parentwatchdog: convert remaining drivers to use SPDX license identifier (diff)
downloadlinux-dev-8d209eb0b167ac6998ef330150a3960032a31c50.tar.xz
linux-dev-8d209eb0b167ac6998ef330150a3960032a31c50.zip
watchdog: atmel: atmel-sama5d4-wdt: Disable watchdog on system suspend
Currently, the atmel-sama5d4-wdt continues to run after system suspend. Unless the system resumes within the watchdog timeout period so the userspace can kick it, the system will be reset. This change disables the watchdog on suspend if it is active and re-enables on resume. These actions occur during the late and early phases of suspend and resume respectively to minimize chances where a lock could occur while the watchdog is disabled. Signed-off-by: Ken Sloat <ksloat@aampglobal.com> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/sama5d4_wdt.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index dc3c0695116f..d193a60430b2 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -275,7 +275,17 @@ static const struct of_device_id sama5d4_wdt_of_match[] = {
MODULE_DEVICE_TABLE(of, sama5d4_wdt_of_match);
#ifdef CONFIG_PM_SLEEP
-static int sama5d4_wdt_resume(struct device *dev)
+static int sama5d4_wdt_suspend_late(struct device *dev)
+{
+ struct sama5d4_wdt *wdt = dev_get_drvdata(dev);
+
+ if (watchdog_active(&wdt->wdd))
+ sama5d4_wdt_stop(&wdt->wdd);
+
+ return 0;
+}
+
+static int sama5d4_wdt_resume_early(struct device *dev)
{
struct sama5d4_wdt *wdt = dev_get_drvdata(dev);
@@ -286,12 +296,17 @@ static int sama5d4_wdt_resume(struct device *dev)
*/
sama5d4_wdt_init(wdt);
+ if (watchdog_active(&wdt->wdd))
+ sama5d4_wdt_start(&wdt->wdd);
+
return 0;
}
#endif
-static SIMPLE_DEV_PM_OPS(sama5d4_wdt_pm_ops, NULL,
- sama5d4_wdt_resume);
+static const struct dev_pm_ops sama5d4_wdt_pm_ops = {
+ SET_LATE_SYSTEM_SLEEP_PM_OPS(sama5d4_wdt_suspend_late,
+ sama5d4_wdt_resume_early)
+};
static struct platform_driver sama5d4_wdt_driver = {
.probe = sama5d4_wdt_probe,