Mesa (main): v3dv: Don't use pthread functions on c11 mutexes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 13 17:57:18 UTC 2022


Module: Mesa
Branch: main
Commit: 30191fd9df1c6804e2041854f2bb79e7df157539
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=30191fd9df1c6804e2041854f2bb79e7df157539

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Mon Apr  4 08:40:30 2022 -0500

v3dv: Don't use pthread functions on c11 mutexes

This only works because c11/threads.h is typedeffing the c11 stuff to
ptrheads.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>

---

 src/broadcom/vulkan/v3dv_device.c         | 14 +++++++-------
 src/broadcom/vulkan/v3dv_pipeline_cache.c |  8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c
index 38913a058d7..2c46c9ebea7 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -852,7 +852,7 @@ physical_device_init(struct v3dv_physical_device *device,
 
    get_device_extensions(device, &device->vk.supported_extensions);
 
-   pthread_mutex_init(&device->mutex, NULL);
+   mtx_init(&device->mutex, mtx_plain);
 
    return VK_SUCCESS;
 
@@ -1857,8 +1857,8 @@ queue_init(struct v3dv_device *device, struct v3dv_queue *queue,
    queue->device = device;
    queue->noop_job = NULL;
    list_inithead(&queue->submit_wait_list);
-   pthread_mutex_init(&queue->mutex, NULL);
-   pthread_mutex_init(&queue->noop_mutex, NULL);
+   mtx_init(&queue->mutex, mtx_plain);
+   mtx_init(&queue->noop_mutex, mtx_plain);
    return VK_SUCCESS;
 }
 
@@ -1869,8 +1869,8 @@ queue_finish(struct v3dv_queue *queue)
    assert(list_is_empty(&queue->submit_wait_list));
    if (queue->noop_job)
       v3dv_job_destroy(queue->noop_job);
-   pthread_mutex_destroy(&queue->mutex);
-   pthread_mutex_destroy(&queue->noop_mutex);
+   mtx_destroy(&queue->mutex);
+   mtx_destroy(&queue->noop_mutex);
 }
 
 static void
@@ -1944,7 +1944,7 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice,
    device->instance = instance;
    device->pdevice = physical_device;
 
-   pthread_mutex_init(&device->mutex, NULL);
+   mtx_init(&device->mutex, mtx_plain);
 
    result = queue_init(device, &device->queue,
                        pCreateInfo->pQueueCreateInfos, 0);
@@ -2012,7 +2012,7 @@ v3dv_DestroyDevice(VkDevice _device,
 
    v3dv_DeviceWaitIdle(_device);
    queue_finish(&device->queue);
-   pthread_mutex_destroy(&device->mutex);
+   mtx_destroy(&device->mutex);
    destroy_device_syncs(device, device->pdevice->render_fd);
    destroy_device_meta(device);
    v3dv_pipeline_cache_finish(&device->default_pipeline_cache);
diff --git a/src/broadcom/vulkan/v3dv_pipeline_cache.c b/src/broadcom/vulkan/v3dv_pipeline_cache.c
index 2e86a63f55f..9d2b816a79e 100644
--- a/src/broadcom/vulkan/v3dv_pipeline_cache.c
+++ b/src/broadcom/vulkan/v3dv_pipeline_cache.c
@@ -67,14 +67,14 @@ static void
 pipeline_cache_lock(struct v3dv_pipeline_cache *cache)
 {
    if (!cache->externally_synchronized)
-      pthread_mutex_lock(&cache->mutex);
+      mtx_lock(&cache->mutex);
 }
 
 static void
 pipeline_cache_unlock(struct v3dv_pipeline_cache *cache)
 {
    if (!cache->externally_synchronized)
-      pthread_mutex_unlock(&cache->mutex);
+      mtx_unlock(&cache->mutex);
 }
 
 void
@@ -203,7 +203,7 @@ v3dv_pipeline_cache_init(struct v3dv_pipeline_cache *cache,
                          bool cache_enabled)
 {
    cache->device = device;
-   pthread_mutex_init(&cache->mutex, NULL);
+   mtx_init(&cache->mutex, mtx_plain);
 
    if (cache_enabled) {
       cache->nir_cache = _mesa_hash_table_create(NULL, sha1_hash_func,
@@ -714,7 +714,7 @@ v3dv_CreatePipelineCache(VkDevice _device,
 void
 v3dv_pipeline_cache_finish(struct v3dv_pipeline_cache *cache)
 {
-   pthread_mutex_destroy(&cache->mutex);
+   mtx_destroy(&cache->mutex);
 
    if (dump_stats_on_destroy)
       cache_dump_stats(cache);



More information about the mesa-commit mailing list