drm/amdgpu: report GUILTY/INNOCENT reset from amdgpu_ctx_query()
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: report GUILTY/INNOCENT reset from amdgpu_ctx_query()
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +8 -3
@@ -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);
Signature · 1 line
2.49.0
Christian König
maintainerQuoted 6 lines · Jesse Zhang
drm/amdgpu: report guilty/innocent context reset status in ctx query
amdgpu_ctx_query()currently reportsAMDGPU_CTX_UNKNOWN_RESETwhenever the device reset counter changes, even if the context can be identified as guilty or unaffected.
Quoted 7 lines
Use
amdgpu_ctx_guilty()in the ctx query path and return:
-AMDGPU_CTX_GUILTY_RESETfor guilty contexts,
-AMDGPU_CTX_INNOCENT_RESETfor non-guilty contexts after a reset,
-AMDGPU_CTX_NO_RESETonly 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.
Quoted 43 lines
Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +8
-3@@ -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);