amdgpu,radeon: add needs_reset param to ctx_query_reset_status

The kernel can do different types of recovery (soft recovery, GPU reset).

Since they both increase gpu_reset_counter, this will cause all contexts
to report AMDGPU_CTX_QUERY2_FLAGS_RESET, which is a bit misleading: if
a single context was soft-recovered, the others are fine and we don't need
special processing.

This commit uses the AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST to distinguish
between the 2 kind of reset and later commits will use this information.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10179>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2021-04-09 18:04:56 +02:00
committed by Marge Bot
parent 3a56f06998
commit bc71f689f1
5 changed files with 25 additions and 6 deletions

View File

@@ -487,7 +487,7 @@ static enum pipe_reset_status r600_get_reset_status(struct pipe_context *ctx)
{ {
struct r600_common_context *rctx = (struct r600_common_context *)ctx; struct r600_common_context *rctx = (struct r600_common_context *)ctx;
return rctx->ws->ctx_query_reset_status(rctx->ctx); return rctx->ws->ctx_query_reset_status(rctx->ctx, NULL);
} }
static void r600_set_debug_callback(struct pipe_context *ctx, static void r600_set_debug_callback(struct pipe_context *ctx,

View File

@@ -491,7 +491,8 @@ struct radeon_winsys {
/** /**
* Query a GPU reset status. * Query a GPU reset status.
*/ */
enum pipe_reset_status (*ctx_query_reset_status)(struct radeon_winsys_ctx *ctx); enum pipe_reset_status (*ctx_query_reset_status)(struct radeon_winsys_ctx *ctx,
bool *needs_reset);
/** /**
* Create a command stream. * Create a command stream.

View File

@@ -352,7 +352,8 @@ static enum pipe_reset_status si_get_reset_status(struct pipe_context *ctx)
{ {
struct si_context *sctx = (struct si_context *)ctx; struct si_context *sctx = (struct si_context *)ctx;
struct si_screen *sscreen = sctx->screen; struct si_screen *sscreen = sctx->screen;
enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(sctx->ctx); bool needs_reset;
enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(sctx->ctx, &needs_reset);
if (status != PIPE_NO_RESET) { if (status != PIPE_NO_RESET) {
/* Call the gallium frontend to set a no-op API dispatch. */ /* Call the gallium frontend to set a no-op API dispatch. */

View File

@@ -334,11 +334,14 @@ static void amdgpu_ctx_destroy(struct radeon_winsys_ctx *rwctx)
} }
static enum pipe_reset_status static enum pipe_reset_status
amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx) amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx, bool *needs_reset)
{ {
struct amdgpu_ctx *ctx = (struct amdgpu_ctx*)rwctx; struct amdgpu_ctx *ctx = (struct amdgpu_ctx*)rwctx;
int r; int r;
if (needs_reset)
*needs_reset = false;
/* Return a failure due to a GPU hang. */ /* Return a failure due to a GPU hang. */
if (ctx->ws->info.drm_minor >= 24) { if (ctx->ws->info.drm_minor >= 24) {
uint64_t flags; uint64_t flags;
@@ -350,6 +353,8 @@ amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx)
} }
if (flags & AMDGPU_CTX_QUERY2_FLAGS_RESET) { if (flags & AMDGPU_CTX_QUERY2_FLAGS_RESET) {
if (needs_reset)
*needs_reset = flags & AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST;
if (flags & AMDGPU_CTX_QUERY2_FLAGS_GUILTY) if (flags & AMDGPU_CTX_QUERY2_FLAGS_GUILTY)
return PIPE_GUILTY_CONTEXT_RESET; return PIPE_GUILTY_CONTEXT_RESET;
else else
@@ -364,6 +369,8 @@ amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx)
return PIPE_NO_RESET; return PIPE_NO_RESET;
} }
if (needs_reset)
*needs_reset = true;
switch (result) { switch (result) {
case AMDGPU_CTX_GUILTY_RESET: case AMDGPU_CTX_GUILTY_RESET:
return PIPE_GUILTY_CONTEXT_RESET; return PIPE_GUILTY_CONTEXT_RESET;
@@ -376,9 +383,13 @@ amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx)
/* Return a failure due to a rejected command submission. */ /* Return a failure due to a rejected command submission. */
if (ctx->ws->num_total_rejected_cs > ctx->initial_num_total_rejected_cs) { if (ctx->ws->num_total_rejected_cs > ctx->initial_num_total_rejected_cs) {
if (needs_reset)
*needs_reset = true;
return ctx->num_rejected_cs ? PIPE_GUILTY_CONTEXT_RESET : return ctx->num_rejected_cs ? PIPE_GUILTY_CONTEXT_RESET :
PIPE_INNOCENT_CONTEXT_RESET; PIPE_INNOCENT_CONTEXT_RESET;
} }
if (needs_reset)
*needs_reset = false;
return PIPE_NO_RESET; return PIPE_NO_RESET;
} }

View File

@@ -87,14 +87,20 @@ static void radeon_drm_ctx_destroy(struct radeon_winsys_ctx *ctx)
} }
static enum pipe_reset_status static enum pipe_reset_status
radeon_drm_ctx_query_reset_status(struct radeon_winsys_ctx *rctx) radeon_drm_ctx_query_reset_status(struct radeon_winsys_ctx *rctx, bool *needs_reset)
{ {
struct radeon_ctx *ctx = (struct radeon_ctx*)rctx; struct radeon_ctx *ctx = (struct radeon_ctx*)rctx;
unsigned latest = radeon_drm_get_gpu_reset_counter(ctx->ws); unsigned latest = radeon_drm_get_gpu_reset_counter(ctx->ws);
if (ctx->gpu_reset_counter == latest) if (ctx->gpu_reset_counter == latest) {
if (needs_reset)
*needs_reset = false;
return PIPE_NO_RESET; return PIPE_NO_RESET;
}
if (needs_reset)
*needs_reset = true;
ctx->gpu_reset_counter = latest; ctx->gpu_reset_counter = latest;
return PIPE_UNKNOWN_CONTEXT_RESET; return PIPE_UNKNOWN_CONTEXT_RESET;