watchdog: imx7ulp: Fix reboot hang
authorFabio Estevam <festevam@gmail.com>
Tue, 29 Oct 2019 17:40:33 +0000 (14:40 -0300)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Mon, 18 Nov 2019 18:53:44 +0000 (19:53 +0100)
The following hang is observed when a 'reboot' command is issued:

# reboot
# Stopping network: OK
Stopping klogd: OK
Stopping syslogd: OK
umount: devtmpfs busy - remounted read-only
[    8.612079] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system reboot
[   10.694753] reboot: Restarting system
[   11.699008] Reboot failed -- System halted

Fix this problem by adding a .restart ops member.

Fixes: 41b630f41bf7 ("watchdog: Add i.MX7ULP watchdog support")
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20191029174037.25381-1-festevam@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/imx7ulp_wdt.c

index c73e37976799b708a50ed719a1f16a3e34308f4b..0a87c6f4bab222928106b9091639cf0b55d84831 100644 (file)
@@ -107,12 +107,28 @@ static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog,
        return 0;
 }
 
+static int imx7ulp_wdt_restart(struct watchdog_device *wdog,
+                              unsigned long action, void *data)
+{
+       struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
+
+       imx7ulp_wdt_enable(wdt->base, true);
+       imx7ulp_wdt_set_timeout(&wdt->wdd, 1);
+
+       /* wait for wdog to fire */
+       while (true)
+               ;
+
+       return NOTIFY_DONE;
+}
+
 static const struct watchdog_ops imx7ulp_wdt_ops = {
        .owner = THIS_MODULE,
        .start = imx7ulp_wdt_start,
        .stop  = imx7ulp_wdt_stop,
        .ping  = imx7ulp_wdt_ping,
        .set_timeout = imx7ulp_wdt_set_timeout,
+       .restart = imx7ulp_wdt_restart,
 };
 
 static const struct watchdog_info imx7ulp_wdt_info = {