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>
1 file changed
tree: 93f72823c2a408b13300f243d8f53902e0b0b22a
  1. include/
  2. service_files/
  3. src/
  4. subprojects/
  5. tests/
  6. .clang-format
  7. .clang-tidy
  8. .gitignore
  9. LICENSE
  10. meson.build
  11. meson_options.txt
  12. OWNERS
  13. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access

dbus interfaces

A typical dbus-sensors object support the following dbus interfaces:

Path        /xyz/openbmc_project/sensors/<type>/<sensor_name>

Interfaces  xyz.openbmc_project.Sensor.Value
            xyz.openbmc_project.Sensor.Threshold.Critical
            xyz.openbmc_project.Sensor.Threshold.Warning
            xyz.openbmc_project.State.Decorator.Availability
            xyz.openbmc_project.State.Decorator.OperationalStatus
            xyz.openbmc_project.Association.Definitions

Sensor interfaces collection are described here.

Consumer examples of these interfaces are Redfish, Phosphor-Pid-Control, IPMI SDR.

Reactor

dbus-sensor daemons are reactors that dynamically create and update sensors configuration when system configuration gets updated.

Using asio timers and async calls, dbus-sensor daemons read sensor values and check thresholds periodically. PropertiesChanged signals will be broadcasted for other services to consume when value or threshold status change. OperationStatus is set to false if the sensor is determined to be faulty.

A simple sensor example can be found here.

configuration

Sensor devices are described using Exposes records in configuration file. Name and Type fields are required. Different sensor types have different fields. Refer to entity manager schema for complete list.

sensor documentation