diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors')
4 files changed, 415 insertions, 90 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch index c9175fd64..6815b5563 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0003-Fix-missing-threshold-de-assert-event-when-threshold.patch @@ -1,105 +1,109 @@ -From 17e3ed85f2ff919ff52b4a3fe7a1eb0026f28898 Mon Sep 17 00:00:00 2001 +From 235bb8a9b809c2449e3f5bf4e999db881012c144 Mon Sep 17 00:00:00 2001 From: Zhikui Ren <zhikui.ren@intel.com> -Date: Thu, 24 Sep 2020 14:27:32 -0700 -Subject: [PATCH] Fix missing threshold de-assert event when threshold changes. +Date: Tue, 22 Jun 2021 11:35:12 -0700 +Subject: [PATCH] Fix missing de-assert event when threshold changes +Issue: Sensor can be re-constructed when sensor configuration changes like a new threshold value. Threshold deassert can be missed if the new threshold value fixes the alarm because the default state for new threshold interface is de-asserted. -Send threshold de-assert message after interfaces are initialized to -ensure de-assert event is logged if there is an active assert -event. + +Resolution: +Add a member variable hadValidSensor that is initialized to false +for new sensor. When hadValidSensor is false, threshold property changed +message will be emitted even if threshold property did not change, +If the previous sensor instance had the threshold raised, +Phosphor-sel-logger would notice the change and log a de-assert event. +If the previous sensor instance did not have the threshold raised, +Phosphor-sel-logger would notice this is not a change and not create +new SEL log. +Set hadValidSensor to true when sensor value is updated with a value +that is not NaN. This is done after threshold property changed message +is emitted. Tested: -step1: -busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 2.457 -ipmitool sel list -SEL has no entries -step2: -busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 3.1 -ipmitool sel list - 1 | 09/24/20 | 21:30:15 UTC | Voltage #0x2d | Lower Non-critical going low | Asserted -step3: -busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/P3VBAT xyz.openbmc_project.Sensor.Threshold.Warning WarningLow d 2.457 -ipmitool sel list - 1 | 09/24/20 | 21:30:15 UTC | Voltage #0x2d | Lower Non-critical going low | Asserted - 2 | 09/24/20 | 21:30:33 UTC | Voltage #0x2d | Lower Non-critical going low | Deasserted +1. Change threshold value for a voltage sensor to force a SEL. + ipmitool raw 0x04 0x26 0x60 0x1b 0x95 0x6b 0x00 0x99 0xa6 0x00 + +2. Verify SEL logged threshold assert event as expected + ipmitool sel list + 1 | Pre-Init |0000007277| Voltage #0x60 | Upper Non-critical going high | Asserted + +3. Use ipmitool to change threshold value back to normal + ipmitool raw 0x04 0x26 0x60 0x1b 0x95 0x6b 0x00 0xa4 0xa6 0x00 + +4. Verify SEL logged threshold de-assert event as expected + ipmitool sel list + 1 | Pre-Init |0000007277| Voltage #0x60 | Upper Non-critical going high | Asserted + 2 | Pre-Init |0000007304| Voltage #0x60 | Upper Non-critical going high | Deasserted Signed-off-by: Zhikui Ren <zhikui.ren@intel.com> -Change-Id: If28870ac1e0d09be4a631a3145408ec70390dfc5 --- - include/Thresholds.hpp | 5 ++++- - include/sensor.hpp | 13 +++++++++++++ - src/ADCSensor.cpp | 1 + - src/Thresholds.cpp | 15 +++++++++++++-- - 4 files changed, 31 insertions(+), 3 deletions(-) + include/Thresholds.hpp | 2 +- + include/sensor.hpp | 2 ++ + src/Thresholds.cpp | 17 ++++++++++++++--- + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/Thresholds.hpp b/include/Thresholds.hpp -index ca2b0a0..c1d0baf 100644 +index af63f72..fd507d0 100644 --- a/include/Thresholds.hpp +++ b/include/Thresholds.hpp -@@ -45,7 +45,10 @@ struct Threshold +@@ -44,7 +44,7 @@ struct Threshold void assertThresholds(Sensor* sensor, double assertValue, thresholds::Level level, thresholds::Direction direction, - bool assert); + bool assert, bool force = false); -+ -+void forceDeassertThresholds(Sensor* sensor, thresholds::Level level, -+ thresholds::Direction direction); struct TimerUsed { diff --git a/include/sensor.hpp b/include/sensor.hpp -index 0ef87d5..d50b2ff 100644 +index b98241b..6235674 100644 --- a/include/sensor.hpp +++ b/include/sensor.hpp -@@ -312,6 +312,19 @@ struct Sensor - operationalInterface->register_property("Functional", true); - operationalInterface->initialize(); +@@ -71,6 +71,7 @@ struct Sensor + std::shared_ptr<sdbusplus::asio::dbus_interface> operationalInterface; + double value = std::numeric_limits<double>::quiet_NaN(); + double rawValue = std::numeric_limits<double>::quiet_NaN(); ++ bool hadValidValue = false; + bool overriddenState = false; + bool internalSet = false; + double hysteresisTrigger; +@@ -432,6 +433,7 @@ struct Sensor + { + markFunctional(true); + markAvailable(true); ++ hadValidValue = true; } -+ -+ // Sensor can be reconstructed when sensor configuration changes -+ // like a new threshold value. Threshold deassert can be missed -+ // if the new threshold value fixes the alarm because -+ // default state for new threshold interface is de-asserted. -+ // Send threshold de-assert message during initialization to -+ // ensure de-assert events are logged if there is an active assert -+ // event. -+ for (auto& threshold : thresholds) -+ { -+ thresholds::forceDeassertThresholds(this, threshold.level, -+ threshold.direction); -+ } } - bool readingStateGood() -diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp -index fe600d7..632fc8c 100644 ---- a/src/ADCSensor.cpp -+++ b/src/ADCSensor.cpp -@@ -88,6 +88,7 @@ ADCSensor::~ADCSensor() - // close the input dev to cancel async operations - inputDev.close(); - waitTimer.cancel(); -+ - objServer.remove_interface(thresholdInterfaceWarning); - objServer.remove_interface(thresholdInterfaceCritical); - objServer.remove_interface(sensorInterface); diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp -index f4d4ed0..3c791c9 100644 +index bbe8e20..78ded55 100644 --- a/src/Thresholds.cpp +++ b/src/Thresholds.cpp -@@ -344,6 +344,7 @@ bool checkThresholds(Sensor* sensor) +@@ -418,10 +418,19 @@ bool checkThresholds(Sensor* sensor) { bool status = true; std::vector<ChangeParam> changes = checkThresholds(sensor, sensor->value); + ++ // Sensor can be reconstructed when sensor configuration changes ++ // like a new threshold value. Threshold deassert can be missed ++ // if the new threshold value fixes the alarm because ++ // default state for new threshold interface is de-asserted. ++ // force sending assert/de-assert message when a not NaN value is updated ++ // for the first time even when threshold property did not change. ++ bool forceAssert = !sensor->hadValidValue; for (const auto& change : changes) { assertThresholds(sensor, change.assertValue, change.threshold.level, -@@ -392,7 +393,7 @@ void checkThresholdsPowerDelay(Sensor* sensor, ThresholdTimer& thresholdTimer) +- change.threshold.direction, change.asserted); ++ change.threshold.direction, change.asserted, ++ forceAssert); + if (change.threshold.level == thresholds::Level::CRITICAL && + change.asserted) + { +@@ -473,7 +482,7 @@ void checkThresholdsPowerDelay(const std::weak_ptr<Sensor>& weakSensor, void assertThresholds(Sensor* sensor, double assertValue, thresholds::Level level, thresholds::Direction direction, @@ -108,7 +112,7 @@ index f4d4ed0..3c791c9 100644 { std::string property; std::shared_ptr<sdbusplus::asio::dbus_interface> interface; -@@ -432,7 +433,9 @@ void assertThresholds(Sensor* sensor, double assertValue, +@@ -513,7 +522,9 @@ void assertThresholds(Sensor* sensor, double assertValue, return; } @@ -119,21 +123,6 @@ index f4d4ed0..3c791c9 100644 { try { -@@ -452,6 +455,14 @@ void assertThresholds(Sensor* sensor, double assertValue, - } - } - -+// Explicitely de-assert a threshold with existing sensor value -+// Should only be called on sensor desctruction -+void forceDeassertThresholds(Sensor* sensor, thresholds::Level level, -+ thresholds::Direction direction) -+{ -+ assertThresholds(sensor, sensor->value, level, direction, false, true); -+} -+ - bool parseThresholdsFromAttr( - std::vector<thresholds::Threshold>& thresholdVector, - const std::string& inputPath, const double& scaleFactor, -- 2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0006-CPUSensor-create-RequirediTempSensor-if-defined.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0006-CPUSensor-create-RequirediTempSensor-if-defined.patch index fb38b0348..0a6e73708 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0006-CPUSensor-create-RequirediTempSensor-if-defined.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0006-CPUSensor-create-RequirediTempSensor-if-defined.patch @@ -1,4 +1,4 @@ -From f516fc884fcbc03bf560b4ef975ad236232bd1e6 Mon Sep 17 00:00:00 2001 +From ba069b63307352ae0dc0a94a837306dc0bc51e94 Mon Sep 17 00:00:00 2001 From: Zhikui Ren <zhikui.ren@intel.com> Date: Tue, 11 May 2021 11:14:55 -0700 Subject: [PATCH] CPUSensor: create RequiredTempSensor if defined @@ -48,7 +48,7 @@ index 29b8209..5d09e4e 100644 static constexpr unsigned int sensorScaleFactor = 1000; static constexpr unsigned int sensorPollMs = 1000; diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp -index 7f9a2c5..7c29cf0 100644 +index c882698..277dd3f 100644 --- a/src/CPUSensor.cpp +++ b/src/CPUSensor.cpp @@ -99,6 +99,75 @@ CPUSensor::CPUSensor(const std::string& path, const std::string& objectType, @@ -65,8 +65,8 @@ index 7f9a2c5..7c29cf0 100644 + std::vector<thresholds::Threshold>&& thresholdsIn, + const std::string& sensorConfiguration) : + Sensor(boost::replace_all_copy(sensorName, " ", "_"), -+ std::move(thresholdsIn), sensorConfiguration, objectType, 0, 0, conn, -+ PowerState::on), ++ std::move(thresholdsIn), sensorConfiguration, objectType, false, 0, ++ 0, conn, PowerState::on), + objServer(objectServer), inputDev(io), waitTimer(io), + privTcontrol(std::numeric_limits<double>::quiet_NaN()), dtsOffset(0), + show(true), pollTime(CPUSensor::sensorPollMs), minMaxReadCounter(0) @@ -128,10 +128,10 @@ index 7f9a2c5..7c29cf0 100644 { // close the input dev to cancel async operations diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp -index 92c1716..4c00551 100644 +index c565890..a28a5be 100644 --- a/src/CPUSensorMain.cpp +++ b/src/CPUSensorMain.cpp -@@ -332,10 +332,9 @@ bool createSensors(boost::asio::io_service& io, +@@ -333,10 +333,9 @@ bool createSensors(boost::asio::io_service& io, { if (debug) { @@ -144,7 +144,7 @@ index 92c1716..4c00551 100644 } // check hidden properties -@@ -636,9 +635,9 @@ void detectCpuAsync( +@@ -637,9 +636,9 @@ void detectCpuAsync( }); } @@ -156,7 +156,7 @@ index 92c1716..4c00551 100644 sdbusplus::asio::object_server& objectServer) { bool useCache = false; -@@ -700,6 +699,45 @@ bool getCpuConfig(const std::shared_ptr<sdbusplus::asio::connection>& systemBus, +@@ -701,6 +700,45 @@ bool getCpuConfig(const std::shared_ptr<sdbusplus::asio::connection>& systemBus, iface->register_property("Present", *present); iface->initialize(); inventoryIfaces[name] = std::move(iface); @@ -202,7 +202,7 @@ index 92c1716..4c00551 100644 } auto findBus = config.second.find("Bus"); -@@ -728,7 +766,6 @@ bool getCpuConfig(const std::shared_ptr<sdbusplus::asio::connection>& systemBus, +@@ -729,7 +767,6 @@ bool getCpuConfig(const std::shared_ptr<sdbusplus::asio::connection>& systemBus, std::cout << "name: " << name << "\n"; std::cout << "type: " << type << "\n"; } @@ -210,7 +210,7 @@ index 92c1716..4c00551 100644 cpuConfigs.emplace(bus, addr, name, State::OFF); } } -@@ -764,7 +801,8 @@ int main() +@@ -765,7 +802,8 @@ int main() return; // we're being canceled } @@ -220,7 +220,7 @@ index 92c1716..4c00551 100644 { detectCpuAsync(pingTimer, creationTimer, io, objectServer, systemBus, cpuConfigs, sensorConfigs); -@@ -792,7 +830,7 @@ int main() +@@ -793,7 +831,7 @@ int main() return; // we're being canceled } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0007-Add-support-for-the-energy-hwmon-type.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0007-Add-support-for-the-energy-hwmon-type.patch new file mode 100644 index 000000000..dbe851fde --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0007-Add-support-for-the-energy-hwmon-type.patch @@ -0,0 +1,267 @@ +From b839028a4dda6fcec027f3a26887e0de0e8172bb Mon Sep 17 00:00:00 2001 +From: Szymon Dompke <szymon.dompke@intel.com> +Date: Tue, 18 May 2021 05:22:33 +0200 +Subject: [PATCH] Add support for the energy hwmon type +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With this commit CPUSensors should be able detect hwmon files of type +‘energy’ described here: + + https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface + +These files hold a cumulative energy [micro Joule]. +Values read from these type of files will be exposed on dbus as a new +sensor. An example: + +└─/xyz + └─/xyz/openbmc_project + └─/xyz/openbmc_project/sensors + ├─/xyz/openbmc_project/sensors/energy + │ └─/xyz/openbmc_project/sensors/energy/Cumulative_Energy_CPU1 + +The energy counter will have different scale factor and different +default min/max values than other types of CPU sensors (power/temp). + +Tested: + Tested on physical machine where the `energy_input` files were present, + works as desired no regression detected. + +Authored-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com> +Signed-off-by: Szymon Dompke <szymon.dompke@intel.com> +--- + include/CPUSensor.hpp | 13 ++++++-- + src/CPUSensor.cpp | 69 +++++++++++++++---------------------------- + src/CPUSensorMain.cpp | 30 ++++++++++++++++--- + 3 files changed, 60 insertions(+), 52 deletions(-) + +diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp +index 5d09e4e..cb3742a 100644 +--- a/include/CPUSensor.hpp ++++ b/include/CPUSensor.hpp +@@ -16,6 +16,15 @@ + #include <variant> + #include <vector> + ++struct SensorProperties ++{ ++ std::string path; ++ std::string units; ++ double max; ++ double min; ++ unsigned int scaleFactor; ++}; ++ + class CPUSensor : public Sensor + { + public: +@@ -25,7 +34,7 @@ class CPUSensor : public Sensor + boost::asio::io_service& io, const std::string& sensorName, + std::vector<thresholds::Threshold>&& thresholds, + const std::string& configuration, int cpuId, bool show, +- double dtsOffset); ++ double dtsOffset, const SensorProperties& sensorProperties); + + // Create a CPUSensor without a path to sensor value + CPUSensor(const std::string& objectType, +@@ -36,7 +45,6 @@ class CPUSensor : public Sensor + const std::string& sensorConfiguration); + + ~CPUSensor() override; +- static constexpr unsigned int sensorScaleFactor = 1000; + static constexpr unsigned int sensorPollMs = 1000; + static constexpr size_t warnAfterErrorCount = 10; + static constexpr const char* labelTcontrol = "Tcontrol"; +@@ -54,6 +62,7 @@ class CPUSensor : public Sensor + size_t pollTime; + bool loggedInterfaceDown = false; + uint8_t minMaxReadCounter; ++ unsigned int scaleFactor; + void setupRead(void); + void handleResponse(const boost::system::error_code& err); + void checkThresholds(void) override; +diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp +index 277dd3f..0621e04 100644 +--- a/src/CPUSensor.cpp ++++ b/src/CPUSensor.cpp +@@ -39,59 +39,37 @@ CPUSensor::CPUSensor(const std::string& path, const std::string& objectType, + boost::asio::io_service& io, const std::string& sensorName, + std::vector<thresholds::Threshold>&& thresholdsIn, + const std::string& sensorConfiguration, int cpuId, +- bool show, double dtsOffset) : ++ bool show, double dtsOffset, ++ const SensorProperties& sensorProperties) : + Sensor(boost::replace_all_copy(sensorName, " ", "_"), +- std::move(thresholdsIn), sensorConfiguration, objectType, false, 0, +- 0, conn, PowerState::on), ++ std::move(thresholdsIn), sensorConfiguration, objectType, false, ++ sensorProperties.max, sensorProperties.min, conn, PowerState::on), + objServer(objectServer), inputDev(io), waitTimer(io), path(path), + privTcontrol(std::numeric_limits<double>::quiet_NaN()), + dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs), +- minMaxReadCounter(0) ++ minMaxReadCounter(0), scaleFactor(sensorProperties.scaleFactor) + { + nameTcontrol = labelTcontrol; + nameTcontrol += " CPU" + std::to_string(cpuId); + if (show) + { +- if (auto fileParts = splitFileName(path)) ++ std::string interfacePath = sensorProperties.path + name; ++ sensorInterface = objectServer.add_interface( ++ interfacePath, "xyz.openbmc_project.Sensor.Value"); ++ if (thresholds::hasWarningInterface(thresholds)) + { +- auto& [type, nr, item] = *fileParts; +- std::string interfacePath; +- const char* units; +- if (type.compare("power") == 0) +- { +- interfacePath = "/xyz/openbmc_project/sensors/power/" + name; +- units = sensor_paths::unitWatts; +- minValue = 0; +- maxValue = 511; +- } +- else +- { +- interfacePath = +- "/xyz/openbmc_project/sensors/temperature/" + name; +- units = sensor_paths::unitDegreesC; +- minValue = -128; +- maxValue = 127; +- } +- +- sensorInterface = objectServer.add_interface( +- interfacePath, "xyz.openbmc_project.Sensor.Value"); +- if (thresholds::hasWarningInterface(thresholds)) +- { +- thresholdInterfaceWarning = objectServer.add_interface( +- interfacePath, +- "xyz.openbmc_project.Sensor.Threshold.Warning"); +- } +- if (thresholds::hasCriticalInterface(thresholds)) +- { +- thresholdInterfaceCritical = objectServer.add_interface( +- interfacePath, +- "xyz.openbmc_project.Sensor.Threshold.Critical"); +- } +- association = objectServer.add_interface(interfacePath, +- association::interface); +- +- setInitialProperties(conn, units); ++ thresholdInterfaceWarning = objectServer.add_interface( ++ interfacePath, "xyz.openbmc_project.Sensor.Threshold.Warning"); ++ } ++ if (thresholds::hasCriticalInterface(thresholds)) ++ { ++ thresholdInterfaceCritical = objectServer.add_interface( ++ interfacePath, "xyz.openbmc_project.Sensor.Threshold.Critical"); + } ++ association = ++ objectServer.add_interface(interfacePath, association::interface); ++ ++ setInitialProperties(conn, sensorProperties.units); + } + + // call setup always as not all sensors call setInitialProperties +@@ -248,7 +226,7 @@ void CPUSensor::updateMinMaxValues(void) + auto& [suffix, oldValue, dbusName, newValue] = vectorItem; + auto attrPath = boost::replace_all_copy(path, fileItem, suffix); + +- if(auto tmp = readFile(attrPath, CPUSensor::sensorScaleFactor)) ++ if (auto tmp = readFile(attrPath, scaleFactor)) + { + newValue.get() = *tmp; + } +@@ -302,7 +280,7 @@ void CPUSensor::handleResponse(const boost::system::error_code& err) + std::getline(responseStream, response); + rawValue = std::stod(response); + responseStream.clear(); +- double nvalue = rawValue / CPUSensor::sensorScaleFactor; ++ double nvalue = rawValue / scaleFactor; + + if (show) + { +@@ -328,8 +306,7 @@ void CPUSensor::handleResponse(const boost::system::error_code& err) + { + std::vector<thresholds::Threshold> newThresholds; + if (parseThresholdsFromAttr(newThresholds, path, +- CPUSensor::sensorScaleFactor, +- dtsOffset)) ++ scaleFactor, dtsOffset)) + { + if (!std::equal(thresholds.begin(), thresholds.end(), + newThresholds.begin(), +diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp +index a28a5be..baa2bb6 100644 +--- a/src/CPUSensorMain.cpp ++++ b/src/CPUSensorMain.cpp +@@ -94,6 +94,18 @@ static constexpr std::array<const char*, 1> sensorTypes = {"XeonCPU"}; + static constexpr std::array<const char*, 3> hiddenProps = { + CPUSensor::labelTcontrol, "Tthrottle", "Tjmax"}; + ++static const boost::container::flat_map<std::string, SensorProperties> ++ sensorPropertiesMap = { ++ {"power", ++ {"/xyz/openbmc_project/sensors/power/", sensor_paths::unitWatts, 511, ++ 0, 1000}}, ++ {"energy", ++ {"/xyz/openbmc_project/sensors/energy/", sensor_paths::unitJoules, ++ std::numeric_limits<uint32_t>::max() / 1000000, 0.0, 1000000}}, ++ {"temp", ++ {"/xyz/openbmc_project/sensors/temperature/", ++ sensor_paths::unitDegreesC, 127.0, -128.0, 1000}}}; ++ + void detectCpuAsync( + boost::asio::deadline_timer& pingTimer, + boost::asio::deadline_timer& creationTimer, boost::asio::io_service& io, +@@ -297,7 +309,8 @@ bool createSensors(boost::asio::io_service& io, + + auto directory = hwmonNamePath.parent_path(); + std::vector<fs::path> inputPaths; +- if (!findFiles(directory, R"((temp|power)\d+_(input|average|cap)$)", ++ if (!findFiles(directory, ++ R"((temp|power|energy)\d+_(input|average|cap)$)", + inputPaths, 0)) + { + std::cerr << "No temperature sensors in system\n"; +@@ -365,6 +378,16 @@ bool createSensors(boost::asio::io_service& io, + } + } + ++ const auto& it = sensorPropertiesMap.find(type); ++ if (it == sensorPropertiesMap.end()) ++ { ++ std::cerr ++ << "Failure getting sensor properties for sensor type: " ++ << type << "\n"; ++ continue; ++ } ++ const SensorProperties& prop = it->second; ++ + std::vector<thresholds::Threshold> sensorThresholds; + std::string labelHead = label.substr(0, label.find(' ')); + parseThresholdsFromConfig(*sensorData, sensorThresholds, +@@ -372,8 +395,7 @@ bool createSensors(boost::asio::io_service& io, + if (sensorThresholds.empty()) + { + if (!parseThresholdsFromAttr(sensorThresholds, inputPathStr, +- CPUSensor::sensorScaleFactor, +- dtsOffset)) ++ prop.scaleFactor, dtsOffset)) + { + std::cerr << "error populating thresholds for " + << sensorName << "\n"; +@@ -385,7 +407,7 @@ bool createSensors(boost::asio::io_service& io, + sensorPtr = std::make_unique<CPUSensor>( + inputPathStr, sensorType, objectServer, dbusConnection, io, + sensorName, std::move(sensorThresholds), *interfacePath, cpuId, +- show, dtsOffset); ++ show, dtsOffset, prop); + createdSensors.insert(sensorName); + if (debug) + { +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0008-CPUSensor-additional-debug-message.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0008-CPUSensor-additional-debug-message.patch new file mode 100644 index 000000000..40c8d46bd --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0008-CPUSensor-additional-debug-message.patch @@ -0,0 +1,69 @@ +From c045d0ace218a8f0c9e9af0b04aed24ec733fc79 Mon Sep 17 00:00:00 2001 +From: Zhikui Ren <zhikui.ren@intel.com> +Date: Tue, 22 Jun 2021 14:49:44 -0700 +Subject: [PATCH] CPUSensor: additional debug message + +Add debug message to capture more information on threshold changes. + +Example output - DTS threshold changes when Tcontrol was first read + Jan 01 00:06:06 intel-obmc cpusensor[461]: Core_16_CPU1: Tcontrol changed from nan to 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: Core_22_CPU1: Tcontrol changed from nan to 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: Core_24_CPU1: Tcontrol changed from nan to 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: DTS_CPU1: Tcontrol changed from nan to 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: Threshold: /sys/bus/peci/devices/peci-0/0-30/peci-cputemp.0/hwmon/hwmon12/temp2_max: 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: Threshold: /sys/bus/peci/devices/peci-0/0-30/peci-cputemp.0/hwmon/hwmon12/temp2_crit: 100 + Jan 01 00:06:06 intel-obmc cpusensor[461]: DTS_CPU1: new threshold value 92 + Jan 01 00:06:06 intel-obmc cpusensor[461]: DTS_CPU1: new threshold value 100 + +The above message will be logged when BMC reset or host resets. + +Signed-off-by: Zhikui Ren <zhikui.ren@intel.com> +--- + src/CPUSensor.cpp | 5 +++++ + src/Thresholds.cpp | 7 ++----- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp +index 0621e04..65acdac 100644 +--- a/src/CPUSensor.cpp ++++ b/src/CPUSensor.cpp +@@ -300,6 +300,7 @@ void CPUSensor::handleResponse(const boost::system::error_code& err) + : std::numeric_limits<double>::quiet_NaN(); + if (gTcontrol != privTcontrol) + { ++ std::cout << name << ": Tcontrol changed from " << privTcontrol << " to " << gTcontrol << "\n"; + privTcontrol = gTcontrol; + + if (!thresholds.empty()) +@@ -318,6 +319,10 @@ void CPUSensor::handleResponse(const boost::system::error_code& err) + thresholds::updateThresholds(this); + } + } ++ for (auto& threshold : thresholds) ++ { ++ std::cout << name << ": new threshold value " << threshold.value << "\n"; ++ } + } + else + { +diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp +index 78ded55..283dacf 100644 +--- a/src/Thresholds.cpp ++++ b/src/Thresholds.cpp +@@ -583,11 +583,8 @@ bool parseThresholdsFromAttr( + if (auto val = readFile(attrPath, scaleFactor)) + { + *val += offset; +- if (debug) +- { +- std::cout << "Threshold: " << attrPath << ": " << *val +- << "\n"; +- } ++ std::cout << "Threshold: " << attrPath << ": " << *val ++ << "\n"; + thresholdVector.emplace_back(level, direction, *val); + } + } +-- +2.17.1 + |