From af97d8ef1350349b0de9fde392dd445ce48b2999 Mon Sep 17 00:00:00 2001 From: Jonico Eustaquio Date: Tue, 2 Jan 2024 14:35:07 -0600 Subject: [PATCH] Add UNC crossing option for FailSafe condition Added a unc-failsafe meson option that if set to true, would then check if any temperature sensor PIDs exceed their upper non-critical threshold. If a sensor is detected to have exceeded their UNC, then the zone associated with that PID would go to FailSafe. By default, this option will be set to false for backwards compatibility. Change-Id: I2fbc6000e8d37b34c51d3578becdaf18d449b0e8 Signed-off-by: Jonico Eustaquio --- dbus/dbushelper.cpp | 29 +++++++++++++++++++++++++++++ dbus/dbushelper.hpp | 2 ++ dbus/dbuspassive.cpp | 19 +++++++++++++++++++ meson.build | 1 + meson.options | 1 + 5 files changed, 52 insertions(+) diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp index 54c75ca8..038e7844 100644 --- a/dbus/dbushelper.cpp +++ b/dbus/dbushelper.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "config.h" #include "dbushelper.hpp" @@ -160,7 +161,9 @@ bool DbusHelper::thresholdsAsserted(const std::string& service, catch (const sdbusplus::exception_t&) { // do nothing, sensors don't have to expose critical thresholds +#ifndef UNC_FAILSAFE return false; +#endif } auto findCriticalLow = criticalMap.find("CriticalAlarmLow"); @@ -178,6 +181,32 @@ bool DbusHelper::thresholdsAsserted(const std::string& service, { asserted = std::get(findCriticalHigh->second); } +#ifdef UNC_FAILSAFE + if (!asserted) + { + auto warning = _bus.new_method_call(service.c_str(), path.c_str(), + propertiesintf, "GetAll"); + warning.append(warningThreshInf); + PropertyMap warningMap; + + try + { + auto msg = _bus.call(warning); + msg.read(warningMap); + } + catch (const sdbusplus::exception_t&) + { + // sensors don't have to expose non-critical thresholds + return false; + } + auto findWarningHigh = warningMap.find("WarningAlarmHigh"); + + if (findWarningHigh != warningMap.end()) + { + asserted = std::get(findWarningHigh->second); + } + } +#endif return asserted; } diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp index 50868265..7d2be2d0 100644 --- a/dbus/dbushelper.hpp +++ b/dbus/dbushelper.hpp @@ -18,6 +18,8 @@ class DbusHelper : public DbusHelperInterface static constexpr char propertiesintf[] = "org.freedesktop.DBus.Properties"; static constexpr char criticalThreshInf[] = "xyz.openbmc_project.Sensor.Threshold.Critical"; + static constexpr char warningThreshInf[] = + "xyz.openbmc_project.Sensor.Threshold.Warning"; static constexpr char availabilityIntf[] = "xyz.openbmc_project.State.Decorator.Availability"; diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp index ac0d5cf7..09637361 100644 --- a/dbus/dbuspassive.cpp +++ b/dbus/dbuspassive.cpp @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "config.h" + #include "dbuspassive.hpp" #include "dbushelper_interface.hpp" @@ -305,6 +307,23 @@ int handleSensorValue(sdbusplus::message_t& msg, DbusPassive* owner) } owner->setFailed(asserted); } +#ifdef UNC_FAILSAFE + else if (msgSensor == "xyz.openbmc_project.Sensor.Threshold.Warning") + { + auto warningAlarmHigh = msgData.find("WarningAlarmHigh"); + if (warningAlarmHigh == msgData.end()) + { + return 0; + } + + bool asserted = false; + if (warningAlarmHigh != msgData.end()) + { + asserted = std::get(warningAlarmHigh->second); + } + owner->setFailed(asserted); + } +#endif else if (msgSensor == "xyz.openbmc_project.State.Decorator.Availability") { auto available = msgData.find("Available"); diff --git a/meson.build b/meson.build index 2a1b06c8..57c25dcb 100644 --- a/meson.build +++ b/meson.build @@ -19,6 +19,7 @@ conf_data.set('BINDIR', bindir) conf_data.set('SYSTEMD_TARGET', get_option('systemd_target')) conf_data.set('STRICT_FAILSAFE_PWM', get_option('strict-failsafe-pwm')) conf_data.set('OFFLINE_FAILSAFE_PWM', get_option('offline-failsafe-pwm')) +conf_data.set('UNC_FAILSAFE', get_option('unc-failsafe')) configure_file(output: 'config.h', configuration: conf_data diff --git a/meson.options b/meson.options index fc65cdb4..a33730f9 100644 --- a/meson.options +++ b/meson.options @@ -3,3 +3,4 @@ option('oe-sdk', type: 'feature', value: 'disabled', description: 'Enable OE SDK option('strict-failsafe-pwm', type: 'boolean', value: false, description: 'Set the fans strictly at the failsafe PWM when in failsafe mode') option('offline-failsafe-pwm', type: 'boolean', value: false, description: 'Set the fans at the failsafe PWM when reloading or terminated.') option('systemd_target', type: 'string', value: 'multi-user.target', description: 'Target for starting this service') +option('unc-failsafe', type: 'boolean', value: false, description: 'Set the fans to failsafe mode when a temp sensor is above upper non-critical threshold')