On Tue, 2026-06-16 at 23:08 +0300, Imre Deak wrote: > Move the debugfs entries for the forced and max DP link parameters to > intel_dp_link_caps. Their functionality is part of the link capability > logic and will be updated to use the link capability state in follow-up > changes. > > Signed-off-by: Imre Deak <[email protected]>
Reviewed-by: Luca Coelho <[email protected]> -- Cheers, Luca. > --- > .../drm/i915/display/intel_display_debugfs.c | 2 + > .../gpu/drm/i915/display/intel_dp_link_caps.c | 280 ++++++++++++++++++ > .../gpu/drm/i915/display/intel_dp_link_caps.h | 3 + > .../drm/i915/display/intel_dp_link_training.c | 263 ---------------- > 4 files changed, 285 insertions(+), 263 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c > b/drivers/gpu/drm/i915/display/intel_display_debugfs.c > index 08004c1ba03f4..3f02868ef105b 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c > +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c > @@ -32,6 +32,7 @@ > #include "intel_display_types.h" > #include "intel_dmc.h" > #include "intel_dp.h" > +#include "intel_dp_link_caps.h" > #include "intel_dp_link_training.h" > #include "intel_dp_mst.h" > #include "intel_dp_test.h" > @@ -1342,6 +1343,7 @@ void intel_connector_debugfs_add(struct intel_connector > *connector) > intel_psr_connector_debugfs_add(connector); > intel_alpm_lobf_debugfs_add(connector); > intel_dp_link_training_debugfs_add(connector); > + intel_dp_link_caps_debugfs_add(connector); > intel_link_bw_connector_debugfs_add(connector); > > if (DISPLAY_VER(display) >= 11 && > 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 e39e6c99ec25f..ea90e84500a89 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c > @@ -3,6 +3,7 @@ > * Copyright © 2026 Intel Corporation > */ > > +#include <linux/debugfs.h> > #include <linux/slab.h> > > #include <drm/drm_print.h> > @@ -70,6 +71,285 @@ void intel_dp_link_caps_get_forced_params(struct > intel_dp_link_caps *link_caps, > forced_params->lane_count = forced_lane_count(link_caps->dp); > } > > +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); > + int current_rate = -1; > + int force_rate; > + int err; > + int i; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + if (intel_dp->link.active) > + current_rate = intel_dp->link_rate; > + > + force_rate = intel_dp->link.force_rate; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + seq_printf(m, "%sauto%s", > + force_rate == 0 ? "[" : "", > + force_rate == 0 ? "]" : ""); > + > + for (i = 0; i < intel_dp->num_source_rates; i++) > + seq_printf(m, " %s%d%s%s", > + intel_dp->source_rates[i] == force_rate ? "[" : "", > + intel_dp->source_rates[i], > + intel_dp->source_rates[i] == current_rate ? "*" : "", > + intel_dp->source_rates[i] == force_rate ? "]" : ""); > + > + seq_putc(m, '\n'); > + > + return 0; > +} > + > +static int parse_link_rate(struct intel_dp *intel_dp, const char __user > *ubuf, size_t len) > +{ > + char *kbuf; > + const char *p; > + int rate; > + int ret = 0; > + > + kbuf = memdup_user_nul(ubuf, len); > + if (IS_ERR(kbuf)) > + return PTR_ERR(kbuf); > + > + p = strim(kbuf); > + > + if (!strcmp(p, "auto")) { > + rate = 0; > + } else { > + ret = kstrtoint(p, 0, &rate); > + if (ret < 0) > + goto out_free; > + > + if (intel_dp_rate_index(intel_dp->source_rates, > + intel_dp->num_source_rates, > + rate) < 0) > + ret = -EINVAL; > + } > + > +out_free: > + kfree(kbuf); > + > + return ret < 0 ? ret : rate; > +} > + > +static ssize_t i915_dp_force_link_rate_write(struct file *file, > + const char __user *ubuf, > + size_t len, loff_t *offp) > +{ > + struct seq_file *m = file->private_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); > + int rate; > + int err; > + > + rate = parse_link_rate(intel_dp, ubuf, len); > + if (rate < 0) > + return rate; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + intel_dp_reset_link_params(intel_dp); > + intel_dp->link.force_rate = rate; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + *offp += len; > + > + return len; > +} > +DEFINE_SHOW_STORE_ATTRIBUTE(i915_dp_force_link_rate); > + > +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); > + int current_lane_count = -1; > + int force_lane_count; > + int err; > + int i; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + if (intel_dp->link.active) > + current_lane_count = intel_dp->lane_count; > + force_lane_count = intel_dp->link.force_lane_count; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + seq_printf(m, "%sauto%s", > + force_lane_count == 0 ? "[" : "", > + force_lane_count == 0 ? "]" : ""); > + > + for (i = 1; i <= 4; i <<= 1) > + seq_printf(m, " %s%d%s%s", > + i == force_lane_count ? "[" : "", > + i, > + i == current_lane_count ? "*" : "", > + i == force_lane_count ? "]" : ""); > + > + seq_putc(m, '\n'); > + > + return 0; > +} > + > +static int parse_lane_count(const char __user *ubuf, size_t len) > +{ > + char *kbuf; > + const char *p; > + int lane_count; > + int ret = 0; > + > + kbuf = memdup_user_nul(ubuf, len); > + if (IS_ERR(kbuf)) > + return PTR_ERR(kbuf); > + > + p = strim(kbuf); > + > + if (!strcmp(p, "auto")) { > + lane_count = 0; > + } else { > + ret = kstrtoint(p, 0, &lane_count); > + if (ret < 0) > + goto out_free; > + > + switch (lane_count) { > + case 1: > + case 2: > + case 4: > + break; > + default: > + ret = -EINVAL; > + } > + } > + > +out_free: > + kfree(kbuf); > + > + return ret < 0 ? ret : lane_count; > +} > + > +static ssize_t i915_dp_force_lane_count_write(struct file *file, > + const char __user *ubuf, > + size_t len, loff_t *offp) > +{ > + struct seq_file *m = file->private_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); > + int lane_count; > + int err; > + > + lane_count = parse_lane_count(ubuf, len); > + if (lane_count < 0) > + return lane_count; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + intel_dp_reset_link_params(intel_dp); > + intel_dp->link.force_lane_count = lane_count; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + *offp += len; > + > + return len; > +} > +DEFINE_SHOW_STORE_ATTRIBUTE(i915_dp_force_lane_count); > + > +static int i915_dp_max_link_rate_show(void *data, u64 *val) > +{ > + struct intel_connector *connector = to_intel_connector(data); > + struct intel_display *display = to_intel_display(connector); > + struct intel_dp *intel_dp = intel_attached_dp(connector); > + int err; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + *val = intel_dp->link.max_rate; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + return 0; > +} > +DEFINE_DEBUGFS_ATTRIBUTE(i915_dp_max_link_rate_fops, > i915_dp_max_link_rate_show, NULL, "%llu\n"); > + > +static int i915_dp_max_lane_count_show(void *data, u64 *val) > +{ > + struct intel_connector *connector = to_intel_connector(data); > + struct intel_display *display = to_intel_display(connector); > + struct intel_dp *intel_dp = intel_attached_dp(connector); > + int err; > + > + err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > + if (err) > + return err; > + > + intel_dp_flush_connector_commits(connector); > + > + *val = intel_dp->link.max_lane_count; > + > + drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > + > + return 0; > +} > +DEFINE_DEBUGFS_ATTRIBUTE(i915_dp_max_lane_count_fops, > i915_dp_max_lane_count_show, NULL, "%llu\n"); > + > + > +/** > + * intel_dp_link_caps_debugfs_add - add link caps debugfs files for a > connector > + * @connector: connector to add the debugfs files for > + * > + * Add the link-capability debugfs files for a DP @connector. > + */ > +void intel_dp_link_caps_debugfs_add(struct intel_connector *connector) > +{ > + struct dentry *root = connector->base.debugfs_entry; > + > + if (connector->base.connector_type != DRM_MODE_CONNECTOR_DisplayPort && > + connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) > + return; > + > + debugfs_create_file("i915_dp_force_link_rate", 0644, root, > + connector, &i915_dp_force_link_rate_fops); > + > + debugfs_create_file("i915_dp_force_lane_count", 0644, root, > + connector, &i915_dp_force_lane_count_fops); > + > + debugfs_create_file("i915_dp_max_link_rate", 0444, root, > + connector, &i915_dp_max_link_rate_fops); > + > + debugfs_create_file("i915_dp_max_lane_count", 0444, root, > + connector, &i915_dp_max_lane_count_fops); > +} > + > struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp *intel_dp) > { > struct intel_dp_link_caps *link_caps; > 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 61dbce86ee3d0..c6a84891db464 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h > +++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h > @@ -4,6 +4,7 @@ > #ifndef __INTEL_DP_LINK_CAPS_H__ > #define __INTEL_DP_LINK_CAPS_H__ > > +struct intel_connector; > struct intel_dp; > struct intel_dp_link_caps; > struct intel_dp_link_config; > @@ -16,6 +17,8 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp); > void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps > *link_caps, > struct intel_dp_link_config > *forced_params); > > +void intel_dp_link_caps_debugfs_add(struct intel_connector *connector); > + > struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp > *intel_dp); > void intel_dp_link_caps_cleanup(struct intel_dp_link_caps *link_caps); > > 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 b915cfdeabd0e..cbef3d45baf9c 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c > @@ -2660,257 +2660,6 @@ void intel_dp_check_link_state(struct intel_dp > *intel_dp) > intel_encoder_link_check_queue_work(encoder, 0); > } > > -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); > - int current_rate = -1; > - int force_rate; > - int err; > - int i; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - if (intel_dp->link.active) > - current_rate = intel_dp->link_rate; > - > - force_rate = intel_dp->link.force_rate; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - seq_printf(m, "%sauto%s", > - force_rate == 0 ? "[" : "", > - force_rate == 0 ? "]" : ""); > - > - for (i = 0; i < intel_dp->num_source_rates; i++) > - seq_printf(m, " %s%d%s%s", > - intel_dp->source_rates[i] == force_rate ? "[" : "", > - intel_dp->source_rates[i], > - intel_dp->source_rates[i] == current_rate ? "*" : "", > - intel_dp->source_rates[i] == force_rate ? "]" : ""); > - > - seq_putc(m, '\n'); > - > - return 0; > -} > - > -static int parse_link_rate(struct intel_dp *intel_dp, const char __user > *ubuf, size_t len) > -{ > - char *kbuf; > - const char *p; > - int rate; > - int ret = 0; > - > - kbuf = memdup_user_nul(ubuf, len); > - if (IS_ERR(kbuf)) > - return PTR_ERR(kbuf); > - > - p = strim(kbuf); > - > - if (!strcmp(p, "auto")) { > - rate = 0; > - } else { > - ret = kstrtoint(p, 0, &rate); > - if (ret < 0) > - goto out_free; > - > - if (intel_dp_rate_index(intel_dp->source_rates, > - intel_dp->num_source_rates, > - rate) < 0) > - ret = -EINVAL; > - } > - > -out_free: > - kfree(kbuf); > - > - return ret < 0 ? ret : rate; > -} > - > -static ssize_t i915_dp_force_link_rate_write(struct file *file, > - const char __user *ubuf, > - size_t len, loff_t *offp) > -{ > - struct seq_file *m = file->private_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); > - int rate; > - int err; > - > - rate = parse_link_rate(intel_dp, ubuf, len); > - if (rate < 0) > - return rate; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - intel_dp_reset_link_params(intel_dp); > - intel_dp->link.force_rate = rate; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - *offp += len; > - > - return len; > -} > -DEFINE_SHOW_STORE_ATTRIBUTE(i915_dp_force_link_rate); > - > -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); > - int current_lane_count = -1; > - int force_lane_count; > - int err; > - int i; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - if (intel_dp->link.active) > - current_lane_count = intel_dp->lane_count; > - force_lane_count = intel_dp->link.force_lane_count; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - seq_printf(m, "%sauto%s", > - force_lane_count == 0 ? "[" : "", > - force_lane_count == 0 ? "]" : ""); > - > - for (i = 1; i <= 4; i <<= 1) > - seq_printf(m, " %s%d%s%s", > - i == force_lane_count ? "[" : "", > - i, > - i == current_lane_count ? "*" : "", > - i == force_lane_count ? "]" : ""); > - > - seq_putc(m, '\n'); > - > - return 0; > -} > - > -static int parse_lane_count(const char __user *ubuf, size_t len) > -{ > - char *kbuf; > - const char *p; > - int lane_count; > - int ret = 0; > - > - kbuf = memdup_user_nul(ubuf, len); > - if (IS_ERR(kbuf)) > - return PTR_ERR(kbuf); > - > - p = strim(kbuf); > - > - if (!strcmp(p, "auto")) { > - lane_count = 0; > - } else { > - ret = kstrtoint(p, 0, &lane_count); > - if (ret < 0) > - goto out_free; > - > - switch (lane_count) { > - case 1: > - case 2: > - case 4: > - break; > - default: > - ret = -EINVAL; > - } > - } > - > -out_free: > - kfree(kbuf); > - > - return ret < 0 ? ret : lane_count; > -} > - > -static ssize_t i915_dp_force_lane_count_write(struct file *file, > - const char __user *ubuf, > - size_t len, loff_t *offp) > -{ > - struct seq_file *m = file->private_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); > - int lane_count; > - int err; > - > - lane_count = parse_lane_count(ubuf, len); > - if (lane_count < 0) > - return lane_count; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - intel_dp_reset_link_params(intel_dp); > - intel_dp->link.force_lane_count = lane_count; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - *offp += len; > - > - return len; > -} > -DEFINE_SHOW_STORE_ATTRIBUTE(i915_dp_force_lane_count); > - > -static int i915_dp_max_link_rate_show(void *data, u64 *val) > -{ > - struct intel_connector *connector = to_intel_connector(data); > - struct intel_display *display = to_intel_display(connector); > - struct intel_dp *intel_dp = intel_attached_dp(connector); > - int err; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - *val = intel_dp->link.max_rate; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - return 0; > -} > -DEFINE_DEBUGFS_ATTRIBUTE(i915_dp_max_link_rate_fops, > i915_dp_max_link_rate_show, NULL, "%llu\n"); > - > -static int i915_dp_max_lane_count_show(void *data, u64 *val) > -{ > - struct intel_connector *connector = to_intel_connector(data); > - struct intel_display *display = to_intel_display(connector); > - struct intel_dp *intel_dp = intel_attached_dp(connector); > - int err; > - > - err = > drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); > - if (err) > - return err; > - > - intel_dp_flush_connector_commits(connector); > - > - *val = intel_dp->link.max_lane_count; > - > - drm_modeset_unlock(&display->drm->mode_config.connection_mutex); > - > - return 0; > -} > -DEFINE_DEBUGFS_ATTRIBUTE(i915_dp_max_lane_count_fops, > i915_dp_max_lane_count_show, NULL, "%llu\n"); > - > static int i915_dp_force_link_training_failure_show(void *data, u64 *val) > { > struct intel_connector *connector = to_intel_connector(data); > @@ -3033,18 +2782,6 @@ void intel_dp_link_training_debugfs_add(struct > intel_connector *connector) > connector->base.connector_type != DRM_MODE_CONNECTOR_eDP) > return; > > - debugfs_create_file("i915_dp_force_link_rate", 0644, root, > - connector, &i915_dp_force_link_rate_fops); > - > - debugfs_create_file("i915_dp_force_lane_count", 0644, root, > - connector, &i915_dp_force_lane_count_fops); > - > - debugfs_create_file("i915_dp_max_link_rate", 0444, root, > - connector, &i915_dp_max_link_rate_fops); > - > - debugfs_create_file("i915_dp_max_lane_count", 0444, root, > - connector, &i915_dp_max_lane_count_fops); > - > debugfs_create_file("i915_dp_force_link_training_failure", 0644, root, > connector, > &i915_dp_force_link_training_failure_fops); >
