summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-10-25 10:56:51 -0500
committerMatthew Barth <msbarth@us.ibm.com>2017-11-17 13:14:11 -0600
commit2b3db618a00a1360d7a61cf0e712e1c50764297f (patch)
treeae3b28ca37a8afacca3beb8e6f803e496cb25c39
parent0decd1bd00ecb1d4b7357c49947ee19142ea8e27 (diff)
downloadphosphor-fan-presence-2b3db618a00a1360d7a61cf0e712e1c50764297f.tar.gz
phosphor-fan-presence-2b3db618a00a1360d7a61cf0e712e1c50764297f.zip
Init zone target speed to current target speed
Whenever fan control (control mode) is started, the target speed for each zone should be initialized to the currently set target speed. In the case where a watchdog has triggered the fans to full speed and the target speed does not reflect this, the proper set of set speed events should be configured. In this case, an event could be defined to use the current tach feedback to adjust the target speed prior to account for the real state of the fan speeds. Change-Id: I538644ffc83a6e01469174304d393c889038d066 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--control/fan.cpp17
-rw-r--r--control/fan.hpp15
-rw-r--r--control/zone.cpp5
3 files changed, 36 insertions, 1 deletions
diff --git a/control/fan.cpp b/control/fan.cpp
index fcbf4f8..1326451 100644
--- a/control/fan.cpp
+++ b/control/fan.cpp
@@ -20,6 +20,7 @@
#include <string>
#include "fan.hpp"
#include "utility.hpp"
+#include "sdbusplus.hpp"
namespace phosphor
{
@@ -43,10 +44,22 @@ Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def):
_bus(bus),
_name(std::get<fanNamePos>(def))
{
+ std::string path;
auto sensors = std::get<sensorListPos>(def);
for (auto& s : sensors)
{
- _sensors.emplace_back(FAN_SENSOR_PATH + s);
+ path = FAN_SENSOR_PATH + s;
+ _sensors.emplace_back(path);
+ }
+ // All sensors associated with this fan are set to same target speed,
+ // so only need to read target property from one.
+ if (!path.empty())
+ {
+ _targetSpeed = util::SDBusPlus::getProperty<uint64_t>(
+ bus,
+ path,
+ FAN_SENSOR_CONTROL_INTF,
+ FAN_TARGET_PROPERTY);
}
}
@@ -84,6 +97,8 @@ void Fan::setSpeed(uint64_t speed)
elog<InternalFailure>();
}
}
+
+ _targetSpeed = speed;
}
}
diff --git a/control/fan.hpp b/control/fan.hpp
index e23d44e..6975248 100644
--- a/control/fan.hpp
+++ b/control/fan.hpp
@@ -46,6 +46,16 @@ class Fan
*/
void setSpeed(uint64_t speed);
+ /**
+ * @brief Get the current fan target speed
+ *
+ * @return - The target speed of the fan
+ */
+ inline auto getTargetSpeed() const
+ {
+ return _targetSpeed;
+ }
+
private:
/**
@@ -71,6 +81,11 @@ class Fan
* Vector of hwmon sensors for the rotors
*/
std::vector<std::string> _sensors;
+
+ /**
+ * Target speed for this fan
+ */
+ uint64_t _targetSpeed;
};
diff --git a/control/zone.cpp b/control/zone.cpp
index 418b3ba..cb8ebfa 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -60,6 +60,11 @@ Zone::Zone(Mode mode,
// Do not enable set speed events when in init mode
if (mode != Mode::init)
{
+ // Update target speed to current zone target speed
+ if (!_fans.empty())
+ {
+ _targetSpeed = _fans.front()->getTargetSpeed();
+ }
// Setup signal trigger for set speed events
for (auto& event : std::get<setSpeedEventsPos>(def))
{
OpenPOWER on IntegriCloud