From 440813114281bfd05c2b0d26c6488d1410790be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Fri, 16 Oct 2020 20:07:28 +0200 Subject: [PATCH] vulkan/wsi: fix possible random stalls in wsi_display_wait_for_event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: da997ebec92 ("vulkan: Add KHR_display extension using DRM [v10]") Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Part-of: --- src/vulkan/wsi/wsi_common_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index 3a304e36537..f6eea5906f8 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -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;