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. Signed-off-by: Jesse Zhang <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index d54cec3e4a53..351c19d2940e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -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; -- 2.49.0
