diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-11-07 17:24:24 -0800 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2016-12-15 15:57:53 +0000 |
commit | 23f1e04abbc6cb97b18a2902e9231983856672dd (patch) | |
tree | 1e78c2834972a221d2f62be2b20a96433584794c | |
parent | cf07f78f7e6b1365bae8bb00e2f9dea0648c5f40 (diff) | |
download | external_mesa3d-23f1e04abbc6cb97b18a2902e9231983856672dd.zip external_mesa3d-23f1e04abbc6cb97b18a2902e9231983856672dd.tar.gz external_mesa3d-23f1e04abbc6cb97b18a2902e9231983856672dd.tar.bz2 |
anv/device: Return the right error for failed maps
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0 13.0" <mesa-dev@lists.freedesktop.org>
(cherry picked from commit 920f34a2d9f14f023aee5203baa110c971519ee8)
-rw-r--r-- | src/intel/vulkan/anv_device.c | 9 | ||||
-rw-r--r-- | src/intel/vulkan/anv_gem.c | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 19358cb..9595fe3 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -24,6 +24,7 @@ #include <assert.h> #include <stdbool.h> #include <string.h> +#include <sys/mman.h> #include <unistd.h> #include <fcntl.h> @@ -1309,8 +1310,12 @@ VkResult anv_MapMemory( /* Let's map whole pages */ map_size = align_u64(map_size, 4096); - mem->map = anv_gem_mmap(device, mem->bo.gem_handle, - map_offset, map_size, gem_flags); + void *map = anv_gem_mmap(device, mem->bo.gem_handle, + map_offset, map_size, gem_flags); + if (map == MAP_FAILED) + return vk_error(VK_ERROR_MEMORY_MAP_FAILED); + + mem->map = map; mem->map_size = map_size; *ppData = mem->map + (offset - map_offset); diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index e654689..0dde6d9 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -88,10 +88,8 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, }; int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_MMAP, &gem_mmap); - if (ret != 0) { - /* FIXME: Is NULL the right error return? Cf MAP_INVALID */ - return NULL; - } + 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; |