[PATCH 010/108] drm/i915/dp_link_training: Add helpers to access force retrain state

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

Add helpers to get and set the force retrain state in preparation for
moving the state from the DP struct to the link training state.

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

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 3821686484483..2ad65ef0f697e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5640,7 +5640,7 @@ static bool
intel_dp_check_mst_status(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
- bool force_retrain = intel_dp->link.force_retrain;
+ bool force_retrain = intel_dp_link_training_get_force_retrain(intel_dp->link.training);
bool reprobe_needed = false;

for (;;) {
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 1762e507dd1ec..72e023b733b33 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1929,9 +1929,25 @@ intel_dp_read_link_status(struct intel_dp *intel_dp, u8 link_status[DP_LINK_STAT
return 0;
}

+bool intel_dp_link_training_get_force_retrain(struct intel_dp_link_training *link_training)
+{
+ struct intel_dp *intel_dp = link_training->dp;
+
+ return intel_dp->link.force_retrain;
+}
+
+static void intel_dp_link_training_set_force_retrain(struct intel_dp_link_training *link_training,
+ bool forced)
+{
+ struct intel_dp *intel_dp = link_training->dp;
+
+ intel_dp->link.force_retrain = forced;
+}
+
static bool
intel_dp_needs_link_retrain(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_training *link_training = intel_dp->link.training;
u8 link_status[DP_LINK_STATUS_SIZE];

if (!intel_dp->link.active)
@@ -1948,7 +1964,7 @@ intel_dp_needs_link_retrain(struct intel_dp *intel_dp)
if (intel_psr_enabled(intel_dp))
return false;

- if (intel_dp->link.force_retrain)
+ if (intel_dp_link_training_get_force_retrain(link_training))
return true;

if (intel_dp_read_link_status(intel_dp, link_status) < 0)
@@ -1990,6 +2006,8 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder,
{
struct intel_display *display = to_intel_display(encoder);
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+ struct intel_dp_link_training *link_training =
+ intel_dp->link.training;
u8 pipe_mask;
int ret;

@@ -2017,13 +2035,13 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder,
drm_dbg_kms(display->drm,
"[ENCODER:%d:%s] retraining link (forced %s)\n",
encoder->base.base.id, encoder->base.name,
- str_yes_no(intel_dp->link.force_retrain));
+ str_yes_no(intel_dp_link_training_get_force_retrain(link_training)));

ret = intel_modeset_commit_pipes(display, pipe_mask, ctx);
if (ret == -EDEADLK)
return ret;

- intel_dp->link.force_retrain = false;
+ intel_dp_link_training_set_force_retrain(link_training, false);

if (ret)
drm_dbg_kms(display->drm,
@@ -2364,7 +2382,6 @@ static int i915_dp_force_link_retrain_show(void *data, u64 *val)
struct intel_display *display = to_intel_display(connector);
struct intel_dp_link_training *link_training =
connector_to_link_training(connector);
- struct intel_dp *intel_dp = link_training->dp;
int err;

err = drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex);
@@ -2373,7 +2390,7 @@ static int i915_dp_force_link_retrain_show(void *data, u64 *val)

intel_dp_flush_connector_commits(connector);

- *val = intel_dp->link.force_retrain;
+ *val = intel_dp_link_training_get_force_retrain(link_training);

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

@@ -2395,7 +2412,7 @@ static int i915_dp_force_link_retrain_write(void *data, u64 val)

intel_dp_flush_connector_commits(connector);

- intel_dp->link.force_retrain = val;
+ intel_dp_link_training_set_force_retrain(link_training, val);

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

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.h b/drivers/gpu/drm/i915/display/intel_dp_link_training.h
index c1e57c6aa3a7d..f80e979f7436c 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.h
@@ -58,6 +58,8 @@ void intel_dp_128b132b_sdp_crc16(struct intel_dp *intel_dp,
bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate,
u8 lane_count);

+bool intel_dp_link_training_get_force_retrain(struct intel_dp_link_training *link_training);
+
void intel_dp_link_check(struct intel_encoder *encoder);
void intel_dp_check_link_state(struct intel_dp *intel_dp);

--
2.49.1