Mesa (main): turnip: Track refcounts on BOs in kgsl as well.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 12 01:26:34 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Apr  6 13:05:40 2022 -0700

turnip: Track refcounts on BOs in kgsl as well.

I'm going to be using the BO refcount for the pipeline and autotune buffer
suballocation.

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

---

 src/freedreno/vulkan/tu_kgsl.c    | 5 +++++
 src/freedreno/vulkan/tu_private.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/freedreno/vulkan/tu_kgsl.c b/src/freedreno/vulkan/tu_kgsl.c
index 55fae932da3..cc7e25cd945 100644
--- a/src/freedreno/vulkan/tu_kgsl.c
+++ b/src/freedreno/vulkan/tu_kgsl.c
@@ -109,6 +109,7 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo **out_bo, uint64_t size,
       .gem_handle = req.id,
       .size = req.mmapsize,
       .iova = req.gpuaddr,
+      .refcnt = 1,
    };
 
    *out_bo = bo;
@@ -156,6 +157,7 @@ tu_bo_init_dmabuf(struct tu_device *dev,
       .gem_handle = req.id,
       .size = info_req.size,
       .iova = info_req.gpuaddr,
+      .refcnt = 1,
    };
 
    *out_bo = bo;
@@ -193,6 +195,9 @@ tu_bo_finish(struct tu_device *dev, struct tu_bo *bo)
 {
    assert(bo->gem_handle);
 
+   if (!p_atomic_dec_zero(&bo->refcnt))
+      return;
+
    if (bo->map)
       munmap(bo->map, bo->size);
 
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index dfbcfd09fbd..39c1e695f7f 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -370,9 +370,9 @@ struct tu_bo
    uint64_t size;
    uint64_t iova;
    void *map;
+   int32_t refcnt;
 
 #ifndef TU_USE_KGSL
-   int32_t refcnt;
    uint32_t bo_list_idx;
 #endif
 



More information about the mesa-commit mailing list