AMD General

Ping...

-----Original Message-----
From: Chengjun Yao <[email protected]>
Sent: Monday, August 31, 2026 7:26 PM
To: Deucher, Alexander <[email protected]>; Shi, Leslie 
<[email protected]>
Cc: [email protected]; Koenig, Christian 
<[email protected]>; Kamal, Asad <[email protected]>; 
[email protected]; Yao, Chengjun <[email protected]>
Subject: [PATCH] drm/amdgpu: fix rmmio iounmap skipped on device removal

amdgpu_pci_remove() calls drm_dev_unplug() before fini_sw(), so
drm_dev_enter() is already false there and the iounmap() guarded by it is 
skipped. This .remove path runs on both hot-unplug and plain rmmod, so the 
register BAR ioremap mapping leaks one instance per unload.

Unmap rmmio unconditionally (guard only on non-NULL) and drop the now unused 
idx.

Fixes: 62d5f9f7110a ("drm/amdgpu: Unmap MMIO mappings when device is not 
unplugged")
Signed-off-by: Chengjun Yao <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 18cfa2dbcc2dc..c175c29040274 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4343,7 +4343,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)

 void amdgpu_device_fini_sw(struct amdgpu_device *adev)  {
-       int i, idx;
+       int i;
        bool px;

        amdgpu_device_ip_fini(adev);
@@ -4385,11 +4385,10 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
        if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
                vga_client_unregister(adev->pdev);

-       if (drm_dev_enter(adev_to_drm(adev), &idx)) {
-
+       /* Unmap rmmio unconditionally; drm_dev_enter() is false after unplug */
+       if (adev->rmmio) {
                iounmap(adev->rmmio);
                adev->rmmio = NULL;
-               drm_dev_exit(idx);
        }

        if (IS_ENABLED(CONFIG_PERF_EVENTS))
--
2.43.0

Reply via email to