Skip to contentSkip to conversation

drm/bridge: analogix_dp: Fix PE/VS value shift mismatch during link training

PATCH Applied Damon Ding 3 participants 3 messages Jun 23 – Jul 3

Subsystems (3)
lore
Share & tools
lore

Damon Ding

author
#0 lore raw

PATCH v2 1/1 drm/bridge: analogix_dp: Fix PE/VS value shift mismatch during link training

VS/PE values returned by drm_dp_get_adjust_request_voltage() and drm_dp_get_adjust_request_pre_emphasis() are already encoded to their native DPCD register bit positions. However, DPCD_VOLTAGE_SWING_SET / DPCD_PRE_EMPHASIS_SET macros perform an extra internal shift. Feeding the raw offset-bearing values directly leads to overlapping bitfields and invalid lane training configuration, causing link training failures and black screen.

Add right shift using DP_TRAIN_*_SHIFT constants to strip the DPCD bit offsets before passing values to the SET macros and subsequent checks. Apply this fix for both clock recovery and adjust training code paths.

Fixes d84b087c7662 ("drm/bridge: analogix_dp: Apply DP helper APIs to get adjusted voltages and pre-emphasises")

---

Changes in v2:
- Fix the ambiguous descriptions in commit msg.

---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4 -0
index 7a85774aaac1..1d39a354c3d9 100644
@@ -309,7 +309,9 @@ static void analogix_dp_get_adjust_training_lane(struct analogix_dp_device *dp,
 	lane_count = dp->link_train.lane_count;
 	for (lane = 0; lane < lane_count; lane++) {
 		voltage_swing = drm_dp_get_adjust_request_voltage(link_status, lane);
+		voltage_swing >>= DP_TRAIN_VOLTAGE_SWING_SHIFT;
 		pre_emphasis = drm_dp_get_adjust_request_pre_emphasis(link_status, lane);
+		pre_emphasis >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;
 		training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
 				DPCD_PRE_EMPHASIS_SET(pre_emphasis);
 
@@ -355,7 +357,9 @@ static int analogix_dp_process_clock_recovery(struct analogix_dp_device *dp)
 	for (lane = 0; lane < lane_count; lane++) {
 		training_lane = analogix_dp_get_lane_link_training(dp, lane);
 		voltage_swing = drm_dp_get_adjust_request_voltage(link_status, lane);
+		voltage_swing >>= DP_TRAIN_VOLTAGE_SWING_SHIFT;
 		pre_emphasis = drm_dp_get_adjust_request_pre_emphasis(link_status, lane);
+		pre_emphasis >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;
 
 		if (DPCD_VOLTAGE_SWING_GET(training_lane) == voltage_swing &&
 		    DPCD_PRE_EMPHASIS_GET(training_lane) == pre_emphasis)
Signature · 1 line
2.34.1
Tested-by on v2 1/1
#1 lore raw
Quoted 51 lines · Damon Ding

VS/PE values returned by drm_dp_get_adjust_request_voltage() and drm_dp_get_adjust_request_pre_emphasis() are already encoded to their native DPCD register bit positions. However, DPCD_VOLTAGE_SWING_SET / DPCD_PRE_EMPHASIS_SET macros perform an extra internal shift. Feeding the raw offset-bearing values directly leads to overlapping bitfields and invalid lane training configuration, causing link training failures and black screen.

Add right shift using DP_TRAIN_*_SHIFT constants to strip the DPCD bit offsets before passing values to the SET macros and subsequent checks. Apply this fix for both clock recovery and adjust training code paths.

Fixes d84b087c7662 ("drm/bridge: analogix_dp: Apply DP helper APIs to get adjusted voltages and pre-emphasises")

---

Changes in v2:
- Fix the ambiguous descriptions in commit msg.

---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4 -1
index 7a85774aaac1..1d39a354c3d9 100644
@@ -309,7 +309,9 @@ static void analogix_dp_get_adjust_training_lane(struct analogix_dp_device *dp,
        lane_count = dp->link_train.lane_count;
        for (lane = 0; lane < lane_count; lane++) {
                voltage_swing = drm_dp_get_adjust_request_voltage(link_status, lane);
+               voltage_swing >>= DP_TRAIN_VOLTAGE_SWING_SHIFT;
                pre_emphasis = drm_dp_get_adjust_request_pre_emphasis(link_status, lane);
+               pre_emphasis >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;
                training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
                                DPCD_PRE_EMPHASIS_SET(pre_emphasis);
 
@@ -355,7 +357,9 @@ static int analogix_dp_process_clock_recovery(struct analogix_dp_device *dp)
        for (lane = 0; lane < lane_count; lane++) {
                training_lane = analogix_dp_get_lane_link_training(dp, lane);
                voltage_swing = drm_dp_get_adjust_request_voltage(link_status, lane);
+               voltage_swing >>= DP_TRAIN_VOLTAGE_SWING_SHIFT;
                pre_emphasis = drm_dp_get_adjust_request_pre_emphasis(link_status, lane);
+               pre_emphasis >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;
 
                if (DPCD_VOLTAGE_SWING_GET(training_lane) == voltage_swing &&
                    DPCD_PRE_EMPHASIS_GET(training_lane) == pre_emphasis)
--
Quoted 1 line

2.34.1

Tested-by Vicente Bergas

This patch was tested toghether with
[PATCH v1] drm/bridge: analogix_dp: Apply standard DP training delay helpers

Regards,
Vicente.

#2 lore raw
In reply to Damon Ding
Quoted 9 lines · Damon Ding

VS/PE values returned by drm_dp_get_adjust_request_voltage() and drm_dp_get_adjust_request_pre_emphasis() are already encoded to their native DPCD register bit positions. However, DPCD_VOLTAGE_SWING_SET / DPCD_PRE_EMPHASIS_SET macros perform an extra internal shift. Feeding the raw offset-bearing values directly leads to overlapping bitfields and invalid lane training configuration, causing link training failures and black screen.

[...]

Applied, thanks!

[1/1] drm/bridge: analogix_dp: Fix PE/VS value shift mismatch during link training

      commit: 6bb8898f702385d363dc2c513a1efa62807f8068

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>