Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: dw_wdt: Try to get a 30 second watchdog by default

The dw_wdt_set_top() function takes in a value in seconds. In
dw_wdt_open() we were calling it with a value that's supposed to
represent the maximum value programmed into the "top" register with a
comment saying that we were trying to set the watchdog to its maximum
value. Instead we ended up setting the watchdog to ~15 seconds.

Let's fix this. However, setting things to the "max" gives me an 86
second watchdog in the system I'm looking at. 86 seconds feels a
little too long. We'll explicitly choose 30 seconds as a more
reasonable value.

NOTE: Ideally this driver should be transitioned to be a real watchdog
driver. Then we could use "watchdog_init_timeout" and let the timeout
be specified in a number of ways (device tree, module parameter, etc).
This patch should be considered a bit of a stopgap solution.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Doug Anderson and committed by
Wim Van Sebroeck
b5ade9bc a0085010

+4 -2
+4 -2
drivers/watchdog/dw_wdt.c
··· 51 51 /* The maximum TOP (timeout period) value that can be set in the watchdog. */ 52 52 #define DW_WDT_MAX_TOP 15 53 53 54 + #define DW_WDT_DEFAULT_SECONDS 30 55 + 54 56 static bool nowayout = WATCHDOG_NOWAYOUT; 55 57 module_param(nowayout, bool, 0); 56 58 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " ··· 181 179 if (!dw_wdt_is_enabled()) { 182 180 /* 183 181 * The watchdog is not currently enabled. Set the timeout to 184 - * the maximum and then start it. 182 + * something reasonable and then start it. 185 183 */ 186 - dw_wdt_set_top(DW_WDT_MAX_TOP); 184 + dw_wdt_set_top(DW_WDT_DEFAULT_SECONDS); 187 185 writel(WDOG_CONTROL_REG_WDT_EN_MASK, 188 186 dw_wdt.regs + WDOG_CONTROL_REG_OFFSET); 189 187 }