|
@@ -64,6 +64,7 @@ struct watchdog_core_data {
|
|
struct watchdog_device *wdd;
|
|
struct watchdog_device *wdd;
|
|
struct mutex lock;
|
|
struct mutex lock;
|
|
unsigned long last_keepalive;
|
|
unsigned long last_keepalive;
|
|
|
|
+ unsigned long last_hw_keepalive;
|
|
struct delayed_work work;
|
|
struct delayed_work work;
|
|
unsigned long status; /* Internal status bits */
|
|
unsigned long status; /* Internal status bits */
|
|
#define _WDOG_DEV_OPEN 0 /* Opened ? */
|
|
#define _WDOG_DEV_OPEN 0 /* Opened ? */
|
|
@@ -137,8 +138,19 @@ static inline void watchdog_update_worker(struct watchdog_device *wdd)
|
|
|
|
|
|
static int __watchdog_ping(struct watchdog_device *wdd)
|
|
static int __watchdog_ping(struct watchdog_device *wdd)
|
|
{
|
|
{
|
|
|
|
+ struct watchdog_core_data *wd_data = wdd->wd_data;
|
|
|
|
+ unsigned long earliest_keepalive = wd_data->last_hw_keepalive +
|
|
|
|
+ msecs_to_jiffies(wdd->min_hw_heartbeat_ms);
|
|
int err;
|
|
int err;
|
|
|
|
|
|
|
|
+ if (time_is_after_jiffies(earliest_keepalive)) {
|
|
|
|
+ mod_delayed_work(watchdog_wq, &wd_data->work,
|
|
|
|
+ earliest_keepalive - jiffies);
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wd_data->last_hw_keepalive = jiffies;
|
|
|
|
+
|
|
if (wdd->ops->ping)
|
|
if (wdd->ops->ping)
|
|
err = wdd->ops->ping(wdd); /* ping the watchdog */
|
|
err = wdd->ops->ping(wdd); /* ping the watchdog */
|
|
else
|
|
else
|
|
@@ -819,6 +831,9 @@ static int watchdog_cdev_register(struct watchdog_device *wdd, dev_t devno)
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /* Record time of most recent heartbeat as 'just before now'. */
|
|
|
|
+ wd_data->last_hw_keepalive = jiffies - 1;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* If the watchdog is running, prevent its driver from being unloaded,
|
|
* If the watchdog is running, prevent its driver from being unloaded,
|
|
* and schedule an immediate ping.
|
|
* and schedule an immediate ping.
|