From: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
Yongxing Mou <yongxing.mou@oss.qualcomm.com>,
Konrad Dybcio <konradybcio@kernel.org>,
Dale Whinham <daleyo@gmail.com>, David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
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 7/7] drm/msm/dp: fix HPD plugged and sink_count state tracking across hotplug
Date: Sat, 21 Nov 2026 22:41:05 +0100 [thread overview]
Message-ID: <20261121214105.32596-8-gianfranco.mariotti94@gmail.com> (raw)
In-Reply-To: <20261121214105.32596-1-gianfranco.mariotti94@gmail.com>
Keep dp->plugged, dp->link->sink_count, AUX transfer enablement, and
runtime PM references consistent across DisplayPort hotplug cycles:
- In msm_dp_hpd_plug_handle(), return early if dp->plugged is already
set so duplicate plug notifications do not leak runtime PM references,
and unwind AUX/PHY/runtime-PM state instead of setting dp->plugged =
true when msm_dp_display_process_hpd_high() fails.
- In msm_dp_display_process_hpd_high(), ensure dp->link->sink_count = 1
when a valid EDID is read from a sink that reports sink_count == 0,
preventing msm_dp_display_prepare_link() from failing with -ENOTCONN.
- In msm_dp_bridge_detect(), stop mutating priv->plugged (which is
paired with the HPD plug/unplug runtime PM reference), and always
disable AUX transfers on exit when !priv->plugged even if the PHY was
already initialized.
- In msm_dp_hpd_unplug_handle(), reset dp->link->sink_count = 0 on
disconnect, and in msm_dp_display_unprepare(), only enter dongle D3
and re-initialize the PHY when dp->link->sink_count == 0 &&
dp->plugged so a full cable unplug powers down the PHY instead of
issuing AUX writes and leaving the PHY active.
Fixes: 3ea2d1c3d154 ("drm/msm/dp: turn link_ready into plugged")
Fixes: 1bda647ce61b ("drm/msm/dp: move link-level teardown from display_disable to display_unprepare")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
drivers/gpu/drm/msm/dp/dp_display.c | 31 +++++++++++++++++++----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index eddeb972d6d6..80f05effd18a 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -307,6 +307,9 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)
dp->msm_dp_display.psr_supported = dp->panel->psr_cap.version && psr_enabled;
dp->audio_supported = info->has_audio;
+ if (drm_edid && dp->link->sink_count == 0)
+ dp->link->sink_count = 1;
+
msm_dp_panel_handle_sink_request(dp->panel, drm_edid);
/*
@@ -417,6 +420,9 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
guard(mutex)(&dp->plugged_lock);
+ if (dp->plugged)
+ return 0;
+
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret) {
DRM_ERROR("failed to pm_runtime_resume\n");
@@ -428,6 +434,12 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
msm_dp_display_host_phy_init(dp);
ret = msm_dp_display_process_hpd_high(dp);
+ if (ret) {
+ msm_dp_aux_enable_xfers(dp->aux, false);
+ msm_dp_display_host_phy_exit(dp);
+ pm_runtime_put(&pdev->dev);
+ return ret;
+ }
drm_dbg_dp(dp->drm_dev, "After, type=%d sink_count=%d\n",
dp->msm_dp_display.connector_type,
@@ -435,8 +447,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
dp->plugged = true;
- return ret;
-};
+ return 0;
+}
static void msm_dp_display_handle_plugged_change(struct msm_dp *msm_dp_display,
bool plugged)
@@ -477,6 +489,8 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)
if (dp->link->sink_count == 0)
msm_dp_display_host_phy_exit(dp);
+ dp->link->sink_count = 0;
+
/*
* We don't need separate work for disconnect as
* connect/attention interrupts are disabled
@@ -923,26 +937,22 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,
DRM_DEBUG_DP("aux link status: %x\n", ret);
if (!priv->plugged && !ret) {
DRM_DEBUG_DP("aux not connected\n");
- priv->plugged = false;
goto end;
}
ret = drm_dp_read_dpcd_caps(priv->aux, dpcd);
if (ret) {
DRM_DEBUG_DP("failed to read caps\n");
- priv->plugged = false;
goto end;
}
ret = drm_dp_read_desc(priv->aux, &desc, drm_dp_is_branch(dpcd));
if (ret) {
DRM_DEBUG_DP("failed to read desc\n");
- priv->plugged = false;
goto end;
}
status = connector_status_connected;
- priv->plugged = true;
if (drm_dp_read_sink_count_cap(connector, dpcd, &desc)) {
int sink_count = drm_dp_read_sink_count(priv->aux);
@@ -959,10 +969,9 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,
* lose the state.
*/
if (!priv->plugged) {
- if (phy_deinit) {
- msm_dp_aux_enable_xfers(priv->aux, false);
+ msm_dp_aux_enable_xfers(priv->aux, false);
+ if (phy_deinit)
msm_dp_display_host_phy_exit(priv);
- }
pm_runtime_put_sync(&dp->pdev->dev);
}
@@ -1524,12 +1533,12 @@ static void msm_dp_display_unprepare(struct msm_dp_display_private *dp)
struct msm_dp *msm_dp_display = &dp->msm_dp_display;
/* dongle is still connected but sinks are disconnected */
- if (dp->link->sink_count == 0)
+ if (dp->link->sink_count == 0 && dp->plugged)
msm_dp_link_psm_config(dp->link, &dp->panel->link_info, true);
msm_dp_ctrl_off_link(dp->ctrl, dp->panel);
- if (dp->link->sink_count == 0)
+ if (dp->link->sink_count == 0 && dp->plugged)
/* re-init the PHY so that we can listen to Dongle disconnect */
msm_dp_ctrl_reinit_phy(dp->ctrl);
else
--
2.25.1
prev parent reply other threads:[~2026-11-21 21:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 21:40 [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
2026-11-21 21:40 ` [PATCH 1/7] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes Gianfranco Mariotti
2026-11-21 21:41 ` [PATCH 2/7] drm/msm/dp: reset cached link rate before reading DPCD capabilities Gianfranco Mariotti
2026-11-21 21:41 ` [PATCH 3/7] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
2026-11-21 21:41 ` [PATCH 4/7] drm/msm/dp: restore source params and reinit video_comp on link maintenance Gianfranco Mariotti
2026-11-21 21:41 ` [PATCH 5/7] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle() Gianfranco Mariotti
2026-11-21 21:41 ` [PATCH 6/7] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread Gianfranco Mariotti
2026-11-21 21:41 ` Gianfranco Mariotti [this message]
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=20261121214105.32596-8-gianfranco.mariotti94@gmail.com \
--to=gianfranco.mariotti94@gmail.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=daleyo@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=konradybcio@kernel.org \
--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=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®