watchdog: Add software pretimeout support
PATCH 1/1 watchdog: Add software pretimeout support
This adds the option to use a software timer to generate a watchdog pretimeout event for hardware watchdogs that do not support the pretimeout feature.
With this enabled, all watchdogs will appear to have pretimeout support in userspace. If no pretimeout value is set, there will be no change in the watchdog's behavior. If a pretimeout value is set for a specific watchdog that does not have built-in pretimeout support, a timer will be started that should fire at the specified time before the watchdog timeout would occur. When the watchdog is successfully pinged, the timer will be restarted. If the timer is allowed to fire it will generate a pretimeout event.
If the watchdog does support a pretimeout natively, that functionality will be used instead of the software timer.
--- drivers/watchdog/Kconfig | 8 +++++ drivers/watchdog/watchdog_dev.c | 62 +++++++++++++++++++++++++++++++--- drivers/watchdog/watchdog_pretimeout.c | 7 ++-- 3 files changed, 71 insertions(+), 6 deletions(-)
drivers/watchdog/Kconfig +8 -0
@@ -73,6 +73,14 @@ config WATCHDOG_SYSFS Say Y here if you want to enable watchdog device status read through sysfs attributes. +config WATCHDOG_SOFTWARE_PRETIMEOUT + bool "Enable software timer based pretimeout support" + help + Enable this if you want to use a software timer based pretimeout for + watchdogs that do not have pretimeout support. Be aware that because + this pretimeout is purely software based, it may not be able to fire + before the actual watchdog fires in some situations. + comment "Watchdog Pretimeout Governors" config WATCHDOG_PRETIMEOUT_GOV
drivers/watchdog/watchdog_dev.c +58 -4
131 lines not on this page · raw message
drivers/watchdog/watchdog_pretimeout.c +5 -2
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2015-2016 Mentor Graphics +* Copyright (C) 2020 Hewlett Packard Enterprise Development LP. */ #include <linux/list.h>
@@ -177,7 +178,8 @@ int watchdog_register_pretimeout(struct watchdog_device *wdd) {struct watchdog_pretimeout *p; -if (!(wdd->info->options &WDIOF_PRETIMEOUT )) +if (!(wdd->info->options &WDIOF_PRETIMEOUT ) && + !IS_ENABLED (CONFIG_WATCHDOG_SOFTWARE_PRETIMEOUT ))return 0 ; p =kzalloc (sizeof (*p),GFP_KERNEL );
@@ -197,7 +199,8 @@ void watchdog_unregister_pretimeout(struct watchdog_device *wdd) {struct watchdog_pretimeout *p, *t; -if (!(wdd->info->options &WDIOF_PRETIMEOUT )) +if (!(wdd->info->options &WDIOF_PRETIMEOUT ) && + !IS_ENABLED (CONFIG_WATCHDOG_SOFTWARE_PRETIMEOUT ))return ;spin_lock_irq (&pretimeout_lock);
Signature · 1 line
2.7.4