[PATCH 050/108] drm/i915/dp_link_caps: Add helpers to set max link limits

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

Add intel_dp_link_caps_set_max_limits() to set the current maximum link
limits (max bound over all allowed configurations) through the link caps
API instead of direct accesses.

This allows tracking the state internally within the link caps module.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_caps.c | 35 +++++++++++++++++++
.../gpu/drm/i915/display/intel_dp_link_caps.h | 2 ++
.../drm/i915/display/intel_dp_link_training.c | 9 +++--
3 files changed, 44 insertions(+), 2 deletions(-)

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 f645c0a9dba69..fa8d3a140414f 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -175,6 +175,15 @@ static int intel_dp_link_config_lane_count(const struct intel_dp_link_config_ent
return 1 << lc->lane_count_exp;
}

+static void set_max_link_limits_no_update(struct intel_dp_link_caps *link_caps,
+ const struct intel_dp_link_config *max_link_limits)
+{
+ struct intel_dp *intel_dp = link_caps->dp;
+
+ intel_dp->link.max_rate = max_link_limits->rate;
+ intel_dp->link.max_lane_count = max_link_limits->lane_count;
+}
+
/**
* intel_dp_link_caps_get_max_limits - get the current maximum link limits
* @link_caps: link capabilities state
@@ -205,6 +214,32 @@ void intel_dp_link_caps_get_max_limits(struct intel_dp_link_caps *link_caps,
max_link_limits->lane_count = intel_dp->link.max_lane_count;
}

+/**
+ * intel_dp_link_caps_set_max_limits - set the current maximum link limits
+ * @link_caps: link capabilities state
+ * @max_link_limits: new maximum link limits
+ *
+ * Set the current maximum rate and lane count limits to @max_link_limits,
+ * constraining the set of allowed configurations.
+ *
+ * Unlike intel_dp_link_caps_get_max_limits(), the caller must serialize
+ * this call against concurrent queries and updates to @link_caps, in line
+ * with the rest of the API.
+ *
+ * Return:
+ * - %true if the @link_caps cached max limits value got updated with
+ * @max_link_limits.
+ * - %false if @max_link_limits is invalid.
+ */
+bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
+ const struct intel_dp_link_config *max_link_limits)
+{
+ set_max_link_limits_no_update(link_caps, max_link_limits);
+
+ /* TODO: validate max_link_limits */
+ return true;
+}
+
static int intel_dp_link_config_bw(struct intel_dp *intel_dp,
const struct intel_dp_link_config_entry *lc)
{
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 35bbe340955a6..ed053d9c81380 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -27,6 +27,8 @@ void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate

void intel_dp_link_caps_get_max_limits(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *max_link_limits);
+bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
+ const struct intel_dp_link_config *max_link_limits);

bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
const int *rates, int num_rates, int max_lane_count);
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 ff146027baa3c..5e60621f4442e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1872,6 +1872,8 @@ static bool reduce_link_params(struct intel_dp *intel_dp, const struct intel_crt
static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
const struct intel_crtc_state *crtc_state)
{
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+ struct intel_dp_link_config max_link_limits;
int new_link_rate;
int new_lane_count;

@@ -1897,8 +1899,11 @@ static int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
crtc_state->lane_count, crtc_state->port_clock,
new_lane_count, new_link_rate);

- intel_dp->link.max_rate = new_link_rate;
- intel_dp->link.max_lane_count = new_lane_count;
+ max_link_limits.rate = new_link_rate;
+ max_link_limits.lane_count = new_lane_count;
+
+ /* TODO: handle an update failure */
+ intel_dp_link_caps_set_max_limits(link_caps, &max_link_limits);

return 0;
}
--
2.49.1