From 5e5060324b75cca071a664eda7badb6b8b215462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Wed, 21 Oct 2020 17:51:22 +0200 Subject: [PATCH] anv: always annotate memory returned from anv_gem_mmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anv_bo_pool_alloc expects that the memory returned by and_gem_mmap was annotated using VALGRIND_MALLOCLIKE_BLOCK, but anv_gem_mmap_offset didn't do that. Move annotation from anv_gem_mmap_legacy to common code. Fixes: 4abf0837cdb ("anv: Add support for new MMAP_OFFSET ioctl.") Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Part-of: (cherry picked from commit b5e2c58ad865be4d88e4d29b5461015a82633e78) --- .pick_status.json | 2 +- src/intel/vulkan/anv_gem.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 0658ea95f3e..aac6ce28eba 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5521,7 +5521,7 @@ "description": "anv: always annotate memory returned from anv_gem_mmap", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "4abf0837cdb14b10a58d28766d5c1d3698d8a6d8" }, diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index fca72a9803e..9d5fbebaf2d 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -105,7 +105,6 @@ anv_gem_mmap_legacy(struct anv_device *device, uint32_t gem_handle, if (ret != 0) return MAP_FAILED; - VG(VALGRIND_MALLOCLIKE_BLOCK(gem_mmap.addr_ptr, gem_mmap.size, 0, 1)); return (void *)(uintptr_t) gem_mmap.addr_ptr; } @@ -116,10 +115,16 @@ void* anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, uint64_t offset, uint64_t size, uint32_t flags) { + void *map; if (device->physical->has_mmap_offset) - return anv_gem_mmap_offset(device, gem_handle, offset, size, flags); + map = anv_gem_mmap_offset(device, gem_handle, offset, size, flags); else - return anv_gem_mmap_legacy(device, gem_handle, offset, size, flags); + map = anv_gem_mmap_legacy(device, gem_handle, offset, size, flags); + + 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 @@ -128,8 +133,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, void anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) { - if (!device->physical->has_mmap_offset) - VG(VALGRIND_FREELIKE_BLOCK(p, 0)); + VG(VALGRIND_FREELIKE_BLOCK(p, 0)); munmap(p, size); }