winsys/amdgpu: drop all IBs if at least one was rejected within the context
authorMarek Olšák <marek.olsak@amd.com>
Thu, 19 Jan 2017 19:44:49 +0000 (20:44 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 23 Jan 2017 22:43:38 +0000 (23:43 +0100)
The corruption is inevitable and hangs are possible too.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c

index d63ff362a008bebc694f8135c58591eb6b437ee2..0bc4ce941b0f8dc18f2fa06a9c6c307325359bb4 100644 (file)
@@ -1039,11 +1039,17 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
       goto cleanup;
    }
 
-   r = amdgpu_cs_submit(acs->ctx->ctx, 0, &cs->request, 1);
+   if (acs->ctx->num_rejected_cs)
+      r = -ECANCELED;
+   else
+      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");
+      else if (r == -ECANCELED)
+         fprintf(stderr, "amdgpu: The CS has been cancelled because the context is lost.\n");
       else
          fprintf(stderr, "amdgpu: The CS has been rejected, "
                  "see dmesg for more information (%i).\n", r);