winsys/amdgpu: clean up error handling in amdgpu_cs_submit_ib
authorMarek Olšák <marek.olsak@amd.com>
Thu, 12 Jul 2018 04:47:11 +0000 (00:47 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 16 Jul 2018 17:32:33 +0000 (13:32 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c

index 872e67a790ad7b940d382e62adb792405fa7d1f7..ac7160a5e5100705f129e2a875068b4b7cd591d4 100644 (file)
@@ -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++)