oem_ibm: Disable Watchdog Timer
The Host watchdog timer is started when the BMC is
powered on with a predefined timer interval. BMC
monitors if the Host boots without failures and
Host is supposed to ping the BMC(through
PlatformEventMessages) within the watchdog timer
interval expiration and BMC resets the watchdog
timer on receiving pings from Host and in case
the Host fails to ping the BMC within the timer
interval expiration, then BMC will trigger a host
dump.
This commit is to disable the watchdog timer after
host poweron completion, which will be followed by
surveillance(monitoring of BMC by Host).
Signed-off-by: Sagar Srinivas <sagar.srinivas@ibm.com>
Change-Id: I734e6e98f6c2936aebd04c0b56bdfebba4cfd40b
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index b3b1961..4a0c8c6 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -492,6 +492,16 @@
});
}
+void pldm::responder::oem_ibm_platform::Handler::checkAndDisableWatchDog()
+{
+ if (!hostOff && setEventReceiverCnt == SET_EVENT_RECEIVER_SENT)
+ {
+ disableWatchDogTimer();
+ }
+
+ return;
+}
+
bool pldm::responder::oem_ibm_platform::Handler::watchDogRunning()
{
static constexpr auto watchDogObjectPath =
@@ -542,6 +552,29 @@
return;
}
}
+
+void pldm::responder::oem_ibm_platform::Handler::disableWatchDogTimer()
+{
+ setEventReceiverCnt = 0;
+ pldm::utils::DBusMapping dbusMapping{"/xyz/openbmc_project/watchdog/host0",
+ "xyz.openbmc_project.State.Watchdog",
+ "Enabled", "bool"};
+ bool wdStatus = watchDogRunning();
+
+ if (!wdStatus)
+ {
+ return;
+ }
+ try
+ {
+ pldm::utils::DBusHandler().setDbusProperty(dbusMapping, false);
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << "Failed To disable watchdog timer"
+ << "ERROR=" << e.what() << "\n";
+ }
+}
} // namespace oem_ibm_platform
} // namespace responder
} // namespace pldm
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index db89acf..84ea2a6 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -47,6 +47,11 @@
POWER_CYCLE_HARD = 0x1,
};
+enum SetEventReceiverCount
+{
+ SET_EVENT_RECEIVER_SENT = 0x2,
+};
+
class Handler : public oem_platform::Handler
{
public:
@@ -60,6 +65,36 @@
mctp_eid(mctp_eid), requester(requester), event(event), handler(handler)
{
codeUpdate->setVersions();
+ setEventReceiverCnt = 0;
+
+ using namespace sdbusplus::bus::match::rules;
+ hostOffMatch = std::make_unique<sdbusplus::bus::match::match>(
+ pldm::utils::DBusHandler::getBus(),
+ propertiesChanged("/xyz/openbmc_project/state/host0",
+ "xyz.openbmc_project.State.Host"),
+ [this](sdbusplus::message::message& msg) {
+ pldm::utils::DbusChangedProps props{};
+ std::string intf;
+ msg.read(intf, props);
+ const auto itr = props.find("CurrentHostState");
+ if (itr != props.end())
+ {
+ pldm::utils::PropertyValue value = itr->second;
+ auto propVal = std::get<std::string>(value);
+ if (propVal ==
+ "xyz.openbmc_project.State.Host.HostState.Off")
+ {
+ hostOff = true;
+ setEventReceiverCnt = 0;
+ disableWatchDogTimer();
+ }
+ else if (propVal ==
+ "xyz.openbmc_project.State.Host.HostState.Running")
+ {
+ hostOff = false;
+ }
+ }
+ });
}
int getOemStateSensorReadingsHandler(
@@ -146,6 +181,15 @@
*/
void _processSystemReboot(sdeventplus::source::EventBase& source);
+ /*keeps track how many times setEventReceiver is sent */
+ void countSetEventReceiver()
+ {
+ setEventReceiverCnt++;
+ }
+
+ /* disables watchdog if running and Host is up */
+ void checkAndDisableWatchDog();
+
/** @brief To check if the watchdog app is running
*
* @return the running status of watchdog app
@@ -157,6 +201,9 @@
*/
void resetWatchDogTimer();
+ /** @brief To disable to the watchdog timer on host poweron completion*/
+ void disableWatchDogTimer();
+
~Handler() = default;
pldm::responder::CodeUpdate* codeUpdate; //!< pointer to CodeUpdate object
@@ -189,6 +236,13 @@
/** @brief PLDM request handler */
pldm::requester::Handler<pldm::requester::Request>* handler;
+
+ /** @brief D-Bus property changed signal match */
+ std::unique_ptr<sdbusplus::bus::match::match> hostOffMatch;
+
+ bool hostOff = true;
+
+ int setEventReceiverCnt = 0;
};
/** @brief Method to encode code update event msg