From b546c9d318731b988aa3d8c4e4735cdbb596cfbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Samuel=20Iglesias=20Gons=C3=A1lvez?= Date: Wed, 3 May 2017 08:02:21 +0200 Subject: [PATCH] anv: anv_gem_mmap() returns MAP_FAILED as mapping error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Take it into account when checking if the mapping failed. v2: - Remove map == NULL and its related comment (Emil) Signed-off-by: Samuel Iglesias Gonsálvez Reviewed-by: Emil Velikov Fixes: 6f3e3c715a7 ("vk/allocator: Add a BO pool") Fixes: 9919a2d34de ("anv/image: Memset hiz surfaces to 0 when binding memory") Cc: "17.0 17.1" --- src/intel/vulkan/anv_allocator.c | 2 +- src/intel/vulkan/anv_image.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 554ca4ac5fa..6ab2da5d64a 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -889,7 +889,7 @@ anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo, uint32_t size) assert(new_bo.size == pow2_size); new_bo.map = anv_gem_mmap(pool->device, new_bo.gem_handle, 0, pow2_size, 0); - if (new_bo.map == NULL) { + if (new_bo.map == MAP_FAILED) { anv_gem_close(pool->device, new_bo.gem_handle); return vk_error(VK_ERROR_MEMORY_MAP_FAILED); } diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 4874f2f3d38..36f5d47e1a5 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "anv_private.h" #include "util/debug.h" @@ -363,11 +364,8 @@ VkResult anv_BindImageMemory( image->aux_surface.isl.size, device->info.has_llc ? 0 : I915_MMAP_WC); - /* If anv_gem_mmap returns NULL, it's likely that the kernel was - * not able to find space on the host to create a proper mapping. - */ - if (map == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + if (map == MAP_FAILED) + return vk_error(VK_ERROR_MEMORY_MAP_FAILED); memset(map, 0, image->aux_surface.isl.size); -- 2.30.2