linux-doc.vger.kernel.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

* [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge()
  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 ` Luca Ceresoli
  2025-12-17 10:15   ` Maxime Ripard
  2025-12-16 17:58 ` [PATCH v3 02/22] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
                   ` (21 subsequent siblings)
  22 siblings, 1 reply; 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

of_drm_find_bridge() does not increment the refcount for the returned
bridge, but that is required now. However converting it and all its users
is not realistically doable at once given the large amount of (direct and
indirect) callers and the complexity of some.

Solve this issue by creating a new of_drm_find_and_get_bridge() function
that is identical to of_drm_find_bridge() except also it takes a
reference. Then of_drm_find_bridge() will be deprecated to be eventually
removed.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

Changes in v3:
- rename to of_drm_find_and_get_bridge()

Changes in v2:
- fix "mutex_unlock() before drm_bridge_get()", and use scoped_guard() to
  do it cleaning instead of complicating code
- rename to of_drm_get_bridge()

Note: a simple implementation would just be
  { return drm_bridge_get(of_drm_find_bridge(np)); }
but it would release the mutex before getting the reference, so it is
not safe. Make things simple by duplicating the code. A later patch will
make instead the (to be deprecated) of_drm_find_bridge() become a wrapper
of the new of_drm_get_bridge()
---
 drivers/gpu/drm/drm_bridge.c | 25 +++++++++++++++++++++++++
 include/drm/drm_bridge.h     |  5 +++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index db40c26d1cb3..0dbc8b59c3be 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1479,6 +1479,31 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge,
 EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
 
 #ifdef CONFIG_OF
+/**
+ * of_drm_find_and_get_bridge - find the bridge corresponding to the device
+ *                              node in the global bridge list
+ * @np: device node
+ *
+ * The refcount of the returned bridge is incremented. Use drm_bridge_put()
+ * when done with it.
+ *
+ * RETURNS:
+ * drm_bridge control struct on success, NULL on failure
+ */
+struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np)
+{
+	struct drm_bridge *bridge;
+
+	scoped_guard(mutex, &bridge_lock) {
+		list_for_each_entry(bridge, &bridge_list, list)
+			if (bridge->of_node == np)
+				return drm_bridge_get(bridge);
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(of_drm_find_and_get_bridge);
+
 /**
  * of_drm_find_bridge - find the bridge corresponding to the device node in
  *			the global bridge list
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index d2683846cc61..8f10d2fd6016 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1325,8 +1325,13 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
 		      enum drm_bridge_attach_flags flags);
 
 #ifdef CONFIG_OF
+struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np);
 struct drm_bridge *of_drm_find_bridge(struct device_node *np);
 #else
+static inline struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np)
+{
+	return NULL;
+}
 static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 {
 	return NULL;

-- 
2.52.0


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

* [PATCH v3 02/22] drm/bridge: deprecate of_drm_find_bridge()
  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-16 17:58 ` 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
                   ` (20 subsequent siblings)
  22 siblings, 0 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

of_drm_find_bridge() does not increment the returned bridge
refcount. of_drm_find_and_get_bridge() is to be used as a replacement.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---

Changes in v3:
- update after of_drm_get_bridge() -> of_drm_find_and_get_bridge() rename

Changes in v2:
- expand comment to mention why this function is dangerous and what users
  should do about refcounting
---
 drivers/gpu/drm/drm_bridge.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 0dbc8b59c3be..f612d486cad0 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -361,7 +361,7 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
  * @bridge: bridge control structure
  *
  * Add the given bridge to the global list of bridges, where they can be
- * found by users via of_drm_find_bridge().
+ * found by users via of_drm_find_and_get_bridge().
  *
  * The bridge to be added must have been allocated by
  * devm_drm_bridge_alloc().
@@ -422,9 +422,9 @@ EXPORT_SYMBOL(devm_drm_bridge_add);
  * @bridge: bridge control structure
  *
  * Remove the given bridge from the global list of registered bridges, so
- * it won't be found by users via of_drm_find_bridge(), and add it to the
- * lingering bridge list, to keep track of it until its allocated memory is
- * eventually freed.
+ * it won't be found by users via of_drm_find_and_get_bridge(), and add it
+ * to the lingering bridge list, to keep track of it until its allocated
+ * memory is eventually freed.
  */
 void drm_bridge_remove(struct drm_bridge *bridge)
 {
@@ -1510,6 +1510,20 @@ EXPORT_SYMBOL(of_drm_find_and_get_bridge);
  *
  * @np: device node
  *
+ * This function is deprecated. Convert to of_drm_find_and_get_bridge()
+ * instead for proper refcounting.
+ *
+ * The bridge returned by this function is not refcounted. This is
+ * dangerous because the bridge might be deallocated even before the caller
+ * has a chance to use it. To use this function you have to do one of:
+ * - get a reference with drm_bridge_get() as soon as possible to
+ *   minimize the race window, and then drm_bridge_put() when no longer
+ *   using the pointer
+ * - not call drm_bridge_get() or drm_bridge_put() at all, which used to
+ *   be the correct practice before dynamic bridge lifetime was introduced
+ * - again, convert to of_drm_find_and_get_bridge(), which is the only safe
+ *   thing to do
+ *
  * RETURNS:
  * drm_bridge control struct on success, NULL on failure
  */

-- 
2.52.0


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

* [PATCH v3 03/22] drm/todo: add entry about converting to of_drm_find_and_get_bridge()
  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-16 17:58 ` [PATCH v3 02/22] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (19 subsequent siblings)
  22 siblings, 0 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

of_drm_find_bridge() is deprecated, but converting some users is very
complex and should be reasonably doable only after the DRM panel bridge
lifetime rework. Add a TODO to track this.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

Changes in v3:
- update after of_drm_get_bridge() -> of_drm_find_and_get_bridge() rename
---
 Documentation/gpu/todo.rst | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 22487ac1b011..520da44a04a6 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -506,6 +506,22 @@ Contact: Maxime Ripard <mripard@kernel.org>,
 
 Level: Intermediate
 
+Convert users of of_drm_find_bridge() to of_drm_find_and_get_bridge()
+---------------------------------------------------------------------
+
+Taking a struct drm_bridge pointer requires getting a reference and putting
+it after disposing of the pointer. Most functions returning a struct
+drm_bridge pointer already call drm_bridge_get() to increment the refcount
+and their users have been updated to call drm_bridge_put() when
+appropriate. of_drm_find_bridge() does not get a reference and it has been
+deprecated in favor of of_drm_find_and_get_bridge() which does, but some
+users still need to be converted.
+
+Contact: Maxime Ripard <mripard@kernel.org>,
+         Luca Ceresoli <luca.ceresoli@bootlin.com>
+
+Level: Intermediate
+
 Core refactorings
 =================
 

-- 
2.52.0


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

* [PATCH v3 04/22] drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge()
  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
                   ` (2 preceding siblings ...)
  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 ` 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
                   ` (18 subsequent siblings)
  22 siblings, 1 reply; 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

of_drm_find_bridge() is identical to of_drm_find_and_get_bridge() except it
does not increment the refcount. Rewrite it as a wrapper and put the bridge
being returned so the behaviour is still the same.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

Changes in v3:
- update after of_drm_get_bridge() -> of_drm_find_and_get_bridge() rename
- fixed kerneldoc syntax for non-kerneldoc comment

Changes in v2:
- Added comment to document why we put the reference
---
 drivers/gpu/drm/drm_bridge.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index f612d486cad0..64aa69dcf46f 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1529,19 +1529,17 @@ EXPORT_SYMBOL(of_drm_find_and_get_bridge);
  */
 struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 {
-	struct drm_bridge *bridge;
-
-	mutex_lock(&bridge_lock);
+	struct drm_bridge *bridge = of_drm_find_and_get_bridge(np);
 
-	list_for_each_entry(bridge, &bridge_list, list) {
-		if (bridge->of_node == np) {
-			mutex_unlock(&bridge_lock);
-			return bridge;
-		}
-	}
+	/*
+	 * We need to emulate the original semantics of
+	 * of_drm_find_bridge(), which was not getting any bridge
+	 * reference. Being now based on of_drm_find_and_get_bridge() which
+	 * gets a reference, put it before returning.
+	 */
+	drm_bridge_put(bridge);
 
-	mutex_unlock(&bridge_lock);
-	return NULL;
+	return bridge;
 }
 EXPORT_SYMBOL(of_drm_find_bridge);
 #endif

-- 
2.52.0


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

* [PATCH v3 05/22] drm/arcpgu: convert to of_drm_find_and_get_bridge()
  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
                   ` (3 preceding siblings ...)
  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-16 17:58 ` 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
                   ` (17 subsequent siblings)
  22 siblings, 1 reply; 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

of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put it when done.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

Changes in v3:
- update after of_drm_get_bridge() -> of_drm_find_and_get_bridge() rename
---
 drivers/gpu/drm/tiny/arcpgu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 7cf0f0ea1bfe..505888497482 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -308,10 +308,9 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 		return ret;
 
 	if (encoder_node) {
-		struct drm_bridge *bridge;
-
 		/* Locate drm bridge from the hdmi encoder DT node */
-		bridge = of_drm_find_bridge(encoder_node);
+		struct drm_bridge *bridge __free(drm_bridge_put) =
+			of_drm_find_and_get_bridge(encoder_node);
 		if (!bridge)
 			return -EPROBE_DEFER;
 

-- 
2.52.0


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

* [PATCH v3 06/22] drm/bridge: add next_bridge pointer to struct drm_bridge
  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
                   ` (4 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 05/22] drm/arcpgu: convert to of_drm_find_and_get_bridge() Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (16 subsequent siblings)
  22 siblings, 1 reply; 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

Many bridge drivers store a next_bridge pointer in their private data and
use it for attach and sometimes other purposes. This is going to be risky
when bridge hot-unplug is used.

Considering this example scenario:

  1. pipeline: encoder --> bridge A --> bridge B --> bridge C
  2. encoder takes a reference to bridge B
  3. bridge B takes a next_bridge reference to bridge C
  4. encoder calls (bridge B)->b_foo(), which in turns references
     next_bridge, e.g.:

       b_foo() {
           bar(b->next_bridge);
       }

If bridges B and C are removed, bridge C can be freed but B is still
allocated because the encoder holds a reference to B. So when step 4
happens, 'b->next-bridge' would be a use-after-free.

Calling drm_bridge_put() in the B bridge .remove function does not solve
the problem as it leaves a (potentially long) risk window between B removal
and the final deallocation of B. A safe moment to put the B reference is in
__drm_bridge_free(), when the last reference has been put. This can be done
by drivers in the .destroy func. However to avoid the need for so many
drivers to implement a .destroy func, just offer a next_bridge pointer to
all bridges that is automatically put it in __drm_bridge_free(), exactly
when the .destroy func is called.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/all/20251201-thick-jasmine-oarfish-1eceb0@houat/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/drm_bridge.c |  2 ++
 include/drm/drm_bridge.h     | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 64aa69dcf46f..6dcf8f6d3ecf 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -275,6 +275,8 @@ static void __drm_bridge_free(struct kref *kref)
 	if (bridge->funcs->destroy)
 		bridge->funcs->destroy(bridge);
 
+	drm_bridge_put(bridge->next_bridge);
+
 	kfree(bridge->container);
 }
 
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 8f10d2fd6016..63660256c4f5 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1278,6 +1278,17 @@ struct drm_bridge {
 	 * @hpd_cb.
 	 */
 	void *hpd_data;
+
+	/**
+	 * @next_bridge: Pointer to the following bridge, automatically put
+	 * when this bridge is freed (i.e. at destroy time). This is for
+	 * drivers needing to store a pointer to the next bridge in the
+	 * chain, and ensures any code still holding a reference to this
+	 * bridge after its removal cannot use-after-free the next
+	 * bridge. Any other bridge pointers stored by the driver must be
+	 * put in the .destroy callback by driver code.
+	 */
+	struct drm_bridge *next_bridge;
 };
 
 static inline struct drm_bridge *

-- 
2.52.0


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

* [PATCH v3 07/22] drm/bridge: ite-it66121: get/put the next bridge
  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
                   ` (5 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 06/22] drm/bridge: add next_bridge pointer to struct drm_bridge Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (15 subsequent siblings)
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

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

diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index 0185f61e6e59..9246e9c15a6e 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -298,7 +298,6 @@ struct it66121_chip_info {
 struct it66121_ctx {
 	struct regmap *regmap;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct drm_connector *connector;
 	struct device *dev;
 	struct gpio_desc *gpio_reset;
@@ -596,7 +595,7 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
 	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
 		return -EINVAL;
 
-	ret = drm_bridge_attach(encoder, ctx->next_bridge, bridge, flags);
+	ret = drm_bridge_attach(encoder, ctx->bridge.next_bridge, bridge, flags);
 	if (ret)
 		return ret;
 
@@ -1543,9 +1542,9 @@ static int it66121_probe(struct i2c_client *client)
 		return -EINVAL;
 	}
 
-	ctx->next_bridge = of_drm_find_bridge(ep);
+	ctx->bridge.next_bridge = of_drm_find_and_get_bridge(ep);
 	of_node_put(ep);
-	if (!ctx->next_bridge) {
+	if (!ctx->bridge.next_bridge) {
 		dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n");
 		return -EPROBE_DEFER;
 	}

-- 
2.52.0


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

* [PATCH v3 08/22] drm/bridge: imx8qxp-pixel-combiner: get/put the next bridge
  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
                   ` (6 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 07/22] drm/bridge: ite-it66121: get/put the next bridge Luca Ceresoli
@ 2025-12-16 17:58 ` Luca Ceresoli
  2025-12-17 10:17   ` Maxime Ripard
  2025-12-16 17:58 ` [PATCH v3 09/22] drm/bridge: simple-bridge: " Luca Ceresoli
                   ` (14 subsequent siblings)
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
index 8517b1c953d4..74eda8b54023 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
@@ -60,7 +60,6 @@ enum imx8qxp_pc_pix_data_format {
 
 struct imx8qxp_pc_channel {
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct imx8qxp_pc *pc;
 	unsigned int stream_id;
 };
@@ -120,7 +119,7 @@ static int imx8qxp_pc_bridge_attach(struct drm_bridge *bridge,
 	}
 
 	return drm_bridge_attach(encoder,
-				 ch->next_bridge, bridge,
+				 ch->bridge.next_bridge, bridge,
 				 DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 }
 
@@ -326,8 +325,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
 			goto free_child;
 		}
 
-		ch->next_bridge = of_drm_find_bridge(remote);
-		if (!ch->next_bridge) {
+		ch->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+		if (!ch->bridge.next_bridge) {
 			of_node_put(remote);
 			ret = -EPROBE_DEFER;
 			DRM_DEV_DEBUG_DRIVER(dev,
@@ -349,7 +348,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
 free_child:
 	of_node_put(child);
 
-	if (i == 1 && pc->ch[0]->next_bridge)
+	if (i == 1 && pc->ch[0]->bridge.next_bridge)
 		drm_bridge_remove(&pc->ch[0]->bridge);
 
 	pm_runtime_disable(dev);

-- 
2.52.0


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

* [PATCH v3 09/22] drm/bridge: simple-bridge: get/put the next bridge
  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
                   ` (7 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 08/22] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
@ 2025-12-16 17:58 ` Luca Ceresoli
  2025-12-17 10:41   ` Maxime Ripard
  2025-12-16 17:58 ` [PATCH v3 10/22] drm/meson: encoder_cvbs: " Luca Ceresoli
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

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

diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 2cd1847ba776..873b32cfb508 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -31,7 +31,6 @@ struct simple_bridge {
 
 	const struct simple_bridge_info *info;
 
-	struct drm_bridge	*next_bridge;
 	struct regulator	*vdd;
 	struct gpio_desc	*enable;
 };
@@ -54,8 +53,8 @@ static int simple_bridge_get_modes(struct drm_connector *connector)
 	const struct drm_edid *drm_edid;
 	int ret;
 
-	if (sbridge->next_bridge->ops & DRM_BRIDGE_OP_EDID) {
-		drm_edid = drm_bridge_edid_read(sbridge->next_bridge, connector);
+	if (sbridge->bridge.next_bridge->ops & DRM_BRIDGE_OP_EDID) {
+		drm_edid = drm_bridge_edid_read(sbridge->bridge.next_bridge, connector);
 		if (!drm_edid)
 			DRM_INFO("EDID read failed. Fallback to standard modes\n");
 	} else {
@@ -90,7 +89,7 @@ simple_bridge_connector_detect(struct drm_connector *connector, bool force)
 {
 	struct simple_bridge *sbridge = drm_connector_to_simple_bridge(connector);
 
-	return drm_bridge_detect(sbridge->next_bridge, connector);
+	return drm_bridge_detect(sbridge->bridge.next_bridge, connector);
 }
 
 static const struct drm_connector_funcs simple_bridge_con_funcs = {
@@ -109,7 +108,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
 	struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge);
 	int ret;
 
-	ret = drm_bridge_attach(encoder, sbridge->next_bridge, bridge,
+	ret = drm_bridge_attach(encoder, sbridge->bridge.next_bridge, bridge,
 				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret < 0)
 		return ret;
@@ -122,7 +121,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
 	ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
 					  &simple_bridge_con_funcs,
 					  sbridge->info->connector_type,
-					  sbridge->next_bridge->ddc);
+					  sbridge->bridge.next_bridge->ddc);
 	if (ret) {
 		DRM_ERROR("Failed to initialize connector\n");
 		return ret;
@@ -180,10 +179,10 @@ static int simple_bridge_probe(struct platform_device *pdev)
 	if (!remote)
 		return -EINVAL;
 
-	sbridge->next_bridge = of_drm_find_bridge(remote);
+	sbridge->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
 	of_node_put(remote);
 
-	if (!sbridge->next_bridge) {
+	if (!sbridge->bridge.next_bridge) {
 		dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n");
 		return -EPROBE_DEFER;
 	}

-- 
2.52.0


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

* [PATCH v3 10/22] drm/meson: encoder_cvbs: get/put the next bridge
  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
                   ` (8 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 09/22] drm/bridge: simple-bridge: " Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (12 subsequent siblings)
  22 siblings, 2 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/meson/meson_encoder_cvbs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
index dc374bfc5951..41071d6e05e5 100644
--- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
@@ -33,7 +33,6 @@
 struct meson_encoder_cvbs {
 	struct drm_encoder	encoder;
 	struct drm_bridge	bridge;
-	struct drm_bridge	*next_bridge;
 	struct meson_drm	*priv;
 };
 
@@ -89,7 +88,7 @@ static int meson_encoder_cvbs_attach(struct drm_bridge *bridge,
 	struct meson_encoder_cvbs *meson_encoder_cvbs =
 					bridge_to_meson_encoder_cvbs(bridge);
 
-	return drm_bridge_attach(encoder, meson_encoder_cvbs->next_bridge,
+	return drm_bridge_attach(encoder, meson_encoder_cvbs->bridge.next_bridge,
 				 &meson_encoder_cvbs->bridge, flags);
 }
 
@@ -241,9 +240,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
 		return 0;
 	}
 
-	meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote);
+	meson_encoder_cvbs->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
 	of_node_put(remote);
-	if (!meson_encoder_cvbs->next_bridge)
+	if (!meson_encoder_cvbs->bridge.next_bridge)
 		return dev_err_probe(priv->dev, -EPROBE_DEFER,
 				     "Failed to find CVBS Connector bridge\n");
 

-- 
2.52.0


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

* [PATCH v3 11/22] drm/meson: encoder_dsi: get/put the next bridge
  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
                   ` (9 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 10/22] drm/meson: encoder_cvbs: " Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (11 subsequent siblings)
  22 siblings, 2 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/meson/meson_encoder_dsi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
index 6c6624f9ba24..eba246791c68 100644
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -25,7 +25,6 @@
 struct meson_encoder_dsi {
 	struct drm_encoder encoder;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct meson_drm *priv;
 };
 
@@ -38,7 +37,7 @@ static int meson_encoder_dsi_attach(struct drm_bridge *bridge,
 {
 	struct meson_encoder_dsi *encoder_dsi = bridge_to_meson_encoder_dsi(bridge);
 
-	return drm_bridge_attach(encoder, encoder_dsi->next_bridge,
+	return drm_bridge_attach(encoder, encoder_dsi->bridge.next_bridge,
 				 &encoder_dsi->bridge, flags);
 }
 
@@ -120,8 +119,8 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
 		return 0;
 	}
 
-	meson_encoder_dsi->next_bridge = of_drm_find_bridge(remote);
-	if (!meson_encoder_dsi->next_bridge)
+	meson_encoder_dsi->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+	if (!meson_encoder_dsi->bridge.next_bridge)
 		return dev_err_probe(priv->dev, -EPROBE_DEFER,
 				     "Failed to find DSI transceiver bridge\n");
 

-- 
2.52.0


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

* [PATCH v3 12/22] drm/meson: encoder_hdmi: get/put the next bridge
  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
                   ` (10 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 11/22] drm/meson: encoder_dsi: " Luca Ceresoli
@ 2025-12-16 17:58 ` Luca Ceresoli
  2025-12-17 10:18   ` Maxime Ripard
  2025-12-21 21:51   ` Martin Blumenstingl
  2025-12-16 17:58 ` [PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers Luca Ceresoli
                   ` (10 subsequent siblings)
  22 siblings, 2 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/meson/meson_encoder_hdmi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 8205ee56a691..dc4e23590a6e 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -38,7 +38,6 @@
 struct meson_encoder_hdmi {
 	struct drm_encoder encoder;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct drm_connector *connector;
 	struct meson_drm *priv;
 	unsigned long output_bus_fmt;
@@ -54,7 +53,7 @@ static int meson_encoder_hdmi_attach(struct drm_bridge *bridge,
 {
 	struct meson_encoder_hdmi *encoder_hdmi = bridge_to_meson_encoder_hdmi(bridge);
 
-	return drm_bridge_attach(encoder, encoder_hdmi->next_bridge,
+	return drm_bridge_attach(encoder, encoder_hdmi->bridge.next_bridge,
 				 &encoder_hdmi->bridge, flags);
 }
 
@@ -334,7 +333,7 @@ static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge,
 		const struct drm_edid *drm_edid;
 		const struct edid *edid;
 
-		drm_edid = drm_bridge_edid_read(encoder_hdmi->next_bridge,
+		drm_edid = drm_bridge_edid_read(encoder_hdmi->bridge.next_bridge,
 						encoder_hdmi->connector);
 		if (!drm_edid)
 			return;
@@ -390,8 +389,8 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
 		return 0;
 	}
 
-	meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote);
-	if (!meson_encoder_hdmi->next_bridge) {
+	meson_encoder_hdmi->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+	if (!meson_encoder_hdmi->bridge.next_bridge) {
 		ret = dev_err_probe(priv->dev, -EPROBE_DEFER,
 				    "Failed to find HDMI transceiver bridge\n");
 		goto err_put_node;

-- 
2.52.0


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

* [PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers
  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
                   ` (11 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 12/22] drm/meson: encoder_hdmi: " Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (9 subsequent siblings)
  22 siblings, 1 reply; 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

Simplify the error-management code in
imx8qxp_pxl2dpi_get_available_ep_from_port() by using a release action for
the struct device_node pointers.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index 111310acab2c..a4941f39a2e6 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -258,35 +258,28 @@ imx8qxp_pxl2dpi_get_available_ep_from_port(struct imx8qxp_pxl2dpi *p2d,
 static struct drm_bridge *
 imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
 {
-	struct device_node *ep, *remote;
 	struct drm_bridge *next_bridge;
 	int ret;
 
-	ep = imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1);
+	struct device_node *ep __free(device_node) =
+		imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1);
 	if (IS_ERR(ep)) {
 		ret = PTR_ERR(ep);
 		return ERR_PTR(ret);
 	}
 
-	remote = of_graph_get_remote_port_parent(ep);
+	struct device_node *remote __free(device_node) = of_graph_get_remote_port_parent(ep);
 	if (!remote || !of_device_is_available(remote)) {
 		DRM_DEV_ERROR(p2d->dev, "no available remote\n");
-		next_bridge = ERR_PTR(-ENODEV);
-		goto out;
+		return ERR_PTR(-ENODEV);
 	} else if (!of_device_is_available(remote->parent)) {
 		DRM_DEV_ERROR(p2d->dev, "remote parent is not available\n");
-		next_bridge = ERR_PTR(-ENODEV);
-		goto out;
+		return ERR_PTR(-ENODEV);
 	}
 
 	next_bridge = of_drm_find_bridge(remote);
-	if (!next_bridge) {
-		next_bridge = ERR_PTR(-EPROBE_DEFER);
-		goto out;
-	}
-out:
-	of_node_put(remote);
-	of_node_put(ep);
+	if (!next_bridge)
+		return ERR_PTR(-EPROBE_DEFER);
 
 	return next_bridge;
 }

-- 
2.52.0


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

* [PATCH v3 14/22] drm/bridge: imx8qxp-pxl2dpi: remove excess error message
  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
                   ` (12 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (8 subsequent siblings)
  22 siblings, 1 reply; 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

imx8qxp_pxl2dpi_find_next_bridge() already emits a DRM_DEV_ERROR() for
every error except -EPROBE_DEFER. The caller emits another one, which is
redundant. Remove the message in the caller and keep the two in
imx8qxp_pxl2dpi_find_next_bridge() as they are more informative about the
error cause.

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

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index a4941f39a2e6..e03a411cb9db 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -415,13 +415,8 @@ static int imx8qxp_pxl2dpi_bridge_probe(struct platform_device *pdev)
 	}
 
 	p2d->next_bridge = imx8qxp_pxl2dpi_find_next_bridge(p2d);
-	if (IS_ERR(p2d->next_bridge)) {
-		ret = PTR_ERR(p2d->next_bridge);
-		if (ret != -EPROBE_DEFER)
-			DRM_DEV_ERROR(dev, "failed to find next bridge: %d\n",
-				      ret);
-		return ret;
-	}
+	if (IS_ERR(p2d->next_bridge))
+		return PTR_ERR(p2d->next_bridge);
 
 	ret = imx8qxp_pxl2dpi_set_pixel_link_sel(p2d);
 	if (ret)

-- 
2.52.0


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

* [PATCH v3 15/22] drm/bridge: imx8qxp-pxl2dpi: imx8qxp_pxl2dpi_find_next_bridge: return int, not ERR_PTR
  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
                   ` (13 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 14/22] drm/bridge: imx8qxp-pxl2dpi: remove excess error message Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (7 subsequent siblings)
  22 siblings, 1 reply; 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

In preparation for using bridge->next_bridge, we need to ensure that it
will never contain anything but NULL or a valid bridge pointer. Current
code stores an ERR_PTR when imx8qxp_pxl2dpi_find_next_bridge() errors
out. Instead of fixing that after the facts in the caller, change the
function to internally set the next_pointer and just return an int error
value.

No functional changes.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 30 +++++++++++-----------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index e03a411cb9db..2e66b003386e 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -255,33 +255,27 @@ imx8qxp_pxl2dpi_get_available_ep_from_port(struct imx8qxp_pxl2dpi *p2d,
 	return ep;
 }
 
-static struct drm_bridge *
-imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
+static int imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
 {
-	struct drm_bridge *next_bridge;
-	int ret;
-
 	struct device_node *ep __free(device_node) =
 		imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1);
-	if (IS_ERR(ep)) {
-		ret = PTR_ERR(ep);
-		return ERR_PTR(ret);
-	}
+	if (IS_ERR(ep))
+		return PTR_ERR(ep);
 
 	struct device_node *remote __free(device_node) = of_graph_get_remote_port_parent(ep);
 	if (!remote || !of_device_is_available(remote)) {
 		DRM_DEV_ERROR(p2d->dev, "no available remote\n");
-		return ERR_PTR(-ENODEV);
+		return -ENODEV;
 	} else if (!of_device_is_available(remote->parent)) {
 		DRM_DEV_ERROR(p2d->dev, "remote parent is not available\n");
-		return ERR_PTR(-ENODEV);
+		return -ENODEV;
 	}
 
-	next_bridge = of_drm_find_bridge(remote);
-	if (!next_bridge)
-		return ERR_PTR(-EPROBE_DEFER);
+	p2d->next_bridge = of_drm_find_bridge(remote);
+	if (!p2d->next_bridge)
+		return -EPROBE_DEFER;
 
-	return next_bridge;
+	return 0;
 }
 
 static int imx8qxp_pxl2dpi_set_pixel_link_sel(struct imx8qxp_pxl2dpi *p2d)
@@ -414,9 +408,9 @@ static int imx8qxp_pxl2dpi_bridge_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	p2d->next_bridge = imx8qxp_pxl2dpi_find_next_bridge(p2d);
-	if (IS_ERR(p2d->next_bridge))
-		return PTR_ERR(p2d->next_bridge);
+	ret = imx8qxp_pxl2dpi_find_next_bridge(p2d);
+	if (ret)
+		return ret;
 
 	ret = imx8qxp_pxl2dpi_set_pixel_link_sel(p2d);
 	if (ret)

-- 
2.52.0


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

* [PATCH v3 16/22] drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge
  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
                   ` (14 preceding siblings ...)
  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-16 17:58 ` 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
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index 2e66b003386e..556aec3b3734 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -35,7 +35,6 @@
 struct imx8qxp_pxl2dpi {
 	struct regmap *regmap;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct drm_bridge *companion;
 	struct device *dev;
 	struct imx_sc_ipc *ipc_handle;
@@ -60,7 +59,7 @@ static int imx8qxp_pxl2dpi_bridge_attach(struct drm_bridge *bridge,
 	}
 
 	return drm_bridge_attach(encoder,
-				 p2d->next_bridge, bridge,
+				 p2d->bridge.next_bridge, bridge,
 				 DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 }
 
@@ -271,8 +270,8 @@ static int imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
 		return -ENODEV;
 	}
 
-	p2d->next_bridge = of_drm_find_bridge(remote);
-	if (!p2d->next_bridge)
+	p2d->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+	if (!p2d->bridge.next_bridge)
 		return -EPROBE_DEFER;
 
 	return 0;
@@ -351,8 +350,8 @@ static int imx8qxp_pxl2dpi_parse_dt_companion(struct imx8qxp_pxl2dpi *p2d)
 	 * the next bridges are connected to.  If they are marked as expecting
 	 * even pixels and odd pixels than we need to use the companion PXL2DPI.
 	 */
-	port1 = of_graph_get_port_by_id(p2d->next_bridge->of_node, 1);
-	port2 = of_graph_get_port_by_id(companion_p2d->next_bridge->of_node, 1);
+	port1 = of_graph_get_port_by_id(p2d->bridge.next_bridge->of_node, 1);
+	port2 = of_graph_get_port_by_id(companion_p2d->bridge.next_bridge->of_node, 1);
 	dual_link = drm_of_lvds_get_dual_link_pixel_order(port1, port2);
 	of_node_put(port1);
 	of_node_put(port2);

-- 
2.52.0


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

* [PATCH v3 17/22] drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge
  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
                   ` (15 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 16/22] drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (5 subsequent siblings)
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use the destroy hook to put the reference on deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index 556aec3b3734..2c40ca86e319 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -63,6 +63,13 @@ static int imx8qxp_pxl2dpi_bridge_attach(struct drm_bridge *bridge,
 				 DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 }
 
+static void imx8qxp_pxl2dpi_bridge_destroy(struct drm_bridge *bridge)
+{
+	struct imx8qxp_pxl2dpi *p2d = bridge->driver_private;
+
+	drm_bridge_put(p2d->companion);
+}
+
 static int
 imx8qxp_pxl2dpi_bridge_atomic_check(struct drm_bridge *bridge,
 				    struct drm_bridge_state *bridge_state,
@@ -205,6 +212,7 @@ static const struct drm_bridge_funcs imx8qxp_pxl2dpi_bridge_funcs = {
 	.atomic_destroy_state	= drm_atomic_helper_bridge_destroy_state,
 	.atomic_reset		= drm_atomic_helper_bridge_reset,
 	.attach			= imx8qxp_pxl2dpi_bridge_attach,
+	.destroy		= imx8qxp_pxl2dpi_bridge_destroy,
 	.atomic_check		= imx8qxp_pxl2dpi_bridge_atomic_check,
 	.mode_set		= imx8qxp_pxl2dpi_bridge_mode_set,
 	.atomic_disable		= imx8qxp_pxl2dpi_bridge_atomic_disable,
@@ -333,7 +341,7 @@ static int imx8qxp_pxl2dpi_parse_dt_companion(struct imx8qxp_pxl2dpi *p2d)
 		goto out;
 	}
 
-	p2d->companion = of_drm_find_bridge(companion);
+	p2d->companion = of_drm_find_and_get_bridge(companion);
 	if (!p2d->companion) {
 		ret = -EPROBE_DEFER;
 		DRM_DEV_DEBUG_DRIVER(p2d->dev,

-- 
2.52.0


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

* [PATCH v3 18/22] drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge
  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
                   ` (16 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 17/22] drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge Luca Ceresoli
@ 2025-12-16 17:58 ` 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
                   ` (4 subsequent siblings)
  22 siblings, 0 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

imx8qxp_pixel_link_find_next_bridge() uses a sophisticated logic to find
the preferred next bridge, using an array with two supporting index
variables. This is more sophisticated than required because we only ever
need a pointer to the "current" bridge and to the "best so far" bridge.

Additionally this logic is going to make the addition of proper refcounting
quite complex.

Rewrite the logic using two drm_bridge pointers, which is by itself
slightly simpler and is a preparation step for introducing bridge
refcounting in a later commit.

Also reword a comment to make it clearer.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index e5943506981d..53016f0d53a0 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -261,12 +261,10 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 {
 	struct device_node *np = pl->dev->of_node;
 	struct device_node *port, *remote;
-	struct drm_bridge *next_bridge[PL_MAX_NEXT_BRIDGES];
+	struct drm_bridge *selected_bridge = NULL;
 	u32 port_id;
 	bool found_port = false;
-	int reg, ep_cnt = 0;
-	/* select the first next bridge by default */
-	int bridge_sel = 0;
+	int reg;
 
 	for (port_id = 1; port_id <= PL_MAX_MST_ADDR + 1; port_id++) {
 		port = of_graph_get_port_by_id(np, port_id);
@@ -300,24 +298,25 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 			continue;
 		}
 
-		next_bridge[ep_cnt] = of_drm_find_bridge(remote);
-		if (!next_bridge[ep_cnt]) {
+		struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
+		if (!next_bridge) {
 			of_node_put(remote);
 			return ERR_PTR(-EPROBE_DEFER);
 		}
 
-		/* specially select the next bridge with companion PXL2DPI */
-		if (of_property_present(remote, "fsl,companion-pxl2dpi"))
-			bridge_sel = ep_cnt;
-
-		ep_cnt++;
+		/*
+		 * Select the next bridge with companion PXL2DPI if
+		 * present, otherwise default to the first bridge
+		 */
+		if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi"))
+			selected_bridge = next_bridge;
 
 		of_node_put(remote);
 	}
 
 	pl->mst_addr = port_id - 1;
 
-	return next_bridge[bridge_sel];
+	return selected_bridge;
 }
 
 static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)

-- 
2.52.0


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

* [PATCH v3 19/22] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
  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
                   ` (17 preceding siblings ...)
  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 ` 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
                   ` (3 subsequent siblings)
  22 siblings, 1 reply; 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

The main loop in imx8qxp_pixel_link_find_next_bridge() requires calling
of_node_put() in multiple places, complicating code flow. Simplify it by
using a cleanup action and making the 'remote' variable scope local to the
loop.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index 53016f0d53a0..2ecc3c1051e5 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -260,7 +260,7 @@ static struct drm_bridge *
 imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 {
 	struct device_node *np = pl->dev->of_node;
-	struct device_node *port, *remote;
+	struct device_node *port;
 	struct drm_bridge *selected_bridge = NULL;
 	u32 port_id;
 	bool found_port = false;
@@ -286,7 +286,8 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 	}
 
 	for (reg = 0; reg < PL_MAX_NEXT_BRIDGES; reg++) {
-		remote = of_graph_get_remote_node(np, port_id, reg);
+		struct device_node *remote __free(device_node) =
+			of_graph_get_remote_node(np, port_id, reg);
 		if (!remote)
 			continue;
 
@@ -294,15 +295,12 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 			DRM_DEV_DEBUG(pl->dev,
 				      "port%u endpoint%u remote parent is not available\n",
 				      port_id, reg);
-			of_node_put(remote);
 			continue;
 		}
 
 		struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
-		if (!next_bridge) {
-			of_node_put(remote);
+		if (!next_bridge)
 			return ERR_PTR(-EPROBE_DEFER);
-		}
 
 		/*
 		 * Select the next bridge with companion PXL2DPI if
@@ -310,8 +308,6 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 		 */
 		if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi"))
 			selected_bridge = next_bridge;
-
-		of_node_put(remote);
 	}
 
 	pl->mst_addr = port_id - 1;

-- 
2.52.0


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

* [PATCH v3 20/22] drm/bridge: imx8qxp-pixel-link: remove excess error message
  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
                   ` (18 preceding siblings ...)
  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-16 17:58 ` 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
                   ` (2 subsequent siblings)
  22 siblings, 1 reply; 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

imx8qxp_pixel_link_find_next_bridge() already emits a DRM_DEV_ERROR() on
error except for -EPROBE_DEFER. The caller emits another one, which is
redundant. Remove the message in the caller and keep the one in
imx8qxp_pixel_link_find_next_bridge() as it is more informative about the
error cause.

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

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index 2ecc3c1051e5..0c5ed06eee1b 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -369,13 +369,8 @@ static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
 		return ret;
 
 	pl->next_bridge = imx8qxp_pixel_link_find_next_bridge(pl);
-	if (IS_ERR(pl->next_bridge)) {
-		ret = PTR_ERR(pl->next_bridge);
-		if (ret != -EPROBE_DEFER)
-			DRM_DEV_ERROR(dev, "failed to find next bridge: %d\n",
-				      ret);
-		return ret;
-	}
+	if (IS_ERR(pl->next_bridge))
+		return PTR_ERR(pl->next_bridge);
 
 	platform_set_drvdata(pdev, pl);
 

-- 
2.52.0


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

* [PATCH v3 21/22] drm/bridge: imx8qxp-pixel-link: imx8qxp_pixel_link_find_next_bridge: return int, not ERR_PTR
  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
                   ` (19 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 20/22] drm/bridge: imx8qxp-pixel-link: remove excess error message Luca Ceresoli
@ 2025-12-16 17:58 ` 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-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
  22 siblings, 1 reply; 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

In preparation for using bridge->next_bridge, we need to ensure that it
will never contain anything but NULL or a valid bridge pointer. Current
code stores an ERR_PTR when imx8qxp_pixel_link_find_next_bridge() errors
out. Instead of fixing that after the facts in the caller, change the
function to internally set pl->next_bridge and just return an int error
value.

No functional changes.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index 0c5ed06eee1b..91e4f4d55469 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -256,8 +256,7 @@ static int imx8qxp_pixel_link_disable_all_controls(struct imx8qxp_pixel_link *pl
 	return imx8qxp_pixel_link_disable_sync(pl);
 }
 
-static struct drm_bridge *
-imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
+static int imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 {
 	struct device_node *np = pl->dev->of_node;
 	struct device_node *port;
@@ -282,7 +281,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 
 	if (!found_port) {
 		DRM_DEV_ERROR(pl->dev, "no available output port\n");
-		return ERR_PTR(-ENODEV);
+		return -ENODEV;
 	}
 
 	for (reg = 0; reg < PL_MAX_NEXT_BRIDGES; reg++) {
@@ -300,7 +299,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 
 		struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
 		if (!next_bridge)
-			return ERR_PTR(-EPROBE_DEFER);
+			return -EPROBE_DEFER;
 
 		/*
 		 * Select the next bridge with companion PXL2DPI if
@@ -311,8 +310,9 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 	}
 
 	pl->mst_addr = port_id - 1;
+	pl->next_bridge = selected_bridge;
 
-	return selected_bridge;
+	return 0;
 }
 
 static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
@@ -368,9 +368,9 @@ static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	pl->next_bridge = imx8qxp_pixel_link_find_next_bridge(pl);
-	if (IS_ERR(pl->next_bridge))
-		return PTR_ERR(pl->next_bridge);
+	ret = imx8qxp_pixel_link_find_next_bridge(pl);
+	if (ret)
+		return ret;
 
 	platform_set_drvdata(pdev, pl);
 

-- 
2.52.0


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

* [PATCH v3 22/22] drm/bridge: imx8qxp-pixel-link: get/put the next bridge
  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
                   ` (20 preceding siblings ...)
  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-16 17:58 ` 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
  22 siblings, 1 reply; 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 driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

This needs to be handled in various steps:

 * the bridge returned of_drm_get_bridge() is stored in the local temporary
   variable next_bridge whose scope is the for loop, so a cleanup action is
   enough
 * the value of next_bridge is copied into selected_bridge, potentially
   more than once, so a cleanup action at function scope plus a
   drm_bridge_put() in case of reassignment are enough
 * on successful return selected_bridge is stored in bridge->next_bridge,
   which ensures it is put when the bridge is deallocated

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index 91e4f4d55469..b3050310a7f0 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -23,7 +23,6 @@
 
 struct imx8qxp_pixel_link {
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 	struct device *dev;
 	struct imx_sc_ipc *ipc_handle;
 	u8 stream_id;
@@ -140,7 +139,7 @@ static int imx8qxp_pixel_link_bridge_attach(struct drm_bridge *bridge,
 	}
 
 	return drm_bridge_attach(encoder,
-				 pl->next_bridge, bridge,
+				 pl->bridge.next_bridge, bridge,
 				 DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 }
 
@@ -260,7 +259,7 @@ static int imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 {
 	struct device_node *np = pl->dev->of_node;
 	struct device_node *port;
-	struct drm_bridge *selected_bridge = NULL;
+	struct drm_bridge *selected_bridge __free(drm_bridge_put) = NULL;
 	u32 port_id;
 	bool found_port = false;
 	int reg;
@@ -297,7 +296,8 @@ static int imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 			continue;
 		}
 
-		struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
+		struct drm_bridge *next_bridge __free(drm_bridge_put) =
+			of_drm_find_and_get_bridge(remote);
 		if (!next_bridge)
 			return -EPROBE_DEFER;
 
@@ -305,12 +305,14 @@ static int imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 		 * Select the next bridge with companion PXL2DPI if
 		 * present, otherwise default to the first bridge
 		 */
-		if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi"))
-			selected_bridge = next_bridge;
+		if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi")) {
+			drm_bridge_put(selected_bridge);
+			selected_bridge = drm_bridge_get(next_bridge);
+		}
 	}
 
 	pl->mst_addr = port_id - 1;
-	pl->next_bridge = selected_bridge;
+	pl->bridge.next_bridge = drm_bridge_get(selected_bridge);
 
 	return 0;
 }

-- 
2.52.0


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

* Re: [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge()
  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
  0 siblings, 1 reply; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:15 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:34 +0100, Luca Ceresoli wrote:
> of_drm_find_bridge() does not increment the refcount for the returned
> bridge, but that is required now. However converting it and all its users
> is not realistically doable at once given the large amount of (direct and
> indirect) callers and the complexity of some.
> 
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 04/22] drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge()
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:16 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:37 +0100, Luca Ceresoli wrote:
> of_drm_find_bridge() is identical to of_drm_find_and_get_bridge() except it
> does not increment the refcount. Rewrite it as a wrapper and put the bridge
> being returned so the behaviour is still the same.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 05/22] drm/arcpgu: convert to of_drm_find_and_get_bridge()
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:16 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:38 +0100, Luca Ceresoli wrote:
> of_drm_find_bridge() is deprecated. Move to its replacement
> of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
> is put it when done.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 06/22] drm/bridge: add next_bridge pointer to struct drm_bridge
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:17 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:39 +0100, Luca Ceresoli wrote:
> Many bridge drivers store a next_bridge pointer in their private data and
> use it for attach and sometimes other purposes. This is going to be risky
> when bridge hot-unplug is used.
> 
> Considering this example scenario:
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 07/22] drm/bridge: ite-it66121: get/put the next bridge
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:17 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:40 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 08/22] drm/bridge: imx8qxp-pixel-combiner: get/put the next bridge
  2025-12-16 17:58 ` [PATCH v3 08/22] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
@ 2025-12-17 10:17   ` Maxime Ripard
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:17 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:41 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 10/22] drm/meson: encoder_cvbs: get/put the next bridge
  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
  1 sibling, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:17 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:43 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 11/22] drm/meson: encoder_dsi: get/put the next bridge
  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
  1 sibling, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:18 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:44 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 12/22] drm/meson: encoder_hdmi: get/put the next bridge
  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
  1 sibling, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:18 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:45 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:18 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:46 +0100, Luca Ceresoli wrote:
> Simplify the error-management code in
> imx8qxp_pxl2dpi_get_available_ep_from_port() by using a release action for
> the struct device_node pointers.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 14/22] drm/bridge: imx8qxp-pxl2dpi: remove excess error message
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:19 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:47 +0100, Luca Ceresoli wrote:
> imx8qxp_pxl2dpi_find_next_bridge() already emits a DRM_DEV_ERROR() for
> every error except -EPROBE_DEFER. The caller emits another one, which is
> redundant. Remove the message in the caller and keep the two in
> imx8qxp_pxl2dpi_find_next_bridge() as they are more informative about the
> error cause.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 15/22] drm/bridge: imx8qxp-pxl2dpi: imx8qxp_pxl2dpi_find_next_bridge: return int, not ERR_PTR
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:20 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:48 +0100, Luca Ceresoli wrote:
> In preparation for using bridge->next_bridge, we need to ensure that it
> will never contain anything but NULL or a valid bridge pointer. Current
> code stores an ERR_PTR when imx8qxp_pxl2dpi_find_next_bridge() errors
> out. Instead of fixing that after the facts in the caller, change the
> function to internally set the next_pointer and just return an int error
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 16/22] drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:20 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:49 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 17/22] drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:20 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:50 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use the destroy hook to put the reference on deallocation.
> 
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 20/22] drm/bridge: imx8qxp-pixel-link: remove excess error message
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:20 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:53 +0100, Luca Ceresoli wrote:
> imx8qxp_pixel_link_find_next_bridge() already emits a DRM_DEV_ERROR() on
> error except for -EPROBE_DEFER. The caller emits another one, which is
> redundant. Remove the message in the caller and keep the one in
> imx8qxp_pixel_link_find_next_bridge() as it is more informative about the
> error cause.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 21/22] drm/bridge: imx8qxp-pixel-link: imx8qxp_pixel_link_find_next_bridge: return int, not ERR_PTR
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:25 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:54 +0100, Luca Ceresoli wrote:
> In preparation for using bridge->next_bridge, we need to ensure that it
> will never contain anything but NULL or a valid bridge pointer. Current
> code stores an ERR_PTR when imx8qxp_pixel_link_find_next_bridge() errors
> out. Instead of fixing that after the facts in the caller, change the
> function to internally set pl->next_bridge and just return an int error
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 19/22] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:25 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:52 +0100, Luca Ceresoli wrote:
> The main loop in imx8qxp_pixel_link_find_next_bridge() requires calling
> of_node_put() in multiple places, complicating code flow. Simplify it by
> using a cleanup action and making the 'remote' variable scope local to the
> loop.
> 
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 22/22] drm/bridge: imx8qxp-pixel-link: get/put the next bridge
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:25 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:55 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 09/22] drm/bridge: simple-bridge: get/put the next bridge
  2025-12-16 17:58 ` [PATCH v3 09/22] drm/bridge: simple-bridge: " Luca Ceresoli
@ 2025-12-17 10:41   ` Maxime Ripard
  0 siblings, 0 replies; 51+ messages in thread
From: Maxime Ripard @ 2025-12-17 10:41 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Maxime Ripard,
	Neil Armstrong, Pengutronix Kernel Team, Phong LE, Robert Foss,
	Sascha Hauer, Shawn Guo, Simona Vetter, Thomas Petazzoni,
	Thomas Zimmermann

On Tue, 16 Dec 2025 18:58:42 +0100, Luca Ceresoli wrote:
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

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

* Re: [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge()
  2025-12-17 10:15   ` Maxime Ripard
@ 2025-12-17 14:31     ` Luca Ceresoli
  2025-12-18 12:50       ` Maxime Ripard
  0 siblings, 1 reply; 51+ messages in thread
From: Luca Ceresoli @ 2025-12-17 14:31 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Neil Armstrong,
	Pengutronix Kernel Team, Phong LE, Robert Foss, Sascha Hauer,
	Shawn Guo, Simona Vetter, Thomas Petazzoni, Thomas Zimmermann

Hi Maxime,

On Wed Dec 17, 2025 at 11:15 AM CET, Maxime Ripard wrote:
> On Tue, 16 Dec 2025 18:58:34 +0100, Luca Ceresoli wrote:
>> of_drm_find_bridge() does not increment the refcount for the returned
>> bridge, but that is required now. However converting it and all its users
>> is not realistically doable at once given the large amount of (direct and
>> indirect) callers and the complexity of some.
>>
>>
>> [ ... ]
>
> Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thank you for the prompt review!

All patches are reviewed now except patch 18 which has no reply. I'm just
pointing out in case it's something you missed.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge()
  2025-12-17 14:31     ` Luca Ceresoli
@ 2025-12-18 12:50       ` Maxime Ripard
  2025-12-18 14:23         ` Luca Ceresoli
  0 siblings, 1 reply; 51+ messages in thread
From: Maxime Ripard @ 2025-12-18 12:50 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Neil Armstrong,
	Pengutronix Kernel Team, Phong LE, Robert Foss, Sascha Hauer,
	Shawn Guo, Simona Vetter, Thomas Petazzoni, Thomas Zimmermann

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

Hi,

On Wed, Dec 17, 2025 at 03:31:01PM +0100, Luca Ceresoli wrote:
> On Wed Dec 17, 2025 at 11:15 AM CET, Maxime Ripard wrote:
> > On Tue, 16 Dec 2025 18:58:34 +0100, Luca Ceresoli wrote:
> >> of_drm_find_bridge() does not increment the refcount for the returned
> >> bridge, but that is required now. However converting it and all its users
> >> is not realistically doable at once given the large amount of (direct and
> >> indirect) callers and the complexity of some.
> >>
> >>
> >> [ ... ]
> >
> > Reviewed-by: Maxime Ripard <mripard@kernel.org>
> 
> Thank you for the prompt review!
> 
> All patches are reviewed now except patch 18 which has no reply. I'm just
> pointing out in case it's something you missed.

Yes, I couldn't really understand the implications of that one, so I'll
leave the review to the maintainers.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

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

* Re: [PATCH v3 01/22] drm/bridge: add of_drm_find_and_get_bridge()
  2025-12-18 12:50       ` Maxime Ripard
@ 2025-12-18 14:23         ` Luca Ceresoli
  0 siblings, 0 replies; 51+ messages in thread
From: Luca Ceresoli @ 2025-12-18 14:23 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: dri-devel, imx, linux-amlogic, linux-arm-kernel, linux-doc,
	linux-kernel, Alexey Brodkin, Andrzej Hajda, David Airlie,
	Fabio Estevam, Hui Pu, Jernej Skrabec, Jerome Brunet,
	Jonas Karlman, Jonathan Corbet, Kevin Hilman, Laurent Pinchart,
	Liu Ying, Maarten Lankhorst, Martin Blumenstingl, Neil Armstrong,
	Pengutronix Kernel Team, Phong LE, Robert Foss, Sascha Hauer,
	Shawn Guo, Simona Vetter, Thomas Petazzoni, Thomas Zimmermann

Hi Maxime,

On Thu Dec 18, 2025 at 1:50 PM CET, Maxime Ripard wrote:
> Hi,
>
> On Wed, Dec 17, 2025 at 03:31:01PM +0100, Luca Ceresoli wrote:
>> On Wed Dec 17, 2025 at 11:15 AM CET, Maxime Ripard wrote:
>> > On Tue, 16 Dec 2025 18:58:34 +0100, Luca Ceresoli wrote:
>> >> of_drm_find_bridge() does not increment the refcount for the returned
>> >> bridge, but that is required now. However converting it and all its users
>> >> is not realistically doable at once given the large amount of (direct and
>> >> indirect) callers and the complexity of some.
>> >>
>> >>
>> >> [ ... ]
>> >
>> > Reviewed-by: Maxime Ripard <mripard@kernel.org>
>>
>> Thank you for the prompt review!
>>
>> All patches are reviewed now except patch 18 which has no reply. I'm just
>> pointing out in case it's something you missed.
>
> Yes, I couldn't really understand the implications of that one, so I'll
> leave the review to the maintainers.

OK, make sense, it's not a trivial patch to review.

Patches 1-4,6 contain the core changes and they are all reviewed, which is
the most important part to me. Everything else is just "a bunch of driver
conversions" and they can flow in over time. I'm also sending more such
driver conversions in separate series, for other drivers.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v3 10/22] drm/meson: encoder_cvbs: get/put the next bridge
  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
  1 sibling, 0 replies; 51+ messages in thread
From: Martin Blumenstingl @ 2025-12-21 21:50 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: 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, Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-doc, imx, linux-arm-kernel, linux-amlogic

On Tue, Dec 16, 2025 at 7:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

* Re: [PATCH v3 11/22] drm/meson: encoder_dsi: get/put the next bridge
  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
  1 sibling, 0 replies; 51+ messages in thread
From: Martin Blumenstingl @ 2025-12-21 21:50 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: 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, Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-doc, imx, linux-arm-kernel, linux-amlogic

On Tue, Dec 16, 2025 at 7:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

* Re: [PATCH v3 12/22] drm/meson: encoder_hdmi: get/put the next bridge
  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
  1 sibling, 1 reply; 51+ messages in thread
From: Martin Blumenstingl @ 2025-12-21 21:51 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: 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, Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-doc, imx, linux-arm-kernel, linux-amlogic

On Tue, Dec 16, 2025 at 7:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> function and stores it until driver removal. of_drm_find_bridge() is
> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> refcounted and use bridge->next_bridge to put the reference on
> deallocation.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
And additionally I runtime tested this on meson-gxl-s905x-libretech-cc
where I still have HDMI output, so:
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

* Re: [PATCH v3 12/22] drm/meson: encoder_hdmi: get/put the next bridge
  2025-12-21 21:51   ` Martin Blumenstingl
@ 2025-12-22  7:30     ` Luca Ceresoli
  2025-12-22 10:38       ` Martin Blumenstingl
  0 siblings, 1 reply; 51+ messages in thread
From: Luca Ceresoli @ 2025-12-22  7:30 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: 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, Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-doc, imx, linux-arm-kernel, linux-amlogic

Hello Martin,

On Sun Dec 21, 2025 at 10:51 PM CET, Martin Blumenstingl wrote:
> On Tue, Dec 16, 2025 at 7:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>>
>> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
>> function and stores it until driver removal. of_drm_find_bridge() is
>> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
>> refcounted and use bridge->next_bridge to put the reference on
>> deallocation.
>>
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> And additionally I runtime tested this on meson-gxl-s905x-libretech-cc
> where I still have HDMI output, so:
> Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Thank you for the quick testing!

I think I can append '# meson-gxl-s905x-libretech-cc' to your 'Tested-by:'
line when I'll apply the patch, to make it more informative.

Best regards,
Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v3 12/22] drm/meson: encoder_hdmi: get/put the next bridge
  2025-12-22  7:30     ` Luca Ceresoli
@ 2025-12-22 10:38       ` Martin Blumenstingl
  0 siblings, 0 replies; 51+ messages in thread
From: Martin Blumenstingl @ 2025-12-22 10:38 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: 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, Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-doc, imx, linux-arm-kernel, linux-amlogic

Hi Luca,

On Mon, Dec 22, 2025 at 8:31 AM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> Hello Martin,
>
> On Sun Dec 21, 2025 at 10:51 PM CET, Martin Blumenstingl wrote:
> > On Tue, Dec 16, 2025 at 7:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> >>
> >> This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
> >> function and stores it until driver removal. of_drm_find_bridge() is
> >> deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
> >> refcounted and use bridge->next_bridge to put the reference on
> >> deallocation.
> >>
> >> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > And additionally I runtime tested this on meson-gxl-s905x-libretech-cc
> > where I still have HDMI output, so:
> > Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>
> Thank you for the quick testing!
Thank you for doing the hard work ;-)

> I think I can append '# meson-gxl-s905x-libretech-cc' to your 'Tested-by:'
> line when I'll apply the patch, to make it more informative.
Sure, please go ahead with that!


Best regards,
Martin

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

* Re: [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 [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
                   ` (21 preceding siblings ...)
  2025-12-16 17:58 ` [PATCH v3 22/22] drm/bridge: imx8qxp-pixel-link: get/put the next bridge Luca Ceresoli
@ 2025-12-30  9:17 ` Luca Ceresoli
  22 siblings, 0 replies; 51+ messages in thread
From: Luca Ceresoli @ 2025-12-30  9:17 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, Luca Ceresoli
  Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
	linux-arm-kernel, linux-amlogic


On Tue, 16 Dec 2025 18:58:33 +0100, Luca Ceresoli wrote:
> 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):
> 
> [...]

Applied, thanks!

[01/22] drm/bridge: add of_drm_find_and_get_bridge()
        commit: 293a8fd7721a90987d9bf149feab60e756dac269
[02/22] drm/bridge: deprecate of_drm_find_bridge()
        commit: 9da0e06abda87b1f97014113d5231fdeb4700749
[03/22] drm/todo: add entry about converting to of_drm_find_and_get_bridge()
        commit: c637217efb892ac5d0d5f9aea3df92147c2e24db
[04/22] drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge()
        commit: 5d7cb36254b5facd2a349331c1a47102d4e66e40
[05/22] drm/arcpgu: convert to of_drm_find_and_get_bridge()
        commit: 7282066e55347b26cb31784059ab62c2de8a3e01
[06/22] drm/bridge: add next_bridge pointer to struct drm_bridge
        commit: 3fdeae134ba956aacbd87d5532c025913c98fc49
[07/22] drm/bridge: ite-it66121: get/put the next bridge
        commit: 8f92a5fcbfe33f86b08f5f74dcc58a41425ea8c0
[08/22] drm/bridge: imx8qxp-pixel-combiner: get/put the next bridge
        commit: ae754f049ce1c01f09d175f80265970f0d5b4489
[09/22] drm/bridge: simple-bridge: get/put the next bridge
        commit: b9a7d5918bd436d64699b80af061f21c168df699
[10/22] drm/meson: encoder_cvbs: get/put the next bridge
        commit: 47fa48b3faa7cae925c9b14b18376cdc4622bae0
[11/22] drm/meson: encoder_dsi: get/put the next bridge
        commit: bfb8f5d0a9e756c57d4fc0f7966e4873bbfb34a5
[12/22] drm/meson: encoder_hdmi: get/put the next bridge
        commit: c87ad784aacb89cf88c00cde78970543010a6d67
[13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers
        commit: ceea3f7806a109baba4a23c9066eb9e86659408b
[14/22] drm/bridge: imx8qxp-pxl2dpi: remove excess error message
        commit: 54af17788629fbf343c5a9ebc55454d6a5486ff8
[15/22] drm/bridge: imx8qxp-pxl2dpi: imx8qxp_pxl2dpi_find_next_bridge: return int, not ERR_PTR
        commit: 0dc4a8d6d096f97a00b10919e8ffe2466666f03c
[16/22] drm/bridge: imx8qxp-pxl2dpi: get/put the next bridge
        commit: 6802c7ee360d98a018962adb8412d42dcca28272
[17/22] drm/bridge: imx8qxp-pxl2dpi: get/put the companion bridge
        commit: 900699ba830fd3558ba00f55fbf014022dc7ecdb
[18/22] drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge
        (no commit info)
[19/22] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
        (no commit info)
[20/22] drm/bridge: imx8qxp-pixel-link: remove excess error message
        commit: 40630210211a34f0714fe976530ccf1291e5ef78
[21/22] drm/bridge: imx8qxp-pixel-link: imx8qxp_pixel_link_find_next_bridge: return int, not ERR_PTR
        (no commit info)
[22/22] drm/bridge: imx8qxp-pixel-link: get/put the next bridge
        (no commit info)

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).