Commit fbbe35df authored by Tero Kristo's avatar Tero Kristo Committed by Wim Van Sebroeck
Browse files

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: default avatarTero Kristo <t-kristo@ti.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200717132958.14304-2-t-kristo@ti.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 36a8947c
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -275,9 +275,11 @@ static int watchdog_start(struct watchdog_device *wdd)
	set_bit(_WDOG_KEEPALIVE, &wd_data->status);

	started_at = ktime_get();
	if (watchdog_hw_running(wdd) && wdd->ops->ping)
		err = wdd->ops->ping(wdd);
	else
	if (watchdog_hw_running(wdd) && wdd->ops->ping) {
		err = __watchdog_ping(wdd);
		if (err == 0)
			set_bit(WDOG_ACTIVE, &wdd->status);
	} else {
		err = wdd->ops->start(wdd);
		if (err == 0) {
			set_bit(WDOG_ACTIVE, &wdd->status);
@@ -285,6 +287,7 @@ static int watchdog_start(struct watchdog_device *wdd)
			wd_data->last_hw_keepalive = started_at;
			watchdog_update_worker(wdd);
		}
	}

	return err;
}