Skip to content

Commit fdf7465

Browse files
Flavio Ceolinnashif
authored andcommitted
pm: Fix multithread issue with force state
The "state forced" flag has to be cleared with the scheduler locked, otherwise the idle thread can be scheduled out without clear it and the next call to force a state will fail. Fixes #41911 Signed-off-by: Flavio Ceolin <[email protected]>
1 parent 8236cdb commit fdf7465

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/pm/pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ bool pm_system_suspend(int32_t ticks)
270270
#endif
271271
pm_stats_update(z_cpus_pm_state[id].state);
272272
pm_system_resume();
273+
atomic_clear_bit(z_cpus_pm_state_forced, id);
273274
k_sched_unlock();
274275
SYS_PORT_TRACING_FUNC_EXIT(pm, system_suspend, ticks,
275276
z_cpus_pm_state[id].state);
276277

277278
end:
278-
atomic_clear_bit(z_cpus_pm_state_forced, id);
279279
return ret;
280280
}
281281

0 commit comments

Comments
 (0)