pm: policy: residency: add compile time checks for timings
Check that minimum residency time is greater than exit latency time for all CPUs power states at compile time. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
d5036eca42
commit
03232f925c
2 changed files with 30 additions and 10 deletions
|
@ -206,14 +206,6 @@ bool pm_system_suspend(int32_t ticks)
|
|||
}
|
||||
|
||||
if (ticks != K_TICKS_FOREVER) {
|
||||
/*
|
||||
* Just a sanity check in case the policy manager does not
|
||||
* handle this error condition properly.
|
||||
*/
|
||||
__ASSERT(z_power_states[id].min_residency_us >=
|
||||
z_power_states[id].exit_latency_us,
|
||||
"min_residency_us < exit_latency_us");
|
||||
|
||||
/*
|
||||
* We need to set the timer to interrupt a little bit early to
|
||||
* accommodate the time required by the CPU to fully wake up.
|
||||
|
|
|
@ -14,6 +14,36 @@
|
|||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(pm, CONFIG_PM_LOG_LEVEL);
|
||||
|
||||
/**
|
||||
* Check CPU power state consistency.
|
||||
*
|
||||
* @param i Power state index.
|
||||
* @param node_id CPU node identifier.
|
||||
*/
|
||||
#define CHECK_POWER_STATE_CONSISTENCY(i, node_id) \
|
||||
BUILD_ASSERT( \
|
||||
DT_PROP_BY_PHANDLE_IDX_OR(node_id, cpu_power_states, i, \
|
||||
min_residency_us, 0U) >= \
|
||||
DT_PROP_BY_PHANDLE_IDX_OR(node_id, cpu_power_states, i, \
|
||||
exit_latency_us, 0U), \
|
||||
"Found CPU power state with min_residency < exit_latency");
|
||||
|
||||
/**
|
||||
* @brief Check CPU power states consistency
|
||||
*
|
||||
* All states should have a minimum residency >= than the exit latency.
|
||||
*
|
||||
* @param node_id A CPU node identifier.
|
||||
*/
|
||||
#define CHECK_POWER_STATES_CONSISTENCY(node_id) \
|
||||
UTIL_LISTIFY(DT_NUM_CPU_POWER_STATES(node_id), \
|
||||
CHECK_POWER_STATE_CONSISTENCY, node_id) \
|
||||
|
||||
/* Check that all power states are consistent */
|
||||
COND_CODE_1(DT_NODE_EXISTS(DT_PATH(cpus)),
|
||||
(DT_FOREACH_CHILD(DT_PATH(cpus), CHECK_POWER_STATES_CONSISTENCY)),
|
||||
())
|
||||
|
||||
#define NUM_CPU_STATES(n) DT_NUM_CPU_POWER_STATES(n),
|
||||
#define CPU_STATES(n) (struct pm_state_info[])PM_STATE_INFO_LIST_FROM_DT_CPU(n),
|
||||
|
||||
|
@ -47,8 +77,6 @@ struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
|
|||
|
||||
min_residency = k_us_to_ticks_ceil32(state->min_residency_us);
|
||||
exit_latency = k_us_to_ticks_ceil32(state->exit_latency_us);
|
||||
__ASSERT(min_residency > exit_latency,
|
||||
"min_residency_us < exit_latency_us");
|
||||
|
||||
if ((ticks == K_TICKS_FOREVER) ||
|
||||
(ticks >= (min_residency + exit_latency))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue