diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2018-03-16 10:03:27 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2018-03-22 16:31:36 -0500 |
commit | a23babd6952cb21397d6aa408a827047d1de81de (patch) | |
tree | 064e56bbbb558e75e0eae150be57d7c1d6dbc794 | |
parent | 147b0337b36e58604fbdd517f71f97a4dae725c1 (diff) | |
download | phosphor-hwmon-a23babd6952cb21397d6aa408a827047d1de81de.tar.gz phosphor-hwmon-a23babd6952cb21397d6aa408a827047d1de81de.zip |
Handle OCC EAGAIN & EREMOTEIO in 4.13
This is a temporary fix until the following issues are completed:
openbmc/openbmc#2327
openbmc/openbmc#2329
When an EAGAIN or an EREMOTEIO return code is received by hwmon
from the OCC driver in the 4.13 kernel, they should be translated to
an unavailable sensor(0x00) and failed sensor(0xFF) scaled values
respectively. This will keep the OCC hwmon instance running and allow
applications to continue using these sensors as they were reported under
the mainline openbmc/linux 4.10 kernel.
Tested:
Verified return codes are caught and sensor value modified
Change-Id: Ie61859863e7d88878caa942e5f5b062acabe67aa
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | mainloop.cpp | 17 | ||||
-rw-r--r-- | mainloop.hpp | 2 | ||||
-rw-r--r-- | sysfs.cpp | 22 | ||||
-rw-r--r-- | sysfs.hpp | 3 |
4 files changed, 38 insertions, 6 deletions
diff --git a/mainloop.cpp b/mainloop.cpp index 9af3053..cfa5483 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -171,7 +171,8 @@ int64_t adjustValue(const SensorSet::key_type& sensor, int64_t value) auto addValue(const SensorSet::key_type& sensor, const std::string& devPath, sysfs::hwmonio::HwmonIO& ioAccess, - ObjectInfo& info) + ObjectInfo& info, + bool isOCC = false) { static constexpr bool deferSignals = true; @@ -190,7 +191,8 @@ auto addValue(const SensorSet::key_type& sensor, sensor.second, hwmon::entry::cinput, sysfs::hwmonio::retries, - sysfs::hwmonio::delay); + sysfs::hwmonio::delay, + isOCC); } catch (const std::system_error& e) { @@ -269,6 +271,11 @@ MainLoop::MainLoop( state(), ioAccess(path) { + if (path.find("occ") != std::string::npos) + { + _isOCC = true; + } + std::string p = path; while (!p.empty() && p.back() == '/') { @@ -371,7 +378,8 @@ void MainLoop::run() objectPath.append(label); ObjectInfo info(&_bus, std::move(objectPath), Object()); - auto valueInterface = addValue(i.first, _devPath, ioAccess, info); + auto valueInterface = addValue(i.first, _devPath, ioAccess, info, + _isOCC); if (!valueInterface) { #ifdef REMOVE_ON_FAIL @@ -469,7 +477,8 @@ void MainLoop::run() i.first.second, input, sysfs::hwmonio::retries, - sysfs::hwmonio::delay); + sysfs::hwmonio::delay, + _isOCC); value = adjustValue(i.first, value); diff --git a/mainloop.hpp b/mainloop.hpp index b62481d..a9ec21e 100644 --- a/mainloop.hpp +++ b/mainloop.hpp @@ -76,6 +76,8 @@ class MainLoop const char* _prefix; /** @brief DBus sensors namespace root. */ const char* _root; + /** @brief hwmon instance is for an OCC. */ + bool _isOCC = false; /** @brief DBus object state. */ SensorState state; /** @brief Sleep interval in microseconds. */ @@ -289,7 +289,8 @@ int64_t HwmonIO::read( const std::string& id, const std::string& sensor, size_t retries, - std::chrono::milliseconds delay) const + std::chrono::milliseconds delay, + bool isOCC) const { int64_t val; std::ifstream ifs; @@ -334,6 +335,25 @@ int64_t HwmonIO::read( exit(0); } + if (isOCC) + { + if (rc == EAGAIN) + { + // For the OCCs, when an EAGAIN is return, just set the + // value to 0 (0x00 = sensor is unavailable) + val = 0; + break; + } + else if (rc == EREMOTEIO) + { + // For the OCCs, when an EREMOTEIO is return, set the + // value to 255*1000 + // (0xFF = sensor is failed, 1000 = sensor factor) + val = 255000; + break; + } + } + if (0 == std::count( retryableErrors.begin(), retryableErrors.end(), @@ -129,7 +129,8 @@ class HwmonIO const std::string& id, const std::string& sensor, size_t retries, - std::chrono::milliseconds delay) const; + std::chrono::milliseconds delay, + bool isOCC = false) const; /** @brief Perform formatted hwmon sysfs write. * |