[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190612150154.16778-1-ksloat@aampglobal.com>
Date: Wed, 12 Jun 2019 15:02:05 +0000
From: Ken Sloat <KSloat@...pglobal.com>
To: "nicolas.ferre@...rochip.com" <nicolas.ferre@...rochip.com>
CC: "alexandre.belloni@...tlin.com" <alexandre.belloni@...tlin.com>,
"ludovic.desroches@...rochip.com" <ludovic.desroches@...rochip.com>,
"wim@...ux-watchdog.org" <wim@...ux-watchdog.org>,
"linux@...ck-us.net" <linux@...ck-us.net>,
Ken Sloat <KSloat@...pglobal.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-watchdog@...r.kernel.org" <linux-watchdog@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v1 1/1] watchdog: atmel: atmel-sama5d4-wdt: Disable watchdog
on system suspend
From: Ken Sloat <ksloat@...pglobal.com>
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@...pglobal.com>
---
drivers/watchdog/sama5d4_wdt.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index 111695223aae..84eb4db23993 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -280,6 +280,18 @@ 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_suspend_late(struct device *dev)
+{
+ struct sama5d4_wdt *wdt;
+
+ wdt = dev_get_drvdata(dev);
+
+ if (watchdog_active(&wdt->wdd))
+ sama5d4_wdt_stop(&wdt->wdd);
+
+ return 0;
+}
+
static int sama5d4_wdt_resume(struct device *dev)
{
struct sama5d4_wdt *wdt = dev_get_drvdata(dev);
@@ -293,10 +305,25 @@ static int sama5d4_wdt_resume(struct device *dev)
return 0;
}
+
+static int sama5d4_wdt_resume_early(struct device *dev)
+{
+ struct sama5d4_wdt *wdt;
+
+ wdt = dev_get_drvdata(dev);
+
+ 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_SYSTEM_SLEEP_PM_OPS(NULL, sama5d4_wdt_resume)
+ 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,
--
2.17.1
Powered by blists - more mailing lists