[PATCH 073/108] drm/i915/dp_link_training: Reset the max link limits in the fallback code

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

The target maximum rate/lane count selected by the fallback logic may
exceed the current link_caps max_limits' rate/lane count, the latter of
which are used as a limit by the lookup functions when filtering allowed
configurations. To ensure the fallback search finds all relevant
candidates, temporarily reset the link_caps max_limits to the maximum
common supported capabilities.

After the fallback search completes, set the link_caps max_limits to the
configuration selected by the fallback logic, as before, determining
the allowed configurations for a subsequent modeset.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../drm/i915/display/intel_dp_link_training.c | 41 ++++++++++++++++---
1 file changed, 36 insertions(+), 5 deletions(-)

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 b7645bcbe0c2b..69396dbb94b2e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1874,10 +1874,12 @@ static bool reduce_link_params(struct intel_dp *intel_dp, const struct intel_crt
static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
const struct intel_crtc_state *crtc_state)
{
+ struct intel_display *display = to_intel_display(intel_dp);
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
struct intel_dp_link_config max_link_limits;
int new_link_rate;
int new_lane_count;
+ int err = -1;

if (intel_dp_is_edp(intel_dp) && !intel_dp->use_max_params) {
lt_dbg(intel_dp, DP_PHY_DPRX,
@@ -1886,14 +1888,34 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
return 0;
}

+ /*
+ * Temporarily reset the max link limit before selecting the fallback
+ * config.
+ *
+ * After fallback, the current logic narrows the allowed configurations
+ * to the selected config's rate and lane count. That can make a later
+ * fallback candidate fall outside the current max_limit, so reset it
+ * before searching.
+ *
+ * TODO: Make max_limit just reflect the maximum of the allowed configs
+ * at all times. Then fallback will stop narrowing the allowed set this
+ * way, the limit will never need to increase, and this reset can be
+ * removed.
+ */
+ intel_dp_link_caps_get_max_limits(link_caps, &max_link_limits);
+ intel_dp_link_caps_reset_max_limits(link_caps);
+
if (!reduce_link_params(intel_dp, crtc_state, &new_link_rate, &new_lane_count))
- return -1;
+ goto out_restore_max_limits;

if (intel_dp_is_edp(intel_dp) &&
!intel_dp_can_link_train_fallback_for_edp(intel_dp, new_link_rate, new_lane_count)) {
lt_dbg(intel_dp, DP_PHY_DPRX,
"Retrying Link training for eDP with same parameters\n");
- return 0;
+
+ err = 0;
+
+ goto out_restore_max_limits;
}

lt_dbg(intel_dp, DP_PHY_DPRX,
@@ -1904,10 +1926,19 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
max_link_limits.rate = new_link_rate;
max_link_limits.lane_count = new_lane_count;

- /* TODO: handle an update failure */
- intel_dp_link_caps_set_max_limits(link_caps, &max_link_limits);
+ err = 0;

- return 0;
+out_restore_max_limits:
+ /*
+ * Shouldn't fail: setting max_limits can only fail if they drop below
+ * the optionally forced rate/lane-count parameters, but the reduced
+ * config was chosen to satisfy those constraints.
+ */
+ if (drm_WARN_ON(display->drm,
+ !intel_dp_link_caps_set_max_limits(link_caps, &max_link_limits)))
+ err = -1;
+
+ return err;
}

static bool intel_dp_schedule_fallback_link_training(struct intel_atomic_state *state,
--
2.49.1