dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] samsung-dsim: move drm_bridge_add() call to probe
@ 2025-07-25 15:28 Luca Ceresoli
  2025-07-28  8:10 ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Luca Ceresoli @ 2025-07-25 15:28 UTC (permalink / raw)
  To: Inki Dae, Jagan Teki, Marek Szyprowski, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, Luca Ceresoli

This bridge driver calls drm_bridge_add() in the DSI host .attach callback
instead of in the probe function. This looks strange, even though
apparently not a problem for currently supported use cases.

However it is a problem for supporting hotplug of DRM bridges, which is in
the works [0][1][2]. The problematic case is when this DSI host is always
present while its DSI device is hot-pluggable. In such case with the
current code the DRM card will not be populated until after the DSI device
attaches to the host, and which could happen a very long time after
booting, or even not happen at all.

Supporting hotplug in the latest public draft is based on an ugly
workaround in the hotplug-bridge driver code. This is visible in the
hotplug_bridge_dsi_attach implementation and documentation in [3] (but
keeping in mind that workaround is complicated as it is also circumventing
another problem: updating the DSI host format when the DSI device gets
connected).

As a preliminary step to supporting hotplug in a proper way, and also make
this driver cleaner, move drm_bridge_add() at probe time, so that the
bridge is available during boot.

However simply moving drm_bridge_add() prevents populating the whole card
when the hot-pluggable addon is not present at boot, for another
reason. The reason is:

 * now the encoder driver finds this bridge instead of getting
   -EPROBE_DEFER as before
 * but it cannot attach it because the bridge attach function in turn tries
   to attach to the following bridge, which has not yet been hot-plugged

This needs to be fixed in the bridge attach function by simply returning
-EPROBE_DEFER ifs the following bridge (i.e. the DSI device) is not yet
present.

[0] https://lpc.events/event/18/contributions/1750/
[1] https://lore.kernel.org/lkml/20240924174254.711c7138@booty/
[2] https://lore.kernel.org/lkml/20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com/
[3] https://lore.kernel.org/lkml/20240917-hotplug-drm-bridge-v4-4-bc4dfee61be6@bootlin.com/

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/samsung-dsim.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
index c4997795db18280903570646b0a5b2c03b666307..173f730edb3707823b0a85460968a11b8206b508 100644
--- a/drivers/gpu/drm/bridge/samsung-dsim.c
+++ b/drivers/gpu/drm/bridge/samsung-dsim.c
@@ -1633,6 +1633,9 @@ static int samsung_dsim_attach(struct drm_bridge *bridge,
 {
 	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
 
+	if (!dsi->out_bridge)
+		return -EPROBE_DEFER;
+
 	return drm_bridge_attach(encoder, dsi->out_bridge, bridge,
 				 flags);
 }
@@ -1749,8 +1752,6 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host,
 		     mipi_dsi_pixel_format_to_bpp(device->format),
 		     device->mode_flags);
 
-	drm_bridge_add(&dsi->bridge);
-
 	/*
 	 * This is a temporary solution and should be made by more generic way.
 	 *
@@ -2011,6 +2012,8 @@ int samsung_dsim_probe(struct platform_device *pdev)
 			goto err_disable_runtime;
 	}
 
+	drm_bridge_add(&dsi->bridge);
+
 	return 0;
 
 err_disable_runtime:

---
base-commit: e48123c607a0db8b9ad02f83c8c3d39918dbda06
change-id: 20250725-drm-bridge-samsung-dsim-add-in-probe-7c549360af90

Best regards,
-- 
Luca Ceresoli <luca.ceresoli@bootlin.com>


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

end of thread, other threads:[~2025-08-19 10:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 15:28 [PATCH] samsung-dsim: move drm_bridge_add() call to probe Luca Ceresoli
2025-07-28  8:10 ` Maxime Ripard
2025-07-28 17:44   ` Luca Ceresoli
2025-07-31 10:05     ` Maxime Ripard
2025-08-08 13:20       ` Luca Ceresoli
2025-08-19 10:01         ` Luca Ceresoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).