[PATCH 020/108] drm/i915/dp_link_training: Add no-fallback link recovery state

Imre Deak
2026-04-28T12:53:21Z

Replace the misnamed retrain_disabled flag with a dedicated link
recovery state indicating that no fallback link configurations remain.

This clarifies the meaning of the state: it has always represented the
situation where no further fallback link configurations are available.

While at it, add a TODO comment to the debugfs entry, to expose this
state via a more appropriately named entry.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../drm/i915/display/intel_dp_link_training.c | 43 +++++++++++++++++--
1 file changed, 39 insertions(+), 4 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 c44416e0e328f..cbabf01d4b670 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -84,13 +84,21 @@
* failures trigger further fallback selections and userspace
* notifications.
*
+ * @INTEL_DP_LINK_RECOVERY_NO_FALLBACK:
+ * Fallback selection is no longer possible, as no usable fallback link
+ * configurations remain. Recovery must proceed via userspace modesets
+ * using the remaining allowed link configuration. Userspace continues
+ * to be notified of subsequent link training failures.
+ *
* Describes the link recovery state used by the Intel DP link recovery
* logic.
*
* See also:
* - link_recovery_autoretrain_pending()
* - link_recovery_autoretrain_allowed()
+ * - link_recovery_has_no_fallback()
* - link_recovery_mark_train_failure()
+ * - link_recovery_mark_no_fallback()
* - link_recovery_reset()
*/
enum intel_dp_link_recovery_state {
@@ -101,6 +109,7 @@ enum intel_dp_link_recovery_state {
INTEL_DP_LINK_RECOVERY_IDLE,
INTEL_DP_LINK_RECOVERY_AUTORETRAIN_PENDING,
INTEL_DP_LINK_RECOVERY_AUTORETRAIN_DISABLED,
+ INTEL_DP_LINK_RECOVERY_NO_FALLBACK,
};

struct intel_dp_link_training {
@@ -108,7 +117,6 @@ struct intel_dp_link_training {

enum intel_dp_link_recovery_state recovery_state;

- bool retrain_disabled;
int force_train_failure;
bool force_retrain;
};
@@ -1317,6 +1325,22 @@ link_recovery_autoretrain_allowed(struct intel_dp_link_training *link_training)
return link_training->recovery_state < INTEL_DP_LINK_RECOVERY_AUTORETRAIN_DISABLED;
}

+/**
+ * link_recovery_has_no_fallback - check whether fallback is unavailable
+ * @link_training: link training state
+ *
+ * Check whether link fallback configurations are unavailable.
+ *
+ * Return:
+ * - %true if fallback is unavailable.
+ * - %false otherwise.
+ */
+static bool
+link_recovery_has_no_fallback(struct intel_dp_link_training *link_training)
+{
+ return link_training->recovery_state == INTEL_DP_LINK_RECOVERY_NO_FALLBACK;
+}
+
/**
* link_recovery_mark_train_failure - record a link training failure
* @link_training: link training state
@@ -1344,6 +1368,17 @@ link_recovery_mark_train_failure(struct intel_dp_link_training *link_training)
return link_recovery_autoretrain_allowed(link_training);
}

+/**
+ * link_recovery_mark_no_fallback - record that fallback is unavailable
+ * @link_training: link training state
+ *
+ * Record that no more link fallback configuration is available.
+ */
+static void
+link_recovery_mark_no_fallback(struct intel_dp_link_training *link_training)
+{
+ link_training->recovery_state = INTEL_DP_LINK_RECOVERY_NO_FALLBACK;
+}

/**
* link_recovery_reset - reset the link recovery state
@@ -1950,7 +1985,7 @@ void intel_dp_start_link_train(struct intel_atomic_state *state,
if (intel_dp_schedule_fallback_link_training(state, intel_dp, crtc_state))
return;

- link_training->retrain_disabled = true;
+ link_recovery_mark_no_fallback(link_training);

if (!passed)
lt_err(intel_dp, DP_PHY_DPRX, "Can't reduce link training parameters after failure\n");
@@ -2550,7 +2585,8 @@ static int i915_dp_link_retrain_disabled_show(struct seq_file *m, void *data)

intel_dp_flush_connector_commits(connector);

- seq_printf(m, "%s\n", str_yes_no(link_training->retrain_disabled));
+ /* TODO: Expose this via a debugfs entry reflecting what the state represents. */
+ seq_printf(m, "%s\n", str_yes_no(link_recovery_has_no_fallback(link_training)));

drm_modeset_unlock(&display->drm->mode_config.connection_mutex);

@@ -2590,7 +2626,6 @@ void intel_dp_link_training_debugfs_add(struct intel_connector *connector)

void intel_dp_link_training_reset(struct intel_dp_link_training *link_training)
{
- link_training->retrain_disabled = false;
link_recovery_reset(link_training);
}

--
2.49.1