soc_reset_me: Support defer issue reset
Support defer issue reset for use case such as polling error counter
before reset SOC.
Google-Bug-Id: 378898045
Change-Id: Ie4733597b76f90e5412a1ffb1cee1cc0af44a82d
Signed-off-by: Dan Zhang <zhdaniel@google.com>
diff --git a/src/soc-reset-me.cpp b/src/soc-reset-me.cpp
index dc40705..8f97cc7 100644
--- a/src/soc-reset-me.cpp
+++ b/src/soc-reset-me.cpp
@@ -99,11 +99,18 @@
}
}
-void SocResetMeHandler::handle(
+void SocResetMeHandler::issueReset(const ResetTimeStamp& requestTime,
+ uint16_t resetType)
+{
+ this->resetSoC(resetType);
+ logRequestIssued(requestTime);
+}
+
+std::optional<ResetTimeStamp> SocResetMeHandler::handleDeferable(
[[maybe_unused]] uint8_t requesterTid,
[[maybe_unused]] const struct pldm_event_oem_google_soc_reset_me*
resetMeMsg,
- [[maybe_unused]] size_t resetMeMsgLen)
+ [[maybe_unused]] size_t resetMeMsgLen, bool resetDeferred)
{
auto requestTime = std::chrono::steady_clock::now();
auto resetReason = std::string(reinterpret_cast<const char*>(resetMeMsg) +
@@ -115,15 +122,20 @@
if (requestTime <= quiescentEnd)
{
logRequestIgnored(requestTime);
- return;
+ return std::nullopt;
}
- this->resetSoC(resetMeMsg->resetType);
-
quiescentEnd = std::chrono::steady_clock::now() +
std::chrono::seconds(resetMeMsg->resetQuiesent);
- logRequestIssued(requestTime);
+ if (resetDeferred)
+ {
+ logRequestDeferred(requestTime);
+ return requestTime;
+ }
+
+ issueReset(requestTime, resetMeMsg->resetType);
+ return requestTime;
}
std::string SocResetMeHandler::requestedHostTransition(
@@ -187,5 +199,19 @@
.count());
}
+void SocResetMeHandler::logRequestDeferred(
+ const ResetTimeStamp& requestTime) const
+{
+ lg2::info(
+ "SOC_RESET_ME request from {SOC_RESET_ME_SOCID}@{SOC_RESET_ME_REQUEST_AT} deferred",
+ "SOC_RESET_ME", "deferred"sv, "SOC_RESET_ME_SOCID",
+ static_cast<int>(socId), "SOC_RESET_ME_REQUEST_AT",
+ duration_cast<std::chrono::seconds>(requestTime.time_since_epoch())
+ .count(),
+ "SOC_RESET_ME_QUIESCENT_END",
+ duration_cast<std::chrono::seconds>(quiescentEnd.time_since_epoch())
+ .count());
+}
+
} // namespace soc_reset_me
} // namespace pldm_oem_google
diff --git a/src/soc-reset-me.hpp b/src/soc-reset-me.hpp
index 43fca30..207593b 100644
--- a/src/soc-reset-me.hpp
+++ b/src/soc-reset-me.hpp
@@ -76,19 +76,31 @@
const ResetDBusParams* cn1DbusParams();
const ResetDBusParams* cn2DbusParams();
+
+using ResetTimeStamp = std::chrono::time_point<std::chrono::steady_clock>;
class SocResetMeHandler
{
public:
SocResetMeHandler(SocId id, sdbusplus::bus_t&& b);
~SocResetMeHandler() = default;
- virtual void
+
+ virtual std::optional<ResetTimeStamp>
handle(uint8_t requesterTid,
const struct pldm_event_oem_google_soc_reset_me* resetMeMsg,
- size_t resetMeMsgLen);
+ size_t resetMeMsgLen)
+ {
+ return handleDeferable(requesterTid, resetMeMsg, resetMeMsgLen, false);
+ };
+ virtual std::optional<ResetTimeStamp> handleDeferable(
+ uint8_t requesterTid,
+ const struct pldm_event_oem_google_soc_reset_me* resetMeMsg,
+ size_t resetMeMsgLen, bool resetDeferred);
+
+ virtual void issueReset(const ResetTimeStamp& requestTime,
+ uint16_t resetType);
protected:
friend class SocResetMeHandlerTest;
- using ResetTimeStamp = std::chrono::time_point<std::chrono::steady_clock>;
virtual void resetSoC(uint16_t resetType);
virtual std::string requestedHostTransition(uint16_t resetType);
virtual void logRequest(uint64_t internalInfo, uint16_t resetType,
@@ -96,6 +108,7 @@
const std::string& resetReason) const;
virtual void logRequestIgnored(const ResetTimeStamp& requestTime) const;
virtual void logRequestIssued(const ResetTimeStamp& requestTime) const;
+ virtual void logRequestDeferred(const ResetTimeStamp& requestTime) const;
const SocId socId;
const ResetDBusParams* dbusParams;