mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot
@ 2026-03-14  0:43 Dmitry Baryshkov
  2026-03-14  0:43 ` [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2026-03-14  0:43 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou
  Cc: dri-devel, linux-kernel

Unlike the USB-C AltMode handling and unlike the DP controller handling
the HPD on its own, if the display-connector is being used to handle the
HPD pin, DP controller might not be able to get either the HPD
notification nor detect the cable state if the cable is plugged in
before the system has booted.

Make the display-connector send the HPD notifications during system
startup for DisplayPort connectors.

It's typically not a problem for other types of display connectors since
there is no special procedure to detect if the monitor is actually
plugged in or not.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
Dmitry Baryshkov (2):
      drm/bridge: display-connector: don't autoenable HPD IRQ
      drm/bridge: display-connector: trigger initial HPD event for DP

 drivers/gpu/drm/bridge/display-connector.c | 36 ++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
---
base-commit: 5c9e55fecf9365890c64f14761a80f9413a3b1d1
change-id: 20260314-dp-connector-hpd-f069e66bc6af

Best regards,
-- 
With best wishes
Dmitry


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

* [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ
  2026-03-14  0:43 [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
@ 2026-03-14  0:43 ` Dmitry Baryshkov
  2026-03-14  0:43 ` [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
  2026-06-08  6:49 ` [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2026-03-14  0:43 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou
  Cc: dri-devel, linux-kernel

If HPD IRQ is enabled in the display_connector's probe, it can be
triggered too early, before the DRM connector is completely setup. Use
the enable_hpd / disable_hpd callbacks to control enablement of the HPD
IRQ.

Fixes: 0c275c30176b ("drm/bridge: Add bridge driver for display connectors")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/gpu/drm/bridge/display-connector.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
index 16c0631adeb1..6bb1134f75c3 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -87,6 +87,20 @@ display_connector_bridge_detect(struct drm_bridge *bridge, struct drm_connector
 	return display_connector_detect(bridge);
 }
 
+static void display_connector_hpd_enable(struct drm_bridge *bridge)
+{
+	struct display_connector *conn = to_display_connector(bridge);
+
+	enable_irq(conn->hpd_irq);
+}
+
+static void display_connector_hpd_disable(struct drm_bridge *bridge)
+{
+	struct display_connector *conn = to_display_connector(bridge);
+
+	disable_irq(conn->hpd_irq);
+}
+
 static const struct drm_edid *display_connector_edid_read(struct drm_bridge *bridge,
 							  struct drm_connector *connector)
 {
@@ -178,6 +192,8 @@ static u32 *display_connector_get_input_bus_fmts(struct drm_bridge *bridge,
 static const struct drm_bridge_funcs display_connector_bridge_funcs = {
 	.attach = display_connector_attach,
 	.detect = display_connector_bridge_detect,
+	.hpd_enable = display_connector_hpd_enable,
+	.hpd_disable = display_connector_hpd_disable,
 	.edid_read = display_connector_edid_read,
 	.atomic_get_output_bus_fmts = display_connector_get_output_bus_fmts,
 	.atomic_get_input_bus_fmts = display_connector_get_input_bus_fmts,
@@ -307,6 +323,7 @@ static int display_connector_probe(struct platform_device *pdev)
 						NULL, display_connector_hpd_irq,
 						IRQF_TRIGGER_RISING |
 						IRQF_TRIGGER_FALLING |
+						IRQF_NO_AUTOEN |
 						IRQF_ONESHOT,
 						"HPD", conn);
 		if (ret) {

-- 
2.47.3


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

* [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP
  2026-03-14  0:43 [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
  2026-03-14  0:43 ` [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
@ 2026-03-14  0:43 ` Dmitry Baryshkov
  2026-03-18 17:40   ` Laurent Pinchart
  2026-06-08  6:49 ` [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
  2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Baryshkov @ 2026-03-14  0:43 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou
  Cc: dri-devel, linux-kernel

If the DisplayPort drivers use display-connector for the HPD detection,
the internal HPD state machine might be not active and thus the hardware
might be not able to handle cable detection correctly. Instead it will
depend on the externall HPD notifications to set the cable state,
bypassing the internal HPD state machine (for example this is the case
for the msm DP driver).

However if the cable has been plugged before the HPD IRQ has been
enabled, there will be no HPD event coming. The drivers might fail
detection in such a case. Trigger the HPD notification after enabling
the HPD IRQ, propagating the cable insertion state.

Fixes: 2e2bf3a5584d ("drm/bridge: display-connector: add DP support")
Reported-by: Yongxing Mou <yongxing.mou@oss.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/gpu/drm/bridge/display-connector.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
index 6bb1134f75c3..f7a5bfd9c075 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -12,6 +12,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/workqueue.h>
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
@@ -25,6 +26,8 @@ struct display_connector {
 
 	struct regulator	*supply;
 	struct gpio_desc	*ddc_en;
+
+	struct work_struct	hpd_work;
 };
 
 static inline struct display_connector *
@@ -92,15 +95,29 @@ static void display_connector_hpd_enable(struct drm_bridge *bridge)
 	struct display_connector *conn = to_display_connector(bridge);
 
 	enable_irq(conn->hpd_irq);
+
+	if (conn->bridge.type == DRM_MODE_CONNECTOR_DisplayPort)
+		schedule_work(&conn->hpd_work);
 }
 
 static void display_connector_hpd_disable(struct drm_bridge *bridge)
 {
 	struct display_connector *conn = to_display_connector(bridge);
 
+	if (conn->bridge.type == DRM_MODE_CONNECTOR_DisplayPort)
+		cancel_work_sync(&conn->hpd_work);
+
 	disable_irq(conn->hpd_irq);
 }
 
+static void display_connector_hpd_work(struct work_struct *work)
+{
+	struct display_connector *conn = container_of(work, struct display_connector, hpd_work);
+	struct drm_bridge *bridge = &conn->bridge;
+
+	drm_bridge_hpd_notify(bridge, display_connector_detect(bridge));
+}
+
 static const struct drm_edid *display_connector_edid_read(struct drm_bridge *bridge,
 							  struct drm_connector *connector)
 {
@@ -395,6 +412,8 @@ static int display_connector_probe(struct platform_device *pdev)
 		conn->bridge.ops |= DRM_BRIDGE_OP_DETECT;
 	if (conn->hpd_irq >= 0)
 		conn->bridge.ops |= DRM_BRIDGE_OP_HPD;
+	if (conn->hpd_irq >= 0 && type == DRM_MODE_CONNECTOR_DisplayPort)
+		INIT_WORK(&conn->hpd_work, display_connector_hpd_work);
 
 	dev_dbg(&pdev->dev,
 		"Found %s display connector '%s' %s DDC bus and %s HPD GPIO (ops 0x%x)\n",

-- 
2.47.3


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

* Re: [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP
  2026-03-14  0:43 ` [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
@ 2026-03-18 17:40   ` Laurent Pinchart
  2026-03-25  4:21     ` Dmitry Baryshkov
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2026-03-18 17:40 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Jonas Karlman,
	Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou,
	dri-devel, linux-kernel

Hi Dmitry,

Thank you for the patch.

On Sat, Mar 14, 2026 at 02:43:12AM +0200, Dmitry Baryshkov wrote:
> If the DisplayPort drivers use display-connector for the HPD detection,
> the internal HPD state machine might be not active and thus the hardware
> might be not able to handle cable detection correctly. Instead it will
> depend on the externall HPD notifications to set the cable state,
> bypassing the internal HPD state machine (for example this is the case
> for the msm DP driver).
> 
> However if the cable has been plugged before the HPD IRQ has been
> enabled, there will be no HPD event coming. The drivers might fail
> detection in such a case. Trigger the HPD notification after enabling
> the HPD IRQ, propagating the cable insertion state.

The explanation makes sense, but it sounds like to could apply the same
way to HDMI. What am I missing ?

Also, wouldn't it be better if the DRM core interrogated the state of
the HPD signal when enabling HPD, instead of relying on all drivers to
implement something similar as this patch ?

> Fixes: 2e2bf3a5584d ("drm/bridge: display-connector: add DP support")
> Reported-by: Yongxing Mou <yongxing.mou@oss.qualcomm.com>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>  drivers/gpu/drm/bridge/display-connector.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
> index 6bb1134f75c3..f7a5bfd9c075 100644
> --- a/drivers/gpu/drm/bridge/display-connector.c
> +++ b/drivers/gpu/drm/bridge/display-connector.c
> @@ -12,6 +12,7 @@
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
> +#include <linux/workqueue.h>
>  
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_bridge.h>
> @@ -25,6 +26,8 @@ struct display_connector {
>  
>  	struct regulator	*supply;
>  	struct gpio_desc	*ddc_en;
> +
> +	struct work_struct	hpd_work;
>  };
>  
>  static inline struct display_connector *
> @@ -92,15 +95,29 @@ static void display_connector_hpd_enable(struct drm_bridge *bridge)
>  	struct display_connector *conn = to_display_connector(bridge);
>  
>  	enable_irq(conn->hpd_irq);
> +
> +	if (conn->bridge.type == DRM_MODE_CONNECTOR_DisplayPort)
> +		schedule_work(&conn->hpd_work);
>  }
>  
>  static void display_connector_hpd_disable(struct drm_bridge *bridge)
>  {
>  	struct display_connector *conn = to_display_connector(bridge);
>  
> +	if (conn->bridge.type == DRM_MODE_CONNECTOR_DisplayPort)
> +		cancel_work_sync(&conn->hpd_work);
> +
>  	disable_irq(conn->hpd_irq);
>  }
>  
> +static void display_connector_hpd_work(struct work_struct *work)
> +{
> +	struct display_connector *conn = container_of(work, struct display_connector, hpd_work);
> +	struct drm_bridge *bridge = &conn->bridge;
> +
> +	drm_bridge_hpd_notify(bridge, display_connector_detect(bridge));
> +}
> +
>  static const struct drm_edid *display_connector_edid_read(struct drm_bridge *bridge,
>  							  struct drm_connector *connector)
>  {
> @@ -395,6 +412,8 @@ static int display_connector_probe(struct platform_device *pdev)
>  		conn->bridge.ops |= DRM_BRIDGE_OP_DETECT;
>  	if (conn->hpd_irq >= 0)
>  		conn->bridge.ops |= DRM_BRIDGE_OP_HPD;
> +	if (conn->hpd_irq >= 0 && type == DRM_MODE_CONNECTOR_DisplayPort)
> +		INIT_WORK(&conn->hpd_work, display_connector_hpd_work);
>  
>  	dev_dbg(&pdev->dev,
>  		"Found %s display connector '%s' %s DDC bus and %s HPD GPIO (ops 0x%x)\n",
> 

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP
  2026-03-18 17:40   ` Laurent Pinchart
@ 2026-03-25  4:21     ` Dmitry Baryshkov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2026-03-25  4:21 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Jonas Karlman,
	Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou,
	dri-devel, linux-kernel

Hi,

On Wed, 18 Mar 2026 at 19:40, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>

Sorry, I missed your email.

>
> On Sat, Mar 14, 2026 at 02:43:12AM +0200, Dmitry Baryshkov wrote:
> > If the DisplayPort drivers use display-connector for the HPD detection,
> > the internal HPD state machine might be not active and thus the hardware
> > might be not able to handle cable detection correctly. Instead it will
> > depend on the externall HPD notifications to set the cable state,
> > bypassing the internal HPD state machine (for example this is the case
> > for the msm DP driver).
> >
> > However if the cable has been plugged before the HPD IRQ has been
> > enabled, there will be no HPD event coming. The drivers might fail
> > detection in such a case. Trigger the HPD notification after enabling
> > the HPD IRQ, propagating the cable insertion state.
>
> The explanation makes sense, but it sounds like to could apply the same
> way to HDMI. What am I missing ?

Well... First of all, since HDMI doesn't have all DP magic, there is
no difference between HPD pin state and the display being plugged in
(so, e.g. dp-connector can't implement OP_DETECT, while hdmi-connector
does). For HDMI we usually don't have a complicated state machine in
the hardware. Nor do we have a an AUX bus with timeouts, etc.

>
> Also, wouldn't it be better if the DRM core interrogated the state of
> the HPD signal when enabling HPD, instead of relying on all drivers to
> implement something similar as this patch ?

Most of the drivers don't require this. It is only limited to the
OP_HPD bridges which don't implement OP_DETECT.

>
> > Fixes: 2e2bf3a5584d ("drm/bridge: display-connector: add DP support")
> > Reported-by: Yongxing Mou <yongxing.mou@oss.qualcomm.com>
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> > ---
> >  drivers/gpu/drm/bridge/display-connector.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)



--
With best wishes
Dmitry

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

* Re: [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot
  2026-03-14  0:43 [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
  2026-03-14  0:43 ` [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
  2026-03-14  0:43 ` [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
@ 2026-06-08  6:49 ` Dmitry Baryshkov
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2026-06-08  6:49 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Tomi Valkeinen,
	Boris Brezillon, Sam Ravnborg, Sebastian Reichel, Yongxing Mou,
	Dmitry Baryshkov
  Cc: dri-devel, linux-kernel

On Sat, 14 Mar 2026 02:43:10 +0200, Dmitry Baryshkov wrote:
> Unlike the USB-C AltMode handling and unlike the DP controller handling
> the HPD on its own, if the display-connector is being used to handle the
> HPD pin, DP controller might not be able to get either the HPD
> notification nor detect the cable state if the cable is plugged in
> before the system has booted.
> 
> Make the display-connector send the HPD notifications during system
> startup for DisplayPort connectors.
> 
> [...]

Applied to drm-misc-next, thanks!

[1/2] drm/bridge: display-connector: don't autoenable HPD IRQ
      commit: 8e9c475060bff87077cfa3bd42011edcb7fb3b0d
[2/2] drm/bridge: display-connector: trigger initial HPD event for DP
      commit: 60dc0946bbad3eef8bc66a5a8b09b98dbc6e09c0

Best regards,
-- 
With best wishes
Dmitry



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

end of thread, other threads:[~2026-06-08  6:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-14  0:43 [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
2026-03-14  0:43 ` [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
2026-03-14  0:43 ` [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
2026-03-18 17:40   ` Laurent Pinchart
2026-03-25  4:21     ` Dmitry Baryshkov
2026-06-08  6:49 ` [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov

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®