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 0d0536c1a7)
This commit is contained in:
Icecream95 2021-01-20 10:46:05 +13:00 committed by Dylan Baker
parent 5fc12bcbc0
commit d038bd7b3e
4 changed files with 24 additions and 1 deletions

View file

@ -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
},

View file

@ -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)
{

View file

@ -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.
*/

View file

@ -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__ */