drm/amdgpu: fix rmmio iounmap skipped on device removal
Subsystems (2)
PATCH 1/1 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 512KB rmmio BAR leaks one mapping per unload/reload.
Unmap rmmio unconditionally (guard only on non-NULL) and drop the now unused idx.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -4
@@ -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 ))
Signature · 1 line
2.43.0
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(), sodrm_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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -4
@@ -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
Kamal, Asad
Reviewed-byAMD General
Thanks & Regards
Asad
-----Original Message-----
From: Yao, Chengjun <[email protected]>
Sent: Monday, September 7, 2026 1:51 PM
To: Deucher, Alexander <[email protected]>; Shi, Leslie <[email protected]>; Zhang, Hawking <[email protected]>
Cc: [email protected]; Koenig, Christian <[email protected]>; Kamal, Asad <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: fix rmmio iounmap skipped on device removal
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(), sodrm_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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -4
@@ -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