[PATCH 2/3] drm/bridge: inno-hdmi: Report hotplug through drm_bridge_hpd_notify()

Michal Wilczynski m.wilczynski at samsung.com
Fri Nov 27 08:19:00 PST 2026


inno_hdmi_irq() passes hdmi->bridge.dev to drm_helper_hpd_irq_event(),
which dereferences it in its first statement:

	if (!dev->mode_config.poll_enabled)

bridge.dev is assigned only by drm_bridge_attach(), but inno_hdmi_bind()
unmutes the hotplug interrupt in inno_hdmi_init_hw() and installs the
handler well before it attaches the bridge:

	inno_hdmi_init_hw(hdmi);		/* unmutes hotplug */
	devm_request_threaded_irq(...);		/* handler goes live */
	...
	hdmi->bridge.ddc = inno_hdmi_i2c_adapter(hdmi);
	devm_drm_bridge_add(dev, &hdmi->bridge);
	drm_bridge_attach(...);			/* bridge.dev set here */

The bridge is allocated by devm_drm_bridge_alloc(), which kzalloc()s it,
so bridge.dev is NULL for all of that window, and a hotplug event
arriving in it enters drm_helper_hpd_irq_event(NULL).

Before the conversion to a bridge the ordering was safe:
inno_hdmi_register() called drmm_connector_hdmi_init(), which set
connector.dev, before the interrupt was requested.

Report hotplug with drm_bridge_hpd_notify() instead. The bridge already
sets DRM_BRIDGE_OP_HPD, and the helper only calls into the connector
while HPD is enabled, under bridge->hpd_mutex, so it does not need
bridge.dev. Unlike a NULL check, it also stays safe against
drm_bridge_detach() if the interrupt outlives the component bind.

hpd_mutex is initialised by drm_bridge_add(), so request the interrupt
after devm_drm_bridge_add().

Fixes: 969325a2597e ("drm/rockchip: inno-hdmi: Convert to drm bridge")
Signed-off-by: Michal Wilczynski <m.wilczynski at samsung.com>
---
This was patch 2 of the JH7110 display series up to v8, and the code is
unchanged from there.

Changes in v8 of that series, prompted by a Sashiko finding on v7
patch 8, "Split probe out of bind":
https://lore.kernel.org/all/sashiko-outbox-201623@kernel.org/
- Report hotplug through drm_bridge_hpd_notify() instead of checking
  bridge.dev, which also covers drm_bridge_detach() racing with the
  interrupt, and request the interrupt after devm_drm_bridge_add(),
  which initialises the HPD mutex. Heiko's Reviewed-by was dropped
  because the approach changed.
- Link: https://lore.kernel.org/all/20261124-jh7110-clean-send-v8-2-de92635dd857@samsung.com/

Changes in v6 of that series:
- Split out of "drm/bridge: inno-hdmi: Split probe out of bind" into
  its own patch (Heiko).
- Link: https://lore.kernel.org/all/20261029-jh7110-clean-send-v6-2-759594e43acf@samsung.com/

Tested on a VisionFive 2 with the display series applied: hotplug is
reported through the new path. The race itself has not been reproduced.
---
 drivers/gpu/drm/bridge/inno-hdmi.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/inno-hdmi.c b/drivers/gpu/drm/bridge/inno-hdmi.c
index 3bdcacf3cbc8427c8420eac9a37e3ecb79682414..bbc90ae9eaae04166d502c05fde52e126462b8be 100644
--- a/drivers/gpu/drm/bridge/inno-hdmi.c
+++ b/drivers/gpu/drm/bridge/inno-hdmi.c
@@ -929,7 +929,8 @@ static irqreturn_t inno_hdmi_irq(int irq, void *dev_id)
 {
 	struct inno_hdmi *hdmi = dev_id;
 
-	drm_helper_hpd_irq_event(hdmi->bridge.dev);
+	drm_bridge_hpd_notify(&hdmi->bridge,
+			      inno_hdmi_bridge_detect(&hdmi->bridge, NULL));
 
 	return IRQ_HANDLED;
 }
@@ -1104,12 +1105,6 @@ struct inno_hdmi *inno_hdmi_bind(struct device *dev,
 	if (irq < 0)
 		return ERR_PTR(irq);
 
-	ret = devm_request_threaded_irq(dev, irq, inno_hdmi_hardirq,
-					inno_hdmi_irq, IRQF_SHARED,
-					dev_name(dev), hdmi);
-	if (ret)
-		return ERR_PTR(ret);
-
 	hdmi->bridge.driver_private = hdmi;
 	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 			   DRM_BRIDGE_OP_EDID |
@@ -1129,6 +1124,16 @@ struct inno_hdmi *inno_hdmi_bind(struct device *dev,
 	if (ret)
 		return ERR_PTR(ret);
 
+	/*
+	 * The hotplug handler takes the bridge's HPD mutex, which
+	 * drm_bridge_add() initialises, so request the interrupt only now.
+	 */
+	ret = devm_request_threaded_irq(dev, irq, inno_hdmi_hardirq,
+					inno_hdmi_irq, IRQF_SHARED,
+					dev_name(dev), hdmi);
+	if (ret)
+		return ERR_PTR(ret);
+
 	ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return ERR_PTR(ret);

-- 
2.34.1




More information about the Linux-rockchip mailing list