[PATCH 045/108] drm/i915/dp_link_caps: Track max common lane count in link_caps

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

Pass the maximum common lane count to intel_dp_link_caps_update() and
track it together with the supported link rates. This prepares for
converting all users of intel_dp_max_common_lane_count() to query the
value from the link caps module instead.

This will make these queries use a cached value, similar to the
supported link rates. The cached max lane count value - along with the
rate list - is recomputed on sink capability changes, via RX_CAP_CHANGED
HPD IRQ or long HPD pulse, through intel_dp_detect() and
intel_dp_reset_link_params() respectively, so using a cached value is
ok.

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

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 666bb8e51f59e..ef980ab274e34 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -698,7 +698,8 @@ static bool intel_dp_set_common_link_params(struct intel_dp *intel_dp)

intel_dp_get_common_rates(intel_dp, common_rates, &num_common_rates);
if (intel_dp_link_caps_update(intel_dp,
- common_rates, num_common_rates))
+ common_rates, num_common_rates,
+ 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);
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 fc0c100835595..214974658b343 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -24,6 +24,7 @@ struct intel_dp_link_caps {
/* Rate, lane count caps common to source and sink. */
int num_rates;
int rates[DP_MAX_SUPPORTED_RATES];
+ int max_lane_count;

/* common rate,lane_count configs in bw order */
int num_configs;
@@ -208,7 +209,7 @@ static bool current_common_caps_match(struct intel_dp_link_caps *link_caps,

/* Return %true if the supported link parameters have changed. */
bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
- const int *rates, int num_rates)
+ const int *rates, int num_rates, int max_lane_count)
{
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
struct intel_display *display = to_intel_display(intel_dp);
@@ -220,13 +221,13 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
int i;
int j;

- if (drm_WARN_ON(display->drm, !is_power_of_2(intel_dp_max_common_lane_count(intel_dp))))
+ if (drm_WARN_ON(display->drm, !is_power_of_2(max_lane_count)))
return false;

if (drm_WARN_ON(display->drm, num_rates > ARRAY_SIZE(link_caps->rates)))
return false;

- num_common_lane_configs = ilog2(intel_dp_max_common_lane_count(intel_dp)) + 1;
+ num_common_lane_configs = ilog2(max_lane_count) + 1;

if (drm_WARN_ON(display->drm, num_rates * num_common_lane_configs >
ARRAY_SIZE(link_caps->configs)))
@@ -237,6 +238,8 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,

memcpy(link_caps->rates, rates, num_rates * sizeof(rates[0]));
link_caps->num_rates = num_rates;
+ link_caps->max_lane_count = max_lane_count;
+
link_caps->num_configs = num_rates * num_common_lane_configs;

lc = &link_caps->configs[0];
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 7ec1612a044ed..7a2e383caeef4 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -27,7 +27,7 @@ int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lan
void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count);

bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
- const int *rates, int num_rates);
+ const int *rates, int num_rates, int max_lane_count);

void intel_dp_link_caps_debugfs_add(struct intel_connector *connector);

--
2.49.1