mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup
@ 2026-11-21 21:40 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
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:40 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

On platforms with a native DisplayPort connector using direct HPD
interrupts, DisplayPort initializes on cold boot, but physical cable
unplug and re-plug cycles leave the display blank even though link
training and stream enable callbacks report success.

This series fixes the underlying PHY lane setup, DPCD link-rate caching,
SST training-pattern handover, link maintenance BPC restoration, and
HPD / runtime-PM state tracking issues:

1. Configure PHY voltage swing and pre-emphasis across all active lanes
   in msm_dp_ctrl_set_vx_px() instead of only lane 0.
2. Reset cached link_info->rate and link_info->use_rate_set in
   msm_dp_panel_read_dpcd() so re-plugging a different sink does not
   skip drm_dp_max_link_rate().
3. Avoid redundant back-to-back link training in
   msm_dp_display_prepare_link() and keep DP_TRAINING_PATTERN_SET active
   until msm_dp_ctrl_on_stream() is ready to switch REG_DP_STATE_CTRL to
   DP_STATE_CTRL_SEND_VIDEO.
4. Reinitialize ctrl->video_comp and restore source BPC/format
   parameters in msm_dp_ctrl_link_maintenance().
5. Dispatch DP_DP_IRQ_HPD_INT_MASK to msm_dp_irq_hpd_handle() instead of
   misrouting expired 0.5-1.0 ms short pulses to msm_dp_hpd_plug_handle()
   (kept separate as it can be dropped once Dmitry Baryshkov's and
   Yongxing Mou's in-flight DRM_CONNECTOR_DP_IRQ_HPD series land).
6. Use asynchronous pm_runtime_put() on HPD unplug/notify paths called
   from msm_dp_display_irq_thread() to avoid a synchronous disable_irq()
   self-deadlock in msm_dp_pm_runtime_suspend().
7. Keep dp->plugged, dp->link->sink_count, AUX transfer enablement, and
   PHY teardown consistent across plug, detect, unplug, and unprepare.

Testing:
Hardware-tested across cold boot, unplug/re-plug, monitor swap, and
IRQ_HPD link-retrain cycles on a QCS8275 (Monaco) SMARC board (SECO F86)
with a native DisplayPort connector running v6.18 + the FROMLIST DP
HPD/MST series (Qualcomm Linux / QLI 2.0), then forward-ported and
build-tested against msm-next.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

Gianfranco Mariotti (7):
  drm/msm/dp: configure voltage swing and pre-emphasis for all active
    lanes
  drm/msm/dp: reset cached link rate before reading DPCD capabilities
  drm/msm/dp: keep training pattern active until stream video is ready
  drm/msm/dp: restore source params and reinit video_comp on link
    maintenance
  drm/msm/dp: dispatch native IRQ_HPD directly to
    msm_dp_irq_hpd_handle()
  drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread
  drm/msm/dp: fix HPD plugged and sink_count state tracking across
    hotplug

 drivers/gpu/drm/msm/dp/dp_ctrl.c    | 23 ++++++++----
 drivers/gpu/drm/msm/dp/dp_display.c | 55 ++++++++++++++++-------------
 drivers/gpu/drm/msm/dp/dp_panel.c   |  2 ++
 3 files changed, 48 insertions(+), 32 deletions(-)


base-commit: d024361c631b3f020a26c07d683e5103404b0fbf
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes
  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 ` Gianfranco Mariotti
  2026-11-21 21:41 ` [PATCH 2/7] drm/msm/dp: reset cached link rate before reading DPCD capabilities Gianfranco Mariotti
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:40 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

msm_dp_ctrl_set_vx_px() only populated voltage[0] and pre[0] and left
phy_opts->dp.lanes and phy_opts->dp.link_rate unset when calling
phy_configure(), leaving lanes 1..3 unconfigured on multi-lane links.

Populate phy_opts->dp.lanes and phy_opts->dp.link_rate from the active
link parameters and program voltage swing and pre-emphasis across all
active lanes.

Fixes: b4745f741e79 ("drm/msm/dp: move phy_configure_opts to dp_ctrl")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index abd3dcdad03c..b896196cf244 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -1374,13 +1374,18 @@ static int msm_dp_ctrl_wait4video_ready(struct msm_dp_ctrl_private *ctrl)
 }
 
 static int msm_dp_ctrl_set_vx_px(struct msm_dp_ctrl_private *ctrl,
-			     u8 v_level, u8 p_level)
+				 u8 v_level, u8 p_level)
 {
 	union phy_configure_opts *phy_opts = &ctrl->phy_opts;
+	int i;
+
+	phy_opts->dp.lanes = ctrl->link->link_params.num_lanes;
+	phy_opts->dp.link_rate = ctrl->link->link_params.rate / 100;
 
-	/* TODO: Update for all lanes instead of just first one */
-	phy_opts->dp.voltage[0] = v_level;
-	phy_opts->dp.pre[0] = p_level;
+	for (i = 0; i < phy_opts->dp.lanes; i++) {
+		phy_opts->dp.voltage[i] = v_level;
+		phy_opts->dp.pre[i] = p_level;
+	}
 	phy_opts->dp.set_voltages = 1;
 	phy_configure(ctrl->phy, phy_opts);
 	phy_opts->dp.set_voltages = 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] drm/msm/dp: reset cached link rate before reading DPCD capabilities
  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 ` Gianfranco Mariotti
  2026-11-21 21:41 ` [PATCH 3/7] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

Commit ed100aa239be ("drm/msm/dp: Enable support for eDP v1.4+ link
rates table") guarded the drm_dp_max_link_rate() fallback in
msm_dp_panel_read_dpcd() behind if (!link_info->rate) so eDP v1.4+
SUPPORTED_LINK_RATES entries take precedence when present.

However, link_info is not cleared across hotplug cycles. Once a monitor
has been connected and link_info->rate is non-zero, unplugging it and
connecting a different DisplayPort sink skips the fallback and reuses
the stale link rate and use_rate_set flag from the previous sink.

Reset link_info->rate and link_info->use_rate_set before parsing DPCD
capabilities.

Fixes: ed100aa239be ("drm/msm/dp: Enable support for eDP v1.4+ link rates table")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_panel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
index d3468b73fdc3..c22a2bc9b635 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -195,6 +195,8 @@ static int msm_dp_panel_read_dpcd(struct msm_dp_panel *msm_dp_panel)
 
 	msm_dp_panel->vsc_sdp_supported = drm_dp_vsc_sdp_supported(panel->aux, dpcd);
 	link_info = &msm_dp_panel->link_info;
+	link_info->rate = 0;
+	link_info->use_rate_set = false;
 	link_info->revision = dpcd[DP_DPCD_REV];
 	major = (link_info->revision >> 4) & 0x0f;
 	minor = link_info->revision & 0x0f;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] drm/msm/dp: keep training pattern active until stream video is ready
  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 ` 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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

Commit ca16db3d18cf ("drm/msm/dp: break up dp_display_enable into two
parts") introduced two regressions on DisplayPort re-plug:

1. msm_dp_display_prepare_link() called msm_dp_ctrl_on_link() on every
   prepare (even when power_on was already true) and unconditionally set
   force_link_train = true when !power_on, causing
   msm_dp_ctrl_prepare_stream_on() to immediately re-run link training a
   second time right after msm_dp_ctrl_on_link() succeeded. Only call
   msm_dp_ctrl_on_link() when !power_on, and pass force_link_train =
   false to msm_dp_ctrl_prepare_stream_on() so it only retrains if
   channel equalization was lost.

2. Splitting msm_dp_ctrl_on_stream() left
   msm_dp_ctrl_clear_training_pattern() in
   msm_dp_ctrl_prepare_stream_on(), clearing DP_TRAINING_PATTERN_SET
   (DPCD 0x102 = 0x00, which re-enables the sink descrambler) ~45 ms
   before msm_dp_ctrl_on_stream() enables the pixel clock, programs the
   TU, and switches REG_DP_STATE_CTRL to DP_STATE_CTRL_SEND_VIDEO.
   During that window the DPTX remains in MR_LINK_TRAINING2 transmitting
   unscrambled TPS symbols, causing SST monitors to lose symbol lock.

Move msm_dp_ctrl_clear_training_pattern() back into
msm_dp_ctrl_on_stream() immediately before DP_STATE_CTRL_SEND_VIDEO.

Fixes: ca16db3d18cf ("drm/msm/dp: break up dp_display_enable into two parts")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c    |  6 +++---
 drivers/gpu/drm/msm/dp/dp_display.c | 16 +++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index b896196cf244..779f743f9418 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2616,9 +2616,6 @@ int msm_dp_ctrl_prepare_stream_on(struct msm_dp_ctrl *msm_dp_ctrl,
 	if (force_link_train || !msm_dp_ctrl_channel_eq_ok(ctrl))
 		msm_dp_ctrl_link_retrain(ctrl, panel);
 
-	/* stop txing train pattern to end link training */
-	msm_dp_ctrl_clear_training_pattern(ctrl, panel, DP_PHY_DPRX);
-
 	return ret;
 }
 
@@ -2663,6 +2660,9 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, struct msm_dp_panel *
 
 	msm_dp_ctrl_setup_tr_unit(ctrl, panel);
 
+	/* stop txing train pattern to end link training */
+	msm_dp_ctrl_clear_training_pattern(ctrl, panel, DP_PHY_DPRX);
+
 	msm_dp_write_link(ctrl, REG_DP_STATE_CTRL, DP_STATE_CTRL_SEND_VIDEO);
 
 	ret = msm_dp_ctrl_wait4video_ready(ctrl);
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index bce641d7d893..b8373740275b 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -632,7 +632,6 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
 {
 	struct msm_dp *msm_dp_display = &dp->msm_dp_display;
 	int rc = 0;
-	bool force_link_train = false;
 
 	drm_dbg_dp(dp->drm_dev, "sink_count=%d\n", dp->link->sink_count);
 
@@ -650,17 +649,16 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
 
 	if (!msm_dp_display->power_on) {
 		msm_dp_display_host_phy_init(dp);
-		force_link_train = true;
-	}
 
-	rc = msm_dp_ctrl_on_link(dp->ctrl, dp->panel);
-	if (rc) {
-		DRM_ERROR("Failed link training (rc=%d)\n", rc);
-		// TODO: schedule drm_connector_set_link_status_property()
-		return rc;
+		rc = msm_dp_ctrl_on_link(dp->ctrl, dp->panel);
+		if (rc) {
+			DRM_ERROR("Failed link training (rc=%d)\n", rc);
+			/* TODO: schedule drm_connector_set_link_status_property() */
+			return rc;
+		}
 	}
 
-	return msm_dp_ctrl_prepare_stream_on(dp->ctrl, dp->panel, force_link_train);
+	return msm_dp_ctrl_prepare_stream_on(dp->ctrl, dp->panel, false);
 }
 
 static int msm_dp_display_enable(struct msm_dp_display_private *dp,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] drm/msm/dp: restore source params and reinit video_comp on link maintenance
  2026-11-21 21:40 [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
                   ` (2 preceding siblings ...)
  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 ` 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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

In msm_dp_ctrl_link_maintenance(), msm_dp_ctrl_setup_main_link() calls
msm_dp_ctrl_config_ctrl_link(), which resets REG_DP_CONFIGURATION_CTRL
to 6 bpc without restoring the active stream's BPC and format via
msm_dp_ctrl_configure_source_params(). In addition, ctrl->video_comp is
not reinitialized before waiting for video ready.

Reinitialize ctrl->video_comp before retraining the link and restore
source parameters via msm_dp_ctrl_configure_source_params() before
switching REG_DP_STATE_CTRL to DP_STATE_CTRL_SEND_VIDEO.

Fixes: 0a19867dfb8d ("drm/msm/dp: split link setup from source params")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 779f743f9418..0904893bd529 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2094,10 +2094,14 @@ static int msm_dp_ctrl_link_maintenance(struct msm_dp_ctrl_private *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)
 		goto end;
 
+	msm_dp_ctrl_configure_source_params(ctrl, panel);
+
 	msm_dp_ctrl_clear_training_pattern(ctrl, panel, DP_PHY_DPRX);
 
 	msm_dp_write_link(ctrl, REG_DP_STATE_CTRL, DP_STATE_CTRL_SEND_VIDEO);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle()
  2026-11-21 21:40 [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
                   ` (3 preceding siblings ...)
  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 ` 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 ` [PATCH 7/7] drm/msm/dp: fix HPD plugged and sink_count state tracking across hotplug Gianfranco Mariotti
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

msm_dp_display_irq_thread() forwards DP_DP_IRQ_HPD_INT_MASK via
drm_bridge_hpd_notify(..., connector_status_connected), relying on
msm_dp_bridge_hpd_notify() to observe ISR_IRQ_HPD_PULSE_COUNT in
REG_DP_DP_HPD_INT_STATUS[STATE_STATUS].

Because an IRQ_HPD short pulse lasts 0.5-1.0 ms, STATE_STATUS has
already returned to DP_DP_HPD_STATE_STATUS_CONNECTED by the time the
threaded IRQ handler runs, misrouting the short pulse to
msm_dp_hpd_plug_handle() instead of msm_dp_irq_hpd_handle().

Dispatch DP_DP_IRQ_HPD_INT_MASK directly to msm_dp_irq_hpd_handle().

Fixes: 5043357e75ba ("drm/msm/dp: rework HPD handling")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
Note: Kept separate from the msm_dp_ctrl_link_maintenance() fix so this
patch can be dropped once Dmitry Baryshkov's and Yongxing Mou's
in-flight DRM_CONNECTOR_DP_IRQ_HPD series land.

 drivers/gpu/drm/msm/dp/dp_display.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index b8373740275b..3a3123dbe417 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1015,10 +1015,8 @@ static irqreturn_t msm_dp_display_irq_thread(int irq, void *dev_id)
 		drm_bridge_hpd_notify(dp->msm_dp_display.bridge,
 				      connector_status_connected);
 
-	/* Send HPD as connected and distinguish it in the notifier */
 	if (hpd_isr_status & DP_DP_IRQ_HPD_INT_MASK)
-		drm_bridge_hpd_notify(dp->msm_dp_display.bridge,
-				      connector_status_connected);
+		msm_dp_irq_hpd_handle(dp);
 
 	ret = IRQ_HANDLED;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread
  2026-11-21 21:40 [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
                   ` (4 preceding siblings ...)
  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 ` Gianfranco Mariotti
  2026-11-21 21:41 ` [PATCH 7/7] drm/msm/dp: fix HPD plugged and sink_count state tracking across hotplug Gianfranco Mariotti
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

msm_dp_pm_runtime_suspend() calls disable_irq(dp->irq). When
msm_dp_hpd_unplug_handle() or msm_dp_bridge_hpd_notify() executes from
msm_dp_display_irq_thread() (i.e. inside dp->irq's own threaded IRQ
handler) and drops the last runtime PM reference via
pm_runtime_put_sync(), runtime suspend runs synchronously on the IRQ
thread and deadlocks in disable_irq(dp->irq) waiting for the currently
executing IRQ thread to finish.

Use asynchronous pm_runtime_put() in msm_dp_hpd_unplug_handle() and
msm_dp_bridge_hpd_notify().

Fixes: 3ea2d1c3d154 ("drm/msm/dp: turn link_ready into plugged")
Fixes: 5043357e75ba ("drm/msm/dp: rework HPD handling")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 3a3123dbe417..eddeb972d6d6 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -495,7 +495,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)
 			dp->link->sink_count);
 
 	if (dp->plugged) {
-		pm_runtime_put_sync(&pdev->dev);
+		pm_runtime_put(&pdev->dev);
 		dp->plugged = false;
 	}
 
@@ -1625,5 +1625,5 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
 		msm_dp_hpd_unplug_handle(dp);
 	}
 
-	pm_runtime_put_sync(&msm_dp_display->pdev->dev);
+	pm_runtime_put(&msm_dp_display->pdev->dev);
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] drm/msm/dp: fix HPD plugged and sink_count state tracking across hotplug
  2026-11-21 21:40 [PATCH 0/7] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
                   ` (5 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-21 21:41 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	Yongxing Mou, Konrad Dybcio, Dale Whinham, David Airlie,
	Simona Vetter, linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Gianfranco Mariotti

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-21 21:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 7/7] drm/msm/dp: fix HPD plugged and sink_count state tracking across hotplug Gianfranco Mariotti

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®