From 18408008609df9007dc40512f00c5700167c5887 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 19 Jan 2017 20:32:28 +0100 Subject: [PATCH] winsys/amdgpu: report a rejected IB as a lost context MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 11 +++++++++++ src/gallium/winsys/amdgpu/drm/amdgpu_cs.h | 2 ++ src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c index 87246f75371..d63ff362a00 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c @@ -178,6 +178,7 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *ws) ctx->ws = amdgpu_winsys(ws); ctx->refcount = 1; + ctx->initial_num_total_rejected_cs = ctx->ws->num_total_rejected_cs; r = amdgpu_cs_ctx_create(ctx->ws->dev, &ctx->ctx); if (r) { @@ -227,6 +228,13 @@ amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx) uint32_t result, hangs; int r; + /* Return a failure due to a rejected command submission. */ + if (ctx->ws->num_total_rejected_cs > ctx->initial_num_total_rejected_cs) { + return ctx->num_rejected_cs ? PIPE_GUILTY_CONTEXT_RESET : + PIPE_INNOCENT_CONTEXT_RESET; + } + + /* Return a failure due to a GPU hang. */ r = amdgpu_cs_query_reset_state(ctx->ctx, &result, &hangs); if (r) { fprintf(stderr, "amdgpu: amdgpu_cs_query_reset_state failed. (%i)\n", r); @@ -1041,6 +1049,9 @@ void amdgpu_cs_submit_ib(void *job, int thread_index) "see dmesg for more information (%i).\n", r); amdgpu_fence_signalled(cs->fence); + + acs->ctx->num_rejected_cs++; + ws->num_total_rejected_cs++; } else { /* Success. */ uint64_t *user_fence = NULL; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h index 5f181a5dad9..90b9e839908 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h @@ -41,6 +41,8 @@ struct amdgpu_ctx { amdgpu_bo_handle user_fence_bo; uint64_t *user_fence_cpu_address_base; int refcount; + unsigned initial_num_total_rejected_cs; + unsigned num_rejected_cs; }; struct amdgpu_cs_buffer { diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h index 2a7900a68d9..c56c342a53a 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h @@ -55,6 +55,7 @@ struct amdgpu_winsys { pipe_mutex bo_fence_lock; int num_cs; /* The number of command streams created. */ + unsigned num_total_rejected_cs; uint32_t next_bo_unique_id; uint64_t allocated_vram; uint64_t allocated_gtt; -- 2.30.2