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,15 +242,16 @@ 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 (pm_suspend_devices()) {
pm_resume_devices();
z_cpus_pm_state[id].state = PM_STATE_ACTIVE;
(void)atomic_add(&z_cpus_active, 1);
SYS_PORT_TRACING_FUNC_EXIT(pm, system_suspend, ticks,
z_cpus_pm_state[id].state);
return false;
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;
(void)atomic_add(&z_cpus_active, 1);
SYS_PORT_TRACING_FUNC_EXIT(pm, system_suspend, ticks,
z_cpus_pm_state[id].state);
return false;
}
}
}
#endif