From a964223bba361d62e14621137b353daaf3dacdc8 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Wed, 24 Jan 2018 21:59:42 -0600 Subject: Add fan shutdown option to stop rotors after chassis powerdown --- control/argument.cpp | 5 ++++- control/fan.cpp | 10 ++++++++++ control/fan.hpp | 5 +++++ control/main.cpp | 10 ++++++++++ control/manager.cpp | 9 +++++++++ control/manager.hpp | 6 ++++++ control/zone.cpp | 9 +++++++++ control/zone.hpp | 10 +++++++++- 8 files changed, 62 insertions(+), 2 deletions(-) diff --git a/control/argument.cpp b/control/argument.cpp index e014453..e46200f 100644 --- a/control/argument.cpp +++ b/control/argument.cpp @@ -1,5 +1,6 @@ /** * Copyright © 2017 IBM Corporation + * Copyright © 2017-2018 Raptor Engineering, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,6 +70,7 @@ void ArgumentParser::usage(char** argv) std::cerr << " --help Print this menu\n"; std::cerr << " --init Sets fans to full speed, delays, exits\n"; std::cerr << " --control Start fan control algorithm\n"; + std::cerr << " --shutdown Shut down fan control algorithm *and* fans. ONLY use after chassis powerdown!\n"; std::cerr << std::flush; } @@ -76,11 +78,12 @@ const option ArgumentParser::options[] = { { "init", no_argument, NULL, 'i' }, { "control", no_argument, NULL, 'c' }, + { "shutdown", no_argument, NULL, 's' }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0}, }; -const char* ArgumentParser::optionstr = "ich?"; +const char* ArgumentParser::optionstr = "icsh?"; const std::string ArgumentParser::true_string = "true"; const std::string ArgumentParser::empty_string = ""; diff --git a/control/fan.cpp b/control/fan.cpp index c86186f..50d1469 100644 --- a/control/fan.cpp +++ b/control/fan.cpp @@ -1,5 +1,6 @@ /** * Copyright © 2017 IBM Corporation + * Copyright © 2017-2018 Raptor Engineering, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,6 +90,15 @@ void Fan::setSpeed(uint64_t speed) _targetSpeed = speed; } +void Fan::disableRotor() +{ + // TODO + // This should set the enable value of the hwmon PWM entry + // For now, just set the fan speed to 0 + + setSpeed(0); +} + } } } diff --git a/control/fan.hpp b/control/fan.hpp index 3e05e16..65fff4b 100644 --- a/control/fan.hpp +++ b/control/fan.hpp @@ -56,6 +56,11 @@ class Fan return _targetSpeed; } + /** + * Disables the fan, stopping the rotor + */ + void disableRotor(); + private: /** diff --git a/control/main.cpp b/control/main.cpp index 4420488..10492b8 100644 --- a/control/main.cpp +++ b/control/main.cpp @@ -1,5 +1,6 @@ /** * Copyright © 2017 IBM Corporation + * Copyright © 2017-2018 Raptor Engineering, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +46,10 @@ int main(int argc, char* argv[]) { mode = Mode::control; } + else if (args["shutdown"] == "true") + { + mode = Mode::shutdown; + } else { args.usage(argv); @@ -65,6 +70,11 @@ int main(int argc, char* argv[]) manager.doInit(); return 0; } + else if (mode == Mode::shutdown) + { + manager.doShutdown(); + return 0; + } return event.loop(); } diff --git a/control/manager.cpp b/control/manager.cpp index 360239c..cbcb1d3 100644 --- a/control/manager.cpp +++ b/control/manager.cpp @@ -1,5 +1,6 @@ /** * Copyright © 2017 IBM Corporation + * Copyright © 2017-2018 Raptor Engineering, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -147,6 +148,14 @@ void Manager::doInit() "replace"); } +void Manager::doShutdown() +{ + for (auto& z : _zones) + { + z.second->disableRotors(); + } +} + } // namespace control } // namespace fan } // namespace phosphor diff --git a/control/manager.hpp b/control/manager.hpp index c87d0d8..5e831f5 100644 --- a/control/manager.hpp +++ b/control/manager.hpp @@ -51,6 +51,12 @@ class Manager */ void doInit(); + /** + * Does the fan control and chassis fan shutdown, which + * disables the fans entirely (stops all rotors) + */ + void doShutdown(); + private: /** diff --git a/control/zone.cpp b/control/zone.cpp index fddca53..468a605 100644 --- a/control/zone.cpp +++ b/control/zone.cpp @@ -1,5 +1,6 @@ /** * Copyright © 2017 IBM Corporation + * Copyright © 2017-2018 Raptor Engineering, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,6 +124,14 @@ void Zone::setFullSpeed() } } +void Zone::disableRotors() +{ + for (auto& fan : _fans) + { + fan->disableRotor(); + } +} + void Zone::setActiveAllow(const Group* group, bool isActiveAllow) { _active[*(group)] = isActiveAllow; diff --git a/control/zone.hpp b/control/zone.hpp index 6da3091..ec0d9bb 100644 --- a/control/zone.hpp +++ b/control/zone.hpp @@ -24,11 +24,13 @@ using ThermalObject = sdbusplus::server::object::object< * The mode fan control will run in: * - init - only do the initialization steps * - control - run normal control algorithms + * - init - shutdown fans, stopping all rotors */ enum class Mode { init, - control + control, + shutdown }; /** @@ -76,6 +78,12 @@ class Zone : public ThermalObject */ void setFullSpeed(); + /** + * Disables the zone and stops all zone fans regardless of + * zone's active state + */ + void disableRotors(); + /** * @brief Sets the automatic fan control allowed active state * -- cgit v1.2.1