pm: policy: Add cpu information in the API
On multicore environments the policy may need to know which CPU is idle. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
9765e93064
commit
dd152c2b89
7 changed files with 19 additions and 8 deletions
|
@ -22,11 +22,12 @@ extern "C" {
|
|||
* idle and returns the most appropriate state based on the number of
|
||||
* ticks to the next event.
|
||||
*
|
||||
* @param cpu CPU index.
|
||||
* @param ticks The number of ticks to the next scheduled event.
|
||||
*
|
||||
* @return The power state the system should use.
|
||||
* @return The power state the system should use for the given cpu.
|
||||
*/
|
||||
struct pm_state_info pm_policy_next_state(int32_t ticks);
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks);
|
||||
|
||||
/** @endcond */
|
||||
|
||||
|
|
|
@ -18,12 +18,14 @@ LOG_MODULE_DECLARE(power, CONFIG_PM_LOG_LEVEL);
|
|||
static const struct pm_state_info pm_dummy_states[] =
|
||||
PM_STATE_INFO_DT_ITEMS_LIST(DT_NODELABEL(cpu0));
|
||||
|
||||
struct pm_state_info pm_policy_next_state(int32_t ticks)
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
|
||||
{
|
||||
static struct pm_state_info cur_pm_state_info;
|
||||
int i = (int)cur_pm_state_info.state;
|
||||
uint8_t states_len = ARRAY_SIZE(pm_dummy_states);
|
||||
|
||||
ARG_UNUSED(cpu);
|
||||
|
||||
if (states_len == 0) {
|
||||
/* No power states to go through. */
|
||||
return STATE_ACTIVE;
|
||||
|
|
|
@ -16,10 +16,12 @@ LOG_MODULE_DECLARE(power);
|
|||
static const struct pm_state_info pm_min_residency[] =
|
||||
PM_STATE_INFO_DT_ITEMS_LIST(DT_NODELABEL(cpu0));
|
||||
|
||||
struct pm_state_info pm_policy_next_state(int32_t ticks)
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
|
||||
{
|
||||
int i;
|
||||
|
||||
ARG_UNUSED(cpu);
|
||||
|
||||
for (i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
|
||||
uint32_t min_residency, exit_latency;
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ enum pm_state pm_system_suspend(int32_t ticks)
|
|||
uint8_t id = _current_cpu->id;
|
||||
|
||||
SYS_PORT_TRACING_FUNC_ENTER(pm, system_suspend, ticks);
|
||||
z_power_states[id] = pm_policy_next_state(ticks);
|
||||
z_power_states[id] = pm_policy_next_state(id, ticks);
|
||||
if (z_power_states[id].state == PM_STATE_ACTIVE) {
|
||||
LOG_DBG("No PM operations done.");
|
||||
SYS_PORT_TRACING_FUNC_EXIT(pm, system_suspend, ticks,
|
||||
|
|
|
@ -23,10 +23,12 @@ static void tdata_dump_callback(const struct k_thread *thread, void *user_data)
|
|||
}
|
||||
|
||||
/* Our PM policy handler */
|
||||
struct pm_state_info pm_policy_next_state(int32_t ticks)
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
|
||||
{
|
||||
static bool test_flag;
|
||||
|
||||
ARG_UNUSED(cpu);
|
||||
|
||||
/* Call k_thread_foreach only once otherwise it will
|
||||
* flood the console with stack dumps.
|
||||
*/
|
||||
|
|
|
@ -57,8 +57,10 @@ void pm_power_state_exit_post_ops(struct pm_state_info info)
|
|||
irq_unlock(0);
|
||||
}
|
||||
|
||||
struct pm_state_info pm_policy_next_state(int32_t ticks)
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
|
||||
{
|
||||
ARG_UNUSED(cpu);
|
||||
|
||||
while (sleep_count < 3) {
|
||||
sleep_count++;
|
||||
return (struct pm_state_info){PM_STATE_SUSPEND_TO_RAM, 0, 0, 0};
|
||||
|
|
|
@ -57,10 +57,12 @@ void pm_power_state_exit_post_ops(struct pm_state_info info)
|
|||
}
|
||||
|
||||
/* Our PM policy handler */
|
||||
struct pm_state_info pm_policy_next_state(int ticks)
|
||||
struct pm_state_info pm_policy_next_state(uint8_t cpu, int ticks)
|
||||
{
|
||||
struct pm_state_info info = {};
|
||||
|
||||
ARG_UNUSED(cpu);
|
||||
|
||||
/* make sure this is idle thread */
|
||||
zassert_true(z_is_idle_thread_object(_current), NULL);
|
||||
zassert_true(ticks == _kernel.idle, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue