diff options
author | Samuel Iglesias Gonsálvez <[email protected]> | 2017-05-03 08:02:21 +0200 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-05-08 11:23:40 +0100 |
commit | 4ad2c57c2647ec8bc30b60df41b5d3d66c9e48e1 (patch) | |
tree | ab8c95419b28a1394422b06f3f8fd5cc06c3354b /src | |
parent | 14bbc51e6d72cf79660e558a3aa3cf2dcf3df529 (diff) |
anv: anv_gem_mmap() returns MAP_FAILED as mapping error
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 <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
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" <[email protected]>
(cherry picked from commit b546c9d318731b988aa3d8c4e4735cdbb596cfbf)
Squashed with:
anv: vkBindImageMemory() should return VK_ERROR_OUT_OF_{HOST,DEVICE}_MEMORY on failure
According to the spec we get VK_ERROR_OUT_OF_HOST_MEMORY or
VK_ERROR_OUT_OF_DEVICE_MEMORY on vkBindImageMemory failure.
Fixes returned value changed by b546c9d.
Fixes: b546c9d ("anv: anv_gem_mmap() returns MAP_FAILED as mapping error")
Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]>
Cc: "17.0 17.1" <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
(cherry picked from commit 939b015736d5091faeabde4f5a373e6a1612c5ed)
Squashed with:
anv: fix anv_gem_mmap comment to not mention NULL
The function cannot return NULL, update the comment accordingly.
Fixes: b546c9d ("anv: anv_gem_mmap() returns MAP_FAILED as mapping error")
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
(cherry picked from commit 9d2aa6e5067752efbc0acbd728bc0bde49aefb61)
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_allocator.c | 2 | ||||
-rw-r--r-- | 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 5f5577f2781..f3e83bc6791 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -884,7 +884,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 cf34dbe3b0a..472ee99a571 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -26,6 +26,7 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> +#include <sys/mman.h> #include "anv_private.h" #include "util/debug.h" @@ -347,7 +348,7 @@ VkResult anv_BindImageMemory( if (image->aux_surface.isl.size > 0) { /* The offset and size must be a multiple of 4K or else the - * anv_gem_mmap call below will return NULL. + * anv_gem_mmap call below will fail. */ assert((image->offset + image->aux_surface.offset) % 4096 == 0); assert(image->aux_surface.isl.size % 4096 == 0); @@ -363,10 +364,7 @@ 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) + if (map == MAP_FAILED) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); memset(map, 0, image->aux_surface.isl.size); |