winsys/amdgpu: return an error on IB submission failures
authorMarek Olšák <marek.olsak@amd.com>
Wed, 13 Jul 2016 16:31:16 +0000 (18:31 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 14 Jul 2016 20:00:54 +0000 (22:00 +0200)
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
src/gallium/winsys/amdgpu/drm/amdgpu_cs.h

index 1094c3f61c8bd0106ae04d06cea2e5b7ebf65d95..1a094fd8d218b243b4fc592c763fb34543c68552 100644 (file)
@@ -900,6 +900,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
       if (!handles) {
          pipe_mutex_unlock(ws->global_bo_list_lock);
          amdgpu_cs_context_cleanup(cs);
+         cs->error_code = -ENOMEM;
          return;
       }
 
@@ -923,10 +924,12 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
       fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r);
       cs->request.resources = NULL;
       amdgpu_fence_signalled(cs->fence);
+      cs->error_code = r;
       goto cleanup;
    }
 
    r = amdgpu_cs_submit(acs->ctx->ctx, 0, &cs->request, 1);
+   cs->error_code = r;
    if (r) {
       if (r == -ENOMEM)
          fprintf(stderr, "amdgpu: Not enough memory for command submission.\n");
@@ -974,6 +977,7 @@ static int amdgpu_cs_flush(struct radeon_winsys_cs *rcs,
 {
    struct amdgpu_cs *cs = amdgpu_cs(rcs);
    struct amdgpu_winsys *ws = cs->ctx->ws;
+   int error_code = 0;
 
    rcs->current.max_dw += amdgpu_cs_epilog_dws(cs->ring_type);
 
@@ -1057,6 +1061,7 @@ static int amdgpu_cs_flush(struct radeon_winsys_cs *rcs,
                             amdgpu_cs_submit_ib);
       } else {
          amdgpu_cs_submit_ib(cs, 0);
+         error_code = cs->cst->error_code;
       }
    } else {
       amdgpu_cs_context_cleanup(cs->csc);
@@ -1069,7 +1074,7 @@ static int amdgpu_cs_flush(struct radeon_winsys_cs *rcs,
       amdgpu_get_new_ib(&ws->base, cs, IB_CONST_PREAMBLE);
 
    ws->num_cs_flushes++;
-   return 0;
+   return error_code;
 }
 
 static void amdgpu_cs_destroy(struct radeon_winsys_cs *rcs)
index f56b5a5a16e776ecdec6d8c984cd4af8227a2667..e80b3337604aa6a933b9cd10ae52ee49be17db62 100644 (file)
@@ -88,6 +88,9 @@ struct amdgpu_cs_context {
    unsigned                    max_dependencies;
 
    struct pipe_fence_handle    *fence;
+
+   /* the error returned from cs_flush for non-async submissions */
+   int                         error_code;
 };
 
 struct amdgpu_cs {