Commit ce336813 authored by Samuel Iglesias Gonsálvez's avatar Samuel Iglesias Gonsálvez Committed by Andres Gomez

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's avatarSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>

Fixes: 6f3e3c71 ("vk/allocator: Add a BO pool")
Fixes: 9919a2d3 ("anv/image: Memset hiz surfaces to 0 when binding memory")
Cc: "17.0 17.1" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit b546c9d3)

Squashed with commit:

anv: fix anv_gem_mmap comment to not mention NULL

The function cannot return NULL, update the comment accordingly.

Fixes: b546c9d3 ("anv: anv_gem_mmap() returns MAP_FAILED as mapping error")
Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Reviewed-by: Samuel Iglesias Gonsálvez's avatarSamuel Iglesias Gonsálvez <siglesias@igalia.com>
(cherry picked from commit 9d2aa6e5)
parent cda9c9fb
......@@ -859,7 +859,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);
}
......
......@@ -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"
......@@ -358,7 +359,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);
......@@ -374,11 +375,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment