pm: Error with handling z_cpus_active count

z_cpus_active count becomes incorrect when the state is
PM_STATE_RUNTIME_IDLE and CONFIG_PM_DEVICE is enabled.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This commit is contained in:
Mahesh Mahadevan 2022-12-16 10:57:29 -06:00 committed by Fabio Baltieri
commit ae97eae8c2

View file

@ -242,8 +242,8 @@ bool pm_system_suspend(int32_t ticks)
}
#if defined(CONFIG_PM_DEVICE) && !defined(CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE)
if ((z_cpus_pm_state[id].state != PM_STATE_RUNTIME_IDLE) &&
(atomic_sub(&z_cpus_active, 1) == 1)) {
if (atomic_sub(&z_cpus_active, 1) == 1) {
if (z_cpus_pm_state[id].state != PM_STATE_RUNTIME_IDLE) {
if (pm_suspend_devices()) {
pm_resume_devices();
z_cpus_pm_state[id].state = PM_STATE_ACTIVE;
@ -253,6 +253,7 @@ bool pm_system_suspend(int32_t ticks)
return false;
}
}
}
#endif
/*
* This function runs with interruptions locked but it is