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>
diff --git a/mainloop.cpp b/mainloop.cpp
index 9af3053..cfa5483 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -171,7 +171,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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. */
diff --git a/sysfs.cpp b/sysfs.cpp
index 0eb7863..f348be4 100644
--- a/sysfs.cpp
+++ b/sysfs.cpp
@@ -289,7 +289,8 @@
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 @@
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(),
diff --git a/sysfs.hpp b/sysfs.hpp
index 70568cd..86be6da 100644
--- a/sysfs.hpp
+++ b/sysfs.hpp
@@ -129,7 +129,8 @@
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.
*