Even if the hardware is not available we should clear the pointer when the owning context is destroyed, otherwise nobody will be able to use this feature again.
Reported-by: Sashiko-bot <[email protected]> Closes: https://sashiko.dev/#/patchset/[email protected]?part=5 Signed-off-by: Pierre-Eric Pelloux-Prayer <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 25b1cf7dc988..2b318ccc9aa6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -426,15 +426,15 @@ void amdgpu_ctx_fini(struct kref *ref) } } - if (drm_dev_enter(adev_to_drm(adev), &idx)) { - mutex_lock(&adev->pm.stable_pstate_ctx_lock); - if (adev->pm.stable_pstate_ctx == ctx) { + mutex_lock(&adev->pm.stable_pstate_ctx_lock); + if (adev->pm.stable_pstate_ctx == ctx) { + if (drm_dev_enter(adev_to_drm(adev), &idx)) { __amdgpu_ctx_set_stable_pstate(ctx, ctx->stable_pstate); - adev->pm.stable_pstate_ctx = NULL; + drm_dev_exit(idx); } - mutex_unlock(&adev->pm.stable_pstate_ctx_lock); - drm_dev_exit(idx); + adev->pm.stable_pstate_ctx = NULL; } + mutex_unlock(&adev->pm.stable_pstate_ctx_lock); kfree(ctx); } -- 2.43.0
