Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2017 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 16 | #include "fan.hpp" |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 17 | |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 18 | #include "logging.hpp" |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 19 | #include "sdbusplus.hpp" |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 20 | #include "system.hpp" |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 21 | #include "types.hpp" |
Matt Spinler | b1e1851 | 2017-04-27 14:42:33 -0500 | [diff] [blame] | 22 | #include "utility.hpp" |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 23 | |
Jay Meyer | a7aed01 | 2020-10-06 14:32:22 -0500 | [diff] [blame] | 24 | #include <fmt/format.h> |
| 25 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 26 | #include <phosphor-logging/log.hpp> |
| 27 | |
| 28 | #include <algorithm> |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 29 | |
| 30 | namespace phosphor |
| 31 | { |
| 32 | namespace fan |
| 33 | { |
| 34 | namespace monitor |
| 35 | { |
| 36 | |
| 37 | using namespace phosphor::logging; |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 38 | using namespace sdbusplus::bus::match; |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 39 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 40 | Fan::Fan(Mode mode, sdbusplus::bus::bus& bus, const sdeventplus::Event& event, |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 41 | std::unique_ptr<trust::Manager>& trust, const FanDefinition& def, |
| 42 | System& system) : |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 43 | _bus(bus), |
| 44 | _name(std::get<fanNameField>(def)), |
| 45 | _deviation(std::get<fanDeviationField>(def)), |
Matt Spinler | c39e859 | 2017-09-28 13:13:08 -0500 | [diff] [blame] | 46 | _numSensorFailsForNonFunc(std::get<numSensorFailsForNonfuncField>(def)), |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 47 | _trustManager(trust), |
| 48 | #ifdef MONITOR_USE_JSON |
| 49 | _monitorDelay(std::get<monitorStartDelayField>(def)), |
| 50 | _monitorTimer(event, std::bind(std::mem_fn(&Fan::startMonitor), this)), |
| 51 | #endif |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 52 | _system(system), |
| 53 | _presenceMatch(bus, |
| 54 | rules::propertiesChanged(util::INVENTORY_PATH + _name, |
| 55 | util::INV_ITEM_IFACE), |
| 56 | std::bind(std::mem_fn(&Fan::presenceChanged), this, |
Matt Spinler | 27f6b68 | 2020-10-27 08:43:37 -0500 | [diff] [blame] | 57 | std::placeholders::_1)), |
| 58 | _fanMissingErrorDelay(std::get<fanMissingErrDelayField>(def)) |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 59 | { |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 60 | // Start from a known state of functional (even if |
| 61 | // _numSensorFailsForNonFunc is 0) |
Jolie Ku | 4c3c24f | 2020-09-09 11:01:46 +0800 | [diff] [blame] | 62 | updateInventory(true); |
| 63 | |
Matthew Barth | 0a9fe16 | 2018-01-26 12:53:15 -0600 | [diff] [blame] | 64 | // Setup tach sensors for monitoring |
| 65 | auto& sensors = std::get<sensorListField>(def); |
| 66 | for (auto& s : sensors) |
| 67 | { |
| 68 | try |
| 69 | { |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 70 | _sensors.emplace_back(std::make_shared<TachSensor>( |
| 71 | mode, bus, *this, std::get<sensorNameField>(s), |
| 72 | std::get<hasTargetField>(s), std::get<funcDelay>(def), |
| 73 | std::get<targetInterfaceField>(s), std::get<factorField>(s), |
Jolie Ku | 69f2f48 | 2020-10-21 09:59:43 +0800 | [diff] [blame] | 74 | std::get<offsetField>(s), std::get<methodField>(def), |
| 75 | std::get<thresholdField>(s), std::get<timeoutField>(def), |
Matt Spinler | f13b42e | 2020-10-26 15:29:49 -0500 | [diff] [blame] | 76 | std::get<nonfuncRotorErrDelayField>(def), event)); |
Matthew Barth | 0a9fe16 | 2018-01-26 12:53:15 -0600 | [diff] [blame] | 77 | |
| 78 | _trustManager->registerSensor(_sensors.back()); |
| 79 | } |
| 80 | catch (InvalidSensorError& e) |
Jolie Ku | 4c3c24f | 2020-09-09 11:01:46 +0800 | [diff] [blame] | 81 | { |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 82 | // Count the number of failed tach sensors, though if |
| 83 | // _numSensorFailsForNonFunc is zero that means the fan should not |
| 84 | // be set to nonfunctional. |
| 85 | if (_numSensorFailsForNonFunc && |
| 86 | (++_numFailedSensor >= _numSensorFailsForNonFunc)) |
Jolie Ku | 5d564a9 | 2020-10-23 09:04:28 +0800 | [diff] [blame] | 87 | { |
| 88 | // Mark associated fan as nonfunctional |
| 89 | updateInventory(false); |
| 90 | } |
Jolie Ku | 4c3c24f | 2020-09-09 11:01:46 +0800 | [diff] [blame] | 91 | } |
Matthew Barth | 0a9fe16 | 2018-01-26 12:53:15 -0600 | [diff] [blame] | 92 | } |
| 93 | |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 94 | #ifndef MONITOR_USE_JSON |
Matthew Barth | 0a9fe16 | 2018-01-26 12:53:15 -0600 | [diff] [blame] | 95 | // Check current tach state when entering monitor mode |
Matthew Barth | 6ad2843 | 2017-08-22 11:18:19 -0500 | [diff] [blame] | 96 | if (mode != Mode::init) |
| 97 | { |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 98 | _monitorReady = true; |
| 99 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 100 | // The TachSensors will now have already read the input |
| 101 | // and target values, so check them. |
Matthew Barth | 6ad2843 | 2017-08-22 11:18:19 -0500 | [diff] [blame] | 102 | tachChanged(); |
| 103 | } |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 104 | #else |
| 105 | // If it used the JSON config, then it also will do all the work |
| 106 | // out of fan-monitor-init, after _monitorDelay. |
| 107 | _monitorTimer.restartOnce(std::chrono::seconds(_monitorDelay)); |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 108 | #endif |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 109 | |
| 110 | // Get the initial presence state |
| 111 | _present = util::SDBusPlus::getProperty<bool>( |
| 112 | util::INVENTORY_PATH + _name, util::INV_ITEM_IFACE, "Present"); |
Matt Spinler | 27f6b68 | 2020-10-27 08:43:37 -0500 | [diff] [blame] | 113 | |
| 114 | if (_fanMissingErrorDelay) |
| 115 | { |
| 116 | _fanMissingErrorTimer = std::make_unique< |
| 117 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>( |
| 118 | event, std::bind(&System::fanMissingErrorTimerExpired, &system, |
| 119 | std::ref(*this))); |
| 120 | |
| 121 | if (!_present) |
| 122 | { |
| 123 | // The fan presence application handles the journal for missing |
| 124 | // fans, so only internally log missing fan info here. |
| 125 | getLogger().log(fmt::format("On startup, fan {} is missing", _name), |
| 126 | Logger::quiet); |
| 127 | _fanMissingErrorTimer->restartOnce( |
| 128 | std::chrono::seconds{*_fanMissingErrorDelay}); |
| 129 | } |
| 130 | } |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void Fan::startMonitor() |
| 134 | { |
| 135 | _monitorReady = true; |
| 136 | |
| 137 | tachChanged(); |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 138 | } |
| 139 | |
Matt Spinler | ebaae61 | 2017-04-27 14:21:48 -0500 | [diff] [blame] | 140 | void Fan::tachChanged() |
| 141 | { |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 142 | if (_monitorReady) |
Matt Spinler | ebaae61 | 2017-04-27 14:21:48 -0500 | [diff] [blame] | 143 | { |
Matt Spinler | b0412d0 | 2020-10-12 16:53:52 -0500 | [diff] [blame] | 144 | for (auto& s : _sensors) |
| 145 | { |
| 146 | tachChanged(*s); |
| 147 | } |
Matt Spinler | ebaae61 | 2017-04-27 14:21:48 -0500 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
Matt Spinler | ebaae61 | 2017-04-27 14:21:48 -0500 | [diff] [blame] | 151 | void Fan::tachChanged(TachSensor& sensor) |
| 152 | { |
Matt Spinler | c39e859 | 2017-09-28 13:13:08 -0500 | [diff] [blame] | 153 | if (_trustManager->active()) |
| 154 | { |
| 155 | if (!_trustManager->checkTrust(sensor)) |
| 156 | { |
| 157 | return; |
| 158 | } |
| 159 | } |
| 160 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 161 | // If this sensor is out of range at this moment, start |
| 162 | // its timer, at the end of which the inventory |
| 163 | // for the fan may get updated to not functional. |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 164 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 165 | // If this sensor is OK, put everything back into a good state. |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 166 | |
| 167 | if (outOfRange(sensor)) |
| 168 | { |
Matthew Barth | e11cbc6 | 2018-02-20 12:11:07 -0600 | [diff] [blame] | 169 | if (sensor.functional()) |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 170 | { |
Jolie Ku | 69f2f48 | 2020-10-21 09:59:43 +0800 | [diff] [blame] | 171 | switch (sensor.getMethod()) |
| 172 | { |
| 173 | case MethodMode::timebased: |
| 174 | // Start nonfunctional timer if not already running |
| 175 | sensor.startTimer(TimerMode::nonfunc); |
| 176 | break; |
| 177 | case MethodMode::count: |
| 178 | sensor.setCounter(true); |
| 179 | if (sensor.getCounter() >= sensor.getThreshold()) |
| 180 | { |
| 181 | updateState(sensor); |
| 182 | } |
| 183 | break; |
| 184 | } |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 185 | } |
| 186 | } |
| 187 | else |
| 188 | { |
Jolie Ku | 69f2f48 | 2020-10-21 09:59:43 +0800 | [diff] [blame] | 189 | switch (sensor.getMethod()) |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 190 | { |
Jolie Ku | 69f2f48 | 2020-10-21 09:59:43 +0800 | [diff] [blame] | 191 | case MethodMode::timebased: |
| 192 | if (sensor.functional()) |
| 193 | { |
| 194 | sensor.stopTimer(); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | // Start functional timer if not already running |
| 199 | sensor.startTimer(TimerMode::func); |
| 200 | } |
| 201 | break; |
| 202 | case MethodMode::count: |
| 203 | sensor.setCounter(false); |
| 204 | if (!sensor.functional() && sensor.getCounter() == 0) |
| 205 | { |
| 206 | updateState(sensor); |
| 207 | } |
| 208 | break; |
Matt Spinler | a4c8f1f | 2017-04-27 14:38:38 -0500 | [diff] [blame] | 209 | } |
| 210 | } |
Matt Spinler | ebaae61 | 2017-04-27 14:21:48 -0500 | [diff] [blame] | 211 | } |
| 212 | |
Matthew Barth | f552ea5 | 2018-01-15 16:22:04 -0600 | [diff] [blame] | 213 | uint64_t Fan::findTargetSpeed() |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 214 | { |
| 215 | uint64_t target = 0; |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 216 | // The sensor doesn't support a target, |
| 217 | // so get it from another sensor. |
Matthew Barth | f552ea5 | 2018-01-15 16:22:04 -0600 | [diff] [blame] | 218 | auto s = std::find_if(_sensors.begin(), _sensors.end(), |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 219 | [](const auto& s) { return s->hasTarget(); }); |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 220 | |
Matthew Barth | f552ea5 | 2018-01-15 16:22:04 -0600 | [diff] [blame] | 221 | if (s != _sensors.end()) |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 222 | { |
Matthew Barth | f552ea5 | 2018-01-15 16:22:04 -0600 | [diff] [blame] | 223 | target = (*s)->getTarget(); |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | return target; |
| 227 | } |
| 228 | |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 229 | bool Fan::tooManySensorsNonfunctional() |
| 230 | { |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 231 | size_t numFailed = |
| 232 | std::count_if(_sensors.begin(), _sensors.end(), |
| 233 | [](const auto& s) { return !s->functional(); }); |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 234 | |
| 235 | return (numFailed >= _numSensorFailsForNonFunc); |
| 236 | } |
| 237 | |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 238 | bool Fan::outOfRange(const TachSensor& sensor) |
| 239 | { |
| 240 | auto actual = static_cast<uint64_t>(sensor.getInput()); |
Matthew Barth | 5008daf | 2018-01-15 16:38:24 -0600 | [diff] [blame] | 241 | auto target = sensor.getTarget(); |
Lei YU | 8e5d197 | 2018-01-26 17:14:00 +0800 | [diff] [blame] | 242 | auto factor = sensor.getFactor(); |
| 243 | auto offset = sensor.getOffset(); |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 244 | |
| 245 | uint64_t min = target * (100 - _deviation) / 100; |
| 246 | uint64_t max = target * (100 + _deviation) / 100; |
| 247 | |
Lei YU | 8e5d197 | 2018-01-26 17:14:00 +0800 | [diff] [blame] | 248 | // TODO: openbmc/openbmc#2937 enhance this function |
| 249 | // either by making it virtual, or by predefining different |
| 250 | // outOfRange ops and selecting by yaml config |
| 251 | min = min * factor + offset; |
| 252 | max = max * factor + offset; |
Matt Spinler | abf8da3 | 2017-04-27 14:08:45 -0500 | [diff] [blame] | 253 | if ((actual < min) || (actual > max)) |
| 254 | { |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | return false; |
| 259 | } |
| 260 | |
Jolie Ku | 69f2f48 | 2020-10-21 09:59:43 +0800 | [diff] [blame] | 261 | void Fan::updateState(TachSensor& sensor) |
Matt Spinler | a9406a7 | 2017-04-27 14:29:24 -0500 | [diff] [blame] | 262 | { |
Matthew Barth | e11cbc6 | 2018-02-20 12:11:07 -0600 | [diff] [blame] | 263 | sensor.setFunctional(!sensor.functional()); |
| 264 | |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 265 | getLogger().log( |
| 266 | fmt::format("Setting tach sensor {} functional state to {}. " |
| 267 | "Actual speed: {} Target speed: {}", |
| 268 | sensor.name(), sensor.functional(), sensor.getInput(), |
| 269 | sensor.getTarget())); |
| 270 | |
| 271 | // A zero value for _numSensorFailsForNonFunc means we aren't dealing |
| 272 | // with fan FRU functional status, only sensor functional status. |
| 273 | if (_numSensorFailsForNonFunc) |
Matthew Barth | e11cbc6 | 2018-02-20 12:11:07 -0600 | [diff] [blame] | 274 | { |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 275 | // If the fan was nonfunctional and enough sensors are now OK, |
| 276 | // the fan can go back to functional |
| 277 | if (!_functional && !tooManySensorsNonfunctional()) |
| 278 | { |
| 279 | getLogger().log( |
| 280 | fmt::format("Setting fan {} back to functional", _name)); |
Matthew Barth | e11cbc6 | 2018-02-20 12:11:07 -0600 | [diff] [blame] | 281 | |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 282 | updateInventory(true); |
| 283 | } |
Matt Spinler | a9406a7 | 2017-04-27 14:29:24 -0500 | [diff] [blame] | 284 | |
Matt Spinler | ae1f8ef | 2020-10-14 16:15:51 -0500 | [diff] [blame] | 285 | // If the fan is currently functional, but too many |
| 286 | // contained sensors are now nonfunctional, update |
| 287 | // the whole fan nonfunctional. |
| 288 | if (_functional && tooManySensorsNonfunctional()) |
| 289 | { |
| 290 | getLogger().log(fmt::format("Setting fan {} to nonfunctional " |
| 291 | "Sensor: {} " |
| 292 | "Actual speed: {} " |
| 293 | "Target speed: {}", |
| 294 | _name, sensor.name(), sensor.getInput(), |
| 295 | sensor.getTarget())); |
| 296 | updateInventory(false); |
| 297 | } |
Matt Spinler | b1e1851 | 2017-04-27 14:42:33 -0500 | [diff] [blame] | 298 | } |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 299 | |
| 300 | _system.fanStatusChange(*this); |
Matt Spinler | a9406a7 | 2017-04-27 14:29:24 -0500 | [diff] [blame] | 301 | } |
| 302 | |
Matt Spinler | b1e1851 | 2017-04-27 14:42:33 -0500 | [diff] [blame] | 303 | void Fan::updateInventory(bool functional) |
| 304 | { |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 305 | auto objectMap = |
| 306 | util::getObjMap<bool>(_name, util::OPERATIONAL_STATUS_INTF, |
| 307 | util::FUNCTIONAL_PROPERTY, functional); |
Matthew Barth | 51dd185 | 2017-11-16 15:21:13 -0600 | [diff] [blame] | 308 | auto response = util::SDBusPlus::lookupAndCallMethod( |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 309 | _bus, util::INVENTORY_PATH, util::INVENTORY_INTF, "Notify", objectMap); |
Matt Spinler | b1e1851 | 2017-04-27 14:42:33 -0500 | [diff] [blame] | 310 | if (response.is_method_error()) |
| 311 | { |
| 312 | log<level::ERR>("Error in Notify call to update inventory"); |
| 313 | return; |
| 314 | } |
| 315 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 316 | // This will always track the current state of the inventory. |
Matt Spinler | b1e1851 | 2017-04-27 14:42:33 -0500 | [diff] [blame] | 317 | _functional = functional; |
| 318 | } |
| 319 | |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 320 | void Fan::presenceChanged(sdbusplus::message::message& msg) |
| 321 | { |
| 322 | std::string interface; |
| 323 | std::map<std::string, std::variant<bool>> properties; |
| 324 | |
| 325 | msg.read(interface, properties); |
| 326 | |
| 327 | auto presentProp = properties.find("Present"); |
| 328 | if (presentProp != properties.end()) |
| 329 | { |
| 330 | _present = std::get<bool>(presentProp->second); |
| 331 | |
Matt Spinler | 27f6b68 | 2020-10-27 08:43:37 -0500 | [diff] [blame] | 332 | getLogger().log( |
| 333 | fmt::format("Fan {} presence state change to {}", _name, _present), |
| 334 | Logger::quiet); |
| 335 | |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 336 | _system.fanStatusChange(*this); |
Matt Spinler | 27f6b68 | 2020-10-27 08:43:37 -0500 | [diff] [blame] | 337 | |
| 338 | if (_fanMissingErrorDelay) |
| 339 | { |
| 340 | if (!_present) |
| 341 | { |
| 342 | _fanMissingErrorTimer->restartOnce( |
| 343 | std::chrono::seconds{*_fanMissingErrorDelay}); |
| 344 | } |
| 345 | else if (_fanMissingErrorTimer->isEnabled()) |
| 346 | { |
| 347 | _fanMissingErrorTimer->setEnabled(false); |
| 348 | } |
| 349 | } |
Matt Spinler | b63aa09 | 2020-10-14 09:45:11 -0500 | [diff] [blame] | 350 | } |
| 351 | } |
Matt Spinler | f13b42e | 2020-10-26 15:29:49 -0500 | [diff] [blame] | 352 | |
| 353 | void Fan::sensorErrorTimerExpired(const TachSensor& sensor) |
| 354 | { |
| 355 | if (_present) |
| 356 | { |
| 357 | _system.sensorErrorTimerExpired(*this, sensor); |
| 358 | } |
| 359 | } |
| 360 | |
Matthew Barth | 177fe98 | 2020-05-26 11:05:19 -0500 | [diff] [blame] | 361 | } // namespace monitor |
| 362 | } // namespace fan |
| 363 | } // namespace phosphor |