diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch')
-rw-r--r-- | meta-openbmc-mods/meta-common/recipes-phosphor/sensors/dbus-sensors/0002-Fix-PECI-client-creation-flow.patch | 159 |
1 files changed, 159 insertions, 0 deletions
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..cfdc99d66 --- /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 0a1b2a13f6dbc64b5851ac2b1ca99d57afa78d60 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 f304e3f..92c1716 100644 +--- a/src/CPUSensorMain.cpp ++++ b/src/CPUSensorMain.cpp +@@ -82,6 +82,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; +@@ -167,7 +168,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, 6)) + { +@@ -403,7 +404,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; +@@ -411,9 +412,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)) + { +@@ -431,20 +435,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, +@@ -460,6 +482,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) +@@ -510,16 +537,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) +@@ -542,6 +582,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 + |