anv: Fix deadlock in anv_timelines_wait
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Tue, 12 May 2020 09:27:58 +0000 (12:27 +0300)
committerMarge Bot <eric+marge@anholt.net>
Thu, 14 May 2020 13:14:57 +0000 (13:14 +0000)
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2945
Fixes: 34f32a6d6648073e2fda3fb78377124fb32bb288
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5005>

src/intel/vulkan/anv_queue.c

index 0fdabf7aa008a96a0af2362872dae71d650590ab..009675e23ead7820eaa946dc1d22e0463e08eb7c 100644 (file)
@@ -2246,9 +2246,10 @@ anv_timelines_wait(struct anv_device *device,
                    uint64_t abs_timeout_ns)
 {
    if (!wait_all && n_timelines > 1) {
+      pthread_mutex_lock(&device->mutex);
+
       while (1) {
          VkResult result;
-         pthread_mutex_lock(&device->mutex);
          for (uint32_t i = 0; i < n_timelines; i++) {
             result =
                anv_timeline_wait_locked(device, timelines[i], serials[i], 0);