msm_dp_ctrl_link_maintenance() waits on ctrl->video_comp without
reinitializing it first, causing msm_dp_ctrl_wait4video_ready() to
consume a stale completion left over from initial stream bring-up.

In addition, if link maintenance runs while no video stream pixel clock
is active (for example in the window between msm_dp_display_prepare_link()
and msm_dp_ctrl_on_stream()):
- Driving DP_STATE_CTRL_PUSH_IDLE via msm_dp_ctrl_push_idle() without an
  active stream times out waiting for idle_comp.
- Clearing DP_TRAINING_PATTERN_SET while REG_DP_STATE_CTRL has not yet
  transitioned to DP_STATE_CTRL_SEND_VIDEO re-enables the sink
  descrambler against unscrambled TPS symbols, and waiting for video
  ready cannot succeed.

Guard msm_dp_ctrl_push_idle() on ctrl->stream_clks_on, reinitialize
ctrl->video_comp before retraining, and return early after
msm_dp_ctrl_setup_main_link() when the stream pixel clock is off so the
training pattern stays active until msm_dp_ctrl_on_stream() enables
video.

Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon 
Chipsets")
Signed-off-by: Gianfranco Mariotti <[email protected]>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 779f743f9418..7201b7b513a3 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2089,13 +2089,16 @@ static int msm_dp_ctrl_link_maintenance(struct 
msm_dp_ctrl_private *ctrl,
        int ret = 0;
        int training_step = DP_TRAINING_NONE;
 
-       msm_dp_ctrl_push_idle(&ctrl->msm_dp_ctrl);
+       if (ctrl->stream_clks_on[panel->stream_id])
+               msm_dp_ctrl_push_idle(&ctrl->msm_dp_ctrl);
 
        ctrl->link->phy_params.p_level = 0;
        ctrl->link->phy_params.v_level = 0;
 
+       reinit_completion(&ctrl->video_comp);
+
        ret = msm_dp_ctrl_setup_main_link(ctrl, panel, &training_step);
-       if (ret)
+       if (ret || !ctrl->stream_clks_on[panel->stream_id])
                goto end;
 
        msm_dp_ctrl_clear_training_pattern(ctrl, panel, DP_PHY_DPRX);
-- 
2.25.1

Reply via email to