public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge()
@ 2026-04-28 15:30 Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 01/11] drm/bridge: drm_bridge_get/put(): ignore ERR_PTR Luca Ceresoli
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Laurent Pinchart, Dmitry Baryshkov

This series converts all the bridge-only callers of the deprecated
drm_of_find_panel_or_bridge() API to a new, simpler API that handles bridge
refcounting.

== Series description

 * Patch 1 (new in v2) makes drm_bridge_get/put() ignore ERR_PTR pointers,
   not only NULL pointers
 * Patch 2 introduces of_drm_get_bridge_by_endpoint() as a replacement for
   bridge-only calls to drm_of_find_panel_or_bridge(); the new function
   refcounts the bridge and is simpler
 * The following patches convert all bridge-only users to the new API
 * The last patch forbids new bridge-only calls to
   drm_of_find_panel_or_bridge()

== Grand plan

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 (v7.2)
       7. ➜ of_drm_find_bridge
          a. ✔ add of_drm_get_bridge() (v7.0),
               convert basic direct users (v7.0-v7.1)
          b. ✔ convert direct of_drm_get_bridge() users, part 2 (v7.0)
          c. ✔ convert direct of_drm_get_bridge() users, part 3 (v7.0)
          d. ✔ convert direct of_drm_get_bridge() users, part 4 (v7.1-v7.2)
          e. ➜ 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_bridge_enter/exit() to protect device resources (v7.0)
    B. … protect private_obj removal from list
    C. ✔ Add drm_bridge_clear_and_put() (v7.1)
 3. … DSI host-device driver interaction
 4. ✔ removing the need for the "always-disconnected" connector
 5. ✔ Migrate i.MX LCDIF driver to bridge-connector (v7.2)
 6. … DRM bridge hotplug
    A. … Bridge hotplug management in the DRM core
       1. … bridge-connector: attach encoder to the connector
    B.   Device tree description

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

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v3:
- patch 3, 8, 10: fixed ERR_PTR deref in the -ENODEV case, and removed
  Dmitry's R-by from those patches as they are changed
- Added review trailers to the other patches
- Link to v2: https://patch.msgid.link/20260428-drm-bridge-alloc-getput-panel_or_bridge-v2-0-4300744a1c47@bootlin.com

Changes in v2:
- Added patch to ignore ERR_PTR values in drm_bridge_get/put()
- Changed API to return the bridge (or a ERR_PTR) in the return value,
  not as a double-pointer output parameter
- Adapted all patches to the new API, dropped Dmitry's review tags as the
  patches are all modified
- Removed bouncing addresses from Cc list
- Link to v1: https://patch.msgid.link/20260413-drm-bridge-alloc-getput-panel_or_bridge-v1-0-acd01cd79a1f@bootlin.com

---
Luca Ceresoli (11):
      drm/bridge: drm_bridge_get/put(): ignore ERR_PTR
      drm/bridge: add of_drm_get_bridge_by_endpoint()
      drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint()
      drm/hisilicon/kirin: switch to of_drm_get_bridge_by_endpoint()
      drm/bridge: chrontel-ch7033: switch to of_drm_get_bridge_by_endpoint()
      drm/bridge: lontium-lt9611uxc: switch to of_drm_get_bridge_by_endpoint()
      drm/bridge: lt9611: switch to of_drm_get_bridge_by_endpoint()
      drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint()
      drm/bridge: lt8713sx: switch to of_drm_get_bridge_by_endpoint()
      drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
      drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge()

 drivers/gpu/drm/bridge/adv7511/adv7511.h     |  1 -
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 15 ++++----
 drivers/gpu/drm/bridge/chrontel-ch7033.c     | 28 +++++++--------
 drivers/gpu/drm/bridge/lontium-lt8713sx.c    | 10 +++---
 drivers/gpu/drm/bridge/lontium-lt9611.c      |  9 +++--
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c   |  9 +++--
 drivers/gpu/drm/drm_bridge.c                 | 53 ++++++++++++++++++++++++----
 drivers/gpu/drm/drm_of.c                     | 26 +++++++-------
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c |  9 +++--
 drivers/gpu/drm/msm/hdmi/hdmi.c              | 11 ++++--
 drivers/gpu/drm/xlnx/zynqmp_dp.c             | 19 +++++-----
 include/drm/drm_bridge.h                     |  8 +++++
 12 files changed, 128 insertions(+), 70 deletions(-)
---
base-commit: 6dbe0c5375e4f88c8d7c90790e0ea29d565b5d0a
change-id: 20260410-drm-bridge-alloc-getput-panel_or_bridge-42501b38eaad

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



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

* [PATCH v3 01/11] drm/bridge: drm_bridge_get/put(): ignore ERR_PTR
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 02/11] drm/bridge: add of_drm_get_bridge_by_endpoint() Luca Ceresoli
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Laurent Pinchart, Dmitry Baryshkov

Most functions returning a struct drm_bridge pointer currently return a
valid pointer or NULL, but this restricts their ability to return an error
code describing the error kind.

In preparation to have new APIs that can return a struct drm_bridge pointer
holding an ERR_PTR (and for those which already do) make drm_bridge_get()
and drm_bridge_put() ignore ERR_PTR values, just like they ignore NULL
pointers.

This will avoid annoying error checking in many places and the risk of
missing error checks.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/all/20260318152533.GA633439@killaraus.ideasonboard.com/
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/all/omlnswxukeqgnatzdvooaashgkfcacjevkvbkm6xt33itgua2k@jcmzll2w6kdq/
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Patch added in v2
---
 drivers/gpu/drm/drm_bridge.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 986e4c79a4e0..cea5babbe99e 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -282,7 +282,7 @@ static void __drm_bridge_free(struct kref *kref)
 
 /**
  * drm_bridge_get - Acquire a bridge reference
- * @bridge: DRM bridge; if NULL this function does nothing
+ * @bridge: DRM bridge; if NULL or an ERR_PTR this function does nothing
  *
  * This function increments the bridge's refcount.
  *
@@ -291,7 +291,7 @@ static void __drm_bridge_free(struct kref *kref)
  */
 struct drm_bridge *drm_bridge_get(struct drm_bridge *bridge)
 {
-	if (bridge)
+	if (!IS_ERR_OR_NULL(bridge))
 		kref_get(&bridge->refcount);
 
 	return bridge;
@@ -300,7 +300,7 @@ EXPORT_SYMBOL(drm_bridge_get);
 
 /**
  * drm_bridge_put - Release a bridge reference
- * @bridge: DRM bridge; if NULL this function does nothing
+ * @bridge: DRM bridge; if NULL or an ERR_PTR this function does nothing
  *
  * This function decrements the bridge's reference count and frees the
  * object if the reference count drops to zero.
@@ -310,7 +310,7 @@ EXPORT_SYMBOL(drm_bridge_get);
  */
 void drm_bridge_put(struct drm_bridge *bridge)
 {
-	if (bridge)
+	if (!IS_ERR_OR_NULL(bridge))
 		kref_put(&bridge->refcount, __drm_bridge_free);
 }
 EXPORT_SYMBOL(drm_bridge_put);
@@ -319,8 +319,8 @@ EXPORT_SYMBOL(drm_bridge_put);
  * drm_bridge_clear_and_put - Given a bridge pointer, clear the pointer
  *                            then put the bridge
  * @bridge_pp: pointer to pointer to a struct drm_bridge; ``bridge_pp``
- *             must be non-NULL; if ``*bridge_pp`` is NULL this function
- *             does nothing
+ *             must be non-NULL; if ``*bridge_pp`` is NULL or an ERR_PTR
+ *             this function does nothing
  *
  * Helper to put a DRM bridge, but only after setting its pointer to
  * NULL. Useful when a struct drm_bridge reference must be dropped without

-- 
2.53.0



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

* [PATCH v3 02/11] drm/bridge: add of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 01/11] drm/bridge: drm_bridge_get/put(): ignore ERR_PTR Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint() Luca Ceresoli
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

drm_of_find_panel_or_bridge() is widely used, but many callers pass NULL
into the @panel or the @bridge arguments, thus making a very partial usage
of this rather complex function.

Besides, the bridge returned in @bridge is not refcounted, thus making this
API unsafe when DRM bridge hotplug will be introduced.

Solve both issues for the cases of calls to drm_of_find_panel_or_bridge()
with a NULL @panel pointer by adding a new function that only looks for
bridges (and is thus much simpler) and increments the refcount of the
returned bridge.

The new function is identical to drm_of_find_panel_or_bridge() except it:

 - handles bridge refcounting: uses of_drm_find_and_get_bridge() instead of
   of_drm_find_bridge() internally to return a refcounted bridge
 - is simpler to use: just takes no @panel parameter, returns the pointer
   in the return value instead of a double pointer argument
 - has a simpler implementation: it is equal to
   drm_of_find_panel_or_bridge() after removing the code that becomes dead
   when @panel == NULL

Also add this function to drm_bridge.c and not drm_of.c because it returns
bridges only.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v2:
- return the bridge in the return value, not a double pointer
---
 drivers/gpu/drm/drm_bridge.c | 41 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_bridge.h     |  8 ++++++++
 2 files changed, 49 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index cea5babbe99e..8a4141bb7b31 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1582,6 +1582,47 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 	return bridge;
 }
 EXPORT_SYMBOL(of_drm_find_bridge);
+
+/**
+ * of_drm_get_bridge_by_endpoint - return DRM bridge connected to a port/endpoint
+ * @np: device tree node containing output ports
+ * @port: port in the device tree node, or -1 for the first port found
+ * @endpoint: endpoint in the device tree node, or -1 for the first endpoint found
+ *
+ * Given a DT node's port and endpoint number, find the connected node and
+ * return the associated drm_bridge device.
+ *
+ * The refcount of the returned bridge is incremented. Use drm_bridge_put()
+ * when done with it.
+ *
+ * Returns a pointer to the connected drm_bridge, or a negative error on failure
+ */
+struct drm_bridge *of_drm_get_bridge_by_endpoint(const struct device_node *np,
+						 int port, int endpoint)
+{
+	struct drm_bridge *bridge;
+
+	/*
+	 * of_graph_get_remote_node() produces a noisy error message if port
+	 * node isn't found and the absence of the port is a legit case here,
+	 * so at first we silently check whether graph presents in the
+	 * device-tree node.
+	 */
+	if (!of_graph_is_present(np))
+		return ERR_PTR(-ENODEV);
+
+	struct device_node *remote __free(device_node) =
+		of_graph_get_remote_node(np, port, endpoint);
+	if (!remote)
+		return ERR_PTR(-ENODEV);
+
+	bridge = of_drm_find_and_get_bridge(remote);
+	if (!bridge)
+		return ERR_PTR(-EPROBE_DEFER);
+
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(of_drm_get_bridge_by_endpoint);
 #endif
 
 /**
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index d6cd0f5af045..c96398460618 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1327,6 +1327,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
 #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);
+struct drm_bridge *of_drm_get_bridge_by_endpoint(const struct device_node *np,
+						 int port, int endpoint);
 #else
 static inline struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np)
 {
@@ -1336,6 +1338,12 @@ static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 {
 	return NULL;
 }
+static inline int of_drm_get_bridge_by_endpoint(const struct device_node *np,
+						int port, int endpoint,
+						struct drm_bridge **bridge)
+{
+	return -ENODEV;
+}
 #endif
 
 static inline bool drm_bridge_is_last(struct drm_bridge *bridge)

-- 
2.53.0



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

* [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 01/11] drm/bridge: drm_bridge_get/put(): ignore ERR_PTR Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 02/11] drm/bridge: add of_drm_get_bridge_by_endpoint() Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 20:32   ` Dmitry Baryshkov
  2026-04-28 15:30 ` [PATCH v3 04/11] drm/hisilicon/kirin: " Luca Ceresoli
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal.

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

---

Changes in v3:
- fix ERR_PTR deref when -ENODEV is returned
---
 drivers/gpu/drm/msm/hdmi/hdmi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
index 852abb2466f0..124dedc084ec 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
@@ -287,9 +287,13 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
 	spin_lock_init(&hdmi->reg_lock);
 	mutex_init(&hdmi->state_mutex);
 
-	ret = drm_of_find_panel_or_bridge(dev_of_node(dev), 1, 0, NULL, &hdmi->next_bridge);
-	if (ret && ret != -ENODEV)
-		return ret;
+	hdmi->next_bridge = of_drm_get_bridge_by_endpoint(dev_of_node(dev), 1, 0);
+	if (IS_ERR(hdmi->next_bridge)) {
+		if (PTR_ERR(hdmi->next_bridge) == -ENODEV)
+			hdmi->next_bridge = NULL;
+		else
+			return PTR_ERR(hdmi->next_bridge);
+	}
 
 	hdmi->mmio = msm_ioremap(pdev, "core_physical");
 	if (IS_ERR(hdmi->mmio))
@@ -383,6 +387,7 @@ static void msm_hdmi_dev_remove(struct platform_device *pdev)
 	component_del(&pdev->dev, &msm_hdmi_ops);
 
 	msm_hdmi_put_phy(hdmi);
+	drm_bridge_put(hdmi->next_bridge);
 }
 
 static int msm_hdmi_runtime_suspend(struct device *dev)

-- 
2.53.0



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

* [PATCH v3 04/11] drm/hisilicon/kirin: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (2 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint() Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 05/11] drm/bridge: chrontel-ch7033: " Luca Ceresoli
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. Here the bridge pointer is
only stored in a temporary variable, so a cleanup action is enough.

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

diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index e80debdc4176..ab3cd309505a 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -778,17 +778,16 @@ static int dsi_host_init(struct device *dev, struct dw_dsi *dsi)
 static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi)
 {
 	struct drm_encoder *encoder = &dsi->encoder;
-	struct drm_bridge *bridge;
+	struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
 	struct device_node *np = dsi->dev->of_node;
-	int ret;
 
 	/*
 	 * Get the endpoint node. In our case, dsi has one output port1
 	 * to which the external HDMI bridge is connected.
 	 */
-	ret = drm_of_find_panel_or_bridge(np, 1, 0, NULL, &bridge);
-	if (ret)
-		return ret;
+	bridge = of_drm_get_bridge_by_endpoint(np, 1, 0);
+	if (IS_ERR(bridge))
+		return PTR_ERR(bridge);
 
 	/* associate the bridge to dsi encoder */
 	return drm_bridge_attach(encoder, bridge, NULL, 0);

-- 
2.53.0



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

* [PATCH v3 05/11] drm/bridge: chrontel-ch7033: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (3 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 04/11] drm/hisilicon/kirin: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 06/11] drm/bridge: lontium-lt9611uxc: " Luca Ceresoli
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/chrontel-ch7033.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/bridge/chrontel-ch7033.c b/drivers/gpu/drm/bridge/chrontel-ch7033.c
index 54d49d4882c8..a237c65ebd69 100644
--- a/drivers/gpu/drm/bridge/chrontel-ch7033.c
+++ b/drivers/gpu/drm/bridge/chrontel-ch7033.c
@@ -199,7 +199,6 @@ enum {
 
 struct ch7033_priv {
 	struct regmap *regmap;
-	struct drm_bridge *next_bridge;
 	struct drm_bridge bridge;
 	struct drm_connector connector;
 };
@@ -215,7 +214,7 @@ static enum drm_connector_status ch7033_connector_detect(
 {
 	struct ch7033_priv *priv = conn_to_ch7033_priv(connector);
 
-	return drm_bridge_detect(priv->next_bridge, connector);
+	return drm_bridge_detect(priv->bridge.next_bridge, connector);
 }
 
 static const struct drm_connector_funcs ch7033_connector_funcs = {
@@ -233,7 +232,7 @@ static int ch7033_connector_get_modes(struct drm_connector *connector)
 	const struct drm_edid *drm_edid;
 	int ret;
 
-	drm_edid = drm_bridge_edid_read(priv->next_bridge, connector);
+	drm_edid = drm_bridge_edid_read(priv->bridge.next_bridge, connector);
 	drm_edid_connector_update(connector, drm_edid);
 	if (drm_edid) {
 		ret = drm_edid_connector_add_modes(connector);
@@ -275,7 +274,7 @@ static int ch7033_bridge_attach(struct drm_bridge *bridge,
 	struct drm_connector *connector = &priv->connector;
 	int ret;
 
-	ret = drm_bridge_attach(encoder, priv->next_bridge, bridge,
+	ret = drm_bridge_attach(encoder, priv->bridge.next_bridge, bridge,
 				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return ret;
@@ -283,15 +282,15 @@ static int ch7033_bridge_attach(struct drm_bridge *bridge,
 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
 		return 0;
 
-	if (priv->next_bridge->ops & DRM_BRIDGE_OP_DETECT) {
+	if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_DETECT) {
 		connector->polled = DRM_CONNECTOR_POLL_HPD;
 	} else {
 		connector->polled = DRM_CONNECTOR_POLL_CONNECT |
 				    DRM_CONNECTOR_POLL_DISCONNECT;
 	}
 
-	if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD) {
-		drm_bridge_hpd_enable(priv->next_bridge, ch7033_hpd_event,
+	if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_HPD) {
+		drm_bridge_hpd_enable(priv->bridge.next_bridge, ch7033_hpd_event,
 				      priv);
 	}
 
@@ -299,8 +298,8 @@ static int ch7033_bridge_attach(struct drm_bridge *bridge,
 				 &ch7033_connector_helper_funcs);
 	ret = drm_connector_init_with_ddc(bridge->dev, &priv->connector,
 					  &ch7033_connector_funcs,
-					  priv->next_bridge->type,
-					  priv->next_bridge->ddc);
+					  priv->bridge.next_bridge->type,
+					  priv->bridge.next_bridge->ddc);
 	if (ret) {
 		DRM_ERROR("Failed to initialize connector\n");
 		return ret;
@@ -313,8 +312,8 @@ static void ch7033_bridge_detach(struct drm_bridge *bridge)
 {
 	struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
 
-	if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD)
-		drm_bridge_hpd_disable(priv->next_bridge);
+	if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_HPD)
+		drm_bridge_hpd_disable(priv->bridge.next_bridge);
 	drm_connector_cleanup(&priv->connector);
 }
 
@@ -543,10 +542,9 @@ static int ch7033_probe(struct i2c_client *client)
 
 	dev_set_drvdata(dev, priv);
 
-	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL,
-					  &priv->next_bridge);
-	if (ret)
-		return ret;
+	priv->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node, 1, -1);
+	if (IS_ERR(priv->bridge.next_bridge))
+		return PTR_ERR(priv->bridge.next_bridge);
 
 	priv->regmap = devm_regmap_init_i2c(client, &ch7033_regmap_config);
 	if (IS_ERR(priv->regmap)) {

-- 
2.53.0



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

* [PATCH v3 06/11] drm/bridge: lontium-lt9611uxc: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (4 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 05/11] drm/bridge: chrontel-ch7033: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 07/11] drm/bridge: lt9611: " Luca Ceresoli
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index 11aab07d88df..9427cc2358ae 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -35,7 +35,6 @@
 struct lt9611uxc {
 	struct device *dev;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 
 	struct regmap *regmap;
 	/* Protects all accesses to registers by stopping the on-chip MCU */
@@ -284,7 +283,7 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
 {
 	struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
 
-	return drm_bridge_attach(encoder, lt9611uxc->next_bridge,
+	return drm_bridge_attach(encoder, lt9611uxc->bridge.next_bridge,
 				 bridge, flags);
 }
 
@@ -487,7 +486,11 @@ static int lt9611uxc_parse_dt(struct device *dev,
 
 	lt9611uxc->dsi1_node = of_graph_get_remote_node(dev->of_node, 1, -1);
 
-	return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, &lt9611uxc->next_bridge);
+	lt9611uxc->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node, 2, -1);
+	if (IS_ERR(lt9611uxc->bridge.next_bridge))
+		return PTR_ERR(lt9611uxc->bridge.next_bridge);
+
+	return 0;
 }
 
 static int lt9611uxc_gpio_init(struct lt9611uxc *lt9611uxc)

-- 
2.53.0



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

* [PATCH v3 07/11] drm/bridge: lt9611: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (5 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 06/11] drm/bridge: lontium-lt9611uxc: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 08/11] drm/bridge: adv7511: " Luca Ceresoli
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/lontium-lt9611.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c
index 4517aee83332..4b4418cc83bf 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611.c
@@ -37,7 +37,6 @@
 struct lt9611 {
 	struct device *dev;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 
 	struct regmap *regmap;
 
@@ -761,7 +760,7 @@ static int lt9611_bridge_attach(struct drm_bridge *bridge,
 {
 	struct lt9611 *lt9611 = bridge_to_lt9611(bridge);
 
-	return drm_bridge_attach(encoder, lt9611->next_bridge,
+	return drm_bridge_attach(encoder, lt9611->bridge.next_bridge,
 				 bridge, flags);
 }
 
@@ -1058,7 +1057,11 @@ static int lt9611_parse_dt(struct device *dev,
 
 	lt9611->ac_mode = of_property_read_bool(dev->of_node, "lt,ac-mode");
 
-	return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, &lt9611->next_bridge);
+	lt9611->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node, 2, -1);
+	if (IS_ERR(lt9611->bridge.next_bridge))
+		return PTR_ERR(lt9611->bridge.next_bridge);
+
+	return 0;
 }
 
 static int lt9611_gpio_init(struct lt9611 *lt9611)

-- 
2.53.0



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

* [PATCH v3 08/11] drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (6 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 07/11] drm/bridge: lt9611: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:41   ` Biju Das
  2026-04-28 20:33   ` Dmitry Baryshkov
  2026-04-28 15:30 ` [PATCH v3 09/11] drm/bridge: lt8713sx: " Luca Ceresoli
                   ` (2 subsequent siblings)
  10 siblings, 2 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

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

---

Changes in v3:
- fix ERR_PTR deref when -ENODEV is returned
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h     |  1 -
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 15 +++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 8be7266fd4f4..12c95198d9a4 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -354,7 +354,6 @@ struct adv7511 {
 	enum drm_connector_status status;
 	bool powered;
 
-	struct drm_bridge *next_bridge;
 	struct drm_display_mode curr_mode;
 
 	unsigned int f_tmds;
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 6bd76c1fb007..3c516551e482 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -851,8 +851,8 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge,
 	struct adv7511 *adv = bridge_to_adv7511(bridge);
 	int ret = 0;
 
-	if (adv->next_bridge) {
-		ret = drm_bridge_attach(encoder, adv->next_bridge, bridge,
+	if (adv->bridge.next_bridge) {
+		ret = drm_bridge_attach(encoder, adv->bridge.next_bridge, bridge,
 					flags | DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 		if (ret)
 			return ret;
@@ -1251,10 +1251,13 @@ static int adv7511_probe(struct i2c_client *i2c)
 
 	memset(&link_config, 0, sizeof(link_config));
 
-	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL,
-					  &adv7511->next_bridge);
-	if (ret && ret != -ENODEV)
-		return ret;
+	adv7511->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node, 1, -1);
+	if (IS_ERR(adv7511->bridge.next_bridge)) {
+		if (PTR_ERR(adv7511->bridge.next_bridge) == -ENODEV)
+			adv7511->bridge.next_bridge = NULL;
+		else
+			return PTR_ERR(adv7511->bridge.next_bridge);
+	}
 
 	if (adv7511->info->link_config)
 		ret = adv7511_parse_dt(dev->of_node, &link_config);

-- 
2.53.0



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

* [PATCH v3 09/11] drm/bridge: lt8713sx: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (7 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 08/11] drm/bridge: adv7511: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:30 ` [PATCH v3 10/11] drm: zynqmp_dp: " Luca Ceresoli
  2026-04-28 15:31 ` [PATCH v3 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge() Luca Ceresoli
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/bridge/lontium-lt8713sx.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt8713sx.c b/drivers/gpu/drm/bridge/lontium-lt8713sx.c
index 18fac6a46db4..cee485adf5e5 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8713sx.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8713sx.c
@@ -32,7 +32,6 @@ DECLARE_CRC8_TABLE(lt8713sx_crc_table);
 struct lt8713sx {
 	struct device *dev;
 	struct drm_bridge bridge;
-	struct drm_bridge *next_bridge;
 
 	struct regmap *regmap;
 	/* Protects all accesses to registers by stopping the on-chip MCU */
@@ -458,7 +457,7 @@ static int lt8713sx_bridge_attach(struct drm_bridge *bridge,
 	struct lt8713sx *lt8713sx = container_of(bridge, struct lt8713sx, bridge);
 
 	return drm_bridge_attach(encoder,
-				lt8713sx->next_bridge,
+				lt8713sx->bridge.next_bridge,
 				bridge, flags);
 }
 
@@ -537,10 +536,9 @@ static int lt8713sx_probe(struct i2c_client *client)
 	if (IS_ERR(lt8713sx->regmap))
 		return dev_err_probe(dev, PTR_ERR(lt8713sx->regmap), "regmap i2c init failed\n");
 
-	ret = drm_of_find_panel_or_bridge(lt8713sx->dev->of_node, 1, -1, NULL,
-					  &lt8713sx->next_bridge);
-	if (ret < 0)
-		return ret;
+	lt8713sx->bridge.next_bridge = of_drm_get_bridge_by_endpoint(lt8713sx->dev->of_node, 1, -1);
+	if (IS_ERR(lt8713sx->bridge.next_bridge))
+		return PTR_ERR(lt8713sx->bridge.next_bridge);
 
 	ret = lt8713sx_gpio_init(lt8713sx);
 	if (ret < 0)

-- 
2.53.0



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

* [PATCH v3 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (8 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 09/11] drm/bridge: lt8713sx: " Luca Ceresoli
@ 2026-04-28 15:30 ` Luca Ceresoli
  2026-04-28 15:37   ` Biju Das
  2026-04-28 15:31 ` [PATCH v3 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge() Luca Ceresoli
  10 siblings, 1 reply; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:30 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli

This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

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

---

Changes in v3:
- fix ERR_PTR deref when -ENODEV is returned
---
 drivers/gpu/drm/xlnx/zynqmp_dp.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 379180fb3004..c5aa236d6b74 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -353,7 +353,6 @@ struct zynqmp_dp_train_set_priv {
  * @lock: Mutex protecting this struct and register access (but not AUX)
  * @irq: irq
  * @bridge: DRM bridge for the DP encoder
- * @next_bridge: The downstream bridge
  * @test: Configuration for test mode
  * @config: IP core configuration from DTS
  * @aux: aux channel
@@ -385,7 +384,6 @@ struct zynqmp_dp {
 	struct completion aux_done;
 	struct mutex lock;
 
-	struct drm_bridge *next_bridge;
 	struct device *dev;
 	struct zynqmp_dpsub *dpsub;
 	void __iomem *iomem;
@@ -1494,8 +1492,8 @@ static int zynqmp_dp_bridge_attach(struct drm_bridge *bridge,
 		return ret;
 	}
 
-	if (dp->next_bridge) {
-		ret = drm_bridge_attach(encoder, dp->next_bridge,
+	if (dp->bridge.next_bridge) {
+		ret = drm_bridge_attach(encoder, dp->bridge.next_bridge,
 					bridge, flags);
 		if (ret < 0)
 			goto error;
@@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
 	 * Acquire the next bridge in the chain. Ignore errors caused by port@5
 	 * not being connected for backward-compatibility with older DTs.
 	 */
-	ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL,
-					  &dp->next_bridge);
-	if (ret < 0 && ret != -ENODEV)
-		goto err_reset;
+	dp->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, 5, 0);
+	if (IS_ERR(dp->bridge.next_bridge)) {
+		if (PTR_ERR(dp->bridge.next_bridge) == -ENODEV) {
+			dp->bridge.next_bridge;
+		} else {
+			ret = PTR_ERR(dp->bridge.next_bridge);
+			goto err_reset;
+		}
+	}
 
 	/* Initialize the hardware. */
 	dp->config.misc0 &= ~ZYNQMP_DP_MAIN_STREAM_MISC0_SYNC_LOCK;

-- 
2.53.0



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

* [PATCH v3 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge()
  2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
                   ` (9 preceding siblings ...)
  2026-04-28 15:30 ` [PATCH v3 10/11] drm: zynqmp_dp: " Luca Ceresoli
@ 2026-04-28 15:31 ` Luca Ceresoli
  10 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 15:31 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
	linux-arm-msm, freedreno, linux-arm-kernel, Luca Ceresoli,
	Dmitry Baryshkov

Up to now drm_of_find_panel_or_bridge() can be called with a bridge pointer
only, a panel pointer only, or both a bridge and a panel pointers. The
logic to handle all the three cases is somewhat complex to read however.

Now all bridge-only callers have been converted to
of_drm_get_bridge_by_endpoint(), which is simpler and handles bridge
refcounting. So forbid new bridge-only users by mandating a non-NULL panel
pointer in the docs and in the sanity checks along with a warning.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 drivers/gpu/drm/drm_of.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index ef6b09316963..d03ada82eac9 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -225,15 +225,15 @@ EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
  * @np: device tree node containing encoder output ports
  * @port: port in the device tree node
  * @endpoint: endpoint in the device tree node
- * @panel: pointer to hold returned drm_panel
+ * @panel: pointer to hold returned drm_panel, must not be NULL
  * @bridge: pointer to hold returned drm_bridge
  *
  * Given a DT node's port and endpoint number, find the connected node and
- * return either the associated struct drm_panel or drm_bridge device. Either
- * @panel or @bridge must not be NULL.
+ * return either the associated struct drm_panel or drm_bridge device.
  *
  * This function is deprecated and should not be used in new drivers. Use
- * devm_drm_of_get_bridge() instead.
+ * of_drm_get_bridge_by_endpoint() instead when not looking for a panel, or
+ * devm_drm_of_get_bridge() otherwise.
  *
  * Returns zero if successful, or one of the standard error codes if it fails.
  */
@@ -245,10 +245,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
 	int ret = -EPROBE_DEFER;
 	struct device_node *remote;
 
-	if (!panel && !bridge)
+	if (WARN_ON(!panel))
 		return -EINVAL;
-	if (panel)
-		*panel = NULL;
+
+	*panel = NULL;
 
 	/*
 	 * of_graph_get_remote_node() produces a noisy error message if port
@@ -263,13 +263,11 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
 	if (!remote)
 		return -ENODEV;
 
-	if (panel) {
-		*panel = of_drm_find_panel(remote);
-		if (!IS_ERR(*panel))
-			ret = 0;
-		else
-			*panel = NULL;
-	}
+	*panel = of_drm_find_panel(remote);
+	if (!IS_ERR(*panel))
+		ret = 0;
+	else
+		*panel = NULL;
 
 	if (bridge) {
 		if (ret) {

-- 
2.53.0



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

* RE: [PATCH v3 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 ` [PATCH v3 10/11] drm: zynqmp_dp: " Luca Ceresoli
@ 2026-04-28 15:37   ` Biju Das
  2026-04-28 16:53     ` Luca Ceresoli
  0 siblings, 1 reply; 17+ messages in thread
From: Biju Das @ 2026-04-28 15:37 UTC (permalink / raw)
  To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
	laurent.pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, Xinliang Liu,
	Sumit Semwal, Yongqin Liu, John Stultz, tomi.valkeinen,
	Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org

Hi Luca,

> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Luca Ceresoli
> Sent: 28 April 2026 16:31
> Subject: [PATCH v3 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
> 
> This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using
> a reduced feature set of that function.
> Replace this call with the simpler of_drm_get_bridge_by_endpoint().
> 
> Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put
> on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the
> bridge::next_bridge pointer which is automatically put when the bridge is eventually freed.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> ---
> 
> Changes in v3:
> - fix ERR_PTR deref when -ENODEV is returned
> ---
>  drivers/gpu/drm/xlnx/zynqmp_dp.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> index 379180fb3004..c5aa236d6b74 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> @@ -353,7 +353,6 @@ struct zynqmp_dp_train_set_priv {
>   * @lock: Mutex protecting this struct and register access (but not AUX)
>   * @irq: irq
>   * @bridge: DRM bridge for the DP encoder
> - * @next_bridge: The downstream bridge
>   * @test: Configuration for test mode
>   * @config: IP core configuration from DTS
>   * @aux: aux channel
> @@ -385,7 +384,6 @@ struct zynqmp_dp {
>  	struct completion aux_done;
>  	struct mutex lock;
> 
> -	struct drm_bridge *next_bridge;
>  	struct device *dev;
>  	struct zynqmp_dpsub *dpsub;
>  	void __iomem *iomem;
> @@ -1494,8 +1492,8 @@ static int zynqmp_dp_bridge_attach(struct drm_bridge *bridge,
>  		return ret;
>  	}
> 
> -	if (dp->next_bridge) {
> -		ret = drm_bridge_attach(encoder, dp->next_bridge,
> +	if (dp->bridge.next_bridge) {
> +		ret = drm_bridge_attach(encoder, dp->bridge.next_bridge,
>  					bridge, flags);
>  		if (ret < 0)
>  			goto error;
> @@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
>  	 * Acquire the next bridge in the chain. Ignore errors caused by port@5
>  	 * not being connected for backward-compatibility with older DTs.
>  	 */
> -	ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL,
> -					  &dp->next_bridge);
> -	if (ret < 0 && ret != -ENODEV)
> -		goto err_reset;
> +	dp->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, 5, 0);
> +	if (IS_ERR(dp->bridge.next_bridge)) {
> +		if (PTR_ERR(dp->bridge.next_bridge) == -ENODEV) {
> +			dp->bridge.next_bridge;


A warning on this patch

drivers/gpu/drm/xlnx/zynqmp_dp.c: In function ‘zynqmp_dp_probe’:
drivers/gpu/drm/xlnx/zynqmp_dp.c:2465:35: warning: statement with no effect [-Wunused-value]
 2465 |                         dp->bridge.next_bridge;
      |                         ~~~~~~~~~~^~~~~~~~~~~~

Cheers,
Biju

> +		} else {
> +			ret = PTR_ERR(dp->bridge.next_bridge);
> +			goto err_reset;
> +		}
> +	}
> 
>  	/* Initialize the hardware. */
>  	dp->config.misc0 &= ~ZYNQMP_DP_MAIN_STREAM_MISC0_SYNC_LOCK;
> 
> --
> 2.53.0


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

* RE: [PATCH v3 08/11] drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 ` [PATCH v3 08/11] drm/bridge: adv7511: " Luca Ceresoli
@ 2026-04-28 15:41   ` Biju Das
  2026-04-28 20:33   ` Dmitry Baryshkov
  1 sibling, 0 replies; 17+ messages in thread
From: Biju Das @ 2026-04-28 15:41 UTC (permalink / raw)
  To: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
	laurent.pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, Xinliang Liu,
	Sumit Semwal, Yongqin Liu, John Stultz, tomi.valkeinen,
	Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org

Hi Luca,

Thanks for the patch.

> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Luca Ceresoli
> Sent: 28 April 2026 16:31
> Subject: [PATCH v3 08/11] drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint()
> 
> This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using
> a reduced feature set of that function.
> Replace this call with the simpler of_drm_get_bridge_by_endpoint().
> 
> Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put
> on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the
> bridge::next_bridge pointer which is automatically put when the bridge is eventually freed.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

Tested on RZ/G3L SMARC EVK connected to ADV7535.

Tested-by: Biju Das <biju.das.jz@bp.renesas.com>

Cheers,
Biju

> 
> ---
> 
> Changes in v3:
> - fix ERR_PTR deref when -ENODEV is returned
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511.h     |  1 -
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 15 +++++++++------
>  2 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h
> index 8be7266fd4f4..12c95198d9a4 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
> @@ -354,7 +354,6 @@ struct adv7511 {
>  	enum drm_connector_status status;
>  	bool powered;
> 
> -	struct drm_bridge *next_bridge;
>  	struct drm_display_mode curr_mode;
> 
>  	unsigned int f_tmds;
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index 6bd76c1fb007..3c516551e482 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -851,8 +851,8 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge,
>  	struct adv7511 *adv = bridge_to_adv7511(bridge);
>  	int ret = 0;
> 
> -	if (adv->next_bridge) {
> -		ret = drm_bridge_attach(encoder, adv->next_bridge, bridge,
> +	if (adv->bridge.next_bridge) {
> +		ret = drm_bridge_attach(encoder, adv->bridge.next_bridge, bridge,
>  					flags | DRM_BRIDGE_ATTACH_NO_CONNECTOR);
>  		if (ret)
>  			return ret;
> @@ -1251,10 +1251,13 @@ static int adv7511_probe(struct i2c_client *i2c)
> 
>  	memset(&link_config, 0, sizeof(link_config));
> 
> -	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL,
> -					  &adv7511->next_bridge);
> -	if (ret && ret != -ENODEV)
> -		return ret;
> +	adv7511->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dev->of_node, 1, -1);
> +	if (IS_ERR(adv7511->bridge.next_bridge)) {
> +		if (PTR_ERR(adv7511->bridge.next_bridge) == -ENODEV)
> +			adv7511->bridge.next_bridge = NULL;
> +		else
> +			return PTR_ERR(adv7511->bridge.next_bridge);
> +	}
> 
>  	if (adv7511->info->link_config)
>  		ret = adv7511_parse_dt(dev->of_node, &link_config);
> 
> --
> 2.53.0


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

* Re: [PATCH v3 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:37   ` Biju Das
@ 2026-04-28 16:53     ` Luca Ceresoli
  0 siblings, 0 replies; 17+ messages in thread
From: Luca Ceresoli @ 2026-04-28 16:53 UTC (permalink / raw)
  To: Biju Das, Andrzej Hajda, Neil Armstrong, Robert Foss,
	laurent.pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, Xinliang Liu,
	Sumit Semwal, Yongqin Liu, John Stultz, tomi.valkeinen,
	Michal Simek
  Cc: Hui Pu, Ian Ray, Thomas Petazzoni,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org

On Tue Apr 28, 2026 at 5:37 PM CEST, Biju Das wrote:
>> @@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
>>  	 * Acquire the next bridge in the chain. Ignore errors caused by port@5
>>  	 * not being connected for backward-compatibility with older DTs.
>>  	 */
>> -	ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL,
>> -					  &dp->next_bridge);
>> -	if (ret < 0 && ret != -ENODEV)
>> -		goto err_reset;
>> +	dp->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, 5, 0);
>> +	if (IS_ERR(dp->bridge.next_bridge)) {
>> +		if (PTR_ERR(dp->bridge.next_bridge) == -ENODEV) {
>> +			dp->bridge.next_bridge;
>
>
> A warning on this patch
>
> drivers/gpu/drm/xlnx/zynqmp_dp.c: In function ‘zynqmp_dp_probe’:
> drivers/gpu/drm/xlnx/zynqmp_dp.c:2465:35: warning: statement with no effect [-Wunused-value]
>  2465 |                         dp->bridge.next_bridge;
>       |                         ~~~~~~~~~~^~~~~~~~~~~~

Ouch. Guess I should have pondered a bit longer before sending, will do
before v4...

Luca

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


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

* Re: [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 ` [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint() Luca Ceresoli
@ 2026-04-28 20:32   ` Dmitry Baryshkov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Baryshkov @ 2026-04-28 20:32 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek, Hui Pu, Ian Ray,
	Thomas Petazzoni, dri-devel, linux-kernel, linux-arm-msm,
	freedreno, linux-arm-kernel

On Tue, Apr 28, 2026 at 05:30:52PM +0200, Luca Ceresoli wrote:
> This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
> @panel parameter, thus using a reduced feature set of that function.
> Replace this call with the simpler of_drm_get_bridge_by_endpoint().
> 
> Since of_drm_get_bridge_by_endpoint() increases the refcount of the
> returned bridge, ensure it is put on removal.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> ---
> 

Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry


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

* Re: [PATCH v3 08/11] drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint()
  2026-04-28 15:30 ` [PATCH v3 08/11] drm/bridge: adv7511: " Luca Ceresoli
  2026-04-28 15:41   ` Biju Das
@ 2026-04-28 20:33   ` Dmitry Baryshkov
  1 sibling, 0 replies; 17+ messages in thread
From: Dmitry Baryshkov @ 2026-04-28 20:33 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, Rob Clark,
	Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, Xinliang Liu, Sumit Semwal, Yongqin Liu,
	John Stultz, Tomi Valkeinen, Michal Simek, Hui Pu, Ian Ray,
	Thomas Petazzoni, dri-devel, linux-kernel, linux-arm-msm,
	freedreno, linux-arm-kernel

On Tue, Apr 28, 2026 at 05:30:57PM +0200, Luca Ceresoli wrote:
> This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
> @panel parameter, thus using a reduced feature set of that function.
> Replace this call with the simpler of_drm_get_bridge_by_endpoint().
> 
> Since of_drm_get_bridge_by_endpoint() increases the refcount of the
> returned bridge, ensure it is put on removal. To achieve this, instead of
> adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
> pointer which is automatically put when the bridge is eventually freed.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> ---
> 
> Changes in v3:
> - fix ERR_PTR deref when -ENODEV is returned

Biju, thanks for pointing this out!


Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>



-- 
With best wishes
Dmitry


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

end of thread, other threads:[~2026-04-28 20:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 15:30 [PATCH v3 00/11] drm/bridge: handle refcounting for bridge-only callers of drm_of_find_panel_or_bridge() Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 01/11] drm/bridge: drm_bridge_get/put(): ignore ERR_PTR Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 02/11] drm/bridge: add of_drm_get_bridge_by_endpoint() Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint() Luca Ceresoli
2026-04-28 20:32   ` Dmitry Baryshkov
2026-04-28 15:30 ` [PATCH v3 04/11] drm/hisilicon/kirin: " Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 05/11] drm/bridge: chrontel-ch7033: " Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 06/11] drm/bridge: lontium-lt9611uxc: " Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 07/11] drm/bridge: lt9611: " Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 08/11] drm/bridge: adv7511: " Luca Ceresoli
2026-04-28 15:41   ` Biju Das
2026-04-28 20:33   ` Dmitry Baryshkov
2026-04-28 15:30 ` [PATCH v3 09/11] drm/bridge: lt8713sx: " Luca Ceresoli
2026-04-28 15:30 ` [PATCH v3 10/11] drm: zynqmp_dp: " Luca Ceresoli
2026-04-28 15:37   ` Biju Das
2026-04-28 16:53     ` Luca Ceresoli
2026-04-28 15:31 ` [PATCH v3 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_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