Mesa (staging/20.1): vulkan/wsi: Really terminate DRM lease in wsi_release_display().

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 22 17:34:49 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 3090516f31fc5a408a3da29bb0b47ed9f52ec1aa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3090516f31fc5a408a3da29bb0b47ed9f52ec1aa

Author: Mario Kleiner <mario.kleiner.de at gmail.com>
Date:   Mon Jun  8 12:51:08 2020 +0200

vulkan/wsi: Really terminate DRM lease in wsi_release_display().

wsi_release_display() implements vkReleaseDisplayEXT() which
is supposed to return control to the lessor of an output
upon call.

We need to terminate the wsi->wait_thread when close()'ing
the wsi->fd, otherwise the wait_thread holds another reference
to the wsi->fd, keeping the lease active, and thereby the
leased output blocked, until vkDestroyInstance() is called.

This gives users their GUI back, instead of extended darkness.

Fixes: 352d320a0745 ("vulkan: Add EXT_direct_mode_display [v2]")
Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Cc: <mesa-stable at lists.freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5396>
(cherry picked from commit 2cc51b0dfffb80e91bf839ed57708fd9f90735d9)

---

 .pick_status.json                   |  2 +-
 src/vulkan/wsi/wsi_common_display.c | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 48e84aa6716..4d672e0a3d3 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -445,7 +445,7 @@
         "description": "vulkan/wsi: Really terminate DRM lease in wsi_release_display().",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "352d320a07458eb05e4929fdc1e0d1dbe1b07dda"
     },
diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c
index 0f9a1ffe8d3..b05d7cc479d 100644
--- a/src/vulkan/wsi/wsi_common_display.c
+++ b/src/vulkan/wsi/wsi_common_display.c
@@ -1228,6 +1228,18 @@ wsi_display_start_wait_thread(struct wsi_display *wsi)
    return 0;
 }
 
+static void
+wsi_display_stop_wait_thread(struct wsi_display *wsi)
+{
+   pthread_mutex_lock(&wsi->wait_mutex);
+   if (wsi->wait_thread) {
+      pthread_cancel(wsi->wait_thread);
+      pthread_join(wsi->wait_thread, NULL);
+      wsi->wait_thread = 0;
+   }
+   pthread_mutex_unlock(&wsi->wait_mutex);
+}
+
 /*
  * Wait for at least one event from the kernel to be processed.
  * Call with wait_mutex held
@@ -1936,12 +1948,7 @@ wsi_display_finish_wsi(struct wsi_device *wsi_device,
          vk_free(wsi->alloc, connector);
       }
 
-      pthread_mutex_lock(&wsi->wait_mutex);
-      if (wsi->wait_thread) {
-         pthread_cancel(wsi->wait_thread);
-         pthread_join(wsi->wait_thread, NULL);
-      }
-      pthread_mutex_unlock(&wsi->wait_mutex);
+      wsi_display_stop_wait_thread(wsi);
       pthread_mutex_destroy(&wsi->wait_mutex);
       pthread_cond_destroy(&wsi->wait_cond);
 
@@ -1961,9 +1968,12 @@ wsi_release_display(VkPhysicalDevice            physical_device,
       (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
 
    if (wsi->fd >= 0) {
+      wsi_display_stop_wait_thread(wsi);
+
       close(wsi->fd);
       wsi->fd = -1;
    }
+
 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
    wsi_display_connector_from_handle(display)->output = None;
 #endif



More information about the mesa-commit mailing list