watchdog: introduce watchdog.open_timeout commandline parameter
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Wed, 5 Jun 2019 14:06:41 +0000 (14:06 +0000)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Mon, 8 Jul 2019 18:04:13 +0000 (20:04 +0200)
commit4d1c6a0ec2d98e51f950127bf9299531caac53e1
treef0d20f2efbe881941a54ebb6efa62bceb7089ad5
parent8c21ead3ea5d896946fb5d85b52b0be757e9bef4
watchdog: introduce watchdog.open_timeout commandline parameter

The watchdog framework takes care of feeding a hardware watchdog until
userspace opens /dev/watchdogN. If that never happens for some reason
(buggy init script, corrupt root filesystem or whatnot) but the kernel
itself is fine, the machine stays up indefinitely. This patch allows
setting an upper limit for how long the kernel will take care of the
watchdog, thus ensuring that the watchdog will eventually reset the
machine.

A value of 0 (the default) means infinite timeout, preserving the
current behaviour.

This is particularly useful for embedded devices where some fallback
logic is implemented in the bootloader (e.g., use a different root
partition, boot from network, ...).

There is already handle_boot_enabled serving a similar purpose. However,
such a binary choice is unsuitable if the hardware watchdog cannot be
programmed by the bootloader to provide a timeout long enough for
userspace to get up and running. Many of the embedded devices we see use
external (gpio-triggered) watchdogs with a fixed timeout of the order of
1-2 seconds.

The open timeout only applies for the first open from
userspace. Should userspace need to close the watchdog device, with
the intention of re-opening it shortly, the application can emulate
the open timeout feature by combining the nowayout feature with an
appropriate WDIOC_SETTIMEOUT immediately prior to closing the device.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Documentation/watchdog/watchdog-parameters.txt
drivers/watchdog/watchdog_dev.c