diff options
author | Iago Toral Quiroga <[email protected]> | 2017-03-03 10:55:19 +0100 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2017-03-16 11:40:05 +0100 |
commit | 68d88f0237cbd743db83c8ad3e313251ab8fcff8 (patch) | |
tree | 2a8d36b8688f9e1d10353d45f8ea1ab12c9fe35e /src/intel/vulkan/anv_batch_chain.c | |
parent | d4bdd871dc295610de776d235e58ce8c5eadfded (diff) |
anv: handle failures when growing reloc lists
Growing the reloc list happens through calling anv_reloc_list_add() or
anv_reloc_list_append(). Make sure that we call these through helpers
that check the result and set the batch error status if needed.
v2:
- Handling the crashes is not good enough, we need to keep track of
the error, for that, keep track of the errors in the batch instead (Jason).
- Make reloc list growth go through helpers so we can have a central
place where we can do error tracking (Jason).
v3:
- Callers that need the offset returned by anv_reloc_list_add() can
compute it themselves since it is extracted from the inputs to the
function, so change the function to return a VkResult, make
anv_batch_emit_reloc() also return a VkResult and let their callers
do the error management (Topi)
v4:
- Let anv_batch_emit_reloc() return an uint64_t as it originally did,
there is no real benefit in having it return a VkResult.
- Do not add an is_aux parameter to add_surface_state_reloc(), instead
do error checking for aux in add_image_view_relocs() separately.
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_batch_chain.c')
-rw-r--r-- | src/intel/vulkan/anv_batch_chain.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index c304d6dc6a5..abd0c171aaa 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -140,7 +140,7 @@ anv_reloc_list_grow(struct anv_reloc_list *list, return VK_SUCCESS; } -uint64_t +VkResult anv_reloc_list_add(struct anv_reloc_list *list, const VkAllocationCallbacks *alloc, uint32_t offset, struct anv_bo *target_bo, uint32_t delta) @@ -151,8 +151,9 @@ anv_reloc_list_add(struct anv_reloc_list *list, const uint32_t domain = target_bo->is_winsys_bo ? I915_GEM_DOMAIN_RENDER : 0; - anv_reloc_list_grow(list, alloc, 1); - /* TODO: Handle failure */ + VkResult result = anv_reloc_list_grow(list, alloc, 1); + if (result != VK_SUCCESS) + return result; /* XXX: Can we use I915_EXEC_HANDLE_LUT? */ index = list->num_relocs++; @@ -166,16 +167,17 @@ anv_reloc_list_add(struct anv_reloc_list *list, entry->write_domain = domain; VG(VALGRIND_CHECK_MEM_IS_DEFINED(entry, sizeof(*entry))); - return target_bo->offset + delta; + return VK_SUCCESS; } -static void +static VkResult anv_reloc_list_append(struct anv_reloc_list *list, const VkAllocationCallbacks *alloc, struct anv_reloc_list *other, uint32_t offset) { - anv_reloc_list_grow(list, alloc, other->num_relocs); - /* TODO: Handle failure */ + VkResult result = anv_reloc_list_grow(list, alloc, other->num_relocs); + if (result != VK_SUCCESS) + return result; memcpy(&list->relocs[list->num_relocs], &other->relocs[0], other->num_relocs * sizeof(other->relocs[0])); @@ -186,6 +188,7 @@ anv_reloc_list_append(struct anv_reloc_list *list, list->relocs[i + list->num_relocs].offset += offset; list->num_relocs += other->num_relocs; + return VK_SUCCESS; } /*-----------------------------------------------------------------------* @@ -215,8 +218,14 @@ uint64_t anv_batch_emit_reloc(struct anv_batch *batch, void *location, struct anv_bo *bo, uint32_t delta) { - return anv_reloc_list_add(batch->relocs, batch->alloc, - location - batch->start, bo, delta); + VkResult result = anv_reloc_list_add(batch->relocs, batch->alloc, + location - batch->start, bo, delta); + if (result != VK_SUCCESS) { + anv_batch_set_error(batch, result); + return 0; + } + + return bo->offset + delta; } void @@ -241,8 +250,12 @@ anv_batch_emit_batch(struct anv_batch *batch, struct anv_batch *other) memcpy(batch->next, other->start, size); offset = batch->next - batch->start; - anv_reloc_list_append(batch->relocs, batch->alloc, - other->relocs, offset); + VkResult result = anv_reloc_list_append(batch->relocs, batch->alloc, + other->relocs, offset); + if (result != VK_SUCCESS) { + anv_batch_set_error(batch, result); + return; + } batch->next += size; } |