[PATCH 048/108] drm/i915/dp_link_caps: Move updating max link limits to link_caps update

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

Move updating the maximum link rate limit to intel_dp_link_caps_update(),
together with the supported link rates and maximum lane count.

This allows updating the max rate and lane count limit - the maximum
bounds over the currently allowed link configurations - alongside both
sink capability changes and link training fallback reductions of the
allowed configuration set.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 18 ---------------
.../gpu/drm/i915/display/intel_dp_link_caps.c | 22 ++++++++++++++++---
.../gpu/drm/i915/display/intel_dp_link_caps.h | 2 --
3 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 18b06e5402611..7326f6d09f186 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -690,11 +690,9 @@ static void intel_dp_get_common_rates(struct intel_dp *intel_dp,
/* Return %true if any supported or maximum link param changed. */
static bool intel_dp_set_common_link_params(struct intel_dp *intel_dp)
{
- int old_max_rate_limit = intel_dp->link.max_rate;
int num_common_rates;
int common_rates[DP_MAX_SUPPORTED_RATES];
bool link_params_changed = false;
- int len;

intel_dp_get_common_rates(intel_dp, common_rates, &num_common_rates);
if (intel_dp_link_caps_update(intel_dp,
@@ -702,13 +700,6 @@ static bool intel_dp_set_common_link_params(struct intel_dp *intel_dp)
intel_dp_max_common_lane_count(intel_dp)))
link_params_changed = true;

- 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);
-
- if (intel_dp->link.max_rate != old_max_rate_limit)
- link_params_changed = true;
-
return link_params_changed;
}

@@ -4738,8 +4729,6 @@ intel_dp_has_sink_count(struct intel_dp *intel_dp)
void intel_dp_update_sink_caps(struct intel_dp *intel_dp)
{
struct intel_connector *connector = intel_dp->attached_connector;
- int old_max_lane_count_limit = intel_dp->link.max_lane_count;
- int current_max_common_lane_count;
bool link_params_changed = false;

intel_dp_set_sink_rates(intel_dp);
@@ -4747,13 +4736,6 @@ void intel_dp_update_sink_caps(struct intel_dp *intel_dp)
if (intel_dp_set_common_link_params(intel_dp))
link_params_changed = true;

- current_max_common_lane_count = intel_dp_max_common_lane_count(intel_dp);
- intel_dp->link.max_lane_count = min(intel_dp->link.max_lane_count,
- current_max_common_lane_count);
-
- if (intel_dp->link.max_lane_count != old_max_lane_count_limit)
- link_params_changed = true;
-
if (link_params_changed)
connector->base.epoch_counter++;
}
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 5d41e6d9b07df..e514103654fde 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -48,8 +48,8 @@ struct intel_dp_link_caps {
};

/* Get length of common rates array potentially limited by max_rate. */
-int intel_dp_common_len_rate_limit(const struct intel_dp *intel_dp,
- int max_rate)
+static int intel_dp_common_len_rate_limit(const struct intel_dp *intel_dp,
+ int max_rate)
{
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;

@@ -223,12 +223,15 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
{
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
struct intel_display *display = to_intel_display(intel_dp);
+ int old_max_lane_count_limit = intel_dp->link.max_lane_count;
+ int old_max_rate_limit = intel_dp->link.max_rate;
int old_rates[DP_MAX_SUPPORTED_RATES];
struct intel_dp_link_config_entry *lc;
bool link_params_changed = false;
int num_common_lane_configs;
int old_max_lane_count;
int num_old_rates;
+ int len;
int i;
int j;

@@ -273,7 +276,20 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
old_max_lane_count))
link_params_changed = true;

- /* TODO: Also detect a change in the max link limits. */
+ /* TODO: Update these as part of the rest of max param updates. */
+ 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);
+
+ if (intel_dp->link.max_rate != old_max_rate_limit)
+ link_params_changed = true;
+
+ intel_dp->link.max_lane_count = min(intel_dp->link.max_lane_count,
+ max_lane_count);
+
+ if (intel_dp->link.max_lane_count != old_max_lane_count_limit)
+ link_params_changed = true;
+
return link_params_changed;
}

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 0283c27b71a8c..9f5bc9b7715fb 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -11,8 +11,6 @@ struct intel_dp;
struct intel_dp_link_caps;
struct intel_dp_link_config;

-int intel_dp_common_len_rate_limit(const struct intel_dp *intel_dp,
- int max_rate);
int intel_dp_common_rate(struct intel_dp *intel_dp, int index);
int intel_dp_link_caps_common_rate_idx(struct intel_dp_link_caps *link_caps, int rate);
int intel_dp_max_common_rate(struct intel_dp *intel_dp);
--
2.49.1