[PATCH 5.4 054/134] watchdog: imx_sc_wdt: Fix reboot on crash

From: Greg Kroah-Hartman
Date: Tue Jun 16 2020 - 11:38:15 EST


From: Fabio Estevam <festevam@xxxxxxxxx>

commit e56d48e92b1017b6a8dbe64923a889283733fd96 upstream.

Currently when running the samples/watchdog/watchdog-simple.c
application and forcing a kernel crash by doing:

# ./watchdog-simple &
# echo c > /proc/sysrq-trigger

The system does not reboot as expected.

Fix it by calling imx_sc_wdt_set_timeout() to configure the i.MX8QXP
watchdog with a proper timeout.

Cc: <stable@xxxxxxxxxxxxxxx>
Fixes: 986857acbc9a ("watchdog: imx_sc: Add i.MX system controller watchdog support")
Reported-by: Breno Lima <breno.lima@xxxxxxx>
Signed-off-by: Fabio Estevam <festevam@xxxxxxxxx>
Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Tested-by: Breno Lima <breno.lima@xxxxxxx>
Link: https://lore.kernel.org/r/20200412230122.5601-1-festevam@xxxxxxxxx
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Signed-off-by: Wim Van Sebroeck <wim@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/watchdog/imx_sc_wdt.c | 5 +++++
1 file changed, 5 insertions(+)

--- a/drivers/watchdog/imx_sc_wdt.c
+++ b/drivers/watchdog/imx_sc_wdt.c
@@ -177,6 +177,11 @@ static int imx_sc_wdt_probe(struct platf
wdog->timeout = DEFAULT_TIMEOUT;

watchdog_init_timeout(wdog, 0, dev);
+
+ ret = imx_sc_wdt_set_timeout(wdog, wdog->timeout);
+ if (ret)
+ return ret;
+
watchdog_stop_on_reboot(wdog);
watchdog_stop_on_unregister(wdog);