drm/amd/display: properly handling AGP aperture in vm setup
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 31 Jan 2023 14:56:46 +0000 (09:56 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 3 Feb 2023 20:42:00 +0000 (15:42 -0500)
Take into account whether or not the AGP aperture is
enabled or not when calculating the system aperture.

Fixes white screens with DCN 3.1.4.

Based on a patch from Yifan Zhang <yifan1.zhang@amd.com>

Cc: Yifan Zhang <yifan1.zhang@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Yifan Zhang <yifan1.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index c40cbfb758b53d849b1fbd173d487301f8b22063..7cfc089084eda5a3861e21676fb7890fe7984c2e 100644 (file)
@@ -1185,24 +1185,38 @@ static void mmhub_read_system_context(struct amdgpu_device *adev, struct dc_phy_
 
        memset(pa_config, 0, sizeof(*pa_config));
 
-       logical_addr_low  = min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18;
-       pt_base = amdgpu_gmc_pd_addr(adev->gart.bo);
-
-       if (adev->apu_flags & AMD_APU_IS_RAVEN2)
-               /*
-                * Raven2 has a HW issue that it is unable to use the vram which
-                * is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR. So here is the
-                * workaround that increase system aperture high address (add 1)
-                * to get rid of the VM fault and hardware hang.
-                */
-               logical_addr_high = max((adev->gmc.fb_end >> 18) + 0x1, adev->gmc.agp_end >> 18);
-       else
-               logical_addr_high = max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18;
-
        agp_base = 0;
        agp_bot = adev->gmc.agp_start >> 24;
        agp_top = adev->gmc.agp_end >> 24;
 
+       /* AGP aperture is disabled */
+       if (agp_bot == agp_top) {
+               logical_addr_low  = adev->gmc.vram_start >> 18;
+               if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                       /*
+                        * Raven2 has a HW issue that it is unable to use the vram which
+                        * is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR. So here is the
+                        * workaround that increase system aperture high address (add 1)
+                        * to get rid of the VM fault and hardware hang.
+                        */
+                       logical_addr_high = (adev->gmc.fb_end >> 18) + 0x1;
+               else
+                       logical_addr_high = adev->gmc.vram_end >> 18;
+       } else {
+               logical_addr_low  = min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18;
+               if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                       /*
+                        * Raven2 has a HW issue that it is unable to use the vram which
+                        * is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR. So here is the
+                        * workaround that increase system aperture high address (add 1)
+                        * to get rid of the VM fault and hardware hang.
+                        */
+                       logical_addr_high = max((adev->gmc.fb_end >> 18) + 0x1, adev->gmc.agp_end >> 18);
+               else
+                       logical_addr_high = max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18;
+       }
+
+       pt_base = amdgpu_gmc_pd_addr(adev->gart.bo);
 
        page_table_start.high_part = (u32)(adev->gmc.gart_start >> 44) & 0xF;
        page_table_start.low_part = (u32)(adev->gmc.gart_start >> 12);