mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 <jessica.zhang@oss.qualcomm.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>,
	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 v2 10/10] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle()
Date: Fri, 27 Nov 2026 11:14:17 +0100	[thread overview]
Message-ID: <20261127101417.24303-11-gianfranco.mariotti94@gmail.com> (raw)
In-Reply-To: <20261127101417.24303-1-gianfranco.mariotti94@gmail.com>

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():
- Guard msm_dp_irq_hpd_handle() with dp->plugged and skip sink requests
  in msm_dp_ctrl_handle_sink_request() while mainlink clocks are off.
- On DS_PORT_STATUS_CHANGED from a branch device, update or clear
  downstream sink state and invoke drm_bridge_hpd_notify() after
  releasing dp->plugged_lock when called from the IRQ thread (skipping
  re-entrant notification when called from msm_dp_bridge_hpd_notify()).

Fixes: 5043357e75ba ("drm/msm/dp: rework HPD handling")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c    |  5 ++
 drivers/gpu/drm/msm/dp/dp_display.c | 86 +++++++++++++++++++++--------
 2 files changed, 68 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 1b2ab7db28cb..2b5e085afbcb 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2329,6 +2329,11 @@ void msm_dp_ctrl_handle_sink_request(struct msm_dp_ctrl *msm_dp_ctrl,
 	}
 
 	ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl);
+	if (!ctrl->link_clks_on) {
+		drm_dbg_dp(ctrl->drm_dev, "link clocks off, skipping sink request\n");
+		return;
+	}
+
 	sink_request = ctrl->link->sink_request;
 
 	if (sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) {
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index fd9d5f176329..fef758ca9062 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -513,32 +513,74 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)
 	return 0;
 }
 
-static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp)
+static int msm_dp_display_handle_ds_port_status(struct msm_dp_display_private *dp,
+						enum drm_connector_status *hpd_status,
+						bool *notify_hpd)
 {
+	struct msm_dp *msm_dp_display = &dp->msm_dp_display;
+	int rc;
+
+	if (dp->link->sink_count) {
+		rc = msm_dp_display_process_hpd_high(dp);
+		if (!rc) {
+			*hpd_status = connector_status_connected;
+			*notify_hpd = true;
+		}
+		return rc;
+	}
+
+	dp->panel->video_test = false;
+	if (!msm_dp_display->is_edp) {
+		drm_edid_connector_update(msm_dp_display->connector, NULL);
+		drm_dp_set_subconnector_property(msm_dp_display->connector,
+						 connector_status_disconnected,
+						 dp->panel->dpcd,
+						 dp->panel->downstream_ports);
+	}
+	msm_dp_display_handle_plugged_change(msm_dp_display, false);
+	*hpd_status = connector_status_disconnected;
+	*notify_hpd = true;
+
+	return 0;
+}
+
+static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, bool notify)
+{
+	enum drm_connector_status hpd_status = connector_status_disconnected;
+	bool notify_hpd = false;
 	u32 sink_request;
 	int rc = 0;
 
-	guard(mutex)(&dp->plugged_lock);
-
-	/* irq_hpd can happen at either connected or disconnected state */
-	drm_dbg_dp(dp->drm_dev, "Before, type=%d, sink_count=%d\n",
-			dp->msm_dp_display.connector_type,
-			dp->link->sink_count);
+	scoped_guard(mutex, &dp->plugged_lock) {
+		if (!dp->plugged)
+			return 0;
+
+		/* irq_hpd can happen at either connected or disconnected state */
+		drm_dbg_dp(dp->drm_dev, "Before, type=%d, sink_count=%d\n",
+			   dp->msm_dp_display.connector_type,
+			   dp->link->sink_count);
+
+		/* check for any test request issued by sink */
+		rc = msm_dp_link_process_request(dp->link);
+		if (!rc) {
+			sink_request = dp->link->sink_request;
+			drm_dbg_dp(dp->drm_dev, "sink_request=%d\n",
+				   sink_request);
+			if (sink_request & DS_PORT_STATUS_CHANGED)
+				rc = msm_dp_display_handle_ds_port_status(dp,
+									  &hpd_status,
+									  &notify_hpd);
+			else
+				rc = msm_dp_display_handle_irq_hpd(dp);
+		}
 
-	/* check for any test request issued by sink */
-	rc = msm_dp_link_process_request(dp->link);
-	if (!rc) {
-		sink_request = dp->link->sink_request;
-		drm_dbg_dp(dp->drm_dev, "sink_request=%d\n", sink_request);
-		if (sink_request & DS_PORT_STATUS_CHANGED)
-			rc = msm_dp_display_process_hpd_high(dp);
-		else
-			rc = msm_dp_display_handle_irq_hpd(dp);
+		drm_dbg_dp(dp->drm_dev, "After, type=%d, sink_count=%d\n",
+			   dp->msm_dp_display.connector_type,
+			   dp->link->sink_count);
 	}
 
-	drm_dbg_dp(dp->drm_dev, "After, type=%d, sink_count=%d\n",
-			dp->msm_dp_display.connector_type,
-			dp->link->sink_count);
+	if (notify && notify_hpd)
+		drm_bridge_hpd_notify(dp->msm_dp_display.bridge, hpd_status);
 
 	return rc;
 }
@@ -1037,10 +1079,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, true);
 
 	ret = IRQ_HANDLED;
 
@@ -1661,7 +1701,7 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
 			msm_dp_hpd_unplug_handle(dp);
 			msm_dp_hpd_plug_handle(dp);
 		} else if (hpd_link_status == ISR_IRQ_HPD_PULSE_COUNT) {
-			msm_dp_irq_hpd_handle(dp);
+			msm_dp_irq_hpd_handle(dp, false);
 		} else {
 			msm_dp_hpd_plug_handle(dp);
 		}
-- 
2.25.1


      parent reply	other threads:[~2026-11-27 10:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 10:14 [PATCH v2 00/10] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 01/10] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 02/10] drm/msm/dp: reset cached link_info before reading DPCD capabilities Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 03/10] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 04/10] drm/msm/dp: reinit video_comp and guard stream state on link maintenance Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 05/10] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 06/10] drm/msm/dp: track DP_SINK_COUNT capability and sync prev_sink_count Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 07/10] drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 08/10] drm/msm/dp: keep PHY initialized while plugged across link unprepare Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 09/10] drm/msm/dp: re-read EDID on demand in get_modes when blob is missing Gianfranco Mariotti
2026-11-27 10:14 ` 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=20261127101417.24303-11-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=jens.glathe@oldschoolsolutions.biz \
    --cc=jessica.zhang@oss.qualcomm.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®