nvk: Drop the device-level mutex
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Mon, 25 Sep 2023 22:20:31 +0000 (17:20 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 26 Sep 2023 05:05:27 +0000 (05:05 +0000)
This existed to let us lock the memory_objects list and for handling
BO-based vk_sync waits.  We don't have either of these things anymore so
there's no need for a device-level lock.  We already have fine-grained
locks around the data structures that need them.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25357>

src/nouveau/vulkan/nvk_device.c
src/nouveau/vulkan/nvk_device.h
src/nouveau/vulkan/nvk_queue_drm_nouveau.c

index 8cbe9a3..960703c 100644 (file)
@@ -215,35 +215,13 @@ nvk_CreateDevice(VkPhysicalDevice physicalDevice,
 
    nvk_slm_area_init(&dev->slm);
 
-   if (pthread_mutex_init(&dev->mutex, NULL) != 0) {
-      result = vk_error(dev, VK_ERROR_INITIALIZATION_FAILED);
-      goto fail_slm;
-   }
-
-   pthread_condattr_t condattr;
-   if (pthread_condattr_init(&condattr) != 0) {
-      result = vk_error(dev, VK_ERROR_INITIALIZATION_FAILED);
-      goto fail_mutex;
-   }
-   if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC) != 0) {
-      pthread_condattr_destroy(&condattr);
-      result = vk_error(dev, VK_ERROR_INITIALIZATION_FAILED);
-      goto fail_mutex;
-   }
-   if (pthread_cond_init(&dev->queue_submit, &condattr) != 0) {
-      pthread_condattr_destroy(&condattr);
-      result = vk_error(dev, VK_ERROR_INITIALIZATION_FAILED);
-      goto fail_mutex;
-   }
-   pthread_condattr_destroy(&condattr);
-
    void *zero_map;
    dev->zero_page = nouveau_ws_bo_new_mapped(dev->ws_dev, 0x1000, 0,
                                              NOUVEAU_WS_BO_LOCAL |
                                              NOUVEAU_WS_BO_NO_SHARE,
                                              NOUVEAU_WS_BO_WR, &zero_map);
    if (dev->zero_page == NULL)
-      goto fail_queue_submit;
+      goto fail_slm;
 
    memset(zero_map, 0, 0x1000);
    nouveau_ws_bo_unmap(dev->zero_page, zero_map);
@@ -278,10 +256,6 @@ fail_vab_memory:
       nouveau_ws_bo_destroy(dev->vab_memory);
 fail_zero_page:
    nouveau_ws_bo_destroy(dev->zero_page);
-fail_queue_submit:
-   pthread_cond_destroy(&dev->queue_submit);
-fail_mutex:
-   pthread_mutex_destroy(&dev->mutex);
 fail_slm:
    nvk_slm_area_finish(&dev->slm);
    nvk_heap_finish(dev, &dev->event_heap);
@@ -312,8 +286,6 @@ nvk_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
 
    nvk_device_finish_meta(dev);
 
-   pthread_cond_destroy(&dev->queue_submit);
-   pthread_mutex_destroy(&dev->mutex);
    nvk_queue_finish(dev, &dev->queue);
    if (dev->vab_memory)
       nouveau_ws_bo_destroy(dev->vab_memory);
index deded52..f2cf612 100644 (file)
@@ -46,9 +46,6 @@ struct nvk_device {
 
    struct nvk_queue queue;
 
-   pthread_mutex_t mutex;
-   pthread_cond_t queue_submit;
-
    struct vk_meta_device meta;
 };
 
index f3e77ed..6812514 100644 (file)
@@ -315,8 +315,6 @@ nvk_queue_submit_drm_nouveau(struct nvk_queue *queue,
       push_add_sync_wait(&pb, &submit->waits[i]);
    }
 
-   pthread_mutex_lock(&dev->mutex);
-
    for (uint32_t i = 0; i < submit->signal_count; i++) {
       push_add_sync_signal(&pb, &submit->signals[i]);
    }
@@ -351,9 +349,5 @@ nvk_queue_submit_drm_nouveau(struct nvk_queue *queue,
       result = push_submit(&pb, queue, sync);
    }
 
-
-   pthread_cond_broadcast(&dev->queue_submit);
-   pthread_mutex_unlock(&dev->mutex);
-
    return result;
 }