From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.152.102 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795444186; b=Bi5mxL+d30uFkFqs8d6f1g3LP5nC66ljZj/4uihZmo8Zg2VZT55jpglww1xIU4zT/jMp O9hKKYvPXoZr6pETqFEGkcOD5PVUdbthqYhilBSsAFXEUTcASv1/9m38xydB3tyiCK4uj 01qpLZhUCK8klAlT9LxmUOHF0PTP1XAY/MMgxm1dJlSn9A0b3a4JqzsjiY/A6UFbsAKQn IZuXmuOab7bywEed6UGellrxrbRySpMSiDdAG4DBGBUiiTEviOVwtASeECjKNXLCh41lJ UD1US6hQ6gIbAQRyHtR/6o6bPisLDe4zRU+CldIMsJZujKhaQqN3ajt3JxCyByPAXqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795444186; h=DMARC-Filter:DKIM-Signature:DKIM-Signature:Message-Instance: DKIM2-Signature:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=MkXnQPFLIFeUAv/oZsnhM3iAjKBN6O3d1KdR5juhmQ4=; b=MaJ+tMpMf1ZKr2vZzlpdIwxlZ8o3galCUPhJe/jFwhiaHj1iYCTB77ylkd3DUdJLAzck Tq7fczfhEF/tBw5QjOS/6M0HZrfhhBSr25mm/fAv+lbHJPturddM6nbKjl37P5cK/1wMh jD78LTZnMeiQeNCWB0VsMpiEx5R4jWGUdrutgB81xC45ZShL0rDHMKsZEF7wSPqXwuGIY 9Az6ERdtREJxhQbKduU8da3srtGJh7Ovm8SCSV2BKorMugYYsN7IF+WIoOriWV4r2FkIi ozYI9sT2bmd8+KwNeQsZdj4ZGQwzBGFsWMtqkK3GPl7H6GZtj3lvqCcVp2+Fi/hsCFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=damsy.net; spf=pass smtp.mailfrom=damsy.net; dkim=pass header.d=damsy.net header.i=@damsy.net header.a=ed25519-sha256 header.s=v1-ed25519-20261120 header.b=fEbnlYJZ; dkim=pass header.d=damsy.net header.i=@damsy.net header.a=rsa-sha256 header.s=v1-rsa-20261120 header.b=NuFOaKFD; arc=none smtp.remote-ip=51.159.152.102 Received: from jeth.damsy.net (jeth.damsy.net [51.159.152.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89EAE606A31A for ; Mon, 23 Nov 2026 14:29:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 89EAE606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=damsy.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=damsy.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass header.d=damsy.net header.i=@damsy.net header.a=ed25519-sha256 header.s=v1-ed25519-20261120 header.b=fEbnlYJZ; dkim=pass (2048-bit key, unprotected) header.d=damsy.net header.i=@damsy.net header.a=rsa-sha256 header.s=v1-rsa-20261120 header.b=NuFOaKFD DKIM-Signature: v=1; a=ed25519-sha256; s=v1-ed25519-20261120; d=damsy.net; c=relaxed/relaxed; r=y; h=From:To:Subject:Date:Message-ID; t=1795444175; bh=MkXnQPFLIFeUAv/oZsnhM3i AjKBN6O3d1KdR5juhmQ4=; b=fEbnlYJZMpnztPIdejn1GckTJYKagcwlK5PzMQ+jvUPSaRyRrg YQQxexw9Yhnut06Ji+b6ihSiIncgiOArRHAQ==; DKIM-Signature: v=1; a=rsa-sha256; s=v1-rsa-20261120; d=damsy.net; c=relaxed/relaxed; r=y; h=From:To:Subject:Date:Message-ID; t=1795444175; bh=MkXnQPFLIFeUAv/oZsnhM3i AjKBN6O3d1KdR5juhmQ4=; b=NuFOaKFDRRkTSsvY3+rtDeXGuftwGXsysw7eg43TOOe/4nyCDW D19Ws+ud1CkPOo3TNQOyY1lKgthe3qDD4t/LDPtZ2DSteqly9wI43AplUIgpWJLk4MGX77r0n2g /2DS3vZsriU+vfAdxahD42GBLFwM6GG87pB49grBK81/EPA3XgHqbZchAu8kn9Hck26tSKF2/3c +36h1XO4MCQ79v+2VCoihy0vQ2lKZnFnLyahrP+XuGcKHff5MRxzGe/HaqKLsQvEkwSKfkodbZY bBbmuyczLp+R344cYwXVGD5jHiHFvHtvAKBT4Q54hMWkoAhFwNV+xGXhgtwSjVbCxFA==; Message-Instance: m=1; h=sha256:0XMuYedH1noaDs/q1o9zl5pibrmf2FTLmTddTXnl UWQ=:1xDnvxYSVgWGiu5qFtXcLEt7qWe4HSTrLPqyrluC7CY=; DKIM2-Signature: i=1; m=1; t=1795444175; d=damsy.net; mf=PHBpZXJyZS1lcmlj QGRhbXN5Lm5ldD4=; rt=PGFsZXhhbmRlci5kZXVjaGVyQGFtZC5jb20+,PGNocmlzdGlhbi5r b2VuaWdAYW1kLmNvbT4=,PHBpZXJyZS1lcmljLnBlbGxvdXgtcHJheWVyQGFtZC5jb20+,PHNp bW9uYUBmZndsbC5jaD4=,PGFpcmxpZWRAZ21haWwuY29tPg==,PGFtZC1nZnhAbGlzdHMuZnJl ZWRlc2t0b3Aub3JnPg==,PGRyaS1kZXZlbEBsaXN0cy5mcmVlZGVza3RvcC5vcmc+,PGxpbnV4 LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=v2-mldsa44-20261103:mldsa44:z4SDfc+o aS8Um+ry8ZU/znS5mLg/kMY1tEs1CuDGIicqiwdXjtA2Y3TRMF6xPWma+qqzLgZkocBZbgZW c51TSeyNbmex0u/FxexgIDK6GGYjm4DKXR+8Idag+k3CGJHkI+g+5ucbj1ifsiD45AkZOZIo Xyk3GDN60Mp32v4WVsg/khhWOsnBmGl9Qx7Hv0DhKr/a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Wdlw5xgWs5VicsBl6cn0BQfxWqPkb8/CS5s2e9xOOVvY+u+qLgNkT WzSX1Zkd6z8+UaFRJFDClciUmI8IvdpM04WQ6jJqABdYScDFpyZJ2kJ1JDsydC0TTbxCU9at hsmh0ZbzhtKP9jj2mR9uJzCXwmep/16Tny6JDY9NeBlkOQwwz9pSc2Is5h50yjdpCClqJ1KD 2BPgAiTtACcpYXJQcul7l3d8+5YZQ3NPILg9WMW+SJC5cZC/C4Mb7aV1XZHJtCceP2kO6tUm 1/oJ+aSlb9jYgKfHKpLrxwhjpGMYtcBFZA1sUg==; Message-ID: <238b5838-a1c8-4292-9eae-0f131ac4dad0@damsy.net> Date: Mon, 23 Nov 2026 15:29:34 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/6] drm/amdgpu: introduce amdgpu_dev_enter / exit To: Pierre-Eric Pelloux-Prayer , Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , David Airlie , Simona Vetter Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20261109171333.4329-1-pierre-eric.pelloux-prayer@amd.com> <20261109171333.4329-6-pierre-eric.pelloux-prayer@amd.com> Content-Language: fr From: Pierre-Eric Pelloux-Prayer In-Reply-To: <20261109171333.4329-6-pierre-eric.pelloux-prayer@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Chritian: you gave your R-b to v3, but this version has some extra changes (see commit message), so it would require another review. Thanks, Pierre-Eric Le 09/11/2026 à 18:13, Pierre-Eric Pelloux-Prayer a écrit : > And use them instead of drm_dev_enter / exit. > > Every place that needs the GPU should already call the drm variant. > The amdgpu version also checks for the wedge status of the device. > > amdgpu_device_skip_hw_access is not used as it's not meant to be > used outside interrupt handlers and reset handler. > > Direct uses of amdgpu_device_is_wedged are still ok for paths where > drm_dev_enter is used like drm ioctls. > > As Sashiko bot pointed out in the v3 review, some places should still > use the drm_dev_enter variant: > * amdgpu_job_timedout: this function has to force-finish fences for > the other rings. > * amdgpu_device_mm_access: accessing memory should be possible for > wedged devices to allow debugging > > Link: https://sashiko.dev/#/patchset/20261029152000.22001-1-pierre-eric.pelloux-prayer@amd.com?part=5 > Signed-off-by: Pierre-Eric Pelloux-Prayer > Reviewed-by: Christian König > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++++++++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 16 ++++++++-------- > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 +++--- > drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 18 +++++++++++++----- > drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 10 +++++----- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 12 ++++++------ > drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 12 ++++++------ > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +++++----- > drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 6 +++--- > drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 6 +++--- > drivers/gpu/drm/amd/amdgpu/psp_v14_0.c | 6 +++--- > drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c | 6 +++--- > drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | 8 ++++---- > drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/vcn_v5_0_2.c | 4 ++-- > 29 files changed, 112 insertions(+), 84 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index cfbb5ab5a2fe..75989767f9b4 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -50,6 +50,7 @@ > #include > > #include > +#include > #include > #include > > @@ -1387,4 +1388,17 @@ static inline bool amdgpu_device_is_wedged(struct amdgpu_device *adev) > return atomic_read(&adev->wedge_status); > } > > +static inline bool amdgpu_dev_enter(struct amdgpu_device *adev, int *idx) > +{ > + if (amdgpu_device_is_wedged(adev)) > + return false; > + > + return drm_dev_enter(adev_to_drm(adev), idx); > +} > + > +static inline void amdgpu_dev_exit(struct amdgpu_device *adev, int idx) > +{ > + drm_dev_exit(idx); > +} > + > #endif > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > index 2b318ccc9aa6..ab3b62379e38 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > @@ -428,9 +428,9 @@ void amdgpu_ctx_fini(struct kref *ref) > > mutex_lock(&adev->pm.stable_pstate_ctx_lock); > if (adev->pm.stable_pstate_ctx == ctx) { > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > __amdgpu_ctx_set_stable_pstate(ctx, ctx->stable_pstate); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > adev->pm.stable_pstate_ctx = NULL; > } > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 7335f9c4d86f..a66e504f7023 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -3025,12 +3025,18 @@ static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) > { > struct amdgpu_device *adev = > container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work); > + int idx; > > WARN_ON_ONCE(adev->gfx.gfx_off_state); > WARN_ON_ONCE(adev->gfx.gfx_off_req_count); > > + if (!amdgpu_dev_enter(adev, &idx)) > + return; > + > if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true, 0)) > adev->gfx.gfx_off_state = true; > + > + amdgpu_dev_exit(adev, idx); > } > > /** > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > index 3e5634de077f..4c3aa4e4d4c9 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -3030,13 +3030,13 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp) > struct drm_device *dev = file_priv->minor->dev; > int idx; > > - if (fpriv && drm_dev_enter(dev, &idx)) { > + if (fpriv && amdgpu_dev_enter(drm_to_adev(dev), &idx)) { > amdgpu_evf_mgr_shutdown(&fpriv->evf_mgr); > amdgpu_userq_mgr_cancel_resume(&fpriv->userq_mgr); > amdgpu_evf_mgr_flush_suspend(&fpriv->evf_mgr); > amdgpu_userq_mgr_fini(&fpriv->userq_mgr); > amdgpu_evf_mgr_fini(&fpriv->evf_mgr); > - drm_dev_exit(idx); > + amdgpu_dev_exit(drm_to_adev(dev), idx); > } > > return drm_release(inode, filp); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > index c4c21dbbbdbf..62e98e50bf35 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > @@ -318,7 +318,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, > if (!adev->gart.ptr) > return; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > t = offset / AMDGPU_GPU_PAGE_SIZE; > @@ -335,7 +335,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, > } > amdgpu_gart_invalidate_tlb(adev); > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /** > @@ -359,7 +359,7 @@ void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, > unsigned i, j, t; > int idx; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > t = offset / AMDGPU_GPU_PAGE_SIZE; > @@ -371,7 +371,7 @@ void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, > page_base += AMDGPU_GPU_PAGE_SIZE; > } > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /** > @@ -400,7 +400,7 @@ void amdgpu_gart_map_vram_range(struct amdgpu_device *adev, uint64_t pa, > /* The SYSTEM flag indicates the pages aren't in VRAM. */ > WARN_ON_ONCE(flags & AMDGPU_PTE_SYSTEM); > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > page_base = pa; > @@ -411,7 +411,7 @@ void amdgpu_gart_map_vram_range(struct amdgpu_device *adev, uint64_t pa, > } > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /** > @@ -440,7 +440,7 @@ void amdgpu_gart_map_gfx9_mqd(struct amdgpu_device *adev, uint64_t offset, > if (!adev->gart.ptr) > return; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > t = offset / AMDGPU_GPU_PAGE_SIZE; > @@ -455,7 +455,7 @@ void amdgpu_gart_map_gfx9_mqd(struct amdgpu_device *adev, uint64_t offset, > page_base += AMDGPU_GPU_PAGE_SIZE; > } > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /** > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > index 9b4c76f198f2..700e4da9cab8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > @@ -128,12 +128,12 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf) > if (ret) > return ret; > > - if (drm_dev_enter(ddev, &idx)) { > + if (amdgpu_dev_enter(drm_to_adev(ddev), &idx)) { > pm_runtime_get_noresume(ddev->dev); > > ret = amdgpu_bo_fault_reserve_notify(bo); > if (ret) { > - drm_dev_exit(idx); > + amdgpu_dev_exit(drm_to_adev(ddev), idx); > goto unlock; > } > > @@ -141,7 +141,7 @@ static vm_fault_t amdgpu_gem_fault(struct vm_fault *vmf) > TTM_BO_VM_NUM_PREFAULT); > > pm_runtime_put_noidle(ddev->dev); > - drm_dev_exit(idx); > + amdgpu_dev_exit(drm_to_adev(ddev), idx); > } else { > ret = ttm_bo_vm_dummy_page(vmf, vmf->vma->vm_page_prot); > } > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c > index 53fa9fa83ae7..94a77bf14c76 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c > @@ -728,9 +728,9 @@ void amdgpu_gmc_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, > struct amdgpu_vmhub *hub = &adev->vmhub[vmhub]; > struct dma_fence *fence; > struct amdgpu_job *job; > - int r; > + int r, idx; > > - if (amdgpu_device_is_wedged(adev)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > ring = to_amdgpu_ring(adev->mman.buffer_funcs_scheds[0]); > @@ -742,8 +742,10 @@ void amdgpu_gmc_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, > * A GPU reset should flush all TLBs anyway, so no need to do > * this while one is ongoing. > */ > - if (!down_read_trylock(&adev->reset_domain->sem)) > + if (!down_read_trylock(&adev->reset_domain->sem)) { > + amdgpu_dev_exit(adev, idx); > return; > + } > > if (adev->gmc.flush_tlb_needs_extra_type_2) > adev->gmc.gmc_funcs->flush_gpu_tlb(adev, vmid, > @@ -756,6 +758,7 @@ void amdgpu_gmc_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, > adev->gmc.gmc_funcs->flush_gpu_tlb(adev, vmid, vmhub, > flush_type); > up_read(&adev->reset_domain->sem); > + amdgpu_dev_exit(adev, idx); > return; > } > > @@ -782,11 +785,13 @@ void amdgpu_gmc_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, > > dma_fence_wait(fence, false); > dma_fence_put(fence); > + amdgpu_dev_exit(adev, idx); > > return; > > error_alloc: > mutex_unlock(&adev->mman.default_entity.lock); > + amdgpu_dev_exit(adev, idx); > dev_err(adev->dev, "Error flushing GPU TLB using the SDMA (%d)!\n", r); > } > > @@ -947,6 +952,9 @@ int amdgpu_gmc_flush_gpu_tlb_pasid_xccs(struct amdgpu_device *adev, u16 pasid, > unsigned long pending = 0; > int xcc, r = 0, err; > > + if (amdgpu_device_is_wedged(adev)) > + return -ENODEV; > + > /* > * A GPU reset should flush all TLBs anyway, so no need to do > * this while one is ongoing. > @@ -1283,7 +1291,7 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev) > u64 gart_ptb_gpu_pa = amdgpu_gmc_vram_pa(adev, adev->gart.bo); > int idx; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return; > > flags |= AMDGPU_PTE_VALID | AMDGPU_PTE_READABLE; > @@ -1315,7 +1323,7 @@ void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev) > flags |= AMDGPU_PTE_SNOOPED | AMDGPU_PDE_BFS_FLAG(adev, 0); > /* Requires gart_ptb_gpu_pa to be 4K aligned */ > amdgpu_gmc_set_pte_pde(adev, adev->gmc.ptr_pdb0, i, gart_ptb_gpu_pa, flags); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /** > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > index 6aa895f63aea..e0c1a876d76a 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c > @@ -1144,12 +1144,12 @@ void amdgpu_bo_fini(struct amdgpu_device *adev) > > amdgpu_ttm_fini(adev); > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) { > arch_phys_wc_del(adev->gmc.vram_mtrr); > arch_io_free_memtype_wc(adev->gmc.aper_base, adev->gmc.aper_size); > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > index 01dca6858833..a0fbb9af818f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > @@ -5109,7 +5109,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev, > return -EBUSY; > } > > - if (!drm_dev_enter(ddev, &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return -ENODEV; > > ret = amdgpu_ucode_request(adev, &usbc_pd_fw, AMDGPU_UCODE_REQUIRED, > @@ -5142,7 +5142,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev, > count = ret; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return count; > } > > @@ -5150,19 +5150,19 @@ int psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size) > { > int idx; > > - if (!drm_dev_enter(adev_to_drm(psp->adev), &idx)) > + if (!amdgpu_dev_enter(psp->adev, &idx)) > return -ENODEV; > > if (!bin_size || bin_size > PSP_1_MEG) { > dev_err(psp->adev->dev, "PSP firmware is invalid\n"); > - drm_dev_exit(idx); > + amdgpu_dev_exit(psp->adev, idx); > return -EINVAL; > } > > memset(psp->fw_pri_buf, 0, PSP_1_MEG); > memcpy(psp->fw_pri_buf, start_addr, bin_size); > > - drm_dev_exit(idx); > + amdgpu_dev_exit(psp->adev, idx); > return 0; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 9c3efc27b363..5209143e7c24 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -1624,7 +1624,7 @@ static int amdgpu_ttm_access_memory_sdma(struct ttm_buffer_object *bo, > if (!adev->mman.sdma_access_ptr) > return -EACCES; > > - if (!adev->mman.buffer_funcs_enabled || !drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!adev->mman.buffer_funcs_enabled || !amdgpu_dev_enter(adev, &idx)) > return -ENODEV; > > if (write) > @@ -1660,7 +1660,7 @@ static int amdgpu_ttm_access_memory_sdma(struct ttm_buffer_object *bo, > if (!(r || write)) > memcpy(buf, adev->mman.sdma_access_ptr, len); > out: > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return r; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c > index cd35ff7ca864..8668684e8e42 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c > @@ -456,14 +456,14 @@ int amdgpu_uvd_prepare_suspend(struct amdgpu_device *adev) > if (!adev->uvd.inst[j].saved_bo) > return -ENOMEM; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > /* re-write 0 since err_event_athub will corrupt VCPU buffer */ > if (amdgpu_ras_intr_triggered()) > memset(adev->uvd.inst[j].saved_bo, 0, size); > else > memcpy_fromio(adev->uvd.inst[j].saved_bo, ptr, size); > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > } > > @@ -495,9 +495,9 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) > ptr = adev->uvd.inst[i].cpu_addr; > > if (adev->uvd.inst[i].saved_bo != NULL) { > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_toio(ptr, adev->uvd.inst[i].saved_bo, size); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > kvfree(adev->uvd.inst[i].saved_bo); > adev->uvd.inst[i].saved_bo = NULL; > @@ -508,10 +508,10 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) > hdr = (const struct common_firmware_header *)adev->uvd.fw->data; > if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) { > offset = le32_to_cpu(hdr->ucode_array_offset_bytes); > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_toio(adev->uvd.inst[i].cpu_addr, adev->uvd.fw->data + offset, > le32_to_cpu(hdr->ucode_size_bytes)); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > size -= le32_to_cpu(hdr->ucode_size_bytes); > ptr += le32_to_cpu(hdr->ucode_size_bytes); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c > index 3952af9ae115..b583c4d41a1d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c > @@ -337,11 +337,11 @@ int amdgpu_vce_resume(struct amdgpu_device *adev) > hdr = (const struct common_firmware_header *)adev->vce.fw->data; > offset = le32_to_cpu(hdr->ucode_array_offset_bytes); > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memset_io(adev->vce.cpu_addr, 0, amdgpu_bo_size(adev->vce.vcpu_bo)); > memcpy_toio(adev->vce.cpu_addr, adev->vce.fw->data + offset, > adev->vce.fw->size - offset); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > return 0; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > index 34e1242d66ea..c286df7c6faf 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c > @@ -332,9 +332,9 @@ static int amdgpu_vcn_save_vcpu_bo_inst(struct amdgpu_device *adev, int i) > if (!adev->vcn.inst[i].saved_bo) > return -ENOMEM; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_fromio(adev->vcn.inst[i].saved_bo, ptr, size); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > return 0; > @@ -383,9 +383,9 @@ int amdgpu_vcn_resume(struct amdgpu_device *adev, int i) > ptr = adev->vcn.inst[i].cpu_addr; > > if (adev->vcn.inst[i].saved_bo != NULL) { > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_toio(ptr, adev->vcn.inst[i].saved_bo, size); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > kvfree(adev->vcn.inst[i].saved_bo); > adev->vcn.inst[i].saved_bo = NULL; > @@ -396,11 +396,11 @@ int amdgpu_vcn_resume(struct amdgpu_device *adev, int i) > hdr = (const struct common_firmware_header *)adev->vcn.inst[i].fw->data; > if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) { > offset = le32_to_cpu(hdr->ucode_array_offset_bytes); > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_toio(adev->vcn.inst[i].cpu_addr, > adev->vcn.inst[i].fw->data + offset, > le32_to_cpu(hdr->ucode_size_bytes)); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > size -= le32_to_cpu(hdr->ucode_size_bytes); > ptr += le32_to_cpu(hdr->ucode_size_bytes); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > index ea8688061237..01f00d55ad6f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > @@ -1035,7 +1035,7 @@ int amdgpu_vm_update_pdes(struct amdgpu_device *adev, > if (list_empty(&vm->kernel.needs_update)) > return 0; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return -ENODEV; > > memset(¶ms, 0, sizeof(params)); > @@ -1069,7 +1069,7 @@ int amdgpu_vm_update_pdes(struct amdgpu_device *adev, > amdgpu_vm_bo_idle(entry); > > error: > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return r; > } > > @@ -1170,12 +1170,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, > struct amdgpu_res_cursor cursor; > int r, idx; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return -ENODEV; > > tlb_cb = kmalloc_obj(*tlb_cb); > if (!tlb_cb) { > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return -ENOMEM; > } > > @@ -1287,7 +1287,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, > error_free: > kfree(tlb_cb); > amdgpu_vm_end_critical(¶ms); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return r; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c > index c73eb416c0e2..9d1fbddcdd7c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c > @@ -387,7 +387,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, > if (r) > return r; > > - if (!drm_dev_enter(adev_to_drm(adev), &idx)) > + if (!amdgpu_dev_enter(adev, &idx)) > return -ENODEV; > > r = vm->update_funcs->map_table(vmbo); > @@ -429,7 +429,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, > > r = vm->update_funcs->commit(¶ms, &vm->last_update); > exit: > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return r; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c > index bd3bb3bfb668..4d51e9c534f0 100644 > --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c > @@ -547,20 +547,20 @@ static int psp_v11_0_memory_training(struct psp_context *psp, uint32_t ops) > return -ENOMEM; > } > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz); > ret = psp_v11_0_memory_training_send_msg(psp, PSP_BL__DRAM_LONG_TRAIN); > if (ret) { > DRM_ERROR("Send long training msg failed.\n"); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return ret; > } > > memcpy_toio(adev->mman.aper_base_kaddr, buf, sz); > amdgpu_device_flush_hdp(adev, NULL); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } else { > vfree(buf); > return -ENODEV; > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c > index f9a3fbfc0634..43bb89d4fa33 100644 > --- a/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c > @@ -635,20 +635,20 @@ static int psp_v13_0_memory_training(struct psp_context *psp, uint32_t ops) > return -ENOMEM; > } > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz); > ret = psp_v13_0_memory_training_send_msg(psp, PSP_BL__DRAM_LONG_TRAIN); > if (ret) { > DRM_ERROR("Send long training msg failed.\n"); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return ret; > } > > memcpy_toio(adev->mman.aper_base_kaddr, buf, sz); > amdgpu_device_flush_hdp(adev, NULL); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } else { > vfree(buf); > return -ENODEV; > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c > index 888c747d6c5c..1c8476fb387d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c > @@ -494,20 +494,20 @@ static int psp_v14_0_memory_training(struct psp_context *psp, uint32_t ops) > return -ENOMEM; > } > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz); > ret = psp_v14_0_memory_training_send_msg(psp, PSP_BL__DRAM_LONG_TRAIN); > if (ret) { > DRM_ERROR("Send long training msg failed.\n"); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return ret; > } > > memcpy_toio(adev->mman.aper_base_kaddr, buf, sz); > amdgpu_device_flush_hdp(adev, NULL); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } else { > vfree(buf); > return -ENODEV; > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c b/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c > index 029d4f4b0961..739fba7a4751 100644 > --- a/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c > @@ -483,20 +483,20 @@ static int psp_v15_0_3_memory_training(struct psp_context *psp, uint32_t ops) > return -ENOMEM; > } > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > memcpy_fromio(buf, adev->mman.aper_base_kaddr, sz); > ret = psp_v15_0_3_memory_training_send_msg(psp, PSP_BL__DRAM_LONG_TRAIN); > if (ret) { > DRM_ERROR("Send long training msg failed.\n"); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > return ret; > } > > memcpy_toio(adev->mman.aper_base_kaddr, buf, sz); > amdgpu_device_flush_hdp(adev, NULL); > vfree(buf); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } else { > vfree(buf); > return -ENODEV; > diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c > index ee445d8abe47..e67f53f36f51 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c > @@ -566,14 +566,14 @@ static int vce_v4_0_suspend(struct amdgpu_ip_block *ip_block) > if (adev->vce.vcpu_bo == NULL) > return 0; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { > unsigned size = amdgpu_bo_size(adev->vce.vcpu_bo); > void *ptr = adev->vce.cpu_addr; > > memcpy_fromio(adev->vce.saved_bo, ptr, size); > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > /* > @@ -616,12 +616,12 @@ static int vce_v4_0_resume(struct amdgpu_ip_block *ip_block) > > if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > unsigned size = amdgpu_bo_size(adev->vce.vcpu_bo); > void *ptr = adev->vce.cpu_addr; > > memcpy_toio(ptr, adev->vce.saved_bo, size); > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > } else { > r = amdgpu_vce_resume(adev); > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c > index 7d2b9e4b913a..2e4b8b025b12 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c > @@ -255,9 +255,9 @@ static int vcn_v2_0_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > struct amdgpu_fw_shared *fw_shared = adev->vcn.inst->fw_shared.cpu_addr; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > fw_shared->present_flag_0 = 0; > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > amdgpu_virt_free_mm_table(adev); > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c > index 10ef5616b2f5..c10c3a672d5e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c > @@ -421,14 +421,14 @@ static int vcn_v2_5_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > struct amdgpu_fw_shared *fw_shared; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > if (adev->vcn.harvest_config & (1 << i)) > continue; > fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr; > fw_shared->present_flag_0 = 0; > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c > index 0f4f4d66e2e4..6189c096e32f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c > @@ -326,7 +326,7 @@ static int vcn_v3_0_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_fw_shared *fw_shared; > > @@ -337,7 +337,7 @@ static int vcn_v3_0_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sw_ring.is_enabled = false; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev)) > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c > index 4b7f7bbe18da..3f0185eac593 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c > @@ -277,7 +277,7 @@ static int vcn_v4_0_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn4_fw_shared *fw_shared; > > @@ -289,7 +289,7 @@ static int vcn_v4_0_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sq.is_enabled = 0; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev)) > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c > index 3f39aa83c319..ebc4729669c2 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c > @@ -296,7 +296,7 @@ static int vcn_v4_0_3_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(&adev->ddev, &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn4_fw_shared *fw_shared; > > @@ -304,7 +304,7 @@ static int vcn_v4_0_3_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->present_flag_0 = 0; > fw_shared->sq.is_enabled = cpu_to_le32(false); > } > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev)) > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c > index f30f80c1b07f..3797038d9f72 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c > @@ -248,7 +248,7 @@ static int vcn_v4_0_5_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn4_fw_shared *fw_shared; > > @@ -260,7 +260,7 @@ static int vcn_v4_0_5_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sq.is_enabled = 0; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev)) > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c > index 7b7c3bc9f046..5d6c3759fa72 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c > @@ -214,7 +214,7 @@ static int vcn_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn5_fw_shared *fw_shared; > > @@ -226,7 +226,7 @@ static int vcn_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sq.is_enabled = 0; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c > index c9e990ab297d..270fb2ab42dc 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c > @@ -259,7 +259,7 @@ static int vcn_v5_0_1_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn5_fw_shared *fw_shared; > > @@ -268,7 +268,7 @@ static int vcn_v5_0_1_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sq.is_enabled = 0; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev)) > diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_2.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_2.c > index ed47ddd5b08c..3565772288b7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_2.c > +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_2.c > @@ -179,7 +179,7 @@ static int vcn_v5_0_2_sw_fini(struct amdgpu_ip_block *ip_block) > struct amdgpu_device *adev = ip_block->adev; > int i, r, idx; > > - if (drm_dev_enter(adev_to_drm(adev), &idx)) { > + if (amdgpu_dev_enter(adev, &idx)) { > for (i = 0; i < adev->vcn.num_vcn_inst; i++) { > struct amdgpu_vcn5_fw_shared *fw_shared; > > @@ -188,7 +188,7 @@ static int vcn_v5_0_2_sw_fini(struct amdgpu_ip_block *ip_block) > fw_shared->sq.is_enabled = 0; > } > > - drm_dev_exit(idx); > + amdgpu_dev_exit(adev, idx); > } > > if (amdgpu_sriov_vf(adev))