power: Consider the exit latency required by an idle state

Set the timeout to expire "exit_latency_us" earlier to the CPU be
capable of honor the next scheduled event.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-04-02 10:49:01 -07:00 committed by Anas Nashif
parent 0f5cfa9f86
commit cdcd2dff85

View File

@ -6,6 +6,7 @@
#include <zephyr.h>
#include <kernel.h>
#include <timeout_q.h>
#include <init.h>
#include <string.h>
#include <power/power.h>
@ -180,6 +181,15 @@ enum pm_state pm_system_suspend(int32_t ticks)
}
post_ops_done = 0;
if (ticks != K_TICKS_FOREVER) {
/*
* We need to set the timer to interrupt a little bit early to
* accommodate the time required by the CPU to fully wake up.
*/
z_set_timeout_expiry(ticks -
k_us_to_ticks_ceil32(z_power_state.exit_latency_us), true);
}
#if CONFIG_PM_DEVICE
bool should_resume_devices = true;