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

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: stm32_iwdg: initialize default timeout

The driver never sets a default timeout value, therefore it is
initialized to zero. When CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is
enabled, the watchdog is started during probe. The kernel is supposed to
automatically ping the watchdog from this point until userspace takes
over, but this does not happen if the configured timeout is zero. A zero
timeout causes watchdog_need_worker() to return false, so the heartbeat
worker does not run and the system therefore resets soon after the
driver is probed.

This patch fixes this by setting an arbitrary non-zero default timeout.
The default could be read from the hardware instead, but I didn't see
any reason to add this complexity.

This has been tested on an STM32F746.

Fixes: 85fdc63fe256 ("drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe")
Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240228182723.12855-1-ben.wolsieffer@hefring.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Ben Wolsieffer and committed by
Wim Van Sebroeck
dbd7c008 f4c53582

+3
+3
drivers/watchdog/stm32_iwdg.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/watchdog.h> 22 22 23 + #define DEFAULT_TIMEOUT 10 24 + 23 25 /* IWDG registers */ 24 26 #define IWDG_KR 0x00 /* Key register */ 25 27 #define IWDG_PR 0x04 /* Prescaler Register */ ··· 250 248 wdd->parent = dev; 251 249 wdd->info = &stm32_iwdg_info; 252 250 wdd->ops = &stm32_iwdg_ops; 251 + wdd->timeout = DEFAULT_TIMEOUT; 253 252 wdd->min_timeout = DIV_ROUND_UP((RLR_MIN + 1) * PR_MIN, wdt->rate); 254 253 wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler * 255 254 1000) / wdt->rate;