From: Frederik Schwan <[email protected]>

128b/132b links use LTTPR-transparent training even when LTTPRs are
present. The DPRX is trained directly in a single phase, without first
training each LTTPR PHY separately. The source must therefore program
its FFE parameters during this DPRX training phase.

The source signal-level update is currently guarded by
intel_dp_phy_is_downstream_of_source(). With LTTPRs present, this only
accepts the source-adjacent LTTPR PHY and rejects DP_PHY_DPRX. That is
appropriate for non-transparent 8b/10b training, but skips the source
FFE update during 128b/132b training. This affects legacy and DP-alt
port modes; in TBT-alt mode the Thunderbolt subsystem owns and programs
the source PHY.

Program the source signal levels for UHBR regardless of the detected
LTTPRs. Also make the per-lane capability check used by
intel_dp_get_lane_adjust_tx_ffe_preset() use the source PHY's capability
for UHBR, rather than treating the DPRX as a separately trained
receiver behind an LTTPR. Preserve the existing 8b/10b behavior.

Enabling UHBR tunneling exposed this older bug on a ThinkPad P1 Gen 8
with a ThinkPad Thunderbolt 5 Smart Dock 7500. Updating the source FFE
presets restores four-lane UHBR20 training and both DP displays.

Fixes: a421d8a99216 ("drm/i915/dp: rewrite DP 2.0 128b/132b link training based 
on errata")
Cc: [email protected] # v5.18+
Link: 
https://lore.kernel.org/regressions/[email protected]/
Assisted-by: Codex:gpt-6
Signed-off-by: Frederik Schwan <[email protected]>
Acked-by: Imre Deak <[email protected]>
Signed-off-by: Imre Deak <[email protected]>
---
 .../drm/i915/display/intel_dp_link_training.c    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

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 ac1aff6edf052..1efc78b329a69 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -773,11 +773,14 @@ static u8 intel_dp_phy_preemph_max(struct intel_dp 
*intel_dp,
 }
 
 static bool has_per_lane_signal_levels(struct intel_dp *intel_dp,
+                                      const struct intel_crtc_state 
*crtc_state,
                                       enum drm_dp_phy dp_phy)
 {
        struct intel_display *display = to_intel_display(intel_dp);
 
-       return !intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy) ||
+       /* UHBR training always adjusts the source PHY, even with LTTPRs. */
+       return (!intel_dp_is_uhbr(crtc_state) &&
+               !intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy)) ||
                DISPLAY_VER(display) >= 10 || display->platform.broxton;
 }
 
@@ -790,7 +793,7 @@ static u8 intel_dp_get_lane_adjust_tx_ffe_preset(struct 
intel_dp *intel_dp,
 {
        u8 tx_ffe = 0;
 
-       if (has_per_lane_signal_levels(intel_dp, dp_phy)) {
+       if (has_per_lane_signal_levels(intel_dp, crtc_state, dp_phy)) {
                lane = min(lane, crtc_state->lane_count - 1);
                tx_ffe = drm_dp_get_adjust_tx_ffe_preset(link_status, lane);
        } else {
@@ -813,7 +816,7 @@ static u8 intel_dp_get_lane_adjust_vswing_preemph(struct 
intel_dp *intel_dp,
        u8 voltage_max;
        u8 preemph_max;
 
-       if (has_per_lane_signal_levels(intel_dp, dp_phy)) {
+       if (has_per_lane_signal_levels(intel_dp, crtc_state, dp_phy)) {
                lane = min(lane, crtc_state->lane_count - 1);
 
                v = drm_dp_get_adjust_request_voltage(link_status, lane);
@@ -1021,7 +1024,12 @@ void intel_dp_set_signal_levels(struct intel_dp 
*intel_dp,
                       TRAIN_SET_PREEMPH_ARGS(intel_dp->train_set));
        }
 
-       if (intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy))
+       /*
+        * UHBR links use transparent training, so the source PHY must be
+        * programmed during the DPRX training phase even with LTTPRs present.
+        */
+       if (intel_dp_is_uhbr(crtc_state) ||
+           intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy))
                encoder->set_signal_levels(encoder, crtc_state);
 }
 
-- 
2.49.1

Reply via email to