diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-08-18 18:29:41 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-08-23 18:56:37 +0530 |
commit | 2dc9b1a24f753270eae01be8b71c0c89a3c669cc (patch) | |
tree | 8a9186650d1402515637a8ee4e1bc6b797dd1a0b /occ_manager.hpp | |
parent | 715595b64ead477ceae235208a290808234cdcf0 (diff) | |
download | openpower-occ-control-2dc9b1a24f753270eae01be8b71c0c89a3c669cc.tar.gz openpower-occ-control-2dc9b1a24f753270eae01be8b71c0c89a3c669cc.zip |
Enable OCC error monitoring
Fixes openbmc/openbmc#2165
Change-Id: I93f317a32c910f279003fa0fce6ae2d597f90312
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'occ_manager.hpp')
-rw-r--r-- | occ_manager.hpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/occ_manager.hpp b/occ_manager.hpp index 7b76703..df6f199 100644 --- a/occ_manager.hpp +++ b/occ_manager.hpp @@ -5,6 +5,8 @@ #include <experimental/filesystem> #include <functional> #include <sdbusplus/bus.hpp> +#include <phosphor-logging/log.hpp> +#include <phosphor-logging/elog.hpp> #include <powercap.hpp> #include "occ_pass_through.hpp" #include "occ_status.hpp" @@ -12,7 +14,6 @@ #include "config.h" namespace sdbusRule = sdbusplus::bus::match::rules; - namespace open_power { namespace occ @@ -68,6 +69,7 @@ struct Manager } } + private: /** @brief Callback that responds to cpu creation in the inventory - * by creating the needed objects. * @@ -92,7 +94,6 @@ struct Manager return 0; } - private: /** @brief Create child OCC objects. * * @param[in] occ - the occ name, such as occ0. @@ -110,7 +111,9 @@ struct Manager std::make_unique<Status>( bus, event, - path.c_str())); + path.c_str(), + std::bind(std::mem_fn(&Manager::statusCallBack), + this, std::placeholders::_1))); // Create the power cap monitor object for master occ (0) if (!pcap) @@ -121,6 +124,49 @@ struct Manager } } + /** @brief Callback handler invoked by Status object when the OccActive + * property is changed. This is needed to make sure that the + * error detection is started only after all the OCCs are bound. + * Similarly, when one of the OCC gets its OccActive property + * un-set, then the OCC error detection needs to be stopped on + * all the OCCs + * + * @param[in] status - OccActive status + */ + void statusCallBack(bool status) + { + using namespace phosphor::logging; + using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; + + // At this time, it won't happen but keeping it + // here just in case something changes in the future + if ((activeCount == 0) && (!status)) + { + log<level::ERR>("Invalid update on OCCActive"); + elog<InternalFailure>(); + } + + activeCount += status ? 1 : -1; + + // If all the OCCs are bound, then start error detection + if (activeCount == statusObjects.size()) + { + for (const auto& occ: statusObjects) + { + occ->addErrorWatch(); + } + } + else if (!status) + { + // If some OCCs are not bound yet, those will be a NO-OP + for (const auto& occ: statusObjects) + { + occ->removeErrorWatch(); + } + } + } + /** @brief reference to the bus */ sdbusplus::bus::bus& bus; @@ -138,6 +184,9 @@ struct Manager /** @brief sbdbusplus match objects */ std::vector<sdbusplus::bus::match_t> cpuMatches; + + /** @brief Number of OCCs that are bound */ + uint8_t activeCount = 0; }; } // namespace occ |