[PATCH 044/108] drm/i915/dp_link_caps: Move tracking of common rates to link_caps struct

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

Now that all users access the supported link rates via helpers, move
tracking of these rates from struct intel_dp to the link_caps state.

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

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 97d2836d0e159..71cb45a2374b0 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1826,9 +1826,6 @@ struct intel_dp {
bool use_rate_select;
/* Max sink lane count as reported by DP_MAX_LANE_COUNT */
int max_sink_lane_count;
- /* intersection of source and sink rates */
- int num_common_rates;
- int common_rates[DP_MAX_SUPPORTED_RATES];
struct {
/* TODO: move the rest of link specific fields to here */
bool active;
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 c99fc7704b3e8..fc0c100835595 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -21,6 +21,10 @@
struct intel_dp_link_caps {
struct intel_dp *dp;

+ /* Rate, lane count caps common to source and sink. */
+ int num_rates;
+ int rates[DP_MAX_SUPPORTED_RATES];
+
/* common rate,lane_count configs in bw order */
int num_configs;
#define INTEL_DP_MAX_LANE_COUNT 4
@@ -30,6 +34,7 @@ struct intel_dp_link_caps {
#define INTEL_DP_MAX_LINK_CONFIGS (DP_MAX_SUPPORTED_RATES * \
INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS)
struct intel_dp_link_config_entry {
+ /* index into rates[] */
u8 link_rate_idx:INTEL_DP_LINK_RATE_IDX_BITS;
u8 lane_count_exp:INTEL_DP_LANE_COUNT_EXP_BITS;
} configs[INTEL_DP_MAX_LINK_CONFIGS];
@@ -45,19 +50,22 @@ struct intel_dp_link_caps {
int intel_dp_common_len_rate_limit(const struct intel_dp *intel_dp,
int max_rate)
{
- return intel_dp_rate_limit_len(intel_dp->common_rates,
- intel_dp->num_common_rates, max_rate);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+
+ return intel_dp_rate_limit_len(link_caps->rates,
+ link_caps->num_rates, max_rate);
}

int intel_dp_common_rate(struct intel_dp *intel_dp, int index)
{
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
struct intel_display *display = to_intel_display(intel_dp);

if (drm_WARN_ON(display->drm,
- index < 0 || index >= intel_dp->num_common_rates))
+ index < 0 || index >= link_caps->num_rates))
return 162000;

- return intel_dp->common_rates[index];
+ return link_caps->rates[index];
}

/**
@@ -78,22 +86,22 @@ 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)
{
- struct intel_dp *intel_dp = link_caps->dp;
-
- return intel_dp_rate_index(intel_dp->common_rates,
- intel_dp->num_common_rates,
+ return intel_dp_rate_index(link_caps->rates,
+ link_caps->num_rates,
rate);
}

/* Theoretical max between source and sink */
int intel_dp_max_common_rate(struct intel_dp *intel_dp)
{
- return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+
+ return intel_dp_common_rate(intel_dp, link_caps->num_rates - 1);
}

int intel_dp_link_caps_num_common_rates(struct intel_dp_link_caps *link_caps)
{
- return link_caps->dp->num_common_rates;
+ return link_caps->num_rates;
}

/**
@@ -113,10 +121,8 @@ int intel_dp_link_caps_num_common_rates(struct intel_dp_link_caps *link_caps)
void intel_dp_link_caps_all_common_rates(struct intel_dp_link_caps *link_caps,
const int **rates, int *num_rates)
{
- struct intel_dp *intel_dp = link_caps->dp;
-
- *rates = intel_dp->common_rates;
- *num_rates = intel_dp->num_common_rates;
+ *rates = link_caps->rates;
+ *num_rates = link_caps->num_rates;
}

static int forced_lane_count(struct intel_dp *intel_dp)
@@ -185,11 +191,11 @@ static int link_config_cmp_by_bw(const void *a, const void *b, const void *p)
intel_dp_link_config_rate(intel_dp, lc_b);
}

-static bool current_common_caps_match(struct intel_dp *intel_dp,
+static bool current_common_caps_match(struct intel_dp_link_caps *link_caps,
const int *rates, int num_rates)
{
- const int *current_rates = intel_dp->common_rates;
- int num_current_rates = intel_dp->num_common_rates;
+ const int *current_rates = link_caps->rates;
+ int num_current_rates = link_caps->num_rates;

if (num_current_rates != num_rates)
return false;
@@ -217,7 +223,7 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
if (drm_WARN_ON(display->drm, !is_power_of_2(intel_dp_max_common_lane_count(intel_dp))))
return false;

- if (drm_WARN_ON(display->drm, num_rates > ARRAY_SIZE(intel_dp->common_rates)))
+ 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;
@@ -226,11 +232,11 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
ARRAY_SIZE(link_caps->configs)))
return false;

- num_old_rates = intel_dp->num_common_rates;
- memcpy(old_rates, intel_dp->common_rates, num_old_rates * sizeof(old_rates[0]));
+ num_old_rates = link_caps->num_rates;
+ memcpy(old_rates, link_caps->rates, num_old_rates * sizeof(old_rates[0]));

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

lc = &link_caps->configs[0];
@@ -248,7 +254,7 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
link_config_cmp_by_bw, NULL,
intel_dp);

- if (!current_common_caps_match(intel_dp, old_rates, num_old_rates))
+ if (!current_common_caps_match(link_caps, old_rates, num_old_rates))
link_params_changed = true;

/* TODO: Also detect a change in the max lane count and max link limits. */
@@ -273,7 +279,7 @@ void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate
int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lane_count)
{
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
- int link_rate_idx = intel_dp_rate_index(intel_dp->common_rates, intel_dp->num_common_rates,
+ int link_rate_idx = intel_dp_rate_index(link_caps->rates, link_caps->num_rates,
link_rate);
int lane_count_exp = ilog2(lane_count);
int i;
--
2.49.1