From: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Yongxing Mou <yongxing.mou@oss.qualcomm.com>,
Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>,
Dale Whinham <daleyo@gmail.com>,
Stephen Boyd <swboyd@chromium.org>,
Bjorn Andersson <andersson@kernel.org>,
Jens Glathe <jens.glathe@oldschoolsolutions.biz>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
Subject: [PATCH v3 04/11] drm/msm/dp: reinit video_comp and guard stream state on link maintenance
Date: Thu, 3 Dec 2026 00:46:33 +0100 [thread overview]
Message-ID: <20261202234640.9379-5-gianfranco.mariotti94@gmail.com> (raw)
In-Reply-To: <20261202234640.9379-1-gianfranco.mariotti94@gmail.com>
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. Also disable the stream pixel clock in msm_dp_ctrl_on_stream()
if msm_dp_ctrl_wait4video_ready() fails so ctrl->stream_clks_on is not
left enabled while power_on remains false, and serialize
msm_dp_display_enable(), msm_dp_display_disable(), and
msm_dp_display_atomic_disable() under dp->plugged_lock so stream
bring-up and teardown cannot race concurrently with
msm_dp_ctrl_link_maintenance().
Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
drivers/gpu/drm/msm/dp/dp_ctrl.c | 11 ++++++++---
drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 779f743f9418..12a889a563d7 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);
@@ -2666,8 +2669,10 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, struct msm_dp_panel *
msm_dp_write_link(ctrl, REG_DP_STATE_CTRL, DP_STATE_CTRL_SEND_VIDEO);
ret = msm_dp_ctrl_wait4video_ready(ctrl);
- if (ret)
+ if (ret) {
+ msm_dp_ctrl_off_pixel_clk(msm_dp_ctrl, panel->stream_id);
return ret;
+ }
mainlink_ready = msm_dp_ctrl_mainlink_ready(ctrl);
drm_dbg_dp(ctrl->drm_dev,
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index b8373740275b..d522b7d254b4 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -667,6 +667,8 @@ static int msm_dp_display_enable(struct msm_dp_display_private *dp,
int rc = 0;
struct msm_dp *msm_dp_display = &dp->msm_dp_display;
+ guard(mutex)(&dp->plugged_lock);
+
drm_dbg_dp(dp->drm_dev, "sink_count=%d\n", dp->link->sink_count);
if (msm_dp_display->power_on) {
drm_dbg_dp(dp->drm_dev, "Link already setup, return\n");
@@ -724,6 +726,8 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp,
{
struct msm_dp *msm_dp_display = &dp->msm_dp_display;
+ guard(mutex)(&dp->plugged_lock);
+
if (!msm_dp_display->power_on)
return 0;
@@ -1504,6 +1508,8 @@ void msm_dp_display_atomic_disable(struct msm_dp *dp)
msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
+ guard(mutex)(&msm_dp_display->plugged_lock);
+
/*
* If .atomic_enable() bailed out - link training failure is the common
* case - the mainlink was never brought up and ->power_on stayed false.
--
2.25.1
next prev parent reply other threads:[~2026-12-02 23:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 23:46 [PATCH v3 00/11] drm/msm/dp: fix DisplayPort hotplug, link training, PHY lifecycle, and external HPD Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 01/11] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 02/11] drm/msm/dp: reset cached link_info before reading DPCD capabilities Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 03/11] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
2026-12-02 23:46 ` Gianfranco Mariotti [this message]
2026-12-02 23:46 ` [PATCH v3 05/11] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 06/11] drm/msm/dp: track DP_SINK_COUNT capability and sync prev_sink_count Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 07/11] drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 08/11] drm/msm/dp: keep PHY initialized while plugged across link unprepare Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 09/11] drm/msm/dp: re-read EDID on demand in get_modes when blob is missing Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 10/11] drm/msm/dp: guard internal HPD state checks when external HPD is used Gianfranco Mariotti
2026-12-02 23:46 ` [PATCH v3 11/11] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle() Gianfranco Mariotti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202234640.9379-5-gianfranco.mariotti94@gmail.com \
--to=gianfranco.mariotti94@gmail.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=daleyo@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jens.glathe@oldschoolsolutions.biz \
--cc=jesszhan0024@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=swboyd@chromium.org \
--cc=xiangxu.yin@oss.qualcomm.com \
--cc=yongxing.mou@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®