reset: Call Suspend / Resume mbox
During factory reset, call to suspend and resume mbox
to notify the host that it should not access the flash
during this operation.
Closes openbmc/openbmc#3210
Tested: Ran factory reset with host running and verified
there were no error messages or failed services.
Change-Id: Id881e5b4021744637d3988e57f784223957562b5
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index baeecdc..76c437c 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -286,6 +286,21 @@
void ItemUpdater::reset()
{
+ std::vector<uint8_t> mboxdArgs;
+
+ // Suspend mboxd - no args required.
+ auto dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH,
+ MBOXD_INTERFACE, "cmd");
+
+ dbusCall.append(static_cast<uint8_t>(3), mboxdArgs);
+
+ auto responseMsg = bus.call(dbusCall);
+ if (responseMsg.is_method_error())
+ {
+ log<level::ERR>("Error in mboxd suspend call");
+ elog<InternalFailure>();
+ }
+
constexpr static auto patchDir = "/usr/local/share/pnor";
if (fs::is_directory(patchDir))
{
@@ -317,6 +332,20 @@
}
}
+ // Resume mboxd with arg 1, indicating that the flash was modified.
+ dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, MBOXD_INTERFACE,
+ "cmd");
+
+ mboxdArgs.push_back(1);
+ dbusCall.append(static_cast<uint8_t>(4), mboxdArgs);
+
+ responseMsg = bus.call(dbusCall);
+ if (responseMsg.is_method_error())
+ {
+ log<level::ERR>("Error in mboxd resume call");
+ elog<InternalFailure>();
+ }
+
return;
}