pm: runtime: fix race when waiting for suspended event
To wait for the asynchronous suspending work item to complete, a combination of semaphores and events is used. First, the semaphore is released, then the events are cleared (through the boolean argument to k_event_wait), then events are awaited. However, if the event flag happens to be set by the work handler in the short time between k_sem_give and k_event_wait, it is then cleared by k_event_wait and k_event_wait blocks forever waiting for the event. Make sure that we clear the event flag before releasing the semaphore. Signed-off-by:Marco Widmer <marco.widmer@bytesatwork.ch> (cherry picked from commit d83c63ec)
Loading
Please sign in to comment