Skip to content

Commit

Permalink
Add UNC crossing option for FailSafe condition
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
JGEustaquio committed Jun 13, 2024
1 parent 8dc277c commit af97d8e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
29 changes: 29 additions & 0 deletions dbus/dbushelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "config.h"

#include "dbushelper.hpp"

Expand Down Expand Up @@ -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");
Expand All @@ -178,6 +181,32 @@ bool DbusHelper::thresholdsAsserted(const std::string& service,
{
asserted = std::get<bool>(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<bool>(findWarningHigh->second);
}
}
#endif
return asserted;
}

Expand Down
2 changes: 2 additions & 0 deletions dbus/dbushelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
19 changes: 19 additions & 0 deletions dbus/dbuspassive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<bool>(warningAlarmHigh->second);
}
owner->setFailed(asserted);
}
#endif
else if (msgSensor == "xyz.openbmc_project.State.Decorator.Availability")
{
auto available = msgData.find("Available");
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit af97d8e

Please sign in to comment.