vulkan/wsi: fix possible random stalls in wsi_display_wait_for_event

pthread_cond_broadcast man page says this:
"The pthread_cond_broadcast() or pthread_cond_signal() functions may
 be called by a thread whether or not it currently owns the mutex that
 threads calling pthread_cond_wait() or pthread_cond_timedwait() have
 associated with the condition variable during their waits; however,
 if predictable scheduling behavior is required, then that mutex shall
 be locked by the thread calling pthread_cond_broadcast() or
 pthread_cond_signal()."

Found by reading the code.
Compile tested only.

Fixes: da997ebec9 ("vulkan: Add KHR_display extension using DRM [v10]")

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7197>
This commit is contained in:
Marcin Ślusarz 2020-10-16 20:07:28 +02:00 committed by Marge Bot
parent 85053c016c
commit 4408131142

View file

@ -1210,8 +1210,8 @@ wsi_display_wait_thread(void *data)
if (ret > 0) {
pthread_mutex_lock(&wsi->wait_mutex);
(void) drmHandleEvent(wsi->fd, &event_context);
pthread_mutex_unlock(&wsi->wait_mutex);
pthread_cond_broadcast(&wsi->wait_cond);
pthread_mutex_unlock(&wsi->wait_mutex);
}
}
return NULL;