summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors')
-rw-r--r--meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0003-Fix-PSU-PWM-fan-control.patch61
-rw-r--r--meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0004-Check-readingStateGood-before-updating-thresholds-pr.patch99
-rw-r--r--meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0005-ExitAir-Move-to-GetSensorConfiguration.patch75
-rw-r--r--meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0006-Treat-negative-temperatures-as-errors.patch73
-rw-r--r--meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors_%.bbappend6
5 files changed, 313 insertions, 1 deletions
diff --git a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0003-Fix-PSU-PWM-fan-control.patch b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0003-Fix-PSU-PWM-fan-control.patch
new file mode 100644
index 000000000..49aaaf5f9
--- /dev/null
+++ b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0003-Fix-PSU-PWM-fan-control.patch
@@ -0,0 +1,61 @@
+From ed3e946c02c89c389c0e28360692e51971734728 Mon Sep 17 00:00:00 2001
+From: James Feist <james.feist@linux.intel.com>
+Date: Thu, 24 Sep 2020 15:31:03 -0700
+Subject: [PATCH 1/1] Fix PSU PWM fan control
+
+105a19754f003956def5934612b1de86225a4bc1 broke the control
+interface range as the interface is supposed to accept 0-255
+fix it.
+
+Tested:
+PSU PID control worked again
+
+Change-Id: I89c03c3382b221256353cc28b1f182c80a063249
+Signed-off-by: James Feist <james.feist@linux.intel.com>
+---
+ src/PwmSensor.cpp | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
+index 0c5d439..4824489 100644
+--- a/src/PwmSensor.cpp
++++ b/src/PwmSensor.cpp
+@@ -27,6 +27,7 @@
+ static constexpr size_t sysPwmMax = 255;
+ static constexpr size_t psuPwmMax = 100;
+ static constexpr double defaultPwm = 30.0;
++static constexpr size_t targetIfaceMax = 255;
+
+ PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
+ std::shared_ptr<sdbusplus::asio::connection>& conn,
+@@ -99,7 +100,7 @@ PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
+ controlInterface->register_property(
+ "Target", static_cast<uint64_t>(pwmValue),
+ [this](const uint64_t& req, uint64_t& resp) {
+- if (req > pwmMax)
++ if (req > targetIfaceMax)
+ {
+ throw std::runtime_error("Value out of range");
+ return -1;
+@@ -108,7 +109,8 @@ PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
+ {
+ return 1;
+ }
+- setValue(req);
++ setValue(
++ std::round(pwmMax * static_cast<double>(req) / targetIfaceMax));
+ resp = req;
+
+ sensorInterface->signal_property("Value");
+@@ -117,6 +119,8 @@ PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
+ },
+ [this](uint64_t& curVal) {
+ uint64_t value = getValue();
++ value = static_cast<uint64_t>(std::round(
++ (static_cast<double>(value) / pwmMax) * targetIfaceMax));
+ if (curVal != value)
+ {
+ curVal = value;
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0004-Check-readingStateGood-before-updating-thresholds-pr.patch b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0004-Check-readingStateGood-before-updating-thresholds-pr.patch
new file mode 100644
index 000000000..ae626661a
--- /dev/null
+++ b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0004-Check-readingStateGood-before-updating-thresholds-pr.patch
@@ -0,0 +1,99 @@
+From 22a81c2898d6d3da1ba82cd9efead70b860b0acb Mon Sep 17 00:00:00 2001
+From: Zhikui Ren <zhikui.ren@intel.com>
+Date: Thu, 1 Oct 2020 08:54:32 -0700
+Subject: [PATCH] Check readingStateGood before updating thresholds property
+
+Sensor read function checks for readingStateGood before
+start. But if host resets while reading is in progress,
+incorrect sensor value maybe returned.
+Check readingStateGood before changing threshold.
+
+Add a timer async call for checkThresholds. This gives
+power match callback a chance to run to update power state.
+This change is only added for cpu sensors to minimize the
+the impact and test needed. Change for other sensors or
+in base class can be done as a follow up task.
+
+Tested:
+Run host reset test for 500 cycles, no erronous sensor
+events were reported. Before the change, same tests
+never run more than 200 cycles.
+
+Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
+---
+ include/CPUSensor.hpp | 1 +
+ src/CPUSensor.cpp | 18 +++++++++++++++---
+ src/Thresholds.cpp | 10 ++++++++++
+ 3 files changed, 26 insertions(+), 3 deletions(-)
+
+diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
+index 07f7ffd..4a56b21 100644
+--- a/include/CPUSensor.hpp
++++ b/include/CPUSensor.hpp
+@@ -37,6 +37,7 @@ class CPUSensor : public Sensor
+
+ private:
+ sdbusplus::asio::object_server& objServer;
++ std::shared_ptr<sdbusplus::asio::connection>& busConn;
+ boost::asio::posix::stream_descriptor inputDev;
+ boost::asio::deadline_timer waitTimer;
+ boost::asio::streambuf readBuf;
+diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
+index 127d68a..401412f 100644
+--- a/src/CPUSensor.cpp
++++ b/src/CPUSensor.cpp
+@@ -45,8 +45,8 @@ CPUSensor::CPUSensor(const std::string& path, const std::string& objectType,
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(_thresholds), sensorConfiguration, objectType, maxReading,
+ minReading, PowerState::on),
+- objServer(objectServer), inputDev(io), waitTimer(io), path(path),
+- privTcontrol(std::numeric_limits<double>::quiet_NaN()),
++ objServer(objectServer), busConn(conn), inputDev(io), waitTimer(io),
++ path(path), privTcontrol(std::numeric_limits<double>::quiet_NaN()),
+ dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs)
+ {
+ nameTcontrol = labelTcontrol;
+@@ -288,6 +288,18 @@ void CPUSensor::checkThresholds(void)
+ {
+ if (show)
+ {
+- thresholds::checkThresholds(this);
++ // give the power match callback to have a chance to run
++ // checkThresholds checks for host power state
++ auto timer = std::make_shared<boost::asio::steady_timer>(
++ busConn->get_io_context());
++ timer->expires_after(std::chrono::milliseconds(100));
++ timer->async_wait([this, timer](boost::system::error_code ec) {
++ if (ec)
++ {
++ // log the error but still check the thresholds
++ std::cerr << "Cpu sensor threshold timer error!\n";
++ }
++ thresholds::checkThresholds(this);
++ });
+ }
+ }
+diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
+index 025057e..ce1c759 100644
+--- a/src/Thresholds.cpp
++++ b/src/Thresholds.cpp
+@@ -421,6 +421,16 @@ void assertThresholds(Sensor* sensor, double assertValue,
+ return;
+ }
+
++ // readingState is verified before sensor read,
++ // but it can change during sensor read
++ // and return an incorrect value
++ if (assert && !sensor->readingStateGood())
++ {
++ std::cout << "bad readingState, ignore theshold assert " << sensor->name
++ << " assert value " << assertValue << "\n";
++ return;
++ }
++
+ if (interface->set_property<bool, true>(property, assert))
+ {
+ try
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0005-ExitAir-Move-to-GetSensorConfiguration.patch b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0005-ExitAir-Move-to-GetSensorConfiguration.patch
new file mode 100644
index 000000000..a7533b88a
--- /dev/null
+++ b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0005-ExitAir-Move-to-GetSensorConfiguration.patch
@@ -0,0 +1,75 @@
+From 655f376a240ce73f7c3fb6f37cd6da0cbce1693e Mon Sep 17 00:00:00 2001
+From: James Feist <james.feist@linux.intel.com>
+Date: Mon, 5 Oct 2020 15:28:15 -0700
+Subject: [PATCH 1/1] ExitAir: Move to GetSensorConfiguration
+
+GetSensorConfiguration has improved to have retries
+and avoid more expensive GetManagedOjects calls. Use
+it.
+
+Tested: System Airflow still worked
+
+Change-Id: Icbbabb6ebda771b9cde563559a83f633ffc3769f
+Signed-off-by: James Feist <james.feist@linux.intel.com>
+---
+ src/ExitAirTempSensor.cpp | 23 ++++++++++-------------
+ 1 file changed, 10 insertions(+), 13 deletions(-)
+
+diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
+index 41d9a19..c667457 100644
+--- a/src/ExitAirTempSensor.cpp
++++ b/src/ExitAirTempSensor.cpp
+@@ -61,6 +61,9 @@ static constexpr double cfmMinReading = 0;
+
+ static constexpr size_t minSystemCfm = 50;
+
++constexpr const std::array<const char*, 2> monitorIfaces = {exitAirIface,
++ cfmIface};
++
+ static std::vector<std::shared_ptr<CFMSensor>> cfmSensors;
+
+ static void setupSensorMatch(
+@@ -827,14 +830,10 @@ void createSensor(sdbusplus::asio::object_server& objectServer,
+ std::cerr << "Connection not created\n";
+ return;
+ }
+- dbusConnection->async_method_call(
+- [&](boost::system::error_code ec, const ManagedObjectType& resp) {
+- if (ec)
+- {
+- std::cerr << "Error contacting entity manager\n";
+- return;
+- }
+-
++ auto getter = std::make_shared<GetSensorConfiguration>(
++ dbusConnection,
++ std::move([&objectServer, &dbusConnection,
++ &exitAirSensor](const ManagedObjectType& resp) {
+ cfmSensors.clear();
+ for (const auto& pathPair : resp)
+ {
+@@ -908,9 +907,9 @@ void createSensor(sdbusplus::asio::object_server& objectServer,
+ exitAirSensor->setupMatches();
+ exitAirSensor->updateReading();
+ }
+- },
+- entityManagerName, "/", "org.freedesktop.DBus.ObjectManager",
+- "GetManagedObjects");
++ }));
++ getter->getConfiguration(
++ std::vector<std::string>(monitorIfaces.begin(), monitorIfaces.end()));
+ }
+
+ int main()
+@@ -944,8 +943,6 @@ int main()
+ }
+ });
+ };
+- constexpr const std::array<const char*, 2> monitorIfaces = {exitAirIface,
+- cfmIface};
+ for (const char* type : monitorIfaces)
+ {
+ auto match = std::make_unique<sdbusplus::bus::match::match>(
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0006-Treat-negative-temperatures-as-errors.patch b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0006-Treat-negative-temperatures-as-errors.patch
new file mode 100644
index 000000000..13dc820d6
--- /dev/null
+++ b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors/0006-Treat-negative-temperatures-as-errors.patch
@@ -0,0 +1,73 @@
+From 6f6b9cb68992e3493489d16b28bd0903e66ce587 Mon Sep 17 00:00:00 2001
+From: Zhikui Ren <zhikui.ren@intel.com>
+Date: Tue, 6 Oct 2020 15:34:29 -0700
+Subject: [PATCH] Treat negative temperatures as errors
+
+During normal operations, temperature sensors are not expected to
+read as zero or have negative values.
+There might be some other root cause need to be identified
+and addressed. Treat zeros and negative readings as errors
+in temperatures as a workaround.
+
+Tested:
+Valid temperature reading are being reported.
+Negative readings are ignored.
+
+Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
+---
+ src/HwmonTempSensor.cpp | 13 +++++++++++--
+ src/IpmbSensor.cpp | 7 ++++---
+ 2 files changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
+index 649ca68..5514504 100644
+--- a/src/HwmonTempSensor.cpp
++++ b/src/HwmonTempSensor.cpp
+@@ -116,8 +116,17 @@ void HwmonTempSensor::handleResponse(const boost::system::error_code& err)
+ try
+ {
+ double nvalue = std::stod(response);
+- nvalue /= sensorScaleFactor;
+- updateValue(nvalue);
++ if (nvalue < 0)
++ {
++ std::cerr << "Hwmon temp sensor " << name
++ << ": ignore negative rawValue " << nvalue << "\n";
++ incrementError();
++ }
++ else
++ {
++ nvalue /= sensorScaleFactor;
++ updateValue(nvalue);
++ }
+ }
+ catch (const std::invalid_argument&)
+ {
+diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
+index bc9d842..1855519 100644
+--- a/src/IpmbSensor.cpp
++++ b/src/IpmbSensor.cpp
+@@ -241,7 +241,6 @@ bool IpmbSensor::processReading(const std::vector<uint8_t>& data, double& resp)
+ return false;
+ }
+ resp = data[0];
+-
+ return true;
+ }
+ case (ReadingFormat::byte3):
+@@ -341,8 +340,10 @@ void IpmbSensor::read(void)
+ }
+
+ double value = 0;
+-
+- if (!processReading(data, value))
++ // Temperature sensors are not expected to read 0
++ // treat them as errors
++ if (!processReading(data, value) ||
++ (subType == IpmbSubType::temp && value == 0.0))
+ {
+ incrementError();
+ read();
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors_%.bbappend b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors_%.bbappend
index a8a74f3e0..a265f04df 100644
--- a/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors_%.bbappend
+++ b/meta-openbmc-mods/meta-ast2500/recipes-phosphor/sensors/dbus-sensors_%.bbappend
@@ -1,4 +1,8 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-Only-allow-drive-sensors-on-bus-2-for-ast2500.patch \
- file://0002-Fix-missing-threshold-de-assert-event-when-threshold.patch"
+ file://0002-Fix-missing-threshold-de-assert-event-when-threshold.patch \
+ file://0003-Fix-PSU-PWM-fan-control.patch \
+ file://0004-Check-readingStateGood-before-updating-thresholds-pr.patch \
+ file://0005-ExitAir-Move-to-GetSensorConfiguration.patch \
+ file://0006-Treat-negative-temperatures-as-errors.patch"