Mesa (master): pan/decode: Free mapped memory objects on BO unreference
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 21 00:44:29 UTC 2021
Module: Mesa
Branch: master
Commit: 0d0536c1a7662e2c1d99d221c444bc19ca3ab566
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d0536c1a7662e2c1d99d221c444bc19ca3ab566
Author: Icecream95 <ixn at disroot.org>
Date: Wed Jan 20 10:46:05 2021 +1300
pan/decode: Free mapped memory objects on BO unreference
Cc: mesa-stable
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8583>
---
src/panfrost/lib/decode_common.c | 18 ++++++++++++++++++
src/panfrost/lib/pan_bo.c | 3 +++
src/panfrost/lib/wrap.h | 2 ++
3 files changed, 23 insertions(+)
diff --git a/src/panfrost/lib/decode_common.c b/src/panfrost/lib/decode_common.c
index 53f2a50de7d..72fba5a7ff3 100644
--- a/src/panfrost/lib/decode_common.c
+++ b/src/panfrost/lib/decode_common.c
@@ -117,6 +117,24 @@ pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name)
_mesa_hash_table_u64_insert(mmap_table, gpu_va + i, mapped_mem);
}
+void
+pandecode_inject_free(uint64_t gpu_va, unsigned sz)
+{
+ struct pandecode_mapped_memory *mem =
+ pandecode_find_mapped_gpu_mem_containing_rw(gpu_va);
+
+ if (!mem)
+ return;
+
+ assert(mem->gpu_va == gpu_va);
+ assert(mem->length == sz);
+
+ free(mem);
+
+ for (unsigned i = 0; i < sz; i += 4096)
+ _mesa_hash_table_u64_remove(mmap_table, gpu_va + i);
+}
+
char *
pointer_as_memory_reference(uint64_t ptr)
{
diff --git a/src/panfrost/lib/pan_bo.c b/src/panfrost/lib/pan_bo.c
index f64a787e828..0852ac63c7c 100644
--- a/src/panfrost/lib/pan_bo.c
+++ b/src/panfrost/lib/pan_bo.c
@@ -436,6 +436,9 @@ panfrost_bo_unreference(struct panfrost_bo *bo)
/* When the reference count goes to zero, we need to cleanup */
panfrost_bo_munmap(bo);
+ if (dev->debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
+ pandecode_inject_free(bo->ptr.gpu, bo->size);
+
/* Rather than freeing the BO now, we'll cache the BO for later
* allocations if we're allowed to.
*/
diff --git a/src/panfrost/lib/wrap.h b/src/panfrost/lib/wrap.h
index abb18c8750b..6167c1e9470 100644
--- a/src/panfrost/lib/wrap.h
+++ b/src/panfrost/lib/wrap.h
@@ -51,6 +51,8 @@ void pandecode_close(void);
void
pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name);
+void pandecode_inject_free(uint64_t gpu_va, unsigned sz);
+
void pandecode_jc(uint64_t jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal);
#endif /* __MMAP_TRACE_H__ */
More information about the mesa-commit
mailing list