[PATCH 099/108] drm/i915/dp_link_training: Disable failed config during fallback

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

Disable the link configuration that failed training when selecting
fallback parameters.

Fallback still selects the next configuration using the existing
fallback order, but now also removes the failed configuration from the
allowed set. Functionally, this only affects the case where an MST <-> SST
mode switch occurs on the same root connector: previously, a configuration
that failed training in one mode could be reused in the other mode due
to the differing config iteration orders.

The current fallback logic also sets a temporary maximum link limit
across the allowed configurations to constrain subsequent modesets. This
legacy behavior is preserved for now; it will be removed once the
fallback logic relies solely on the individually disabled configurations
to restrict the allowed set.

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

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 6eb5b67b6168b..e7f3d40c5ec08 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -1056,6 +1056,35 @@ void intel_dp_link_caps_reset_max_limits(struct intel_dp_link_caps *link_caps)
update_max_link_info(link_caps);
}

+/**
+ * intel_dp_link_caps_disable_config - disable a configuration
+ * @link_caps: link capabilities state
+ * @config_idx: configuration index to disable
+ *
+ * Disable the configuration identified by @config_idx and update the derived
+ * maximum-link information accordingly. This removes the configuration from
+ * the set of allowed configurations.
+ *
+ * The configuration remains disallowed until intel_dp_link_caps_reset() is
+ * called, which normally happens after a connector disconnect, or until some
+ * error condition triggers recovery because the set of allowed
+ * configurations would otherwise become empty.
+ *
+ * Return:
+ * - %true if @config_idx was valid and the derived state was updated.
+ * - %false if @config_idx was invalid or the derived state could not be
+ * updated.
+ */
+bool intel_dp_link_caps_disable_config(struct intel_dp_link_caps *link_caps, int config_idx)
+{
+ if (!config_idx_is_valid(link_caps, config_idx))
+ return false;
+
+ link_caps->config_table.disabled_config_mask |= BIT(config_idx);
+
+ return update_max_link_info(link_caps);
+}
+
static void enable_link_config_no_update(struct intel_dp_link_caps *link_caps, int config_idx)
{
struct intel_display *display = to_intel_display(link_caps->dp);
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 1e4ce6a58e4fd..da2eb1f7453a0 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -205,6 +205,8 @@ int intel_dp_link_caps_get_max_config_idx(struct intel_dp_link_caps *link_caps,
enum intel_dp_link_caps_config_order_key order_key,
u32 config_mask);

+bool intel_dp_link_caps_disable_config(struct intel_dp_link_caps *link_caps, int idx);
+
void intel_dp_link_caps_get_max_limits(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *max_link_limits);
bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
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 a9955f04d507f..c47d2bc84460a 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1954,6 +1954,11 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
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;
+ struct intel_dp_link_config current_config = {
+ .rate = crtc_state->port_clock,
+ .lane_count = crtc_state->lane_count,
+ };
+ int current_config_idx;
int new_link_rate;
int new_lane_count;
int err = -1;
@@ -1965,6 +1970,13 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
return 0;
}

+ current_config_idx =
+ intel_dp_link_caps_find_allowed_config_idx(link_caps,
+ INTEL_DP_LINK_CAPS_CONFIG_MATCH_FUZZY_RATE,
+ &current_config);
+ if (drm_WARN_ON(display->drm, current_config_idx < 0))
+ return -1;
+
/*
* Temporarily reset the max link limit before selecting the fallback
* config.
@@ -1982,6 +1994,13 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
intel_dp_link_caps_get_max_limits(link_caps, &max_link_limits);
intel_dp_link_caps_reset_max_limits(link_caps);

+ /*
+ * TODO: Make fallback depend only on disabling the current config,
+ * once max_limit no longer constrains the allowed config set. Then
+ * disabling the current config will define the allowed configs for
+ * the subsequent modeset, so there will be no need to select a
+ * reduced config separately here.
+ */
if (!reduce_link_params(intel_dp, crtc_state, &new_link_rate, &new_lane_count))
goto out_restore_max_limits;

@@ -1995,6 +2014,14 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
goto out_restore_max_limits;
}

+ /*
+ * Shouldn't fail: the current config was enabled, and reducing the
+ * link parameters should still leave the fallback config allowed.
+ */
+ if (drm_WARN_ON(display->drm,
+ !intel_dp_link_caps_disable_config(link_caps, current_config_idx)))
+ return -1;
+
lt_dbg(intel_dp, DP_PHY_DPRX,
"Reducing link parameters from %dx%d to %dx%d\n",
crtc_state->lane_count, crtc_state->port_clock,
--
2.49.1