[PATCH 001/108] drm/i915/dp: Move clamping max link rate to common rates setup

Imre Deak
2026-04-28T12:52:50Z

Limit intel_dp->link.max_rate already in intel_dp_set_common_rates(), so
it always gets updated alongside the common rates.

This prepares for detecting changes in the supported link capabilities
(common rates, lane count, and max_rate) in follow-up changes in this
patchset, allowing automatic link retraining to be re-enabled and the
maximum link parameters to be updated after such capability changes.

During the first connector probing after a sink is connected, the common
rates will be detected in intel_dp_set_common_rates() without
intel_dp->link.max_rate being set (after driver loading) or reset (after
the previous sink got disconnected) to the current sink's maximum
supported rate. In those cases max_rate will be reset in
intel_dp_reset_link_params() called after the common rates detection.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 8631df908b07f..c6a961d02a4bc 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -790,6 +790,7 @@ int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lan
static void intel_dp_set_common_rates(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
+ int len;

drm_WARN_ON(display->drm,
!intel_dp->num_source_rates || !intel_dp->num_sink_rates);
@@ -807,6 +808,10 @@ static void intel_dp_set_common_rates(struct intel_dp *intel_dp)
}

intel_dp_link_config_init(intel_dp);
+
+ len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.max_rate);
+ if (len > 0)
+ intel_dp->link.max_rate = intel_dp_common_rate(intel_dp, len - 1);
}

bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate,
@@ -1677,14 +1682,10 @@ static int forced_link_rate(struct intel_dp *intel_dp)
int
intel_dp_max_link_rate(struct intel_dp *intel_dp)
{
- int len;
-
if (intel_dp->link.force_rate)
return forced_link_rate(intel_dp);

- len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.max_rate);
-
- return intel_dp_common_rate(intel_dp, len - 1);
+ return intel_dp->link.max_rate;
}

static int
--
2.49.1