From 0d387da08349e1bdd222efae0657fc74009d9955 Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Wed, 20 Feb 2019 15:26:43 -0800 Subject: [PATCH] anv: Add anv_device parameter to anv_gem_munmap. Also update all of its callers. On the next commit, the device will be used by anv_gem_munmap to choose whether we need to call the valgrind code or not, depending on which type of mmap we are using. Reviewed-by: Kenneth Graunke Reviewed-by: Jordan Justen Part-of: --- src/intel/vulkan/anv_allocator.c | 6 +++--- src/intel/vulkan/anv_device.c | 3 ++- src/intel/vulkan/anv_gem.c | 2 +- src/intel/vulkan/anv_gem_stubs.c | 2 +- src/intel/vulkan/anv_private.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 010da4b8c4e..42bc0405e81 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -434,7 +434,7 @@ anv_block_pool_finish(struct anv_block_pool *pool) { anv_block_pool_foreach_bo(bo, pool) { if (bo->map) - anv_gem_munmap(bo->map, bo->size); + anv_gem_munmap(pool->device, bo->map, bo->size); anv_gem_close(pool->device, bo->gem_handle); } @@ -1643,7 +1643,7 @@ anv_device_alloc_bo(struct anv_device *device, align, alloc_flags, explicit_address); if (new_bo.offset == 0) { if (new_bo.map) - anv_gem_munmap(new_bo.map, size); + anv_gem_munmap(device, new_bo.map, size); anv_gem_close(device, new_bo.gem_handle); return vk_errorf(device, NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY, "failed to allocate virtual address for BO"); @@ -1968,7 +1968,7 @@ anv_device_release_bo(struct anv_device *device, assert(bo->refcount == 0); if (bo->map && !bo->from_host_ptr) - anv_gem_munmap(bo->map, bo->size); + anv_gem_munmap(device, bo->map, bo->size); if (bo->_ccs_size > 0) { assert(device->physical->has_implicit_ccs); diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 11fb4f6c3fc..f80b4f66763 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3721,12 +3721,13 @@ void anv_UnmapMemory( VkDevice _device, VkDeviceMemory _memory) { + ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device_memory, mem, _memory); if (mem == NULL || mem->host_ptr) return; - anv_gem_munmap(mem->map, mem->map_size); + anv_gem_munmap(device, mem->map, mem->map_size); mem->map = NULL; mem->map_size = 0; diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 2deccb88b97..bdaebb9bc27 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -90,7 +90,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, * this map is no longer valid. Pair this with anv_gem_mmap(). */ void -anv_gem_munmap(void *p, uint64_t size) +anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) { VG(VALGRIND_FREELIKE_BLOCK(p, 0)); munmap(p, size); diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index bc9d7e066ba..c4d1c87b75a 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -60,7 +60,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, * this map is no longer valid. Pair this with anv_gem_mmap(). */ void -anv_gem_munmap(void *p, uint64_t size) +anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) { munmap(p, size); } diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 20ed281d062..a0d954df5ef 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1471,7 +1471,7 @@ uint64_t anv_get_absolute_timeout(uint64_t timeout); void* anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, uint64_t offset, uint64_t size, uint32_t flags); -void anv_gem_munmap(void *p, uint64_t size); +void anv_gem_munmap(struct anv_device *device, void *p, uint64_t size); uint32_t anv_gem_create(struct anv_device *device, uint64_t size); void anv_gem_close(struct anv_device *device, uint32_t gem_handle); uint32_t anv_gem_userptr(struct anv_device *device, void *mem, size_t size); -- 2.30.2