pseq: Use event for power good failure wait
The current 7 second wait after power good failure blocks D-Bus message
processing. Use a systemd event instead to address.
Signed-off-by: Jim Wright <jlwright@us.ibm.com>
Change-Id: I7870fc264f6e5318a980869183bdd8aebfd85810
diff --git a/phosphor-power-sequencer/src/power_control.cpp b/phosphor-power-sequencer/src/power_control.cpp
index e120532..5578491 100644
--- a/phosphor-power-sequencer/src/power_control.cpp
+++ b/phosphor-power-sequencer/src/power_control.cpp
@@ -50,6 +50,7 @@
"xyz.openbmc_project.EntityManager"),
std::bind(&PowerControl::interfacesAddedHandler, this,
std::placeholders::_1)},
+ pgoodWaitTimer{event, std::bind(&PowerControl::onFailureCallback, this)},
powerOnAllowedTime{std::chrono::steady_clock::now() + minimumColdStartTime},
timer{event, std::bind(&PowerControl::pollPgood, this), pollInterval}
{
@@ -147,6 +148,26 @@
}
}
+void PowerControl::onFailureCallback()
+{
+ log<level::INFO>("After onFailure wait");
+
+ onFailure(false);
+
+ // Power good has failed, call for chassis hard power off
+ auto method = bus.new_method_call(util::SYSTEMD_SERVICE, util::SYSTEMD_ROOT,
+ util::SYSTEMD_INTERFACE, "StartUnit");
+ method.append(util::POWEROFF_TARGET);
+ method.append("replace");
+ bus.call_noreply(method);
+}
+
+void PowerControl::onFailure(bool timeout)
+{
+ // Call device on failure
+ device->onFailure(timeout, powerSupplyError);
+}
+
void PowerControl::pollPgood()
{
if (inStateTransition)
@@ -163,7 +184,7 @@
if (state)
{
// Time out powering on
- device->onFailure(true, powerSupplyError);
+ onFailure(true);
}
else
{
@@ -206,16 +227,8 @@
{
// Not in power off state, not changing state, and power good is off
log<level::ERR>("Chassis pgood failure");
- device->onFailure(false, powerSupplyError);
+ pgoodWaitTimer.restartOnce(std::chrono::seconds(7));
failureFound = true;
-
- // Power good has failed, call for chassis hard power off
- auto method =
- bus.new_method_call(util::SYSTEMD_SERVICE, util::SYSTEMD_ROOT,
- util::SYSTEMD_INTERFACE, "StartUnit");
- method.append(util::POWEROFF_TARGET);
- method.append("replace");
- bus.call_noreply(method);
}
}