Power: change sys_pm_force_power_state only works for one shot

Change sys_pm_force_power_state only works for the current ongoing
suspend operation, before the end of syspend state forced_pm_state
will be cleared.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
Wentong Wu 2020-01-22 03:29:50 -05:00 committed by Anas Nashif
commit a9bd208b5b
2 changed files with 8 additions and 7 deletions

View file

@ -146,14 +146,13 @@ static inline void _sys_pm_idle_exit_notification_disable(void)
/**
* @brief Force usage of given power state.
*
* This function overrides decision made by PM policy
* forcing usage of given power state in all subsequent
* suspend operations. Forcing the SYS_POWER_STATE_AUTO
* state restores normal operation.
* This function overrides decision made by PM policy forcing
* usage of given power state in the ongoing suspend operation.
* And before the end of suspend, the state of forced_pm_state
* is cleared with interrupt disabled.
*
* @param state Power state which should be used in all
* subsequent suspend operations or
* SYS_POWER_STATE_AUTO.
* @param state Power state which should be used in the ongoing
* suspend operation or SYS_POWER_STATE_AUTO.
*/
void sys_pm_force_power_state(enum power_states state);

View file

@ -152,6 +152,8 @@ enum power_states _sys_suspend(s32_t ticks)
if (!post_ops_done) {
post_ops_done = 1;
/* clear forced_pm_state */
forced_pm_state = SYS_POWER_STATE_AUTO;
sys_pm_notify_power_state_exit(pm_state);
_sys_pm_power_state_exit_post_ops(pm_state);
}