As the QGV points are sorted based on dclk for pmdemand cases, there is no need to go through the entire QGV points to find out the acceptable peak bw. We could break the loop as soon as we find out the first QGV point with the acceptable deratedbw for the current display required bw.
Signed-off-by: Vinod Govindapillai <[email protected]> --- drivers/gpu/drm/i915/display/intel_bw.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c index f05fdb5f24c9..177c3fd8f74a 100644 --- a/drivers/gpu/drm/i915/display/intel_bw.c +++ b/drivers/gpu/drm/i915/display/intel_bw.c @@ -1080,10 +1080,8 @@ static int mtl_find_qgv_points(struct intel_display *display, unsigned int num_active_planes, struct intel_bw_state *new_bw_state) { - unsigned int best_rate = UINT_MAX; unsigned int num_qgv_points = display->bw.max[0].num_qgv_points; unsigned int qgv_peak_bw = 0; - int i; int ret; ret = intel_atomic_lock_global_state(&new_bw_state->base); @@ -1105,7 +1103,7 @@ static int mtl_find_qgv_points(struct intel_display *display, * Find the best QGV point by comparing the data_rate with max data rate * offered per plane group */ - for (i = 0; i < num_qgv_points; i++) { + for (int i = 0; i < num_qgv_points; i++) { unsigned int bw_index = tgl_max_bw_index(display, num_active_planes, i); unsigned int max_data_rate; @@ -1118,13 +1116,8 @@ static int mtl_find_qgv_points(struct intel_display *display, if (max_data_rate < data_rate) continue; - if (max_data_rate - data_rate < best_rate) { - best_rate = max_data_rate - data_rate; - qgv_peak_bw = display->bw.max[bw_index].peakbw[i]; - } - - drm_dbg_kms(display->drm, "QGV point %d: max bw %d required %d qgv_peak_bw: %d\n", - i, max_data_rate, data_rate, qgv_peak_bw); + qgv_peak_bw = display->bw.max[bw_index].peakbw[i]; + break; } drm_dbg_kms(display->drm, "Matching peaks QGV bw: %d for required data rate: %d\n", -- 2.43.0
