Kernel doorbell BOs needs to be freed before ttm_fini.

Fixes: 54c30d2a8def ("drm/amdgpu: create kernel doorbell pages")
Signed-off-by: ZhenGuo Yin <zhenguo....@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d4b01ef00025..b49604ade6c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4807,6 +4807,13 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
        int i, idx;
        bool px;
 
+       if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+               iounmap(adev->rmmio);
+               adev->rmmio = NULL;
+               amdgpu_doorbell_fini(adev);
+               drm_dev_exit(idx);
+       }
+
        amdgpu_device_ip_fini(adev);
        amdgpu_fence_driver_sw_fini(adev);
        amdgpu_ucode_release(&adev->firmware.gpu_info_fw);
@@ -4847,14 +4854,6 @@ 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)) {
-
-               iounmap(adev->rmmio);
-               adev->rmmio = NULL;
-               amdgpu_doorbell_fini(adev);
-               drm_dev_exit(idx);
-       }
-
        if (IS_ENABLED(CONFIG_PERF_EVENTS))
                amdgpu_pmu_fini(adev);
        if (adev->mman.discovery_bin)
-- 
2.35.1

Reply via email to