Commit 57230f0c authored by Andrey Grodzovsky's avatar Andrey Grodzovsky Committed by Alex Deucher
Browse files

drm/amdgpu: Fix sigsev when accessing MMIO on hot unplug.



Protect with drm_dev_enter/exit

Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 7d4108e4
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
 */

#include <drm/drm_auth.h>
#include <drm/drm_drv.h>
#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;
		}
	}

	if (drm_dev_enter(&adev->ddev, &idx)) {
		amdgpu_ctx_set_stable_pstate(ctx, AMDGPU_CTX_STABLE_PSTATE_NONE);
		drm_dev_exit(idx);
	}

	kfree(ctx);
}