[PATCH 075/108] drm/i915/dp_link_training: Look up configurations using fuzzy rate matching

Imre Deak
2026-04-28T12:55:30Z

Look up an allowed link configuration during the BW-order fallback using
a fuzzy rate match to account for differences between the computed link
rate and the nominal rate tracked by the allowed configurations.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_caps.c | 20 -------------------
.../gpu/drm/i915/display/intel_dp_link_caps.h | 2 --
.../drm/i915/display/intel_dp_link_training.c | 19 +++++++++---------
3 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
index 103490eec3d23..7643c468588d0 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -878,26 +878,6 @@ bool intel_dp_link_caps_update(struct intel_dp_link_caps *link_caps,
return link_params_changed;
}

-int intel_dp_link_config_index(struct intel_dp_link_caps *link_caps,
- int link_rate, int lane_count)
-{
- const struct intel_dp_link_caps_config_table *table = &link_caps->config_table;
- int link_rate_idx = intel_dp_rate_index(table->rates, table->num_rates,
- link_rate);
- int lane_count_exp = ilog2(lane_count);
- int i;
-
- for (i = 0; i < table->num_configs; i++) {
- const struct intel_dp_link_config_entry *lc = &table->configs[i];
-
- if (lc->lane_count_exp == lane_count_exp &&
- lc->link_rate_idx == link_rate_idx)
- return i;
- }
-
- return -1;
-}
-
/**
* intel_dp_link_caps_reset - reset link capability restrictions
* @link_caps: link capabilities state
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
index b380beedd8990..6599325932ab6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -100,8 +100,6 @@ void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *forced_params);
u32 intel_dp_link_caps_get_allowed_config_mask(struct intel_dp_link_caps *link_caps);

-int intel_dp_link_config_index(struct intel_dp_link_caps *link_caps,
- int link_rate, int lane_count);
bool
intel_dp_link_caps_get_config_by_pos(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_caps_config_order config_order,
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index 9dd302bb4968b..fb20795a7086f 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1782,8 +1782,16 @@ static bool reduce_link_params_in_bw_order(struct intel_dp *intel_dp,
forced_rate = forced_params.rate;
forced_lane_count = forced_params.lane_count;

- i = intel_dp_link_config_index(intel_dp->link.caps,
- crtc_state->port_clock, crtc_state->lane_count);
+ /*
+ * The computed link rate could differ from the nominal rate
+ * due to platform specific PLL restrictions, so use a fuzzy
+ * matching.
+ */
+ i = intel_dp_link_caps_find_allowed_config_pos(link_caps,
+ bw_asc_order,
+ INTEL_DP_LINK_CAPS_CONFIG_MATCH_FUZZY_RATE,
+ &link_config);
+
for (i--; i >= 0; i--) {
bool config_found;

@@ -1794,13 +1802,6 @@ static bool reduce_link_params_in_bw_order(struct intel_dp *intel_dp,
if (drm_WARN_ON(display->drm, !config_found))
return false;

- /*
- * Atm, the index of the configuration must match its
- * iteration position.
- */
- if (drm_WARN_ON(display->drm, link_config_idx != i))
- return false;
-
link_rate = link_config.rate;
lane_count = link_config.lane_count;

--
2.49.1