drm/amdgpu: Enable doorbell selfring after resize FB BAR
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / amd / amdgpu / soc15.c
index 4d1487a..3221522 100644 (file)
@@ -619,13 +619,6 @@ static void soc15_program_aspm(struct amdgpu_device *adev)
                adev->nbio.funcs->program_aspm(adev);
 }
 
-static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,
-                                          bool enable)
-{
-       adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
-       adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
-}
-
 const struct amdgpu_ip_block_version vega10_common_ip_block =
 {
        .type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -1125,6 +1118,11 @@ static int soc15_common_late_init(void *handle)
        if (amdgpu_sriov_vf(adev))
                xgpu_ai_mailbox_get_irq(adev);
 
+       /* Enable selfring doorbell aperture late because doorbell BAR
+        * aperture will change if resize BAR successfully in gmc sw_init.
+        */
+       adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, true);
+
        return 0;
 }
 
@@ -1182,7 +1180,8 @@ static int soc15_common_hw_init(void *handle)
                adev->nbio.funcs->remap_hdp_registers(adev);
 
        /* enable the doorbell aperture */
-       soc15_enable_doorbell_aperture(adev, true);
+       adev->nbio.funcs->enable_doorbell_aperture(adev, true);
+
        /* HW doorbell routing policy: doorbell writing not
         * in SDMA/IH/MM/ACV range will be routed to CP. So
         * we need to init SDMA doorbell range prior
@@ -1198,8 +1197,14 @@ static int soc15_common_hw_fini(void *handle)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-       /* disable the doorbell aperture */
-       soc15_enable_doorbell_aperture(adev, false);
+       /* Disable the doorbell aperture and selfring doorbell aperture
+        * separately in hw_fini because soc15_enable_doorbell_aperture
+        * has been removed and there is no need to delay disabling
+        * selfring doorbell.
+        */
+       adev->nbio.funcs->enable_doorbell_aperture(adev, false);
+       adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, false);
+
        if (amdgpu_sriov_vf(adev))
                xgpu_ai_mailbox_put_irq(adev);