diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/sensors')
3 files changed, 270 insertions, 1 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0001-Add-check-for-min-max-received-from-hwmon-files.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0001-Add-check-for-min-max-received-from-hwmon-files.patch new file mode 100644 index 000000000..33d35ec5e --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0001-Add-check-for-min-max-received-from-hwmon-files.patch @@ -0,0 +1,108 @@ +From 2516d67f8bb5ecd241b8dcdec3f8c58d0e3c4744 Mon Sep 17 00:00:00 2001 +From: Wojciech Dembinski <wojciech.dembinski@intel.com> +Date: Mon, 7 Dec 2020 19:23:10 +0100 +Subject: [PATCH] Add check for min/max received from hwmon files + +When hwmon reports incorrect min/max values or CPU Sensor cannot access +readings, it shall keep the last known good readings and not update +DBus with incorrect values. +This patch adds min < max verification check for the values received +from hwmon and removes check for power on/off in the case of a read +failure. + +Tested manually on a physical platform, test cases cover incorrect +max/min values and failing access to hwmon files. +SDR over IPMI can be fully received in the case of error. + +Signed-off-by: Wojciech Dembinski <wojciech.dembinski@intel.com> +Change-Id: Ia061f849b0f434812f822ed1902c8964d4c64b45 +--- + src/CPUSensor.cpp | 50 ++++++++++++++++++++++++----------------------- + 1 file changed, 26 insertions(+), 24 deletions(-) + +diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp +index 2356821..01f5eb6 100644 +--- a/src/CPUSensor.cpp ++++ b/src/CPUSensor.cpp +@@ -1,5 +1,5 @@ + /* +-// Copyright (c) 2018 Intel Corporation ++// Copyright (c) 2018-2021 Intel Corporation + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. +@@ -146,19 +146,22 @@ void CPUSensor::setupRead(void) + + void CPUSensor::updateMinMaxValues(void) + { ++ double newMin = std::numeric_limits<double>::quiet_NaN(); ++ double newMax = std::numeric_limits<double>::quiet_NaN(); ++ + const boost::container::flat_map< + std::string, + std::vector<std::tuple<const char*, std::reference_wrapper<double>, +- const char*>>> +- map = { ++ const char*, std::reference_wrapper<double>>>> ++ map = { ++ { ++ "cap", + { +- "cap", +- { +- std::make_tuple("cap_max", std::ref(maxValue), "MaxValue"), +- std::make_tuple("cap_min", std::ref(minValue), "MinValue"), +- }, ++ std::make_tuple("cap_max", std::ref(maxValue), "MaxValue", std::ref(newMax)), ++ std::make_tuple("cap_min", std::ref(minValue), "MinValue", std::ref(newMin)), + }, +- }; ++ }, ++ }; + + if (auto fileParts = splitFileName(path)) + { +@@ -168,26 +171,25 @@ void CPUSensor::updateMinMaxValues(void) + { + for (const auto& vectorItem : mapIt->second) + { +- auto& [suffix, oldValue, dbusName] = vectorItem; ++ auto& [suffix, oldValue, dbusName, newValue] = vectorItem; + auto attrPath = boost::replace_all_copy(path, fileItem, suffix); +- if (auto newVal = +- readFile(attrPath, CPUSensor::sensorScaleFactor)) ++ ++ if(auto tmp = readFile(attrPath, CPUSensor::sensorScaleFactor)) + { +- updateProperty(sensorInterface, oldValue, *newVal, +- dbusName); ++ newValue.get() = *tmp; + } + else + { +- if (isPowerOn()) +- { +- updateProperty(sensorInterface, oldValue, 0, dbusName); +- } +- else +- { +- updateProperty(sensorInterface, oldValue, +- std::numeric_limits<double>::quiet_NaN(), +- dbusName); +- } ++ newValue.get() = std::numeric_limits<double>::quiet_NaN(); ++ } ++ } ++ ++ if(std::isfinite(newMin) && std::isfinite(newMax) && (newMin < newMax)) ++ { ++ for (const auto& vectorItem : mapIt->second) ++ { ++ auto& [suffix, oldValue, dbusName, newValue] = vectorItem; ++ updateProperty(sensorInterface, oldValue, newValue, dbusName); + } + } + } +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch new file mode 100644 index 000000000..0b2c19d32 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch @@ -0,0 +1,159 @@ +From 6d553f9fb6829d7dbbe2f625a09f476b0ef91ca0 Mon Sep 17 00:00:00 2001 +From: Jae Hyun Yoo <jae.hyun.yoo@intel.com> +Date: Wed, 27 Jan 2021 15:52:16 -0800 +Subject: [PATCH] Fix PECI client creation flow + +This commit fixes the PECI client creation flow to make it retry +the creation when the client is not exposed correctly. + +Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com> +--- + src/CPUSensorMain.cpp | 66 +++++++++++++++++++++++++++++++++++-------- + 1 file changed, 54 insertions(+), 12 deletions(-) + +diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp +index dfc942fcf7f3..67be7447e74e 100644 +--- a/src/CPUSensorMain.cpp ++++ b/src/CPUSensorMain.cpp +@@ -84,6 +84,7 @@ struct CPUConfig + }; + + static constexpr const char* peciDev = "/dev/peci-"; ++static constexpr const char* peciDevPath = "/sys/bus/peci/devices/"; + static constexpr const unsigned int rankNumMax = 8; + + namespace fs = std::filesystem; +@@ -169,7 +170,7 @@ bool createSensors(boost::asio::io_service& io, + } + + std::vector<fs::path> hwmonNamePaths; +- if (!findFiles(fs::path(R"(/sys/bus/peci/devices)"), ++ if (!findFiles(fs::path(peciDevPath), + R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)", + hwmonNamePaths, 1)) + { +@@ -405,7 +406,7 @@ bool createSensors(boost::asio::io_service& io, + return true; + } + +-void exportDevice(const CPUConfig& config) ++int exportDevice(const CPUConfig& config) + { + std::ostringstream hex; + hex << std::hex << config.addr; +@@ -413,9 +414,12 @@ void exportDevice(const CPUConfig& config) + std::string busStr = std::to_string(config.bus); + + std::string parameters = "peci-client 0x" + addrHexStr; +- std::string device = "/sys/bus/peci/devices/peci-" + busStr + "/new_device"; ++ std::string devPath = peciDevPath; ++ std::string delDevice = devPath + "peci-" + busStr + "/delete_device"; ++ std::string newDevice = devPath + "peci-" + busStr + "/new_device"; ++ std::string newClient = devPath + busStr + "-" + addrHexStr + "/driver"; + +- std::filesystem::path devicePath(device); ++ std::filesystem::path devicePath(newDevice); + const std::string& dir = devicePath.parent_path().string(); + for (const auto& path : std::filesystem::directory_iterator(dir)) + { +@@ -433,20 +437,38 @@ void exportDevice(const CPUConfig& config) + std::cout << parameters << " on bus " << busStr + << " is already exported\n"; + } +- return; ++ ++ std::ofstream delDeviceFile(delDevice); ++ if (!delDeviceFile.good()) ++ { ++ std::cerr << "Error opening " << delDevice << "\n"; ++ return -1; ++ } ++ delDeviceFile << parameters; ++ delDeviceFile.close(); ++ ++ break; + } + } + +- std::ofstream deviceFile(device); ++ std::ofstream deviceFile(newDevice); + if (!deviceFile.good()) + { +- std::cerr << "Error writing " << device << "\n"; +- return; ++ std::cerr << "Error opening " << newDevice << "\n"; ++ return -1; + } + deviceFile << parameters; + deviceFile.close(); + ++ if (!std::filesystem::exists(newClient)) ++ { ++ std::cerr << "Error creating " << newClient << "\n"; ++ return -1; ++ } ++ + std::cout << parameters << " on bus " << busStr << " is exported\n"; ++ ++ return 0; + } + + void detectCpu(boost::asio::deadline_timer& pingTimer, +@@ -462,6 +484,11 @@ void detectCpu(boost::asio::deadline_timer& pingTimer, + + for (CPUConfig& config : cpuConfigs) + { ++ if (config.state == State::READY) ++ { ++ continue; ++ } ++ + std::string peciDevPath = peciDev + std::to_string(config.bus); + auto file = open(peciDevPath.c_str(), O_RDWR | O_CLOEXEC); + if (file < 0) +@@ -512,16 +539,29 @@ void detectCpu(boost::asio::deadline_timer& pingTimer, + newState = State::OFF; + } + +- close(file); +- + if (config.state != newState) + { + if (newState != State::OFF) + { + if (config.state == State::OFF) + { +- std::cout << config.name << " is detected\n"; +- exportDevice(config); ++ struct peci_rd_pkg_cfg_msg msg; ++ msg.addr = config.addr; ++ msg.index = PECI_MBX_INDEX_CPU_ID; ++ msg.param = 0; ++ msg.rx_len = 4; ++ if (!ioctl(file, PECI_IOC_RD_PKG_CFG, &msg)) ++ { ++ std::cout << config.name << " is detected\n"; ++ if (exportDevice(config)) ++ { ++ newState = State::OFF; ++ } ++ } ++ else ++ { ++ newState = State::OFF; ++ } + } + + if (newState == State::ON) +@@ -544,6 +584,8 @@ void detectCpu(boost::asio::deadline_timer& pingTimer, + keepPinging = true; + } + ++ close(file); ++ + if (DEBUG) + { + std::cout << config.name << ", state: " << config.state << "\n"; +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend index 9a50b255d..39a6f1581 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors_%.bbappend @@ -1,11 +1,13 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" PROJECT_SRC_DIR := "${THISDIR}/${PN}" -SRCREV = "6736d4b2a77cec00a8919f26035176c8b8025a4d" +SRCREV = "a3e8f2a391f389ffb2c379ca0c181e67de43824e" #SRC_URI = "git://github.com/openbmc/dbus-sensors.git" SRC_URI += "\ file://intrusionsensor-depend-on-networkd.conf \ + file://0001-Add-check-for-min-max-received-from-hwmon-files.patch \ + file://0002-Fix-PECI-client-creation-flow.patch \ " DEPENDS_append = " libgpiod libmctp" |