[PATCH] watchdog: da9063: wake up parent ahead of reboot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch ensures our parent is awake before a reboot takes place. This
prevents situations in which the I2C host has been suspended and cannot
be safely woken up anymore when it needs to talk to us.

Signed-off-by: Ulrich Hecht <uli+renesas@xxxxxxxx>
---

Hi!

This is supposed to resolve the issue that came up in the review of
"[PATCH v2] i2c: sh_mobile: implement atomic transfers" that the parent
controller may be suspended when the restart method is called. See
https://www.spinics.net/lists/linux-i2c/msg46367.html for details.

CU
Uli


 drivers/watchdog/da9063_wdt.c   | 21 +++++++++++++++++++++
 include/linux/mfd/da9063/core.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 423584252606..89718733491e 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -18,6 +18,8 @@
 #include <linux/mfd/da9063/registers.h>
 #include <linux/mfd/da9063/core.h>
 #include <linux/regmap.h>
+#include <linux/pm_runtime.h>
+#include <linux/reboot.h>
 
 /*
  * Watchdog selector to timeout in seconds.
@@ -158,6 +160,21 @@ static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
 	return ret;
 }
 
+static int da9063_reboot_notifier(struct notifier_block *nb,
+				  unsigned long code, void *unused)
+{
+	struct da9063 *da9063 = container_of(nb, struct da9063, reboot_nb);
+
+	/*
+	 * Make sure parent device is running. This cannot be done in the
+	 * restart handler because it is no longer safe to do runtime PM
+	 * there.
+	 */
+	pm_runtime_get_sync(da9063->dev->parent);
+
+	return NOTIFY_DONE;
+}
+
 static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action,
 			      void *data)
 {
@@ -233,6 +250,10 @@ static int da9063_wdt_probe(struct platform_device *pdev)
 		set_bit(WDOG_HW_RUNNING, &wdd->status);
 	}
 
+	/* Get early notification of reboot so we can wake up the parent. */
+	da9063->reboot_nb.notifier_call = da9063_reboot_notifier;
+	devm_register_reboot_notifier(dev, &da9063->reboot_nb);
+
 	return devm_watchdog_register_device(dev, wdd);
 }
 
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index fa7a43f02f27..9a3283d488b7 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -85,6 +85,8 @@ struct da9063 {
 	int		chip_irq;
 	unsigned int	irq_base;
 	struct regmap_irq_chip_data *regmap_irq;
+
+	struct notifier_block reboot_nb;
 };
 
 int da9063_device_init(struct da9063 *da9063, unsigned int irq);
-- 
2.20.1




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux