On 6/11/26 09:33, Jesse Zhang wrote:
> drm/amdgpu: report guilty/innocent context reset status in ctx query
> 
> amdgpu_ctx_query() currently reports AMDGPU_CTX_UNKNOWN_RESET whenever
> the device reset counter changes, even if the context can be identified
> as guilty or unaffected.
> 
> Use amdgpu_ctx_guilty() in the ctx query path and return:
> - AMDGPU_CTX_GUILTY_RESET for guilty contexts,
> - AMDGPU_CTX_INNOCENT_RESET for non-guilty contexts after a reset,
> - AMDGPU_CTX_NO_RESET only when no reset occurred and context is not guilty.
> 
> This provides accurate per-context reset attribution to userspace instead
> of collapsing all reset cases into UNKNOWN.

I think I have to reject that.

The amdgpu_ctx_query() function is deprecated and replaced by the 
amdgpu_ctx_query2() function exactly because we couldn't extend the interface 
with such information.

IIRC the last time we tried to change it something broke in userspace and we 
had to revert that.

Just using the amdgpu_ctx_query2() should work as well.

Regards,
Christian.

> Signed-off-by: Jesse Zhang <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index d54cec3e4a53..a88443e0254c 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)
> @@ -549,6 +551,7 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,
>       struct amdgpu_ctx *ctx;
>       struct amdgpu_ctx_mgr *mgr;
>       unsigned reset_counter;
> +     bool guilty;
>  
>       if (!fpriv)
>               return -EINVAL;
> @@ -567,11 +570,13 @@ 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)
> +     guilty = amdgpu_ctx_guilty(ctx);
> +     if (ctx->reset_counter_query == reset_counter && !guilty)
>               out->state.reset_status = AMDGPU_CTX_NO_RESET;
> +     else if (guilty)
> +             out->state.reset_status = AMDGPU_CTX_GUILTY_RESET;
>       else
> -             out->state.reset_status = AMDGPU_CTX_UNKNOWN_RESET;
> +             out->state.reset_status = AMDGPU_CTX_INNOCENT_RESET;
>       ctx->reset_counter_query = reset_counter;
>  
>       mutex_unlock(&mgr->lock);

Reply via email to