diff options
author | Icecream95 <ixn@disroot.org> | 2021-01-20 10:46:05 +1300 |
---|---|---|
committer | Dylan Baker <dylan.c.baker@intel.com> | 2021-01-25 10:49:58 -0800 |
commit | d038bd7b3ed729bcc3be120dbdaf53dc0a3484cf (patch) | |
tree | 33dc6446922ceaafceba48baba1e956c399036c4 | |
parent | 5fc12bcbc009d09868da63ac9502b62f715bfe9b (diff) |
pan/decode: Free mapped memory objects on BO unreference
Cc: mesa-stable
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8583>
(cherry picked from commit 0d0536c1a7662e2c1d99d221c444bc19ca3ab566)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/panfrost/lib/decode_common.c | 18 | ||||
-rw-r--r-- | src/panfrost/lib/pan_bo.c | 3 | ||||
-rw-r--r-- | src/panfrost/lib/wrap.h | 2 |
4 files changed, 24 insertions, 1 deletions
diff --git a/.pick_status.json b/.pick_status.json index f6018c1d373..422282faffc 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1084,7 +1084,7 @@ "description": "pan/decode: Free mapped memory objects on BO unreference", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, 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__ */ |