Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1275037
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 4/8] watchdog: Add support for minimum time between heartbeats |
| Date | 2015-11-23 04:30 +0100 |
| Message-ID | <qxPZg-4Er-23@gated-at.bofh.it> (permalink) |
| References | <qxPZf-4Er-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Some watchdogs require a minimum time between heartbeats.
Examples are the watchdogs in DA9062 and AT91SAM9x.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v5: Rebased to v4.4-rc1
Fixed typo in documentation.
v4: Added patch
---
Documentation/watchdog/watchdog-kernel-api.txt | 4 ++++
drivers/watchdog/watchdog_dev.c | 12 ++++++++++++
include/linux/watchdog.h | 6 ++++++
3 files changed, 22 insertions(+)
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
index f480a9355b43..f9f6eccbbc0b 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -53,11 +53,13 @@ struct watchdog_device {
unsigned int timeout;
unsigned int min_timeout;
unsigned int max_timeout;
+ unsigned int min_hw_heartbeat_ms;
unsigned int max_hw_timeout_ms;
void *driver_data;
unsigned long status;
struct mutex lock;
unsigned long last_keepalive;
+ unsigned long last_hw_keepalive;
struct delayed_work work;
struct list_head deferred;
};
@@ -83,6 +85,8 @@ It contains following fields:
* max_timeout: the watchdog timer's maximum timeout value (in seconds),
as seen from userspace. If set, the maximum configurable value for
'timeout'. Not used if max_hw_timeout_ms is non-zero.
+* min_hw_heartbeat_ms: Minimum time between heartbeats sent to the chip,
+ in milli-seconds.
* max_hw_timeout_ms: Maximum hardware timeout, in milli-seconds.
If set, the infrastructure will send heartbeats to the watchdog driver
if 'timeout' is larger than max_hw_timeout, unless WDOG_ACTIVE
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index e73407b42df5..832bd5ac15b5 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -111,6 +111,8 @@ static inline void watchdog_update_worker(struct watchdog_device *wdd,
static int _watchdog_ping(struct watchdog_device *wdd)
{
+ unsigned long earliest_keepalive = wdd->last_hw_keepalive +
+ msecs_to_jiffies(wdd->min_hw_heartbeat_ms);
int err;
if (test_bit(WDOG_UNREGISTERED, &wdd->status))
@@ -119,6 +121,13 @@ static int _watchdog_ping(struct watchdog_device *wdd)
if (!watchdog_active(wdd) && !watchdog_running(wdd))
return 0;
+ if (time_is_after_jiffies(earliest_keepalive)) {
+ mod_delayed_work(watchdog_wq, &wdd->work,
+ earliest_keepalive - jiffies);
+ return 0;
+ }
+
+ wdd->last_hw_keepalive = jiffies;
if (wdd->ops->ping)
err = wdd->ops->ping(wdd); /* ping the watchdog */
else
@@ -665,6 +674,9 @@ int watchdog_dev_register(struct watchdog_device *wdd)
return err;
}
+ /* Record time of most recent heartbeat as 'just before now'. */
+ wdd->last_hw_keepalive = jiffies - 1;
+
/*
* If the watchdog is running, prevent its driver from being unloaded,
* and schedule an immediate ping.
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index f0292d56caf0..84bd76b674a3 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -66,6 +66,8 @@ struct watchdog_ops {
* @max_timeout:The watchdog devices maximum timeout value (in seconds)
* as configurable from user space. Only relevant if
* max_hw_timeout_ms is not provided.
+ * @min_hw_heartbeat_ms:
+ * Minimum time between heartbeats, in milli-seconds.
* @max_hw_timeout_ms:
* Hardware limit for maximum timeout, in milli-seconds.
* Replaces max_timeout if specified.
@@ -75,6 +77,8 @@ struct watchdog_ops {
* @last_keepalive:
* Time of most recent keepalive triggered from user space,
* in jiffies (watchdog core internal).
+ * @last_hw_keepalive:
+ * Time of most recent keepalive sent to the driver, in jiffies.
* @work: Data structure for worker function (watchdog core internal).
* @deferred: entry in wtd_deferred_reg_list which is used to
* register early initialized watchdogs.
@@ -99,6 +103,7 @@ struct watchdog_device {
unsigned int timeout;
unsigned int min_timeout;
unsigned int max_timeout;
+ unsigned int min_hw_heartbeat_ms;
unsigned int max_hw_timeout_ms;
void *driver_data;
unsigned long status;
@@ -112,6 +117,7 @@ struct watchdog_device {
/* the following variables are for internal use only */
struct mutex lock;
unsigned long last_keepalive;
+ unsigned long last_hw_keepalive;
struct delayed_work work;
struct list_head deferred;
};
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/8] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
[PATCH v5 3/8] watchdog: Make set_timeout function optional Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
[PATCH v5 5/8] watchdog: Simplify update_worker Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
Re: [PATCH v5 5/8] watchdog: Simplify update_worker Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-24 08:20 +0100
Re: [PATCH v5 5/8] watchdog: Simplify update_worker Guenter Roeck <linux@roeck-us.net> - 2015-11-24 08:30 +0100
[PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
Re: [PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Alexander Stein <alexander.stein@systec-electronic.com> - 2015-11-23 17:40 +0100
Re: [PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Guenter Roeck <linux@roeck-us.net> - 2015-11-23 17:50 +0100
Re: [PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-23 20:30 +0100
Re: [PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Guenter Roeck <linux@roeck-us.net> - 2015-11-23 22:50 +0100
[RFT PATCH v5 8/8] watchdog: at91sam9: Convert to use infrastructure triggered keepalives Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
[PATCH v5 4/8] watchdog: Add support for minimum time between heartbeats Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
[PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <linux@roeck-us.net> - 2015-11-23 04:30 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-23 09:00 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <linux@roeck-us.net> - 2015-11-23 17:20 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-23 19:30 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <linux@roeck-us.net> - 2015-11-23 23:00 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-24 08:20 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <linux@roeck-us.net> - 2015-11-24 16:10 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-24 17:20 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <linux@roeck-us.net> - 2015-11-24 17:50 +0100
Re: [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-24 22:20 +0100
csiph-web