From a791805d10d4b5cb43037593abfac2cbb2273d9e Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 11 Apr 2024 17:04:20 -0700 Subject: [PATCH] anv/sparse: rework anv_free_sparse_bindings() error handling None of the callers of anv_free_sparse_bindings() check for its return result, and they also don't have a way to propagate it up the stack. So just don't return error codes that won't be checked. Instead, add an assertion so at least we can detect failures in our CI or development runs. Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_private.h | 4 ++-- src/intel/vulkan/anv_sparse.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 049c2edfd3c..185e2409b34 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3052,8 +3052,8 @@ VkResult anv_init_sparse_bindings(struct anv_device *device, enum anv_bo_alloc_flags alloc_flags, uint64_t client_address, struct anv_address *out_address); -VkResult anv_free_sparse_bindings(struct anv_device *device, - struct anv_sparse_binding_data *sparse); +void anv_free_sparse_bindings(struct anv_device *device, + struct anv_sparse_binding_data *sparse); VkResult anv_sparse_bind_buffer(struct anv_device *device, struct anv_buffer *buffer, const VkSparseMemoryBind *vk_bind, diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index a4fa29462f4..09e57d353d5 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -658,12 +658,12 @@ anv_init_sparse_bindings(struct anv_device *device, return VK_SUCCESS; } -VkResult +void anv_free_sparse_bindings(struct anv_device *device, struct anv_sparse_binding_data *sparse) { if (!sparse->address) - return VK_SUCCESS; + return; sparse_debug("%s: address:0x%016"PRIx64" size:0x%08"PRIx64"\n", __func__, sparse->address, sparse->size); @@ -686,12 +686,16 @@ anv_free_sparse_bindings(struct anv_device *device, .signal_count = 0, }; VkResult res = anv_sparse_bind(device, &submit); + + /* Our callers don't have a way to signal failure to the upper layers, so + * just keep the vma if we fail to unbind it. Still, let's have an + * assertion because this really shouldn't be happening. + */ + assert(res == VK_SUCCESS); if (res != VK_SUCCESS) - return res; + return; anv_vma_free(device, sparse->vma_heap, sparse->address, sparse->size); - - return VK_SUCCESS; } static VkExtent3D