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.
@@ -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
