From: Andrey Grodzovsky Date: Tue, 1 Mar 2022 00:03:36 +0000 (-0500) Subject: drm/amdgpu: Fix sigsev when accessing MMIO on hot unplug. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=57230f0ce6eda6d47a2029b7b3a39cc5bb63fe32;p=linux.git drm/amdgpu: Fix sigsev when accessing MMIO on hot unplug. Protect with drm_dev_enter/exit Reviewed-by: Christian König Signed-off-by: Andrey Grodzovsky Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index f522b52725e40..4294f17cedcb7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -23,6 +23,7 @@ */ #include +#include #include "amdgpu.h" #include "amdgpu_sched.h" #include "amdgpu_ras.h" @@ -339,7 +340,7 @@ static void amdgpu_ctx_fini(struct kref *ref) { struct amdgpu_ctx *ctx = container_of(ref, struct amdgpu_ctx, refcount); struct amdgpu_device *adev = ctx->adev; - unsigned i, j; + unsigned i, j, idx; if (!adev) return; @@ -350,7 +351,12 @@ static void amdgpu_ctx_fini(struct kref *ref) ctx->entities[i][j] = NULL; } } - amdgpu_ctx_set_stable_pstate(ctx, AMDGPU_CTX_STABLE_PSTATE_NONE); + + if (drm_dev_enter(&adev->ddev, &idx)) { + amdgpu_ctx_set_stable_pstate(ctx, AMDGPU_CTX_STABLE_PSTATE_NONE); + drm_dev_exit(idx); + } + kfree(ctx); }