Update the saved power state after checking the restore policy
If the power state changes while power control is not running
(e.g. during BMC boot), the stored state can be left stale
causing it to behave incorrectly on a power-loss.
For example:
1. The system is shut down and the 'Off' state is saved.
2. The BMC is rebooted.
3. The power button is used to boot the system.
4. Power control will start with 'On' as the current state,
but with 'Off' still as the saved state.
5. The system loses power.
6. On restore, the previous state should be detected as 'On',
but is instead detected as 'Off'.
This change updates the saved power state to match the current
state after checking the restore policy.
Tested:
Ran the scenario above and confirmed that the system correctly
detected and restored the 'On' state in step 6.
Change-Id: Ia7b79f58c34150fe15434bb054de815a4f0d85e9
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index 49320fb..ba33124 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -626,6 +626,9 @@
std::cerr << "No power drop, restoring Host Off state\n";
}
}
+ // We're done with the previous power state for the restore policy, so store
+ // the current state
+ savePowerState(powerState);
}
static void powerRestorePolicyDelay(int delay)