Skip to content

Commit 36681f1

Browse files
Austin Zhengalexdeucher
authored andcommitted
drm/amd/display: Account For OTO Prefetch Bandwidth When Calculating Urgent Bandwidth
[Why] 1) The current calculations for OTO prefetch bandwidth do not consider the number of DPP pipes in use. As a result, OTO prefetch bandwidth may be larger than the vactive bandwidth if multiple DPP pipes are used. OTO prefetch bandwidth should never exceed the vactive bandwidth. 2) Mode programming may be mismatched with mode support In cases where mode support has chosen to use the equalized (equ) prefetch schedule, mode programming may end up using oto prefetch schedule instead. The bandwidth required to do the oto schedule may end up being higher than the equ schedule. This can cause the required urgent bandwidth to exceed the available urgent bandwidth. [How] Output the oto prefetch bandwidth and incorperate it into the urgent bandwidth calculations even if the prefetch schedule being used is not the oto schedule. Reviewed-by: Dillon Varone <dillon.varone@amd.com> Signed-off-by: Austin Zheng <Austin.Zheng@amd.com> Signed-off-by: Zaeem Mohamed <zaeem.mohamed@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 4a4077b commit 36681f1

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4909,6 +4909,7 @@ static double get_urgent_bandwidth_required(
49094909
double ReadBandwidthChroma[],
49104910
double PrefetchBandwidthLuma[],
49114911
double PrefetchBandwidthChroma[],
4912+
double PrefetchBandwidthOto[],
49124913
double excess_vactive_fill_bw_l[],
49134914
double excess_vactive_fill_bw_c[],
49144915
double cursor_bw[],
@@ -4972,8 +4973,9 @@ static double get_urgent_bandwidth_required(
49724973
l->vm_row_bw = NumberOfDPP[k] * prefetch_vmrow_bw[k];
49734974
l->flip_and_active_bw = l->per_plane_flip_bw[k] + ReadBandwidthLuma[k] * l->adj_factor_p0 + ReadBandwidthChroma[k] * l->adj_factor_p1 + cursor_bw[k] * l->adj_factor_cur;
49744975
l->flip_and_prefetch_bw = l->per_plane_flip_bw[k] + NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * l->adj_factor_p0_pre + PrefetchBandwidthChroma[k] * l->adj_factor_p1_pre) + prefetch_cursor_bw[k] * l->adj_factor_cur_pre;
4976+
l->flip_and_prefetch_bw_oto = l->per_plane_flip_bw[k] + NumberOfDPP[k] * (PrefetchBandwidthOto[k] * l->adj_factor_p0_pre + PrefetchBandwidthChroma[k] * l->adj_factor_p1_pre) + prefetch_cursor_bw[k] * l->adj_factor_cur_pre;
49754977
l->active_and_excess_bw = (ReadBandwidthLuma[k] + excess_vactive_fill_bw_l[k]) * l->tmp_nom_adj_factor_p0 + (ReadBandwidthChroma[k] + excess_vactive_fill_bw_c[k]) * l->tmp_nom_adj_factor_p1 + dpte_row_bw[k] + meta_row_bw[k];
4976-
surface_required_bw[k] = math_max4(l->vm_row_bw, l->flip_and_active_bw, l->flip_and_prefetch_bw, l->active_and_excess_bw);
4978+
surface_required_bw[k] = math_max5(l->vm_row_bw, l->flip_and_active_bw, l->flip_and_prefetch_bw, l->active_and_excess_bw, l->flip_and_prefetch_bw_oto);
49774979

49784980
/* export peak required bandwidth for the surface */
49794981
surface_peak_required_bw[k] = math_max2(surface_required_bw[k], surface_peak_required_bw[k]);
@@ -5171,6 +5173,7 @@ static bool CalculatePrefetchSchedule(struct dml2_core_internal_scratch *scratch
51715173
s->Tsw_est3 = 0.0;
51725174
s->cursor_prefetch_bytes = 0;
51735175
*p->prefetch_cursor_bw = 0;
5176+
*p->RequiredPrefetchBWOTO = 0.0;
51745177

51755178
dcc_mrq_enable = (p->dcc_enable && p->mrq_present);
51765179

@@ -5384,6 +5387,9 @@ static bool CalculatePrefetchSchedule(struct dml2_core_internal_scratch *scratch
53845387
s->prefetch_bw_oto += (p->swath_width_chroma_ub * p->myPipe->BytePerPixelC) / s->LineTime;
53855388
}
53865389

5390+
/* oto prefetch bw should be always be less than total vactive bw */
5391+
DML2_ASSERT(s->prefetch_bw_oto < s->per_pipe_vactive_sw_bw * p->myPipe->DPPPerSurface);
5392+
53875393
s->prefetch_bw_oto = math_max2(s->per_pipe_vactive_sw_bw, s->prefetch_bw_oto) * p->mall_prefetch_sdp_overhead_factor;
53885394

53895395
s->prefetch_bw_oto = math_min2(s->prefetch_bw_oto, *p->prefetch_sw_bytes/(s->min_Lsw_oto*s->LineTime));
@@ -5394,6 +5400,12 @@ static bool CalculatePrefetchSchedule(struct dml2_core_internal_scratch *scratch
53945400
p->vm_bytes * p->HostVMInefficiencyFactor / (31 * s->LineTime) - *p->Tno_bw,
53955401
(p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor + p->meta_row_bytes + tdlut_row_bytes) / (15 * s->LineTime));
53965402

5403+
/* oto bw needs to be outputted even if the oto schedule isn't being used to avoid ms/mp mismatch.
5404+
* mp will fail if ms decides to use equ schedule and mp decides to use oto schedule
5405+
* and the required bandwidth increases when going from ms to mp
5406+
*/
5407+
*p->RequiredPrefetchBWOTO = s->prefetch_bw_oto;
5408+
53975409
#ifdef __DML_VBA_DEBUG__
53985410
dml2_printf("DML::%s: vactive_sw_bw_l = %f\n", __func__, p->vactive_sw_bw_l);
53995411
dml2_printf("DML::%s: vactive_sw_bw_c = %f\n", __func__, p->vactive_sw_bw_c);
@@ -6154,6 +6166,7 @@ static void calculate_peak_bandwidth_required(
61546166
p->surface_read_bandwidth_c,
61556167
l->zero_array, //PrefetchBandwidthLuma,
61566168
l->zero_array, //PrefetchBandwidthChroma,
6169+
l->zero_array, //PrefetchBWOTO
61576170
l->zero_array,
61586171
l->zero_array,
61596172
l->zero_array,
@@ -6190,6 +6203,7 @@ static void calculate_peak_bandwidth_required(
61906203
p->surface_read_bandwidth_c,
61916204
l->zero_array, //PrefetchBandwidthLuma,
61926205
l->zero_array, //PrefetchBandwidthChroma,
6206+
l->zero_array, //PrefetchBWOTO
61936207
p->excess_vactive_fill_bw_l,
61946208
p->excess_vactive_fill_bw_c,
61956209
p->cursor_bw,
@@ -6226,6 +6240,7 @@ static void calculate_peak_bandwidth_required(
62266240
p->surface_read_bandwidth_c,
62276241
p->prefetch_bandwidth_l,
62286242
p->prefetch_bandwidth_c,
6243+
p->prefetch_bandwidth_oto, // to prevent ms/mp mismatch when oto bw > total vactive bw
62296244
p->excess_vactive_fill_bw_l,
62306245
p->excess_vactive_fill_bw_c,
62316246
p->cursor_bw,
@@ -6262,6 +6277,7 @@ static void calculate_peak_bandwidth_required(
62626277
p->surface_read_bandwidth_c,
62636278
p->prefetch_bandwidth_l,
62646279
p->prefetch_bandwidth_c,
6280+
p->prefetch_bandwidth_oto, // to prevent ms/mp mismatch when oto bw > total vactive bw
62656281
p->excess_vactive_fill_bw_l,
62666282
p->excess_vactive_fill_bw_c,
62676283
p->cursor_bw,
@@ -6298,6 +6314,7 @@ static void calculate_peak_bandwidth_required(
62986314
p->surface_read_bandwidth_c,
62996315
p->prefetch_bandwidth_l,
63006316
p->prefetch_bandwidth_c,
6317+
p->prefetch_bandwidth_oto, // to prevent ms/mp mismatch when oto bw > total vactive bw
63016318
p->excess_vactive_fill_bw_l,
63026319
p->excess_vactive_fill_bw_c,
63036320
p->cursor_bw,
@@ -9060,6 +9077,7 @@ static bool dml_core_mode_support(struct dml2_core_calcs_mode_support_ex *in_out
90609077
CalculatePrefetchSchedule_params->VRatioPrefetchC = &mode_lib->ms.VRatioPreC[k];
90619078
CalculatePrefetchSchedule_params->RequiredPrefetchPixelDataBWLuma = &mode_lib->ms.RequiredPrefetchPixelDataBWLuma[k]; // prefetch_sw_bw_l
90629079
CalculatePrefetchSchedule_params->RequiredPrefetchPixelDataBWChroma = &mode_lib->ms.RequiredPrefetchPixelDataBWChroma[k]; // prefetch_sw_bw_c
9080+
CalculatePrefetchSchedule_params->RequiredPrefetchBWOTO = &mode_lib->ms.RequiredPrefetchBWOTO[k];
90639081
CalculatePrefetchSchedule_params->NotEnoughTimeForDynamicMetadata = &mode_lib->ms.NoTimeForDynamicMetadata[k];
90649082
CalculatePrefetchSchedule_params->Tno_bw = &mode_lib->ms.Tno_bw[k];
90659083
CalculatePrefetchSchedule_params->Tno_bw_flip = &mode_lib->ms.Tno_bw_flip[k];
@@ -9204,6 +9222,7 @@ static bool dml_core_mode_support(struct dml2_core_calcs_mode_support_ex *in_out
92049222
calculate_peak_bandwidth_params->surface_read_bandwidth_c = mode_lib->ms.vactive_sw_bw_c;
92059223
calculate_peak_bandwidth_params->prefetch_bandwidth_l = mode_lib->ms.RequiredPrefetchPixelDataBWLuma;
92069224
calculate_peak_bandwidth_params->prefetch_bandwidth_c = mode_lib->ms.RequiredPrefetchPixelDataBWChroma;
9225+
calculate_peak_bandwidth_params->prefetch_bandwidth_oto = mode_lib->ms.RequiredPrefetchBWOTO;
92079226
calculate_peak_bandwidth_params->excess_vactive_fill_bw_l = mode_lib->ms.excess_vactive_fill_bw_l;
92089227
calculate_peak_bandwidth_params->excess_vactive_fill_bw_c = mode_lib->ms.excess_vactive_fill_bw_c;
92099228
calculate_peak_bandwidth_params->cursor_bw = mode_lib->ms.cursor_bw;
@@ -9370,6 +9389,7 @@ static bool dml_core_mode_support(struct dml2_core_calcs_mode_support_ex *in_out
93709389
calculate_peak_bandwidth_params->surface_read_bandwidth_c = mode_lib->ms.vactive_sw_bw_c;
93719390
calculate_peak_bandwidth_params->prefetch_bandwidth_l = mode_lib->ms.RequiredPrefetchPixelDataBWLuma;
93729391
calculate_peak_bandwidth_params->prefetch_bandwidth_c = mode_lib->ms.RequiredPrefetchPixelDataBWChroma;
9392+
calculate_peak_bandwidth_params->prefetch_bandwidth_oto = mode_lib->ms.RequiredPrefetchBWOTO;
93739393
calculate_peak_bandwidth_params->excess_vactive_fill_bw_l = mode_lib->ms.excess_vactive_fill_bw_l;
93749394
calculate_peak_bandwidth_params->excess_vactive_fill_bw_c = mode_lib->ms.excess_vactive_fill_bw_c;
93759395
calculate_peak_bandwidth_params->cursor_bw = mode_lib->ms.cursor_bw;
@@ -11286,6 +11306,7 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex
1128611306
CalculatePrefetchSchedule_params->VRatioPrefetchC = &mode_lib->mp.VRatioPrefetchC[k];
1128711307
CalculatePrefetchSchedule_params->RequiredPrefetchPixelDataBWLuma = &mode_lib->mp.RequiredPrefetchPixelDataBWLuma[k];
1128811308
CalculatePrefetchSchedule_params->RequiredPrefetchPixelDataBWChroma = &mode_lib->mp.RequiredPrefetchPixelDataBWChroma[k];
11309+
CalculatePrefetchSchedule_params->RequiredPrefetchBWOTO = &s->dummy_single_array[0][k];
1128911310
CalculatePrefetchSchedule_params->NotEnoughTimeForDynamicMetadata = &mode_lib->mp.NotEnoughTimeForDynamicMetadata[k];
1129011311
CalculatePrefetchSchedule_params->Tno_bw = &mode_lib->mp.Tno_bw[k];
1129111312
CalculatePrefetchSchedule_params->Tno_bw_flip = &mode_lib->mp.Tno_bw_flip[k];
@@ -11428,6 +11449,7 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex
1142811449
calculate_peak_bandwidth_params->surface_read_bandwidth_c = mode_lib->mp.vactive_sw_bw_c;
1142911450
calculate_peak_bandwidth_params->prefetch_bandwidth_l = mode_lib->mp.RequiredPrefetchPixelDataBWLuma;
1143011451
calculate_peak_bandwidth_params->prefetch_bandwidth_c = mode_lib->mp.RequiredPrefetchPixelDataBWChroma;
11452+
calculate_peak_bandwidth_params->prefetch_bandwidth_oto = s->dummy_single_array[0];
1143111453
calculate_peak_bandwidth_params->excess_vactive_fill_bw_l = mode_lib->mp.excess_vactive_fill_bw_l;
1143211454
calculate_peak_bandwidth_params->excess_vactive_fill_bw_c = mode_lib->mp.excess_vactive_fill_bw_c;
1143311455
calculate_peak_bandwidth_params->cursor_bw = mode_lib->mp.cursor_bw;
@@ -11560,6 +11582,7 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex
1156011582
calculate_peak_bandwidth_params->surface_read_bandwidth_c = mode_lib->mp.vactive_sw_bw_c;
1156111583
calculate_peak_bandwidth_params->prefetch_bandwidth_l = mode_lib->mp.RequiredPrefetchPixelDataBWLuma;
1156211584
calculate_peak_bandwidth_params->prefetch_bandwidth_c = mode_lib->mp.RequiredPrefetchPixelDataBWChroma;
11585+
calculate_peak_bandwidth_params->prefetch_bandwidth_oto = s->dummy_single_array[k];
1156311586
calculate_peak_bandwidth_params->excess_vactive_fill_bw_l = mode_lib->mp.excess_vactive_fill_bw_l;
1156411587
calculate_peak_bandwidth_params->excess_vactive_fill_bw_c = mode_lib->mp.excess_vactive_fill_bw_c;
1156511588
calculate_peak_bandwidth_params->cursor_bw = mode_lib->mp.cursor_bw;

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ struct dml2_core_internal_mode_support {
484484
double WriteBandwidth[DML2_MAX_PLANES][DML2_MAX_WRITEBACK];
485485
double RequiredPrefetchPixelDataBWLuma[DML2_MAX_PLANES];
486486
double RequiredPrefetchPixelDataBWChroma[DML2_MAX_PLANES];
487+
/* oto bw should also be considered when calculating urgent bw to avoid situations oto/equ mismatches between ms and mp */
488+
double RequiredPrefetchBWOTO[DML2_MAX_PLANES];
487489
double cursor_bw[DML2_MAX_PLANES];
488490
double prefetch_cursor_bw[DML2_MAX_PLANES];
489491
double prefetch_vmrow_bw[DML2_MAX_PLANES];
@@ -1381,6 +1383,7 @@ struct dml2_core_shared_get_urgent_bandwidth_required_locals {
13811383
double vm_row_bw;
13821384
double flip_and_active_bw;
13831385
double flip_and_prefetch_bw;
1386+
double flip_and_prefetch_bw_oto;
13841387
double active_and_excess_bw;
13851388
};
13861389

@@ -1792,6 +1795,7 @@ struct dml2_core_calcs_CalculatePrefetchSchedule_params {
17921795
double *VRatioPrefetchC;
17931796
double *RequiredPrefetchPixelDataBWLuma;
17941797
double *RequiredPrefetchPixelDataBWChroma;
1798+
double *RequiredPrefetchBWOTO;
17951799
bool *NotEnoughTimeForDynamicMetadata;
17961800
double *Tno_bw;
17971801
double *Tno_bw_flip;
@@ -2025,6 +2029,7 @@ struct dml2_core_calcs_calculate_peak_bandwidth_required_params {
20252029
double *surface_read_bandwidth_c;
20262030
double *prefetch_bandwidth_l;
20272031
double *prefetch_bandwidth_c;
2032+
double *prefetch_bandwidth_oto;
20282033
double *excess_vactive_fill_bw_l;
20292034
double *excess_vactive_fill_bw_c;
20302035
double *cursor_bw;

0 commit comments

Comments
 (0)