Mesa (main): gallium/pb_cache: use simple_mtx_t

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 00:12:41 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Oct  1 15:44:30 2021 -0400

gallium/pb_cache: use simple_mtx_t

Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13152>

---

 src/gallium/auxiliary/pipebuffer/pb_cache.c | 20 ++++++++++----------
 src/gallium/auxiliary/pipebuffer/pb_cache.h |  3 ++-
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/pipebuffer/pb_cache.c b/src/gallium/auxiliary/pipebuffer/pb_cache.c
index 18c856f875b..87b50cc9429 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_cache.c
@@ -87,7 +87,7 @@ pb_cache_add_buffer(struct pb_cache_entry *entry)
    struct pb_buffer *buf = entry->buffer;
    unsigned i;
 
-   mtx_lock(&mgr->mutex);
+   simple_mtx_lock(&mgr->mutex);
    assert(!pipe_is_referenced(&buf->reference));
 
    int64_t current_time = os_time_get();
@@ -98,7 +98,7 @@ pb_cache_add_buffer(struct pb_cache_entry *entry)
    /* Directly release any buffer that exceeds the limit. */
    if (mgr->cache_size + buf->size > mgr->max_cache_size) {
       mgr->destroy_buffer(mgr->winsys, buf);
-      mtx_unlock(&mgr->mutex);
+      simple_mtx_unlock(&mgr->mutex);
       return;
    }
 
@@ -107,7 +107,7 @@ pb_cache_add_buffer(struct pb_cache_entry *entry)
    list_addtail(&entry->head, cache);
    ++mgr->num_buffers;
    mgr->cache_size += buf->size;
-   mtx_unlock(&mgr->mutex);
+   simple_mtx_unlock(&mgr->mutex);
 }
 
 /**
@@ -157,7 +157,7 @@ pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size,
    assert(bucket_index < mgr->num_heaps);
    struct list_head *cache = &mgr->buckets[bucket_index];
 
-   mtx_lock(&mgr->mutex);
+   simple_mtx_lock(&mgr->mutex);
 
    entry = NULL;
    cur = cache->next;
@@ -210,13 +210,13 @@ pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size,
       mgr->cache_size -= buf->size;
       list_del(&entry->head);
       --mgr->num_buffers;
-      mtx_unlock(&mgr->mutex);
+      simple_mtx_unlock(&mgr->mutex);
       /* Increase refcount */
       pipe_reference_init(&buf->reference, 1);
       return buf;
    }
 
-   mtx_unlock(&mgr->mutex);
+   simple_mtx_unlock(&mgr->mutex);
    return NULL;
 }
 
@@ -230,7 +230,7 @@ pb_cache_release_all_buffers(struct pb_cache *mgr)
    struct pb_cache_entry *buf;
    unsigned i;
 
-   mtx_lock(&mgr->mutex);
+   simple_mtx_lock(&mgr->mutex);
    for (i = 0; i < mgr->num_heaps; i++) {
       struct list_head *cache = &mgr->buckets[i];
 
@@ -243,7 +243,7 @@ pb_cache_release_all_buffers(struct pb_cache *mgr)
          next = curr->next;
       }
    }
-   mtx_unlock(&mgr->mutex);
+   simple_mtx_unlock(&mgr->mutex);
 }
 
 void
@@ -293,7 +293,7 @@ pb_cache_init(struct pb_cache *mgr, uint num_heaps,
    for (i = 0; i < num_heaps; i++)
       list_inithead(&mgr->buckets[i]);
 
-   (void) mtx_init(&mgr->mutex, mtx_plain);
+   (void) simple_mtx_init(&mgr->mutex, mtx_plain);
    mgr->winsys = winsys;
    mgr->cache_size = 0;
    mgr->max_cache_size = maximum_cache_size;
@@ -313,7 +313,7 @@ void
 pb_cache_deinit(struct pb_cache *mgr)
 {
    pb_cache_release_all_buffers(mgr);
-   mtx_destroy(&mgr->mutex);
+   simple_mtx_destroy(&mgr->mutex);
    FREE(mgr->buckets);
    mgr->buckets = NULL;
 }
diff --git a/src/gallium/auxiliary/pipebuffer/pb_cache.h b/src/gallium/auxiliary/pipebuffer/pb_cache.h
index 4afa0c804ec..cda0f99844e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_cache.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_cache.h
@@ -30,6 +30,7 @@
 #define PB_CACHE_H
 
 #include "pb_buffer.h"
+#include "util/simple_mtx.h"
 #include "util/list.h"
 #include "os/os_thread.h"
 
@@ -52,7 +53,7 @@ struct pb_cache
     */
    struct list_head *buckets;
 
-   mtx_t mutex;
+   simple_mtx_t mutex;
    void *winsys;
    uint64_t cache_size;
    uint64_t max_cache_size;



More information about the mesa-commit mailing list