Add threshold value scanning logic into cpusensor
Threshold values of a CPU sensor can be changed at runtime by BIOS
based on the thermal policy changes of the host machine. So this
commit adds runtime scanning logic for reading threshold values
from hwmon subsystem attributes.
Tested:
Check threshold properties in xyz.openbmc_projects.CPUSensor.
All threshold vaues should reflect peci hwmon values dynamically.
Change-Id: Ib5b0ce72f567437e69879a7e655d6f34f156013e
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 0d0dd1b..d8d0ecb 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -107,6 +107,25 @@
{
updateValue(nvalue);
}
+ if (!thresholds.empty())
+ {
+ std::vector<thresholds::Threshold> newThresholds;
+ if (parseThresholdsFromAttr(newThresholds, path,
+ CPUSensor::sensorScaleFactor))
+ {
+ if (!std::equal(thresholds.begin(), thresholds.end(),
+ newThresholds.begin(), newThresholds.end()))
+ {
+ thresholds = newThresholds;
+ thresholds::updateThresholds(this);
+ }
+ }
+ else
+ {
+ std::cerr << "Failure to update thresholds for " << name
+ << "\n";
+ }
+ }
errCount = 0;
}
catch (const std::invalid_argument&)