From f8aa116c3c6d33c4f9076d04355d6226debbb88b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 12 Jul 2018 00:47:11 -0400 Subject: [PATCH] winsys/amdgpu: clean up error handling in amdgpu_cs_submit_ib Reviewed-by: Samuel Pitoiset --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c index 872e67a790a..ac7160a5e51 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c @@ -1312,8 +1312,6 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) simple_mtx_unlock(&ws->global_bo_list_lock); if (r) { fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r); - amdgpu_fence_signalled(cs->fence); - cs->error_code = r; goto cleanup; } } else { @@ -1321,8 +1319,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) if (!amdgpu_add_sparse_backing_buffers(cs)) { fprintf(stderr, "amdgpu: amdgpu_add_sparse_backing_buffers failed\n"); - amdgpu_fence_signalled(cs->fence); - cs->error_code = -ENOMEM; + r = -ENOMEM; goto cleanup; } @@ -1348,8 +1345,6 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) handles, flags, &bo_list); if (r) { fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r); - amdgpu_fence_signalled(cs->fence); - cs->error_code = r; goto cleanup; } } @@ -1458,7 +1453,6 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) num_chunks, chunks, &seq_no); } - cs->error_code = r; if (r) { if (r == -ENOMEM) fprintf(stderr, "amdgpu: Not enough memory for command submission.\n"); @@ -1468,8 +1462,6 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) fprintf(stderr, "amdgpu: The CS has been rejected, " "see dmesg for more information (%i).\n", r); - amdgpu_fence_signalled(cs->fence); - acs->ctx->num_rejected_cs++; ws->num_total_rejected_cs++; } else { @@ -1486,6 +1478,13 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) amdgpu_bo_list_destroy(bo_list); cleanup: + /* If there was an error, signal the fence, because it won't be signalled + * by the hardware. */ + if (r) + amdgpu_fence_signalled(cs->fence); + + cs->error_code = r; + for (i = 0; i < cs->num_real_buffers; i++) p_atomic_dec(&cs->real_buffers[i].bo->num_active_ioctls); for (i = 0; i < cs->num_slab_buffers; i++) -- 2.30.2