From a9555f37d5b15c86aed73d0dab8d514751e12a54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Wed, 6 Mar 2019 10:49:21 +0200 Subject: [PATCH] anv: use anv_gem_munmap in block pool cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use anv_gem_munmap for unmap when softpin in use, this corresponds to anv_gem_mmap used in anv_block_pool_expand_range. This fixes valgrind errors seen for each pool when softpin is in use: ==25581== 262,144 bytes in 1 blocks are definitely lost in loss record 31 of 31 ==25581== at 0x50E77E8: anv_gem_mmap (anv_gem.c:96) ==25581== by 0x50EEE2B: anv_block_pool_expand_range (anv_allocator.c:543) ==25581== by 0x50EEB51: anv_block_pool_init (anv_allocator.c:477) ==25581== by 0x50EF7EF: anv_state_pool_init (anv_allocator.c:920) ==25581== by 0x510B8EB: anv_CreateDevice (anv_device.c:2031) Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin --- src/intel/vulkan/anv_allocator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index dd967165bbb..109f5f71bc4 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -493,10 +493,14 @@ void anv_block_pool_finish(struct anv_block_pool *pool) { struct anv_mmap_cleanup *cleanup; + const bool use_softpin = !!(pool->bo_flags & EXEC_OBJECT_PINNED); u_vector_foreach(cleanup, &pool->mmap_cleanups) { - if (cleanup->map) + if (use_softpin) + anv_gem_munmap(cleanup->map, cleanup->size); + else munmap(cleanup->map, cleanup->size); + if (cleanup->gem_handle) anv_gem_close(pool->device, cleanup->gem_handle); } -- 2.30.2