Add Bus class to reset OCC bus driver
For some systems, the OCC is accessed over the SBEFIFO, acting as a bus.
If the SBE experiences a failure, the SBEFIFO driver is unable to
recover. Therefore, the OCC control application must force a reset of
the SBEFIFO driver when the OCC goes active.
Add a Bus class and reset method to unbind and bind the appropriate
SBEFIFO devices when the OCC devices are bound.
Testing: Powered on the system successfully. Injected SBE error through
a putscom. Without this fix, I intermittently saw SBEFIFO errors on the
BMC after the injection. With the fix, I saw no errors despite ~20
iterations.
Resolves openbmc/openbmc#3156
Change-Id: I0f9a230c57d0a3a7b59a874f62cdb1d93c6dcdfb
Signed-off-by: Eddie James <eajames@us.ibm.com>
diff --git a/occ_device.hpp b/occ_device.hpp
index efa46dc..85abde6 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -2,6 +2,7 @@
#include <fstream>
#include <experimental/filesystem>
+#include "occ_bus.hpp"
#include "occ_events.hpp"
#include "occ_errors.hpp"
#include "occ_presence.hpp"
@@ -34,16 +35,20 @@
* @param[in] event - Unique ptr reference to sd_event
* @param[in] name - OCC instance name
* @param[in] manager - OCC manager instance
+ * @param[in] status - OCC status instance
+ * @param[in] instance - OCC device index
* @param[in] callback - Optional callback on errors
*/
Device(EventPtr& event,
const std::string& name,
const Manager& manager,
Status& status,
+ int instance,
std::function<void(bool)> callBack = nullptr) :
config(name),
errorFile(fs::path(config) / "occ_error"),
statusObject(status),
+ busObject(instance),
error(event, errorFile, callBack),
presence(event,
fs::path(config) / "occs_present",
@@ -74,6 +79,9 @@
/** @brief Binds device to the OCC driver */
inline void bind()
{
+ // Reset this OCC's bus driver
+ busObject.reset();
+
// Bind the device
return write(bindPath, config);
}
@@ -128,6 +136,21 @@
}
}
+ /** @brief file writer to achieve bind and unbind
+ *
+ * @param[in] filename - Name of file to be written
+ * @param[in] data - Data to be written to
+ * @return - None
+ */
+ static void write(const fs::path& fileName, const std::string& data)
+ {
+ // If there is an error, move the exception all the way up
+ std::ofstream file(fileName, std::ios::out);
+ file << data;
+ file.close();
+ return;
+ }
+
private:
/** @brief Config value to be used to do bind and unbind */
const std::string config;
@@ -149,6 +172,9 @@
/** Store the associated Status instance */
Status& statusObject;
+ /** Store the associated Bus instance */
+ const Bus busObject;
+
/** Abstraction of error monitoring */
Error error;
@@ -160,21 +186,6 @@
Error throttleProcPower;
Error throttleMemTemp;
- /** @brief file writer to achieve bind and unbind
- *
- * @param[in] filename - Name of file to be written
- * @param[in] data - Data to be written to
- * @return - None
- */
- void write(const fs::path& fileName, const std::string& data)
- {
- // If there is an error, move the exception all the way up
- std::ofstream file(fileName, std::ios::out);
- file << data;
- file.close();
- return;
- }
-
/** @brief Returns if device represents the master OCC */
bool master() const;