[PATCH 015/108] drm/i915/dp_link_training: Add helper to query pending autoretrain

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

Add link_recovery_autoretrain_pending() to make it clearer what the
condition is about at its callers: an autoretrain work has been queued.

This also prepares for replacing the sequential link training failure
counter with an enum in a follow-up change.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../drm/i915/display/intel_dp_link_training.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 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 0c5b7816dfff9..77697a7619812 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1249,6 +1249,20 @@ intel_dp_128b132b_intra_hop(struct intel_dp *intel_dp,
return sink_status & DP_INTRA_HOP_AUX_REPLY_INDICATION ? 1 : 0;
}

+/**
+ * link_recovery_autoretrain_pending - check for a pending automatic retraining
+ * @link_training: link training state
+ *
+ * Return:
+ * - %true if automatic retraining is pending.
+ * - %false otherwise.
+ */
+static bool
+link_recovery_autoretrain_pending(struct intel_dp_link_training *link_training)
+{
+ return link_training->seq_train_failures == 1;
+}
+
/**
* intel_dp_stop_link_train - stop link training
* @intel_dp: DP struct
@@ -1290,7 +1304,7 @@ void intel_dp_stop_link_train(struct intel_dp *intel_dp,

if (!display->hotplug.ignore_long_hpd &&
link_training->seq_train_failures < MAX_SEQ_TRAIN_FAILURES) {
- int delay_ms = link_training->seq_train_failures == 1 ? 0 : 2000;
+ int delay_ms = link_recovery_autoretrain_pending(link_training) ? 0 : 2000;

intel_encoder_link_check_queue_work(encoder, delay_ms);
}
@@ -1991,7 +2005,7 @@ intel_dp_needs_link_retrain(struct intel_dp *intel_dp)
if (link_training->seq_train_failures >= MAX_SEQ_TRAIN_FAILURES)
return false;

- if (link_training->seq_train_failures == 1)
+ if (link_recovery_autoretrain_pending(link_training))
return true;

/* Retrain if link not ok */
--
2.49.1