drm/amd/display: Fix prefetch vratio check
authorAlvin Lee <Alvin.Lee2@amd.com>
Tue, 31 Jan 2023 15:12:43 +0000 (10:12 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 14 Feb 2023 21:00:40 +0000 (16:00 -0500)
[Why & How]
- For prefetch max vratio check, use the calculated
  prefetch bandwidth from dml32_CalculatePrefetchSchedule
  instead of max prefetch bandwidth
- Also multiply prefetch bandwidth by VRatio since scaling
  is not considered one calculating require prefetch bw

Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.h

index 55567b9fcfc82d539b0520c03337e307f222fa5e..7a99a6656676746e0bdfd28e005007883d7378b1 100644 (file)
@@ -942,6 +942,9 @@ static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerforman
                                        v->UrgBurstFactorLumaPre,
                                        v->UrgBurstFactorChromaPre,
                                        v->UrgBurstFactorCursorPre,
+                                       v->PrefetchBandwidth,
+                                       v->VRatio,
+                                       v->MaxVRatioPre,
 
                                        /* output */
                                        &MaxTotalRDBandwidth,
@@ -972,6 +975,9 @@ static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerforman
                                        v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
                                        v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
                                        v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
+                                       v->PrefetchBandwidth,
+                                       v->VRatio,
+                                       v->MaxVRatioPre,
 
                                        /* output */
                                        &v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[0],
@@ -3373,6 +3379,9 @@ void dml32_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
                                                        mode_lib->vba.UrgentBurstFactorLumaPre,
                                                        mode_lib->vba.UrgentBurstFactorChromaPre,
                                                        mode_lib->vba.UrgentBurstFactorCursorPre,
+                                                       v->PrefetchBW,
+                                                       v->VRatio,
+                                                       v->MaxVRatioPre,
 
                                                        /* output */
                                                        &v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[0],   // Single  *PrefetchBandwidth
index 069e9abb83cbbfde83a711be47a5fab5b27bd2e3..d1000aa4c481621961bd91788d3714d2769a6360 100644 (file)
@@ -6143,9 +6143,12 @@ void dml32_CalculatePrefetchBandwithSupport(unsigned int NumberOfActiveSurfaces,
                double UrgentBurstFactorLumaPre[],
                double UrgentBurstFactorChromaPre[],
                double UrgentBurstFactorCursorPre[],
+               double PrefetchBW[],
+               double VRatio[],
+               double MaxVRatioPre,
 
                /* output */
-               double  *PrefetchBandwidth,
+               double  *MaxPrefetchBandwidth,
                double  *FractionOfUrgentBandwidth,
                bool *PrefetchBandwidthSupport)
 {
@@ -6153,25 +6156,33 @@ void dml32_CalculatePrefetchBandwithSupport(unsigned int NumberOfActiveSurfaces,
        double ActiveBandwidthPerSurface;
        bool NotEnoughUrgentLatencyHiding = false;
        double TotalActiveBandwidth = 0;
+       double TotalPrefetchBandwidth = 0;
+
        for (k = 0; k < NumberOfActiveSurfaces; ++k) {
                if (NotUrgentLatencyHiding[k]) {
                        NotEnoughUrgentLatencyHiding = true;
                }
        }
 
-       *PrefetchBandwidth = 0;
+       *MaxPrefetchBandwidth = 0;
        for (k = 0; k < NumberOfActiveSurfaces; ++k) {
                ActiveBandwidthPerSurface = ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k] + NumberOfDPP[k] * (meta_row_bandwidth[k] + dpte_row_bandwidth[k]);
 
                TotalActiveBandwidth += ActiveBandwidthPerSurface;
 
-               *PrefetchBandwidth = *PrefetchBandwidth + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
+               TotalPrefetchBandwidth = TotalPrefetchBandwidth + PrefetchBW[k] * VRatio[k];
+
+               *MaxPrefetchBandwidth = *MaxPrefetchBandwidth + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
                                ActiveBandwidthPerSurface,
                                NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k]) + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
        }
 
-       *PrefetchBandwidthSupport = (*PrefetchBandwidth <= ReturnBW) &&  (*PrefetchBandwidth <= TotalActiveBandwidth * __DML_MAX_BW_RATIO_PRE__) && !NotEnoughUrgentLatencyHiding;
-       *FractionOfUrgentBandwidth = *PrefetchBandwidth / ReturnBW;
+       if (MaxVRatioPre == __DML_MAX_VRATIO_PRE__)
+               *PrefetchBandwidthSupport = (*MaxPrefetchBandwidth <= ReturnBW) && (TotalPrefetchBandwidth <= TotalActiveBandwidth * __DML_MAX_BW_RATIO_PRE__) && !NotEnoughUrgentLatencyHiding;
+       else
+               *PrefetchBandwidthSupport = (*MaxPrefetchBandwidth <= ReturnBW) && !NotEnoughUrgentLatencyHiding;
+
+       *FractionOfUrgentBandwidth = *MaxPrefetchBandwidth / ReturnBW;
 }
 
 double dml32_CalculateBandwidthAvailableForImmediateFlip(unsigned int NumberOfActiveSurfaces,
index d41c4d8b0c7a33c81d5b390c93a0f9d1bcaa4ffa..9ba792c633a5dce4cee524ff3f8708275d5e18fb 100644 (file)
@@ -1096,9 +1096,12 @@ void dml32_CalculatePrefetchBandwithSupport(unsigned int NumberOfActiveSurfaces,
                double UrgentBurstFactorLumaPre[],
                double UrgentBurstFactorChromaPre[],
                double UrgentBurstFactorCursorPre[],
+               double PrefetchBW[],
+               double VRatio[],
+               double MaxVRatioPre,
 
                /* output */
-               double  *PrefetchBandwidth,
+               double  *MaxPrefetchBandwidth,
                double  *FractionOfUrgentBandwidth,
                bool *PrefetchBandwidthSupport);