[PATCH 035/108] drm/i915/dp_link_caps: Move forced link params to link_caps

Imre Deak
2026-04-28T12:53:45Z

Move tracking of the forced link parameters from struct intel_dp to
struct intel_dp_link_caps.

Previous changes made all users access these parameters through the link
caps helpers, so the state can now be kept internal to the link caps
module.

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

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index d11686ce2963d..1fae80c8c241b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1856,8 +1856,6 @@ struct intel_dp {
*/
int mst_probed_lane_count;
int mst_probed_rate;
- int force_lane_count;
- int force_rate;
struct intel_dp_link_training *training;
struct intel_dp_link_caps *caps;
} link;
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 ed05a8597fc01..e11a36ea2d178 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -15,6 +15,12 @@

struct intel_dp_link_caps {
struct intel_dp *dp;
+
+ /*
+ * Forced parameters requested via debugfs. Remains set across sink
+ * disconnects.
+ */
+ struct intel_dp_link_config forced_params;
};

/* Get length of common rates array potentially limited by max_rate. */
@@ -44,20 +50,24 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp)

static int forced_lane_count(struct intel_dp *intel_dp)
{
- if (!intel_dp->link.force_lane_count)
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+
+ if (!link_caps->forced_params.lane_count)
return 0;

- return clamp(intel_dp->link.force_lane_count, 1, intel_dp_max_common_lane_count(intel_dp));
+ return clamp(link_caps->forced_params.lane_count,
+ 1, intel_dp_max_common_lane_count(intel_dp));
}

static int forced_link_rate(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int len;

- if (!intel_dp->link.force_rate)
+ if (!link_caps->forced_params.rate)
return 0;

- len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
+ len = intel_dp_common_len_rate_limit(intel_dp, link_caps->forced_params.rate);
if (len == 0)
return intel_dp_common_rate(intel_dp, 0);

@@ -76,6 +86,7 @@ static int i915_dp_force_link_rate_show(struct seq_file *m, void *data)
struct intel_connector *connector = to_intel_connector(m->private);
struct intel_display *display = to_intel_display(connector);
struct intel_dp *intel_dp = intel_attached_dp(connector);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int current_rate = -1;
int force_rate;
int err;
@@ -90,7 +101,7 @@ static int i915_dp_force_link_rate_show(struct seq_file *m, void *data)
if (intel_dp->link.active)
current_rate = intel_dp->link_rate;

- force_rate = intel_dp->link.force_rate;
+ force_rate = link_caps->forced_params.rate;

drm_modeset_unlock(&display->drm->mode_config.connection_mutex);

@@ -150,6 +161,7 @@ static ssize_t i915_dp_force_link_rate_write(struct file *file,
struct intel_connector *connector = to_intel_connector(m->private);
struct intel_display *display = to_intel_display(connector);
struct intel_dp *intel_dp = intel_attached_dp(connector);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int rate;
int err;

@@ -164,7 +176,7 @@ static ssize_t i915_dp_force_link_rate_write(struct file *file,
intel_dp_flush_connector_commits(connector);

intel_dp_reset_link_params(intel_dp);
- intel_dp->link.force_rate = rate;
+ link_caps->forced_params.rate = rate;

drm_modeset_unlock(&display->drm->mode_config.connection_mutex);

@@ -179,6 +191,7 @@ static int i915_dp_force_lane_count_show(struct seq_file *m, void *data)
struct intel_connector *connector = to_intel_connector(m->private);
struct intel_display *display = to_intel_display(connector);
struct intel_dp *intel_dp = intel_attached_dp(connector);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int current_lane_count = -1;
int force_lane_count;
int err;
@@ -192,7 +205,7 @@ static int i915_dp_force_lane_count_show(struct seq_file *m, void *data)

if (intel_dp->link.active)
current_lane_count = intel_dp->lane_count;
- force_lane_count = intel_dp->link.force_lane_count;
+ force_lane_count = link_caps->forced_params.lane_count;

drm_modeset_unlock(&display->drm->mode_config.connection_mutex);

@@ -256,6 +269,7 @@ static ssize_t i915_dp_force_lane_count_write(struct file *file,
struct intel_connector *connector = to_intel_connector(m->private);
struct intel_display *display = to_intel_display(connector);
struct intel_dp *intel_dp = intel_attached_dp(connector);
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int lane_count;
int err;

@@ -270,7 +284,7 @@ static ssize_t i915_dp_force_lane_count_write(struct file *file,
intel_dp_flush_connector_commits(connector);

intel_dp_reset_link_params(intel_dp);
- intel_dp->link.force_lane_count = lane_count;
+ link_caps->forced_params.lane_count = lane_count;

drm_modeset_unlock(&display->drm->mode_config.connection_mutex);

--
2.49.1