IntelCPUSensor: Fix threshold hysteresis is nan Threshold's hysteresis is set to nan as default in constructor, the function parseThresholdsFromAttr will forcely update threshold's hysteresis as nan[1]. Because IntelCPUSensor will run parseThresholdsFromAttr in IntelCPUSensor::handleResponse, this nan will not be updated by hysteresisTrigger in function setInitialProperties[2]. When the threshold's hysteresis is always nan, the condition of deassert will never be satisfied. Update theshold's hysteresis to be 0 base on max/min chosed in IntelCPUSensor[3] because the function parseThresholdsFromAttr is only used by IntelCPUSensor for now. Refs: ``` [1] https://github.com/openbmc/dbus-sensors/blob/master/src/Thresholds.cpp#L519 [2] https://github.com/openbmc/dbus-sensors/blob/master/src/sensor.hpp#L277 [3] https://github.com/openbmc/dbus-sensors/blob/master/src/IntelCPUSensor.cpp#L46 ``` Tested: DIMM_B0_CPU0 sensor with threshold 93/95 as UWT/UCT, respectively. Enable flag 'insecure-sensor-override' and then set sensor value to 100 on dbus and then set sensor value to 50 on dbus. Before change: ``` root@qbmc:~# busctl introspect xyz.openbmc_project.IntelCPUSensor /xyz/openbmc_project/sensors/temperature/DIMM_B0_CPU0 NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Association.Definitions interface - - - .Associations property a(sss) 1 "chassis" "all_sensors" "/xyz/openb... emits-change xyz.openbmc_project.Sensor.Threshold.Critical interface - - - .CriticalAlarmHigh property b true emits-change .CriticalAlarmLow property b false emits-change .CriticalHigh property d 95 emits-change writable .CriticalLow property d nan emits-change writable xyz.openbmc_project.Sensor.Threshold.Warning interface - - - .WarningAlarmHigh property b true emits-change .WarningAlarmLow property b false emits-change .WarningHigh property d 93 emits-change writable .WarningLow property d nan emits-change writable xyz.openbmc_project.Sensor.Value interface - - - .MaxValue property d 127 emits-change .MinValue property d -128 emits-change .Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change .Value property d 50 emits-change writable xyz.openbmc_project.State.Decorator.Availability interface - - - .Available property b true emits-change writable xyz.openbmc_project.State.Decorator.OperationalStatus interface - - - .Functional property b true emits-change ``` After: ``` root@qbmc:~# busctl introspect xyz.openbmc_project.IntelCPUSensor /xyz/openbmc_project/sensors/temperature/DIMM_B0_CPU0 NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Association.Definitions interface - - - .Associations property a(sss) 1 "chassis" "all_sensors" "/xyz/openb... emits-change xyz.openbmc_project.Sensor.Threshold.Critical interface - - - .CriticalAlarmHigh property b false emits-change .CriticalAlarmLow property b false emits-change .CriticalHigh property d 95 emits-change writable .CriticalLow property d nan emits-change writable xyz.openbmc_project.Sensor.Threshold.Warning interface - - - .WarningAlarmHigh property b false emits-change .WarningAlarmLow property b false emits-change .WarningHigh property d 93 emits-change writable .WarningLow property d nan emits-change writable xyz.openbmc_project.Sensor.Value interface - - - .MaxValue property d 127 emits-change .MinValue property d -128 emits-change .Unit property s "xyz.openbmc_project.Sensor.Value.Uni... emits-change .Value property d 50 emits-change writable xyz.openbmc_project.State.Decorator.Availability interface - - - .Available property b true emits-change writable xyz.openbmc_project.State.Decorator.OperationalStatus interface - - - .Functional property b true emits-change ``` and the signal "ThresholdAsserted" for deassert is triggered. Change-Id: I107a2ac587f5791c47b9e7fd5a7c06ef4a312941 Signed-off-by: Jeff Lin <JeffLin2@quantatw.com>
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp index 5f56ae2..b751c67 100644 --- a/src/Thresholds.cpp +++ b/src/Thresholds.cpp
@@ -516,7 +516,7 @@ std::cout << "Threshold: " << attrPath << ": " << *val << "\n"; } - thresholdVector.emplace_back(level, direction, *val); + thresholdVector.emplace_back(level, direction, *val, 0); } } }