Skip to content

Commit

Permalink
Handle OCC EAGAIN & EREMOTEIO in 4.13
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Doyle Huang <doyle.sy.huang@mail.foxconn.com>
  • Loading branch information
msbarth authored and Doyle Huang committed Apr 10, 2018
1 parent 4301304 commit 743eba0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
17 changes: 13 additions & 4 deletions mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ int adjustValue(const SensorSet::key_type& sensor, int 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;

Expand All @@ -220,7 +221,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)
{
Expand Down Expand Up @@ -323,6 +325,11 @@ MainLoop::MainLoop(
state(),
ioAccess(path)
{
if (path.find("occ") != std::string::npos)
{
_isOCC = true;
}

std::string p = path;
while (!p.empty() && p.back() == '/')
{
Expand Down Expand Up @@ -399,7 +406,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
Expand Down Expand Up @@ -480,7 +488,8 @@ void MainLoop::run()
i.first.second,
hwmon::entry::cinput,
sysfs::hwmonio::retries,
sysfs::hwmonio::delay);
sysfs::hwmonio::delay,
_isOCC);

value = adjustValue(i.first, value);

Expand Down
2 changes: 2 additions & 0 deletions mainloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
22 changes: 21 additions & 1 deletion sysfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ uint32_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
{
uint32_t val;
std::ifstream ifs;
Expand Down Expand Up @@ -334,6 +335,25 @@ uint32_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(),
Expand Down
3 changes: 2 additions & 1 deletion sysfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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.
*
Expand Down

0 comments on commit 743eba0

Please sign in to comment.