From 4b017a9b8728d19880d8d0de9cb994d7c0273769 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 27 Apr 2018 14:31:08 -0700 Subject: watchdog: Use ResetTimeRemaining for wd_reset Using this helper method reduces the number of dbus calls made during each watchdog reset. Change-Id: I373db3babe03e05fca33eb4dbbbc7c07f95a39ea Signed-off-by: William A. Kennington III --- app/watchdog.cpp | 8 ++------ app/watchdog_service.cpp | 22 ++++++++++++++++++++++ app/watchdog_service.hpp | 8 ++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/watchdog.cpp b/app/watchdog.cpp index c1f25ac..dbd7426 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -40,12 +40,8 @@ ipmi_ret_t ipmi_app_watchdog_reset( return IPMI_WDOG_CC_NOT_INIT; } - // Reset the countdown to make sure we don't expire our timer - wd_service.setTimeRemaining(wd_prop.interval); - - // The spec states that the timer is activated by reset - wd_service.setEnabled(true); - + // The ipmi standard dictates we enable the watchdog during reset + wd_service.resetTimeRemaining(true); return IPMI_CC_OK; } catch (const InternalFailure& e) diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp index c95c092..26962dc 100644 --- a/app/watchdog_service.cpp +++ b/app/watchdog_service.cpp @@ -32,6 +32,28 @@ WatchdogService::WatchdogService() { } +void WatchdogService::resetTimeRemaining(bool enableWatchdog) +{ + bool wasValid = wd_service.isValid(bus); + auto request = wd_service.newMethodCall( + bus, wd_intf, "ResetTimeRemaining"); + request.append(enableWatchdog); + auto response = bus.call(request); + if (response.is_method_error()) + { + wd_service.invalidate(); + if (wasValid) + { + // Retry the request once in case the cached service was stale + return resetTimeRemaining(enableWatchdog); + } + log( + "WatchdogService: Method error resetting time remaining", + entry("ENABLE_WATCHDOG=%d", !!enableWatchdog)); + elog(); + } +} + WatchdogService::Properties WatchdogService::getProperties() { bool wasValid = wd_service.isValid(bus); diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp index e93b7f3..ad92213 100644 --- a/app/watchdog_service.hpp +++ b/app/watchdog_service.hpp @@ -15,6 +15,14 @@ class WatchdogService { using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action; + /** @brief Resets the time remaining on the watchdog. + * Equivalent to setTimeRemaining(getInterval()). + * Optionally enables the watchdog. + * + * @param[in] enableWatchdog - Should the call also enable the watchdog + */ + void resetTimeRemaining(bool enableWatchdog); + /** @brief Contains a copy of the properties enumerated by the * watchdog service. */ -- cgit v1.2.1