diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index b9583b07288..87909c83735 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1590,11 +1590,12 @@ anv_device_map_bo(struct anv_device *device, assert(!bo->from_host_ptr); assert(size > 0); - void *map = anv_gem_mmap(device, bo, offset, size); + void *map = device->kmd_backend->gem_mmap(device, bo, offset, size); if (unlikely(map == MAP_FAILED)) return vk_errorf(device, VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m"); assert(map != NULL); + VG(VALGRIND_MALLOCLIKE_BLOCK(map, size, 0, 1)); if (map_out) *map_out = map; @@ -1609,7 +1610,8 @@ anv_device_unmap_bo(struct anv_device *device, { assert(!bo->from_host_ptr); - anv_gem_munmap(device, map, map_size); + VG(VALGRIND_FREELIKE_BLOCK(map, 0)); + munmap(map, map_size); } VkResult diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 80f33cc7c9a..e721885cb55 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -34,28 +34,6 @@ #include "i915/anv_gem.h" -void * -anv_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset, - uint64_t size) -{ - void *map = device->kmd_backend->gem_mmap(device, bo, offset, size); - - if (map != MAP_FAILED) - VG(VALGRIND_MALLOCLIKE_BLOCK(map, size, 0, 1)); - - return map; -} - -/* This is just a wrapper around munmap, but it also notifies valgrind that - * this map is no longer valid. Pair this with gem_mmap(). - */ -void -anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) -{ - VG(VALGRIND_FREELIKE_BLOCK(p, 0)); - munmap(p, size); -} - /** * On error, \a timeout_ns holds the remaining time. */ diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 195ddee1278..36d0076dad1 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -100,27 +100,6 @@ stub_bo_alloc_flags_to_bo_flags(struct anv_device *device, return 0; } -void * -anv_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset, - uint64_t size) -{ - void *map = device->kmd_backend->gem_mmap(device, bo, offset, size); - - if (map != MAP_FAILED) - VG(VALGRIND_MALLOCLIKE_BLOCK(map, size, 0, 1)); - - return map; -} - -/* This is just a wrapper around munmap, but it also notifies valgrind that - * this map is no longer valid. Pair this with gem_mmap(). - */ -void -anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) -{ - munmap(p, size); -} - static uint32_t stub_gem_create_userptr(struct anv_device *device, void *mem, uint64_t size) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 779b3f481e4..ac05ccd819b 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2097,10 +2097,6 @@ anv_queue_post_submit(struct anv_queue *queue, VkResult submit_result) return result; } -void * -anv_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset, - uint64_t size); -void anv_gem_munmap(struct anv_device *device, void *p, uint64_t size); int anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns); int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle, uint32_t stride, uint32_t tiling); diff --git a/src/intel/vulkan/genX_cmd_video.c b/src/intel/vulkan/genX_cmd_video.c index 8eacbf12eef..44df84e35b5 100644 --- a/src/intel/vulkan/genX_cmd_video.c +++ b/src/intel/vulkan/genX_cmd_video.c @@ -597,8 +597,17 @@ anv_h265_decode_video(struct anv_cmd_buffer *cmd_buffer, /* Slice parsing */ uint32_t last_slice = h265_pic_info->sliceSegmentCount - 1; - void *slice_map = anv_gem_mmap(cmd_buffer->device, src_buffer->address.bo, - src_buffer->address.offset, frame_info->srcBufferRange); + void *slice_map; + VkResult result = + anv_device_map_bo(cmd_buffer->device, + src_buffer->address.bo, + src_buffer->address.offset, + frame_info->srcBufferRange, + &slice_map); + if (result != VK_SUCCESS) { + anv_batch_set_error(&cmd_buffer->batch, result); + return; + } struct vk_video_h265_slice_params slice_params[h265_pic_info->sliceSegmentCount]; @@ -617,7 +626,7 @@ anv_h265_decode_video(struct anv_cmd_buffer *cmd_buffer, vk_fill_video_h265_reference_info(frame_info, h265_pic_info, &slice_params[s], ref_slots); } - anv_gem_munmap(cmd_buffer->device, slice_map, frame_info->srcBufferRange); + anv_device_unmap_bo(cmd_buffer->device, src_buffer->address.bo, slice_map, frame_info->srcBufferRange); for (unsigned s = 0; s < h265_pic_info->sliceSegmentCount; s++) { uint32_t ctb_size = 1 << (sps->log2_diff_max_min_luma_coding_block_size +