amdgpu_pci_remove() calls drm_dev_unplug() before invoking the fini
routines. After drm_dev_unplug() the drm_dev_enter() guard in
amdgpu_ttm_fini() always returns false, so iounmap() for
aper_base_kaddr is silently skipped. On reload the PAT entry for the
aperture range is still live and ioremap_wc() returns -ENXIO, making
the driver fail to re-probe.

Remove the drm_dev_enter() guard and call iounmap() unconditionally.

Fixes: 9d0af8b4def0 ("drm/amdgpu: pre-map device buffer as cached for A+A 
config")
Signed-off-by: Asad Kamal <[email protected]>
Reviewed-by: Lijo Lazar <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 0b00625603c0..5bcb6a966941 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2278,7 +2278,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_fini(struct amdgpu_device *adev)
 {
-       int idx;
        if (!adev->mman.initialized)
                return;
 
@@ -2301,13 +2300,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
        amdgpu_ttm_unmark_vram_reserved(adev, AMDGPU_RESV_FW_VRAM_USAGE);
        amdgpu_ttm_unmark_vram_reserved(adev, AMDGPU_RESV_DRV_VRAM_USAGE);
 
-       if (drm_dev_enter(adev_to_drm(adev), &idx)) {
-
-               if (adev->mman.aper_base_kaddr)
-                       iounmap(adev->mman.aper_base_kaddr);
+       if (adev->mman.aper_base_kaddr) {
+               iounmap(adev->mman.aper_base_kaddr);
                adev->mman.aper_base_kaddr = NULL;
-
-               drm_dev_exit(idx);
        }
 
        if (!adev->gmc.is_app_apu)
-- 
2.46.0

Reply via email to