linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/22] drm/bridge: add of_drm_find_and_get_bridge() and a managed *next_bridge, deprecate of_drm_find_bridge()
@ 2025-12-16 17:58 Luca Ceresoli
  2025-12-16 17:58 ` [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge() Luca Ceresoli
                   ` (22 more replies)
  0 siblings, 23 replies; 51+ messages in thread
From: Luca Ceresoli @ 2025-12-16 17:58 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, Jonathan Corbet,
	Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
	linux-arm-kernel, linux-amlogic, Luca Ceresoli

This series deprecates of_drm_find_bridge(), adds a replacement which
handles bridge refcounting, and converts some of the direct users.

This is part of the work to support hotplug of DRM bridges. The grand plan
was discussed in [0].

Here's the work breakdown (➜ marks the current series):

 1. ➜ add refcounting to DRM bridges struct drm_bridge,
      based on devm_drm_bridge_alloc()
    A. ✔ add new alloc API and refcounting (v6.16)
    B. ✔ convert all bridge drivers to new API (v6.17)
    C. ✔ kunit tests (v6.17)
    D. ✔ add get/put to drm_bridge_add/remove() + attach/detach()
         and warn on old allocation pattern (v6.17)
    E. ➜ add get/put on drm_bridge accessors
       1. ✔ drm_bridge_chain_get_first_bridge(), add cleanup action (v6.18)
       2. ✔ drm_bridge_get_prev_bridge() (v6.18)
       3. ✔ drm_bridge_get_next_bridge() (v6.19)
       4. ✔ drm_for_each_bridge_in_chain() (v6.19)
       5. ✔ drm_bridge_connector_init (v6.19)
       6. … protect encoder bridge chain with a mutex
       7. ➜ of_drm_find_bridge()
          a. ➜ add of_drm_find_and_get_bridge(), convert some direct users
	  b. convert other direct users
	  c. convert bridge-only drm_of_find_panel_or_bridge() users
       8. drm_of_find_panel_or_bridge, *_of_get_bridge
       9. ✔ enforce drm_bridge_add before drm_bridge_attach (v6.19)
    F. ✔ debugfs improvements
       1. ✔ add top-level 'bridges' file (v6.16)
       2. ✔ show refcount and list lingering bridges (v6.19)
 2. … handle gracefully atomic updates during bridge removal
    A. ✔ Add drm_dev_enter/exit() to protect device resources (v6.20?)
    B. … protect private_obj removal from list
 3. … DSI host-device driver interaction
 4. ✔ removing the need for the "always-disconnected" connector
 5. finish the hotplug bridge work, moving code to the core and potentially
    removing the hotplug-bridge itself (this needs to be clarified as
    points 1-3 are developed)

[0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/#t

Almost all the functions returning a struct drm_bridge pointer have been
modified to drm_bridge_get() the returned bridge, and their users updated
to drm_bridge_put() it. See items 1.E.{1-6} above.

of_drm_find_bridge() could be modified easily in the same way, but it has a
lot of (direct + indirect) callers, and most notably
drm_of_find_panel_or_bridge() which is very hard to adapt without reworking
the panel_bridge lifetime.

This has been discussed in [1] and Maxime proposed an incremental approach:

> So maybe we can just create drm_of_find_bridge() that takes a reference,
> make of_drm_find_bridge() deprecated in favour of drm_of_find_bridge(),
> add a TODO, and call it a day. People will gradually switch to the new
> API over time.

That proposal is implemented by this series with the various changes
discussed after the initial proposal. Some of the direct callers are also
converted: a few of the simple ones plus two complex cases. One of the
complex cases also shows how to use the .destroy func when the next_bridge
is not enough.

Follow-up series will:
- convert remaining direct callers of of_drm_find_bridge()
- convert simple cases of drm_of_find_panel_or_bridge()

[1] https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v3:
- Completely rewrote using the __drm_bridge_free() idea to prevent
  use-after-free of the next_bridge for the common cases
- Added needed cleanups to the imx8qxp-pixel-link and imx8qxp-pxl2dpi
  drivers
- Removed various patches converting simple cases, to reduce the number of
  e-mails sent; will be moved to the follow-up series
- Link to v2: https://lore.kernel.org/r/20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@bootlin.com

Changes in v2:
- All patches: renamed drm_of_find_bridge() -> of_drm_get_bridge()
- Various fixes and improvements to patches 1-6, see individual patches
  changelog
- Removed bouncing recipient: Edmund Dea <edmund.j.dea@intel.com>
- Link to v1: https://lore.kernel.org/r/20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-0-0db98a7fe474@bootlin.com

---
Luca Ceresoli (22):
      drm/bridge: add of_drm_find_and_get_bridge()
      drm/bridge: deprecate of_drm_find_bridge()
      drm/todo: add entry about converting to of_drm_find_and_get_bridge()
      drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge()
      drm/arcpgu: convert to of_drm_find_and_get_bridge()
      drm/bridge: add next_bridge pointer to struct drm_bridge
      drm/bridge: ite-it66121: get/put the next bridge
      drm/bridge: imx8qxp-pixel-combiner: get/put the next bridge
      drm/bridge: simple-bridge: get/put the next bridge
      drm/meson: encoder_cvbs: get/put the next bridge
      drm/meson: encoder_dsi: get/put the next bridge
      drm/meson: encoder_hdmi: get/put the next bridge
      drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers
      drm/bridge: imx8qxp-pxl2dpi: remove excess error message
      drm/bridge: imx8qxp-pxl2dpi: imx8qxp_pxl2dpi_find_next_bridge: return int, not ERR_PTR
      drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge
      drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge
      drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge
      drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
      drm/bridge: imx8qxp-pixel-link: remove excess error message
      drm/bridge: imx8qxp-pixel-link: imx8qxp_pixel_link_find_next_bridge: return int, not ERR_PTR
      drm/bridge: imx8qxp-pixel-link: get/put the next bridge

 Documentation/gpu/todo.rst                         | 16 +++++
 .../gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c    |  9 ++-
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c    | 56 ++++++++----------
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c       | 63 ++++++++------------
 drivers/gpu/drm/bridge/ite-it66121.c               |  7 +--
 drivers/gpu/drm/bridge/simple-bridge.c             | 15 +++--
 drivers/gpu/drm/drm_bridge.c                       | 69 +++++++++++++++++-----
 drivers/gpu/drm/meson/meson_encoder_cvbs.c         |  7 +--
 drivers/gpu/drm/meson/meson_encoder_dsi.c          |  7 +--
 drivers/gpu/drm/meson/meson_encoder_hdmi.c         |  9 ++-
 drivers/gpu/drm/tiny/arcpgu.c                      |  5 +-
 include/drm/drm_bridge.h                           | 16 +++++
 12 files changed, 162 insertions(+), 117 deletions(-)
---
base-commit: 441223656cd43291f4f8277ab98fd3e9e61eeb33
change-id: 20251117-drm-bridge-alloc-getput-drm_of_find_bridge-74903367448d

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



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

end of thread, other threads:[~2025-12-30  9:17 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 17:58 [PATCH v3 00/22] drm/bridge: add of_drm_find_and_get_bridge() and a managed *next_bridge, deprecate of_drm_find_bridge() Luca Ceresoli
2025-12-16 17:58 ` [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge() Luca Ceresoli
2025-12-17 10:15   ` Maxime Ripard
2025-12-17 14:31     ` Luca Ceresoli
2025-12-18 12:50       ` Maxime Ripard
2025-12-18 14:23         ` Luca Ceresoli
2025-12-16 17:58 ` [PATCH v3 02/22] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
2025-12-16 17:58 ` [PATCH v3 03/22] drm/todo: add entry about converting to of_drm_find_and_get_bridge() Luca Ceresoli
2025-12-16 17:58 ` [PATCH v3 04/22] drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge() Luca Ceresoli
2025-12-17 10:16   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 05/22] drm/arcpgu: convert to of_drm_find_and_get_bridge() Luca Ceresoli
2025-12-17 10:16   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 06/22] drm/bridge: add next_bridge pointer to struct drm_bridge Luca Ceresoli
2025-12-17 10:17   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 07/22] drm/bridge: ite-it66121: get/put the next bridge Luca Ceresoli
2025-12-17 10:17   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 08/22] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-12-17 10:17   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 09/22] drm/bridge: simple-bridge: " Luca Ceresoli
2025-12-17 10:41   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 10/22] drm/meson: encoder_cvbs: " Luca Ceresoli
2025-12-17 10:17   ` Maxime Ripard
2025-12-21 21:50   ` Martin Blumenstingl
2025-12-16 17:58 ` [PATCH v3 11/22] drm/meson: encoder_dsi: " Luca Ceresoli
2025-12-17 10:18   ` Maxime Ripard
2025-12-21 21:50   ` Martin Blumenstingl
2025-12-16 17:58 ` [PATCH v3 12/22] drm/meson: encoder_hdmi: " Luca Ceresoli
2025-12-17 10:18   ` Maxime Ripard
2025-12-21 21:51   ` Martin Blumenstingl
2025-12-22  7:30     ` Luca Ceresoli
2025-12-22 10:38       ` Martin Blumenstingl
2025-12-16 17:58 ` [PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers Luca Ceresoli
2025-12-17 10:18   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 14/22] drm/bridge: imx8qxp-pxl2dpi: remove excess error message Luca Ceresoli
2025-12-17 10:19   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 15/22] drm/bridge: imx8qxp-pxl2dpi: imx8qxp_pxl2dpi_find_next_bridge: return int, not ERR_PTR Luca Ceresoli
2025-12-17 10:20   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 16/22] drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge Luca Ceresoli
2025-12-17 10:20   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 17/22] drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge Luca Ceresoli
2025-12-17 10:20   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 18/22] drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge Luca Ceresoli
2025-12-16 17:58 ` [PATCH v3 19/22] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node Luca Ceresoli
2025-12-17 10:25   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 20/22] drm/bridge: imx8qxp-pixel-link: remove excess error message Luca Ceresoli
2025-12-17 10:20   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 21/22] drm/bridge: imx8qxp-pixel-link: imx8qxp_pixel_link_find_next_bridge: return int, not ERR_PTR Luca Ceresoli
2025-12-17 10:25   ` Maxime Ripard
2025-12-16 17:58 ` [PATCH v3 22/22] drm/bridge: imx8qxp-pixel-link: get/put the next bridge Luca Ceresoli
2025-12-17 10:25   ` Maxime Ripard
2025-12-30  9:17 ` [PATCH v3 00/22] drm/bridge: add of_drm_find_and_get_bridge() and a managed *next_bridge, deprecate of_drm_find_bridge() 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).