pm: Make pm_power_state_force multicore aware

Change pm_power_state_force to receive which cpu the state should be
forced. Also, it changed the API behavior to force the given state only
when the idle thread for that core is executed.

In a multicore environment force arbitrarily a core to suspend is not
safe because the kernel cannot infer what that cpu is running and how it
impacts the overall system, for example, if it is holding a lock that is
required by a thread that is running in another cpu.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-11-14 11:04:56 -08:00 committed by Carles Cufí
commit 4998c52ba8
5 changed files with 23 additions and 33 deletions

View file

@ -69,14 +69,15 @@ struct pm_notifier {
* @brief Force usage of given power state.
*
* This function overrides decision made by PM policy forcing
* usage of given power state immediately.
* usage of given power state upon next entry of the idle thread.
*
* @note This function can only run in thread context
*
* @param cpu CPU index.
* @param info Power state which should be used in the ongoing
* suspend operation.
*/
void pm_power_state_force(struct pm_state_info info);
bool pm_power_state_force(uint8_t cpu, struct pm_state_info info);
/**
* @brief Register a power management notifier