Add counters for link training pass/failure events and a connector debugfs entry showing these and relevant link training information. This is meant to be used by automated testing of the driver's link retraining and link parameter fallback functionality. Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx> --- .../drm/i915/display/intel_display_debugfs.c | 38 +++++++++++++++++++ .../drm/i915/display/intel_display_types.h | 3 ++ drivers/gpu/drm/i915/display/intel_dp.c | 7 +++- .../drm/i915/display/intel_dp_link_training.c | 3 ++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 4f19d30e6972f..b25af91883584 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -1612,6 +1612,41 @@ DEFINE_DEBUGFS_ATTRIBUTE(i915_dp_force_link_retrain_fops, i915_dp_force_link_retrain_show, i915_dp_force_link_retrain_write, "%llu\n"); +static int i915_dp_link_training_info_show(struct seq_file *m, void *data) +{ + struct intel_connector *connector = to_intel_connector(m->private); + struct drm_i915_private *i915 = to_i915(connector->base.dev); + struct intel_dp *intel_dp; + int ret; + + ret = drm_modeset_lock_single_interruptible(&i915->drm.mode_config.connection_mutex); + if (ret) + return ret; + + intel_dp = intel_connector_to_intel_dp(connector); + + seq_printf(m, + "max_rate: %d\n" + "max_lane_count: %d\n" + "train_count: %d\n" + "retrain_count: %d\n" + "retrain_disabled: %s\n" + "all_failures: %d\n" + "seq_failures: %d\n", + intel_dp->link_train.max_rate, + intel_dp->link_train.max_lane_count, + intel_dp->link_train.train_count, + intel_dp->link_train.retrain_count, + str_yes_no(intel_dp->link_train.retrain_disabled), + intel_dp->link_train.all_failures, + intel_dp->link_train.seq_failures); + + drm_modeset_unlock(&i915->drm.mode_config.connection_mutex); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(i915_dp_link_training_info); + static int i915_dsc_output_format_show(struct seq_file *m, void *data) { struct intel_connector *connector = m->private; @@ -1832,6 +1867,9 @@ void intel_connector_debugfs_add(struct intel_connector *connector) debugfs_create_file("i915_dp_force_link_retrain", 0644, root, connector, &i915_dp_force_link_retrain_fops); + + debugfs_create_file("i915_dp_link_training_info", 0444, root, + connector, &i915_dp_link_training_info_fops); } if (DISPLAY_VER(i915) >= 11 && diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 345e2883d9cfc..6ff1819fc225e 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1765,7 +1765,10 @@ struct intel_dp { int max_lane_count; /* Max rate for the current link */ int max_rate; + int train_count; + int retrain_count; bool retrain_disabled; + int all_failures; /* Sequential failures after a passing LT */ int seq_failures; int force_failure; diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 28842ae51039a..0da081c457726 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -2997,6 +2997,9 @@ void intel_dp_reset_link_train_params(struct intel_dp *intel_dp) intel_dp->link_train.max_lane_count = intel_dp_max_common_lane_count(intel_dp); intel_dp->link_train.max_rate = intel_dp_max_common_rate(intel_dp); intel_dp->link_train.retrain_disabled = false; + intel_dp->link_train.train_count = 0; + intel_dp->link_train.retrain_count = 0; + intel_dp->link_train.all_failures = 0; intel_dp->link_train.seq_failures = 0; } @@ -5290,8 +5293,10 @@ static int intel_dp_retrain_link(struct intel_encoder *encoder, } out: - if (ret != -EDEADLK) + if (ret != -EDEADLK) { + intel_dp->link_train.retrain_count++; intel_dp->link_train.force_retrain = false; + } return ret; } 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 c260299c53b7c..c43af290a4373 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c +++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c @@ -1484,6 +1484,8 @@ void intel_dp_start_link_train(struct intel_dp *intel_dp, else passed = intel_dp_link_train_all_phys(intel_dp, crtc_state, lttpr_count); + intel_dp->link_train.train_count++; + if (intel_dp->link_train.force_failure) { intel_dp->link_train.force_failure--; lt_dbg(intel_dp, DP_PHY_DPRX, "Forcing link training failure\n"); @@ -1493,6 +1495,7 @@ void intel_dp_start_link_train(struct intel_dp *intel_dp, return; } + intel_dp->link_train.all_failures++; intel_dp->link_train.seq_failures++; /* -- 2.43.3