Skip to contentSkip to conversation

drm/amdgpu: report reset in amdgpu_ctx_query() for per-queue resets

PATCH New Jesse Zhang 1 participant 1 message Jun 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: report reset in amdgpu_ctx_query() for per-queue resets

amdgpu_ctx_query() (CTX_OP_QUERY_STATE) derives reset_status only from the global gpu_reset_counter. A per-queue reset recovers the guilty queue without a full device reset, so the counter is never bumped and QUERY_STATE keeps returning AMDGPU_CTX_NO_RESET -- while QUERY_STATE2 already reports it guilty via amdgpu_ctx_guilty().

Treat a guilty context as reset in amdgpu_ctx_query() so both ioctls agree. The reset path sets the fence error (-ETIME) before signalling it, so a woken client always observes guilty even when the counter has not changed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
index d54cec3e4a53..351c19d2940e 100644
@@ -542,6 +542,8 @@ static int amdgpu_ctx_free(struct amdgpu_fpriv *fpriv, uint32_t id)
 	return ctx ? 0 : -EINVAL;
 }
 
+static bool amdgpu_ctx_guilty(struct amdgpu_ctx *ctx);
+
 static int amdgpu_ctx_query(struct amdgpu_device *adev,
 			    struct amdgpu_fpriv *fpriv, uint32_t id,
 			    union drm_amdgpu_ctx_out *out)
@@ -568,7 +570,8 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,
 	/* determine if a GPU reset has occured since the last call */
 	reset_counter = atomic_read(&adev->gpu_reset_counter);
 	/* TODO: this should ideally return NO, GUILTY, or INNOCENT. */
-	if (ctx->reset_counter_query == reset_counter)
+	if (ctx->reset_counter_query == reset_counter &&
+	    !amdgpu_ctx_guilty(ctx))
 		out->state.reset_status = AMDGPU_CTX_NO_RESET;
 	else
 		out->state.reset_status = AMDGPU_CTX_UNKNOWN_RESET;
Signature · 1 line
2.49.0