amdgpu,radeon: add full_reset_only param to ctx_query_reset_status

Using this boolean the caller tells if it wants to ignore resets
fixed by a soft recovery.

When true, amdgpu can skip the call to libdrm if no cs has been
rejected (since only full gpu reset cause cs rejections).

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-12 10:04:02 +02:00
committed by Marge Bot
parent 93183480fc
commit 8fd912b9ae
5 changed files with 17 additions and 7 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, NULL); return rctx->ws->ctx_query_reset_status(rctx->ctx, false, NULL);
} }
static void r600_set_debug_callback(struct pipe_context *ctx, static void r600_set_debug_callback(struct pipe_context *ctx,

View File

@@ -492,6 +492,7 @@ 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 full_reset_only,
bool *needs_reset); bool *needs_reset);
/** /**

View File

@@ -355,7 +355,7 @@ static enum pipe_reset_status si_get_reset_status(struct pipe_context *ctx)
return PIPE_NO_RESET; return PIPE_NO_RESET;
bool needs_reset; bool needs_reset;
enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(sctx->ctx, &needs_reset); enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(sctx->ctx, false, &needs_reset);
if (status != PIPE_NO_RESET && needs_reset && !(sctx->context_flags & SI_CONTEXT_FLAG_AUX)) { if (status != PIPE_NO_RESET && needs_reset && !(sctx->context_flags & SI_CONTEXT_FLAG_AUX)) {
/* Call the gallium frontend to set a no-op API dispatch. */ /* Call the gallium frontend to set a no-op API dispatch. */
@@ -744,12 +744,11 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
/* Check if the aux_context needs to be recreated */ /* Check if the aux_context needs to be recreated */
struct si_context *saux = (struct si_context *)sscreen->aux_context; struct si_context *saux = (struct si_context *)sscreen->aux_context;
bool needs_reset;
simple_mtx_lock(&sscreen->aux_context_lock); simple_mtx_lock(&sscreen->aux_context_lock);
enum pipe_reset_status status = sctx->ws->ctx_query_reset_status( enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(
saux->ctx, &needs_reset); saux->ctx, true, NULL);
if (status != PIPE_NO_RESET && needs_reset) { if (status != PIPE_NO_RESET) {
/* We lost the aux_context, create a new one */ /* We lost the aux_context, create a new one */
struct u_log_context *aux_log = (saux)->log; struct u_log_context *aux_log = (saux)->log;
sscreen->aux_context->set_log_context(sscreen->aux_context, NULL); sscreen->aux_context->set_log_context(sscreen->aux_context, NULL);

View File

@@ -334,7 +334,8 @@ 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, bool *needs_reset) amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx, bool full_reset_only,
bool *needs_reset)
{ {
struct amdgpu_ctx *ctx = (struct amdgpu_ctx*)rwctx; struct amdgpu_ctx *ctx = (struct amdgpu_ctx*)rwctx;
int r; int r;
@@ -346,6 +347,14 @@ amdgpu_ctx_query_reset_status(struct radeon_winsys_ctx *rwctx, bool *needs_reset
if (ctx->ws->info.drm_minor >= 24) { if (ctx->ws->info.drm_minor >= 24) {
uint64_t flags; uint64_t flags;
if (full_reset_only &&
ctx->initial_num_total_rejected_cs == ctx->ws->num_total_rejected_cs) {
/* If the caller is only interested in full reset (= wants to ignore soft
* recoveries), we can use the rejected cs count as a quick first check.
*/
return PIPE_NO_RESET;
}
r = amdgpu_cs_query_reset_state2(ctx->ctx, &flags); r = amdgpu_cs_query_reset_state2(ctx->ctx, &flags);
if (r) { if (r) {
fprintf(stderr, "amdgpu: amdgpu_cs_query_reset_state failed. (%i)\n", r); fprintf(stderr, "amdgpu: amdgpu_cs_query_reset_state failed. (%i)\n", r);

View File

@@ -87,7 +87,8 @@ 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, bool *needs_reset) radeon_drm_ctx_query_reset_status(struct radeon_winsys_ctx *rctx, bool full_reset_only,
bool *needs_reset)
{ {
struct radeon_ctx *ctx = (struct radeon_ctx*)rctx; struct radeon_ctx *ctx = (struct radeon_ctx*)rctx;