Skip to content

Commit fbbe35d

Browse files
Tero KristoWim Van Sebroeck
authored andcommitted
watchdog: use __watchdog_ping in startup
Current watchdog startup functionality does not respect the minimum hw heartbeat setup and the last watchdog ping timeframe when watchdog is already running and userspace process attaches to it. Fix this by using the __watchdog_ping from the startup also. For this code path, we can also let the __watchdog_ping handle the bookkeeping for the worker and last keepalive times. Signed-off-by: Tero Kristo <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 36a8947 commit fbbe35d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/watchdog/watchdog_dev.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,18 @@ static int watchdog_start(struct watchdog_device *wdd)
275275
set_bit(_WDOG_KEEPALIVE, &wd_data->status);
276276

277277
started_at = ktime_get();
278-
if (watchdog_hw_running(wdd) && wdd->ops->ping)
279-
err = wdd->ops->ping(wdd);
280-
else
278+
if (watchdog_hw_running(wdd) && wdd->ops->ping) {
279+
err = __watchdog_ping(wdd);
280+
if (err == 0)
281+
set_bit(WDOG_ACTIVE, &wdd->status);
282+
} else {
281283
err = wdd->ops->start(wdd);
282-
if (err == 0) {
283-
set_bit(WDOG_ACTIVE, &wdd->status);
284-
wd_data->last_keepalive = started_at;
285-
wd_data->last_hw_keepalive = started_at;
286-
watchdog_update_worker(wdd);
284+
if (err == 0) {
285+
set_bit(WDOG_ACTIVE, &wdd->status);
286+
wd_data->last_keepalive = started_at;
287+
wd_data->last_hw_keepalive = started_at;
288+
watchdog_update_worker(wdd);
289+
}
287290
}
288291

289292
return err;

0 commit comments

Comments
 (0)