* [PATCH 01/26] drm/bridge: add drm_of_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 14:22 ` Louis Chauvet
2025-11-24 10:15 ` Maxime Ripard
2025-11-19 13:05 ` [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
` (24 subsequent siblings)
25 siblings, 2 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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. Also, "of_drm_find_bridge is
oddly named according to our convention and it would make more sense to be
called drm_of_find_bridge()" (quoted from Link: below).
Solve both issues by creating a new drm_of_find_bridge() that is identical
to of_drm_find_bridge() except 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>
---
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 drm_of_find_bridge()
---
drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++++
include/drm/drm_bridge.h | 5 +++++
2 files changed, 34 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 8f355df883d8..d98a7b4a83c0 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1417,6 +1417,35 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge,
EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
#ifdef CONFIG_OF
+/**
+ * drm_of_find_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 *drm_of_find_bridge(struct device_node *np)
+{
+ struct drm_bridge *bridge;
+
+ mutex_lock(&bridge_lock);
+
+ list_for_each_entry(bridge, &bridge_list, list) {
+ if (bridge->of_node == np) {
+ mutex_unlock(&bridge_lock);
+ return drm_bridge_get(bridge);
+ }
+ }
+
+ mutex_unlock(&bridge_lock);
+ return NULL;
+}
+EXPORT_SYMBOL(drm_of_find_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 0ff7ab4aa868..e74e91004c48 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1313,8 +1313,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 *drm_of_find_bridge(struct device_node *np);
struct drm_bridge *of_drm_find_bridge(struct device_node *np);
#else
+static inline struct drm_bridge *drm_of_find_bridge(struct device_node *np)
+{
+ return NULL;
+}
static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
{
return NULL;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 01/26] drm/bridge: add drm_of_find_bridge()
2025-11-19 13:05 ` [PATCH 01/26] drm/bridge: add drm_of_find_bridge() Luca Ceresoli
@ 2025-11-19 14:22 ` Louis Chauvet
2025-11-19 14:29 ` Luca Ceresoli
2025-11-24 10:15 ` Maxime Ripard
1 sibling, 1 reply; 43+ messages in thread
From: Louis Chauvet @ 2025-11-19 14:22 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, Jonathan Corbet, Alexey Brodkin, Phong LE,
Liu Ying, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
On 11/19/25 13:05, 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. Also, "of_drm_find_bridge is
> oddly named according to our convention and it would make more sense to be
> called drm_of_find_bridge()" (quoted from Link: below).
>
> Solve both issues by creating a new drm_of_find_bridge() that is identical
> to of_drm_find_bridge() except 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>
>
> ---
>
> 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 drm_of_find_bridge()
> ---
> drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++++
> include/drm/drm_bridge.h | 5 +++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 8f355df883d8..d98a7b4a83c0 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -1417,6 +1417,35 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge,
> EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
>
> #ifdef CONFIG_OF
> +/**
> + * drm_of_find_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 *drm_of_find_bridge(struct device_node *np)
> +{
> + struct drm_bridge *bridge;
> +
> + mutex_lock(&bridge_lock);
> +
> + list_for_each_entry(bridge, &bridge_list, list) {
> + if (bridge->of_node == np) {
> + mutex_unlock(&bridge_lock);
It seems a bit strange to unlock the mutex just before the
drm_bridge_get, is it expected?
If no, I think you can use scoped_guard(mutex, &bridge_lock) to avoid
messing with mutex_unlock, IIRC, scoped_guard will unlock the mutex just
after the return, so in your case, just after the drm_bridge_get.
> + return drm_bridge_get(bridge);
> + }
> + }
> +
> + mutex_unlock(&bridge_lock);
> + return NULL;
> +}
> +EXPORT_SYMBOL(drm_of_find_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 0ff7ab4aa868..e74e91004c48 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -1313,8 +1313,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 *drm_of_find_bridge(struct device_node *np);
> struct drm_bridge *of_drm_find_bridge(struct device_node *np);
> #else
> +static inline struct drm_bridge *drm_of_find_bridge(struct device_node *np)
> +{
> + return NULL;
> +}
> static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
> {
> return NULL;
>
^ permalink raw reply [flat|nested] 43+ messages in thread* Re: [PATCH 01/26] drm/bridge: add drm_of_find_bridge()
2025-11-19 14:22 ` Louis Chauvet
@ 2025-11-19 14:29 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 14:29 UTC (permalink / raw)
To: Louis Chauvet, 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, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
Hi Louis,
On Wed Nov 19, 2025 at 3:22 PM CET, Louis Chauvet wrote:
>
>
> On 11/19/25 13:05, 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. Also, "of_drm_find_bridge is
>> oddly named according to our convention and it would make more sense to be
>> called drm_of_find_bridge()" (quoted from Link: below).
>>
>> Solve both issues by creating a new drm_of_find_bridge() that is identical
>> to of_drm_find_bridge() except 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>
...
>> +struct drm_bridge *drm_of_find_bridge(struct device_node *np)
>> +{
>> + struct drm_bridge *bridge;
>> +
>> + mutex_lock(&bridge_lock);
>> +
>> + list_for_each_entry(bridge, &bridge_list, list) {
>> + if (bridge->of_node == np) {
>> + mutex_unlock(&bridge_lock);
>
> It seems a bit strange to unlock the mutex just before the
> drm_bridge_get, is it expected?
Ouch. No, it's not expected, it is a very silly mistake. Thanks for
noticing.
> If no, I think you can use scoped_guard(mutex, &bridge_lock) to avoid
> messing with mutex_unlock, IIRC, scoped_guard will unlock the mutex just
> after the return, so in your case, just after the drm_bridge_get.
>
>> + return drm_bridge_get(bridge);
>> + }
>> + }
My intent was to keep the function as similar as possible to the original
one, thus I just added a drm_bridge_get(), but that is of course wrong.
So these lines should instead have been:
if (bridge->of_node == np) {
drm_bridge_get(bridge);
mutex_unlock(&bridge_lock);
return bridge;
}
But indeed scoped_guard() is much cleaner and less error-prone, so I'm
probably going to use it in v2.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/26] drm/bridge: add drm_of_find_bridge()
2025-11-19 13:05 ` [PATCH 01/26] drm/bridge: add drm_of_find_bridge() Luca Ceresoli
2025-11-19 14:22 ` Louis Chauvet
@ 2025-11-24 10:15 ` Maxime Ripard
2025-11-24 16:03 ` Luca Ceresoli
1 sibling, 1 reply; 43+ messages in thread
From: Maxime Ripard @ 2025-11-24 10:15 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 869 bytes --]
Hi,
On Wed, Nov 19, 2025 at 02:05:32PM +0100, Luca Ceresoli wrote:
> #ifdef CONFIG_OF
> +/**
> + * drm_of_find_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 *drm_of_find_bridge(struct device_node *np)
So the convention we've mostly had was that the first argument would
define the prefix, ie. if we pass a drm_* pointer, the prefix is drm, if
we pass a device_node pointer, then the prefix is of.
Considering that convention, of_drm_find_bridge would be the ideal
candidate, but we can't use that obviously. What about
of_drm_find_and_get_bridge, or of_drm_get_bridge?
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/26] drm/bridge: add drm_of_find_bridge()
2025-11-24 10:15 ` Maxime Ripard
@ 2025-11-24 16:03 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-24 16:03 UTC (permalink / raw)
To: Maxime Ripard
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
Hello Maxime,
On Mon Nov 24, 2025 at 11:15 AM CET, Maxime Ripard wrote:
> Hi,
>
> On Wed, Nov 19, 2025 at 02:05:32PM +0100, Luca Ceresoli wrote:
>> #ifdef CONFIG_OF
>> +/**
>> + * drm_of_find_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 *drm_of_find_bridge(struct device_node *np)
>
> So the convention we've mostly had was that the first argument would
> define the prefix, ie. if we pass a drm_* pointer, the prefix is drm, if
> we pass a device_node pointer, then the prefix is of.
>
> Considering that convention, of_drm_find_bridge would be the ideal
> candidate, but we can't use that obviously. What about
> of_drm_find_and_get_bridge, or of_drm_get_bridge?
Ah, it sounded the other way around during the old discussion [0]. :-) But
no problem in using a different name of course. of_drm_get_bridge() looks
like the best to me, so I'll rename that way in v2.
[0] https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
2025-11-19 13:05 ` [PATCH 01/26] drm/bridge: add drm_of_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 14:28 ` Louis Chauvet
2025-11-19 13:05 ` [PATCH 03/26] drm/todo: add entry about converting to drm_of_find_bridge() Luca Ceresoli
` (23 subsequent siblings)
25 siblings, 1 reply; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, Luca Ceresoli
of_drm_find_bridge() does not increment the returned bridge
refcount. drm_of_find_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/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_bridge.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index d98a7b4a83c0..6debbf20aaa8 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -299,7 +299,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 drm_of_find_bridge().
*
* The bridge to be added must have been allocated by
* devm_drm_bridge_alloc().
@@ -360,7 +360,7 @@ 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
+ * it won't be found by users via drm_of_find_bridge(), and add it to the
* lingering bridge list, to keep track of it until its allocated memory is
* eventually freed.
*/
@@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
*
* @np: device node
*
+ * This function is deprecated. Use drm_of_find_bridge() instead for proper
+ * refcounting.
+ *
* RETURNS:
* drm_bridge control struct on success, NULL on failure
*/
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
2025-11-19 13:05 ` [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
@ 2025-11-19 14:28 ` Louis Chauvet
2025-11-19 15:13 ` Luca Ceresoli
2025-11-24 10:18 ` Maxime Ripard
0 siblings, 2 replies; 43+ messages in thread
From: Louis Chauvet @ 2025-11-19 14:28 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, Jonathan Corbet, Alexey Brodkin, Phong LE,
Liu Ying, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
On 11/19/25 13:05, Luca Ceresoli wrote:
> of_drm_find_bridge() does not increment the returned bridge
> refcount. drm_of_find_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/
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/drm_bridge.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index d98a7b4a83c0..6debbf20aaa8 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -299,7 +299,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 drm_of_find_bridge().
> *
> * The bridge to be added must have been allocated by
> * devm_drm_bridge_alloc().
> @@ -360,7 +360,7 @@ 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
> + * it won't be found by users via drm_of_find_bridge(), and add it to the
> * lingering bridge list, to keep track of it until its allocated memory is
> * eventually freed.
> */
> @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
> *
> * @np: device node
> *
> + * This function is deprecated. Use drm_of_find_bridge() instead for proper
> + * refcounting.
> + *
I think it should be more explicit that the refcounting is not done by
this function, like:
This function is deprecated. The returned bridge is not refcounted, you
should not use drm_bridge_put(). Use drm_of_find_bridge() instead for
proper refcounting.
> * RETURNS:
> * drm_bridge control struct on success, NULL on failure
> */
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
2025-11-19 14:28 ` Louis Chauvet
@ 2025-11-19 15:13 ` Luca Ceresoli
2025-11-24 10:18 ` Maxime Ripard
1 sibling, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 15:13 UTC (permalink / raw)
To: Louis Chauvet, 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, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
On Wed Nov 19, 2025 at 3:28 PM CET, Louis Chauvet wrote:
>
>
> On 11/19/25 13:05, Luca Ceresoli wrote:
>> of_drm_find_bridge() does not increment the returned bridge
>> refcount. drm_of_find_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/
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
...
>> @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
>> *
>> * @np: device node
>> *
>> + * This function is deprecated. Use drm_of_find_bridge() instead for proper
>> + * refcounting.
>> + *
>
> I think it should be more explicit that the refcounting is not done by
> this function, like:
>
> This function is deprecated. The returned bridge is not refcounted, you
> should not use drm_bridge_put(). Use drm_of_find_bridge() instead for
> proper refcounting.
OK.
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
2025-11-19 14:28 ` Louis Chauvet
2025-11-19 15:13 ` Luca Ceresoli
@ 2025-11-24 10:18 ` Maxime Ripard
2025-11-24 16:23 ` Luca Ceresoli
1 sibling, 1 reply; 43+ messages in thread
From: Maxime Ripard @ 2025-11-24 10:18 UTC (permalink / raw)
To: Louis Chauvet
Cc: Luca Ceresoli, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Jonathan Corbet, Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Adrien Grassein, Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 2324 bytes --]
On Wed, Nov 19, 2025 at 02:28:41PM +0000, Louis Chauvet wrote:
> On 11/19/25 13:05, Luca Ceresoli wrote:
> > of_drm_find_bridge() does not increment the returned bridge
> > refcount. drm_of_find_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/
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > ---
> > drivers/gpu/drm/drm_bridge.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> > index d98a7b4a83c0..6debbf20aaa8 100644
> > --- a/drivers/gpu/drm/drm_bridge.c
> > +++ b/drivers/gpu/drm/drm_bridge.c
> > @@ -299,7 +299,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 drm_of_find_bridge().
> > *
> > * The bridge to be added must have been allocated by
> > * devm_drm_bridge_alloc().
> > @@ -360,7 +360,7 @@ 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
> > + * it won't be found by users via drm_of_find_bridge(), and add it to the
> > * lingering bridge list, to keep track of it until its allocated memory is
> > * eventually freed.
> > */
> > @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
> > *
> > * @np: device node
> > *
> > + * This function is deprecated. Use drm_of_find_bridge() instead for proper
> > + * refcounting.
> > + *
>
> I think it should be more explicit that the refcounting is not done by this
> function, like:
>
> This function is deprecated. The returned bridge is not refcounted, you
> should not use drm_bridge_put(). Use drm_of_find_bridge() instead for proper
> refcounting.
I'd rather say that the callers must take care of the refcounting by
themselves but that it's racy, or at least that it *must* not use
drm_bridge_put().
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
2025-11-24 10:18 ` Maxime Ripard
@ 2025-11-24 16:23 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-24 16:23 UTC (permalink / raw)
To: Maxime Ripard, Louis Chauvet
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
Hi Maxime,
On Mon Nov 24, 2025 at 11:18 AM CET, Maxime Ripard wrote:
> On Wed, Nov 19, 2025 at 02:28:41PM +0000, Louis Chauvet wrote:
>> On 11/19/25 13:05, Luca Ceresoli wrote:
>> > of_drm_find_bridge() does not increment the returned bridge
>> > refcount. drm_of_find_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/
>> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>> > ---
>> > drivers/gpu/drm/drm_bridge.c | 7 +++++--
>> > 1 file changed, 5 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> > index d98a7b4a83c0..6debbf20aaa8 100644
>> > --- a/drivers/gpu/drm/drm_bridge.c
>> > +++ b/drivers/gpu/drm/drm_bridge.c
>> > @@ -299,7 +299,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 drm_of_find_bridge().
>> > *
>> > * The bridge to be added must have been allocated by
>> > * devm_drm_bridge_alloc().
>> > @@ -360,7 +360,7 @@ 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
>> > + * it won't be found by users via drm_of_find_bridge(), and add it to the
>> > * lingering bridge list, to keep track of it until its allocated memory is
>> > * eventually freed.
>> > */
>> > @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
>> > *
>> > * @np: device node
>> > *
>> > + * This function is deprecated. Use drm_of_find_bridge() instead for proper
>> > + * refcounting.
>> > + *
>>
>> I think it should be more explicit that the refcounting is not done by this
>> function, like:
>>
>> This function is deprecated. The returned bridge is not refcounted, you
>> should not use drm_bridge_put(). Use drm_of_find_bridge() instead for proper
>> refcounting.
>
> I'd rather say that the callers must take care of the refcounting by
> themselves but that it's racy, or at least that it *must* not use
> drm_bridge_put().
I was rather leaning towards "Deprecated. Convert to drm_of_get_bridge().".
But if we want to still support existing (lazy) users, with yours and
Louis' comments taken into account, what about:
* This function is deprecated. Convert to of_drm_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_get_bridge(), which is the only safe thing
* to do
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 03/26] drm/todo: add entry about converting to drm_of_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
2025-11-19 13:05 ` [PATCH 01/26] drm/bridge: add drm_of_find_bridge() Luca Ceresoli
2025-11-19 13:05 ` [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-24 10:21 ` Maxime Ripard
2025-11-19 13:05 ` [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge() Luca Ceresoli
` (22 subsequent siblings)
25 siblings, 1 reply; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Documentation/gpu/todo.rst | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 9013ced318cb..1a4a11dee036 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 drm_of_find_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 drm_of_find_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.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 03/26] drm/todo: add entry about converting to drm_of_find_bridge()
2025-11-19 13:05 ` [PATCH 03/26] drm/todo: add entry about converting to drm_of_find_bridge() Luca Ceresoli
@ 2025-11-24 10:21 ` Maxime Ripard
0 siblings, 0 replies; 43+ messages in thread
From: Maxime Ripard @ 2025-11-24 10:21 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]
On Wed, Nov 19, 2025 at 02:05:34PM +0100, Luca Ceresoli wrote:
> 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/
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> Documentation/gpu/todo.rst | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 9013ced318cb..1a4a11dee036 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 drm_of_find_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 drm_of_find_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
> +
My understanding is that there's no users left after this series, so do
we really need a todo?
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (2 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 03/26] drm/todo: add entry about converting to drm_of_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-24 10:22 ` Maxime Ripard
2025-11-19 13:05 ` [PATCH 05/26] drm/arcpgu: convert to drm_of_find_bridge() Luca Ceresoli
` (21 subsequent siblings)
25 siblings, 1 reply; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, Luca Ceresoli
of_drm_find_bridge() is identical to drm_of_find_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>
---
drivers/gpu/drm/drm_bridge.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 6debbf20aaa8..09ad825f9cb8 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1460,19 +1460,11 @@ EXPORT_SYMBOL(drm_of_find_bridge);
*/
struct drm_bridge *of_drm_find_bridge(struct device_node *np)
{
- struct drm_bridge *bridge;
-
- mutex_lock(&bridge_lock);
+ struct drm_bridge *bridge = drm_of_find_bridge(np);
- list_for_each_entry(bridge, &bridge_list, list) {
- if (bridge->of_node == np) {
- mutex_unlock(&bridge_lock);
- return bridge;
- }
- }
+ drm_bridge_put(bridge);
- mutex_unlock(&bridge_lock);
- return NULL;
+ return bridge;
}
EXPORT_SYMBOL(of_drm_find_bridge);
#endif
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge()
2025-11-19 13:05 ` [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge() Luca Ceresoli
@ 2025-11-24 10:22 ` Maxime Ripard
2025-11-24 16:44 ` Luca Ceresoli
0 siblings, 1 reply; 43+ messages in thread
From: Maxime Ripard @ 2025-11-24 10:22 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]
Hi,
On Wed, Nov 19, 2025 at 02:05:35PM +0100, Luca Ceresoli wrote:
> of_drm_find_bridge() is identical to drm_of_find_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>
Kind of the same comment than on the TODO. Is it worth doing that patch
when we could just remove it at the end of the series?
> ---
> drivers/gpu/drm/drm_bridge.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 6debbf20aaa8..09ad825f9cb8 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -1460,19 +1460,11 @@ EXPORT_SYMBOL(drm_of_find_bridge);
> */
> struct drm_bridge *of_drm_find_bridge(struct device_node *np)
> {
> - struct drm_bridge *bridge;
> -
> - mutex_lock(&bridge_lock);
> + struct drm_bridge *bridge = drm_of_find_bridge(np);
>
> - list_for_each_entry(bridge, &bridge_list, list) {
> - if (bridge->of_node == np) {
> - mutex_unlock(&bridge_lock);
> - return bridge;
> - }
> - }
> + drm_bridge_put(bridge);
And if it does make sense to keep that patch, we should add a comment
here to document why we are doing this.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread* Re: [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge()
2025-11-24 10:22 ` Maxime Ripard
@ 2025-11-24 16:44 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-24 16:44 UTC (permalink / raw)
To: Maxime Ripard
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc, Anusha Srivatsa
Hi,
+Cc Anusha
On Mon Nov 24, 2025 at 11:22 AM CET, Maxime Ripard wrote:
> Hi,
>
> On Wed, Nov 19, 2025 at 02:05:35PM +0100, Luca Ceresoli wrote:
>> of_drm_find_bridge() is identical to drm_of_find_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>
>
> Kind of the same comment than on the TODO. Is it worth doing that patch
> when we could just remove it at the end of the series?
This series is not converting all users I'm afraid.
There are still some drivers to convert, but not a big deal.
The main user to be converted is drm_of_find_panel_or_bridge(), which is
very tricky, and in turn it is used by devm_drm_of_get_bridge(). We
discussed this in the past and the conclusion was a rework of the drm_panel
lifetime was needed to be able to properly replace
drm_of_find_panel_or_bridge().
A drm_panel rework had started very well with devm_drm_panel_alloc() that
got upstreamed by Anusha, but I'm not sure if it has made further progress
after that. So AFAICT the plan is still "People will gradually switch to
the new API over time", and the deprecated of_drm_find_bridge() will be
removed after that.
Does it still make sense to you?
Maxime, Anusha, are you aware of any steps forward about dynamic panel
lifetime, after devm_drm_panel_alloc()?
>> @@ -1460,19 +1460,11 @@ EXPORT_SYMBOL(drm_of_find_bridge);
>> */
>> struct drm_bridge *of_drm_find_bridge(struct device_node *np)
>> {
>> - struct drm_bridge *bridge;
>> -
>> - mutex_lock(&bridge_lock);
>> + struct drm_bridge *bridge = drm_of_find_bridge(np);
>>
>> - list_for_each_entry(bridge, &bridge_list, list) {
>> - if (bridge->of_node == np) {
>> - mutex_unlock(&bridge_lock);
>> - return bridge;
>> - }
>> - }
>> + drm_bridge_put(bridge);
>
> And if it does make sense to keep that patch, we should add a comment
> here to document why we are doing this.
OK, what about:
/**
* We need to emulate the original semantice of of_drm_find_bridge(), which
* was not getting any bridge reference. Being now based on
* drm_of_find_bridge() which gets a reference, put it before returning.
*/
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 05/26] drm/arcpgu: convert to drm_of_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (3 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of drm_of_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge Luca Ceresoli
` (20 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
drm_of_find_bridge() which gets a bridge reference, and put it when done.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/tiny/arcpgu.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 7cf0f0ea1bfe..bd9794897197 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -308,10 +308,8 @@ 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) = drm_of_find_bridge(encoder_node);
if (!bridge)
return -EPROBE_DEFER;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (4 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 05/26] drm/arcpgu: convert to drm_of_find_bridge() Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 14:33 ` Louis Chauvet
2025-11-24 10:39 ` Maxime Ripard
2025-11-19 13:05 ` [PATCH 07/26] drm/bridge: ite-it66121: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
` (19 subsequent siblings)
25 siblings, 2 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, Luca Ceresoli
Several drivers (about 20) follow the same pattern:
1. get a pointer to a bridge (typically the next bridge in the chain) by
calling of_drm_find_bridge()
2. store the returned pointer in the private driver data, keep it until
driver .remove
3. dereference the pointer at attach time and possibly at other times
of_drm_find_bridge() is now deprecated because it does not increment the
refcount and should be replaced with drm_of_find_bridge() +
drm_bridge_put().
However some of those drivers have a complex code flow and adding a
drm_bridge_put() call in all the appropriate locations is error-prone,
leads to ugly and more complex code, and can lead to errors over time with
code flow changes.
To handle all those drivers in a straightforward way, add a devm variant of
drm_of_find_bridge() that adds a devm action to invoke drm_bridge_put()
when the said driver is removed. This allows all those drivers to put the
reference automatically and safely with a one line change:
- priv->next_bridge = of_drm_find_bridge(remote_np);
+ priv->next_bridge = devm_drm_of_find_bridge(dev, remote_np);
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++
include/drm/drm_bridge.h | 5 +++++
2 files changed, 35 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 09ad825f9cb8..c7baafbe5695 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1446,6 +1446,36 @@ struct drm_bridge *drm_of_find_bridge(struct device_node *np)
}
EXPORT_SYMBOL(drm_of_find_bridge);
+/**
+ * devm_drm_of_find_bridge - find the bridge corresponding to the device
+ * node in the global bridge list and add a devm
+ * action to put it
+ *
+ * @dev: device requesting the bridge
+ * @np: device node
+ *
+ * On success the returned bridge refcount is incremented, and a devm
+ * action is added to call drm_bridge_put() when @dev is removed. So the
+ * caller does not have to put the returned bridge explicitly.
+ *
+ * RETURNS:
+ * drm_bridge control struct on success, NULL on failure
+ */
+struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
+{
+ struct drm_bridge *bridge = drm_of_find_bridge(np);
+
+ if (bridge) {
+ int err = devm_add_action_or_reset(dev, drm_bridge_put_void, bridge);
+
+ if (err)
+ return ERR_PTR(err);
+ }
+
+ return bridge;
+}
+EXPORT_SYMBOL(devm_drm_of_find_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 e74e91004c48..98d5433f7d35 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1314,12 +1314,17 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
#ifdef CONFIG_OF
struct drm_bridge *drm_of_find_bridge(struct device_node *np);
+struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np);
struct drm_bridge *of_drm_find_bridge(struct device_node *np);
#else
static inline struct drm_bridge *drm_of_find_bridge(struct device_node *np)
{
return NULL;
}
+static inline struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
+{
+ return NULL;
+}
static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
{
return NULL;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge
2025-11-19 13:05 ` [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge Luca Ceresoli
@ 2025-11-19 14:33 ` Louis Chauvet
2025-11-19 15:05 ` Luca Ceresoli
2025-11-24 10:39 ` Maxime Ripard
1 sibling, 1 reply; 43+ messages in thread
From: Louis Chauvet @ 2025-11-19 14:33 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, Jonathan Corbet, Alexey Brodkin, Phong LE,
Liu Ying, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
On 11/19/25 13:05, Luca Ceresoli wrote:
> Several drivers (about 20) follow the same pattern:
>
> 1. get a pointer to a bridge (typically the next bridge in the chain) by
> calling of_drm_find_bridge()
> 2. store the returned pointer in the private driver data, keep it until
> driver .remove
> 3. dereference the pointer at attach time and possibly at other times
>
> of_drm_find_bridge() is now deprecated because it does not increment the
> refcount and should be replaced with drm_of_find_bridge() +
> drm_bridge_put().
>
> However some of those drivers have a complex code flow and adding a
> drm_bridge_put() call in all the appropriate locations is error-prone,
> leads to ugly and more complex code, and can lead to errors over time with
> code flow changes.
>
> To handle all those drivers in a straightforward way, add a devm variant of
> drm_of_find_bridge() that adds a devm action to invoke drm_bridge_put()
> when the said driver is removed. This allows all those drivers to put the
> reference automatically and safely with a one line change:
>
> - priv->next_bridge = of_drm_find_bridge(remote_np);
> + priv->next_bridge = devm_drm_of_find_bridge(dev, remote_np);
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++
> include/drm/drm_bridge.h | 5 +++++
> 2 files changed, 35 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 09ad825f9cb8..c7baafbe5695 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -1446,6 +1446,36 @@ struct drm_bridge *drm_of_find_bridge(struct device_node *np)
> }
> EXPORT_SYMBOL(drm_of_find_bridge);
>
> +/**
> + * devm_drm_of_find_bridge - find the bridge corresponding to the device
> + * node in the global bridge list and add a devm
> + * action to put it
> + *
> + * @dev: device requesting the bridge
> + * @np: device node
> + *
> + * On success the returned bridge refcount is incremented, and a devm
> + * action is added to call drm_bridge_put() when @dev is removed. So the
> + * caller does not have to put the returned bridge explicitly.
> + *
> + * RETURNS:
> + * drm_bridge control struct on success, NULL on failure
I am not sure for the "NULL on failure", you return ERR_PTR(err), which
is probably not NULL but an error code.
> + */
> +struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
> +{
> + struct drm_bridge *bridge = drm_of_find_bridge(np);
> +
> + if (bridge) {
> + int err = devm_add_action_or_reset(dev, drm_bridge_put_void, bridge);
> +
> + if (err)
> + return ERR_PTR(err);
> + }
> +
> + return bridge;
> +}
> +EXPORT_SYMBOL(devm_drm_of_find_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 e74e91004c48..98d5433f7d35 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -1314,12 +1314,17 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
>
> #ifdef CONFIG_OF
> struct drm_bridge *drm_of_find_bridge(struct device_node *np);
> +struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np);
> struct drm_bridge *of_drm_find_bridge(struct device_node *np);
> #else
> static inline struct drm_bridge *drm_of_find_bridge(struct device_node *np)
> {
> return NULL;
> }
> +static inline struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
> +{
> + return NULL;
> +}
> static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
> {
> return NULL;
>
^ permalink raw reply [flat|nested] 43+ messages in thread* Re: [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge
2025-11-19 14:33 ` Louis Chauvet
@ 2025-11-19 15:05 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 15:05 UTC (permalink / raw)
To: Louis Chauvet, 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, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
Hi Louis,
On Wed Nov 19, 2025 at 3:33 PM CET, Louis Chauvet wrote:
>
>
> On 11/19/25 13:05, Luca Ceresoli wrote:
>> Several drivers (about 20) follow the same pattern:
>>
>> 1. get a pointer to a bridge (typically the next bridge in the chain) by
>> calling of_drm_find_bridge()
>> 2. store the returned pointer in the private driver data, keep it until
>> driver .remove
>> 3. dereference the pointer at attach time and possibly at other times
>>
>> of_drm_find_bridge() is now deprecated because it does not increment the
>> refcount and should be replaced with drm_of_find_bridge() +
>> drm_bridge_put().
>>
>> However some of those drivers have a complex code flow and adding a
>> drm_bridge_put() call in all the appropriate locations is error-prone,
>> leads to ugly and more complex code, and can lead to errors over time with
>> code flow changes.
>>
>> To handle all those drivers in a straightforward way, add a devm variant of
>> drm_of_find_bridge() that adds a devm action to invoke drm_bridge_put()
>> when the said driver is removed. This allows all those drivers to put the
>> reference automatically and safely with a one line change:
>>
>> - priv->next_bridge = of_drm_find_bridge(remote_np);
>> + priv->next_bridge = devm_drm_of_find_bridge(dev, remote_np);
>>
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>> ---
>> drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++
>> include/drm/drm_bridge.h | 5 +++++
>> 2 files changed, 35 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> index 09ad825f9cb8..c7baafbe5695 100644
>> --- a/drivers/gpu/drm/drm_bridge.c
>> +++ b/drivers/gpu/drm/drm_bridge.c
>> @@ -1446,6 +1446,36 @@ struct drm_bridge *drm_of_find_bridge(struct device_node *np)
>> }
>> EXPORT_SYMBOL(drm_of_find_bridge);
>>
>> +/**
>> + * devm_drm_of_find_bridge - find the bridge corresponding to the device
>> + * node in the global bridge list and add a devm
>> + * action to put it
>> + *
>> + * @dev: device requesting the bridge
>> + * @np: device node
>> + *
>> + * On success the returned bridge refcount is incremented, and a devm
>> + * action is added to call drm_bridge_put() when @dev is removed. So the
>> + * caller does not have to put the returned bridge explicitly.
>> + *
>> + * RETURNS:
>> + * drm_bridge control struct on success, NULL on failure
>
> I am not sure for the "NULL on failure", you return ERR_PTR(err), which
> is probably not NULL but an error code.
Indeed.
Apologies for the mess in this series: it was adapted from an old one using
a different approach, so I had to adapt lots of details, and missed a few
along the way. :(
About the value to return, maybe it's better to use the same semantics as
drm_of_find_bridge(), i.e. NULL on error. I don't think a caller would have
anything clever to do with an error return value other tan bailing out. And
the only error path for devm_add_action_or_reset() is on a small
allocation, so it basically cannot happen.
>> +struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
>> +{
>> + struct drm_bridge *bridge = drm_of_find_bridge(np);
>> +
>> + if (bridge) {
>> + int err = devm_add_action_or_reset(dev, drm_bridge_put_void, bridge);
>> +
>> + if (err)
>> + return ERR_PTR(err);
>> + }
So this would become:
if (bridge) {
if (devm_add_action_or_reset(dev, drm_bridge_put_void, bridge))
return NULL;
}
>> +
>> + return bridge;
>> +}
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge
2025-11-19 13:05 ` [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge Luca Ceresoli
2025-11-19 14:33 ` Louis Chauvet
@ 2025-11-24 10:39 ` Maxime Ripard
2025-11-24 16:25 ` Luca Ceresoli
1 sibling, 1 reply; 43+ messages in thread
From: Maxime Ripard @ 2025-11-24 10:39 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 3880 bytes --]
On Wed, Nov 19, 2025 at 02:05:37PM +0100, Luca Ceresoli wrote:
> Several drivers (about 20) follow the same pattern:
>
> 1. get a pointer to a bridge (typically the next bridge in the chain) by
> calling of_drm_find_bridge()
> 2. store the returned pointer in the private driver data, keep it until
> driver .remove
> 3. dereference the pointer at attach time and possibly at other times
>
> of_drm_find_bridge() is now deprecated because it does not increment the
> refcount and should be replaced with drm_of_find_bridge() +
> drm_bridge_put().
>
> However some of those drivers have a complex code flow and adding a
> drm_bridge_put() call in all the appropriate locations is error-prone,
> leads to ugly and more complex code, and can lead to errors over time with
> code flow changes.
>
> To handle all those drivers in a straightforward way, add a devm variant of
> drm_of_find_bridge() that adds a devm action to invoke drm_bridge_put()
> when the said driver is removed. This allows all those drivers to put the
> reference automatically and safely with a one line change:
>
> - priv->next_bridge = of_drm_find_bridge(remote_np);
> + priv->next_bridge = devm_drm_of_find_bridge(dev, remote_np);
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
> drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++
> include/drm/drm_bridge.h | 5 +++++
> 2 files changed, 35 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 09ad825f9cb8..c7baafbe5695 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -1446,6 +1446,36 @@ struct drm_bridge *drm_of_find_bridge(struct device_node *np)
> }
> EXPORT_SYMBOL(drm_of_find_bridge);
>
> +/**
> + * devm_drm_of_find_bridge - find the bridge corresponding to the device
> + * node in the global bridge list and add a devm
> + * action to put it
> + *
> + * @dev: device requesting the bridge
> + * @np: device node
> + *
> + * On success the returned bridge refcount is incremented, and a devm
> + * action is added to call drm_bridge_put() when @dev is removed. So the
> + * caller does not have to put the returned bridge explicitly.
> + *
> + * RETURNS:
> + * drm_bridge control struct on success, NULL on failure
> + */
> +struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
> +{
> + struct drm_bridge *bridge = drm_of_find_bridge(np);
> +
> + if (bridge) {
> + int err = devm_add_action_or_reset(dev, drm_bridge_put_void, bridge);
> +
> + if (err)
> + return ERR_PTR(err);
> + }
> +
> + return bridge;
> +}
> +EXPORT_SYMBOL(devm_drm_of_find_bridge);
That's inherently unsafe though, because even if the bridge is removed
other parts of DRM might still have a reference to it and could call
into it.
We'd then have dropped our reference to the next bridge, which could
have been freed, and it's a use-after-free.
It's more complicated than it sounds, because we only have access to the
drm_device when the bridge is attached, so later than probe.
I wonder if we shouldn't tie the lifetime of that reference to the
lifetime of the bridge itself, and we would give up the next_bridge
reference only when we're destroyed ourselves.
Storing a list of all the references we need to drop is going to be
intrusive though, so maybe the easiest way to do it would be to create a
next_bridge field in drm_bridge, and only drop the reference stored
there?
And possibly tie the whole thing together using a helper?
Anyway, I'm not sure it should be a prerequisite to this series. I we do
want to go the devm_drm_of_find_bridge route however, we should at least
document that it's unsafe, and add a TODO entry to clean up the mess
later on.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread* Re: [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge
2025-11-24 10:39 ` Maxime Ripard
@ 2025-11-24 16:25 ` Luca Ceresoli
0 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-24 16:25 UTC (permalink / raw)
To: Maxime Ripard
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Jonathan Corbet,
Alexey Brodkin, Phong LE, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar, Hui Pu, Thomas Petazzoni,
dri-devel, linux-kernel, linux-doc, imx, linux-arm-kernel,
linux-renesas-soc, linux-amlogic, linux-mediatek,
linux-samsung-soc
Hi Maxime,
On Mon Nov 24, 2025 at 11:39 AM CET, Maxime Ripard wrote:
> On Wed, Nov 19, 2025 at 02:05:37PM +0100, Luca Ceresoli wrote:
>> Several drivers (about 20) follow the same pattern:
>>
>> 1. get a pointer to a bridge (typically the next bridge in the chain) by
>> calling of_drm_find_bridge()
>> 2. store the returned pointer in the private driver data, keep it until
>> driver .remove
>> 3. dereference the pointer at attach time and possibly at other times
>>
>> of_drm_find_bridge() is now deprecated because it does not increment the
>> refcount and should be replaced with drm_of_find_bridge() +
>> drm_bridge_put().
>>
>> However some of those drivers have a complex code flow and adding a
>> drm_bridge_put() call in all the appropriate locations is error-prone,
>> leads to ugly and more complex code, and can lead to errors over time with
>> code flow changes.
>>
>> To handle all those drivers in a straightforward way, add a devm variant of
>> drm_of_find_bridge() that adds a devm action to invoke drm_bridge_put()
>> when the said driver is removed. This allows all those drivers to put the
>> reference automatically and safely with a one line change:
>>
>> - priv->next_bridge = of_drm_find_bridge(remote_np);
>> + priv->next_bridge = devm_drm_of_find_bridge(dev, remote_np);
>>
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>>
>> ---
>> drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++
>> include/drm/drm_bridge.h | 5 +++++
>> 2 files changed, 35 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> index 09ad825f9cb8..c7baafbe5695 100644
>> --- a/drivers/gpu/drm/drm_bridge.c
>> +++ b/drivers/gpu/drm/drm_bridge.c
>> @@ -1446,6 +1446,36 @@ struct drm_bridge *drm_of_find_bridge(struct device_node *np)
>> }
>> EXPORT_SYMBOL(drm_of_find_bridge);
>>
>> +/**
>> + * devm_drm_of_find_bridge - find the bridge corresponding to the device
>> + * node in the global bridge list and add a devm
>> + * action to put it
>> + *
>> + * @dev: device requesting the bridge
>> + * @np: device node
>> + *
>> + * On success the returned bridge refcount is incremented, and a devm
>> + * action is added to call drm_bridge_put() when @dev is removed. So the
>> + * caller does not have to put the returned bridge explicitly.
>> + *
>> + * RETURNS:
>> + * drm_bridge control struct on success, NULL on failure
>> + */
>> +struct drm_bridge *devm_drm_of_find_bridge(struct device *dev, struct device_node *np)
>> +{
>> + struct drm_bridge *bridge = drm_of_find_bridge(np);
>> +
>> + if (bridge) {
>> + int err = devm_add_action_or_reset(dev, drm_bridge_put_void, bridge);
>> +
>> + if (err)
>> + return ERR_PTR(err);
>> + }
>> +
>> + return bridge;
>> +}
>> +EXPORT_SYMBOL(devm_drm_of_find_bridge);
>
> That's inherently unsafe though, because even if the bridge is removed
> other parts of DRM might still have a reference to it and could call
> into it.
>
> We'd then have dropped our reference to the next bridge, which could
> have been freed, and it's a use-after-free.
I think you refer to this scenario:
1. pipeline: encoder --> bridge A --> bridge B --> bridge C
2. encoder takes a reference to bridge B
using devm_drm_of_find_bridge() or other means
3. bridge B takes a next_bridge reference to bridge C
using devm_drm_of_find_bridge()
4. encoder calls (bridge 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 ref. So when step 4 happens, 'b->c'
would be a use-after-free (or NULL deref if b.remove cleared it, which is
just as bad).
If I got you correctly, then I'm a bit surprised by your comment. This
series is part of the first chapter of the hotplug work, which does not aim
at fixing everything but rather at fixing one part: handle dynamic
_allocation_ lifetime of drm_bridges by adding a refcount and
drm_bridge_get/put().
Chapter 2 of the work is adding drm_bridge_enter/exit/unplug() [1] and
other changes in order to avoid code of drivers of removed bridges to
access fields they shouldn't. So the above example at point 4 would become:
b_foo() {
if (!drm_bridge_enter())
return;
bar(b->c);
drm_bridge_exit();
}
And that avoids 'b->c' after bridge B is removed.
Does that answer your remark?
> It's more complicated than it sounds, because we only have access to the
> drm_device when the bridge is attached, so later than probe.
>
> I wonder if we shouldn't tie the lifetime of that reference to the
> lifetime of the bridge itself, and we would give up the next_bridge
> reference only when we're destroyed ourselves.
I'm afraid I'm not following you, sorry. Do you refer to the time between
the bridge removal (driver .remove) and the last bridge put (when
deallocation happens)?
In that time frame the struct drm_bridge is still allocated along with any
next_bridge pointer it may contain, but the following bridge could have
been deallocated.
What do you mean by "give up the next_bridge"?
> Storing a list of all the references we need to drop is going to be
> intrusive though, so maybe the easiest way to do it would be to create a
> next_bridge field in drm_bridge, and only drop the reference stored
> there?
>
> And possibly tie the whole thing together using a helper?
>
> Anyway, I'm not sure it should be a prerequisite to this series. I we do
> want to go the devm_drm_of_find_bridge route however, we should at least
> document that it's unsafe, and add a TODO entry to clean up the mess
> later on.
Do you mean the drm variant is unsafe while the original
(drm_of_find_bridge() in this series, might be renamed) is not? I don't see
how that can happen. If the driver for bridge B were to use
drm_of_find_bridge(), that driver would be responsible to
drm_bridge_put(b->next_bridge) in its .remove() function or earlier. So the
next_bridge pointing to bridge C would equally become subject to
use-after-free. devm does not make it worse, on the opposite it postpones
the drm_bridge_put(next_bridge) as late as possible: just after b.remove().
One final, high-level thought about the various 'next_bridge' pointers that
many bridge drivers have. Most of them do:
0. have a 'struct drm_bridge next_bridge *' in their private struct
1. take the next_bridge reference during probe or another startup phase
2. store it in their private driver struct
3. use it to call drm_bridge_attach
4. (pending) put the reference to it in their .remove or earlier
I'm wondering whether we could let the DRM bridge core do it all, by
removing items 0, 1, 2 and 4, and change 3 as:
- drm_bridge_attach(encoder, me->next_bridge, &me->bridge, flags);
+ drm_of_bridge_attach(encoder, &me->bridge, dev->of_node, 1, -1, flags);
where dev->of_node and the following integers are the same flags passed to
devm_drm_of_get_bridge() and the like, i.e. the endpoint info needed to
walk the DT graph and reach the next bridge.
This would allow the core to take care of all locking and lifetime of the
next bridge, and most (all?) bridges would never access any pointers to the
next bridge. The idea is to let the core do the right thing in a single
place instead of trying to make all drivers do the right thing (and
touching dozen files when needing to touch the logic).
That is more a long-term ideal than something I'd do right now, but having
opinions would be very interesting.
[1] https://lore.kernel.org/lkml/20251112-drm-bridge-atomic-vs-remove-v3-0-85db717ce094@bootlin.com/
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 07/26] drm/bridge: ite-it66121: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (5 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 14:36 ` Louis Chauvet
2025-11-19 13:05 ` [PATCH 08/26] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
` (18 subsequent siblings)
25 siblings, 1 reply; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ite-it66121.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index aa7b1dcc5d70..5bc4e5afb823 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -1542,7 +1542,7 @@ static int it66121_probe(struct i2c_client *client)
return -EINVAL;
}
- ctx->next_bridge = of_drm_find_bridge(ep);
+ ctx->next_bridge = devm_drm_of_find_bridge(dev, ep);
of_node_put(ep);
if (!ctx->next_bridge) {
dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n");
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* Re: [PATCH 07/26] drm/bridge: ite-it66121: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 ` [PATCH 07/26] drm/bridge: ite-it66121: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
@ 2025-11-19 14:36 ` Louis Chauvet
0 siblings, 0 replies; 43+ messages in thread
From: Louis Chauvet @ 2025-11-19 14:36 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, Jonathan Corbet, Alexey Brodkin, Phong LE,
Liu Ying, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Adrien Grassein, Laurent Pinchart, Tomi Valkeinen,
Kieran Bingham, Geert Uytterhoeven, Magnus Damm, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc
On 11/19/25 13:05, 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 devm_drm_of_find_bridge() which puts the bridge
> reference on remove or on probe failure.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ite-it66121.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
> index aa7b1dcc5d70..5bc4e5afb823 100644
> --- a/drivers/gpu/drm/bridge/ite-it66121.c
> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
> @@ -1542,7 +1542,7 @@ static int it66121_probe(struct i2c_client *client)
> return -EINVAL;
> }
>
> - ctx->next_bridge = of_drm_find_bridge(ep);
> + ctx->next_bridge = devm_drm_of_find_bridge(dev, ep);
> of_node_put(ep);
> if (!ctx->next_bridge) {
And for all the patches converting of_drm_find_bridge to
devm_drm_of_find_bridge, I think the pattern:
bridge = devm_drm_of_find_bridge(dev, ep);
if(!bridge)
return -E...;
is wrong, because devm_drm_of_find_bridge can return a non-null error code.
> dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n");
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 08/26] drm/bridge: imx8qxp-pixel-combiner: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (6 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 07/26] drm/bridge: ite-it66121: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 09/26] drm/bridge: simple-bridge: " Luca Ceresoli
` (17 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
index 8517b1c953d4..8ec8f1fba62a 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
@@ -326,7 +326,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
goto free_child;
}
- ch->next_bridge = of_drm_find_bridge(remote);
+ ch->next_bridge = devm_drm_of_find_bridge(dev, remote);
if (!ch->next_bridge) {
of_node_put(remote);
ret = -EPROBE_DEFER;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 09/26] drm/bridge: simple-bridge: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (7 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 08/26] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 10/26] drm/bridge: tpd12s015: " Luca Ceresoli
` (16 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/simple-bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 90abda199cea..a4f74c940dd1 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -180,7 +180,7 @@ static int simple_bridge_probe(struct platform_device *pdev)
if (!remote)
return -EINVAL;
- sbridge->next_bridge = of_drm_find_bridge(remote);
+ sbridge->next_bridge = devm_drm_of_find_bridge(&pdev->dev, remote);
of_node_put(remote);
if (!sbridge->next_bridge) {
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 10/26] drm/bridge: tpd12s015: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (8 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 09/26] drm/bridge: simple-bridge: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 11/26] drm/bridge: thc63lvd1024: " Luca Ceresoli
` (15 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c b/drivers/gpu/drm/bridge/ti-tpd12s015.c
index dcf686c4e73d..cef01106db31 100644
--- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
+++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
@@ -138,7 +138,7 @@ static int tpd12s015_probe(struct platform_device *pdev)
if (!node)
return -ENODEV;
- tpd->next_bridge = of_drm_find_bridge(node);
+ tpd->next_bridge = devm_drm_of_find_bridge(&pdev->dev, node);
of_node_put(node);
if (!tpd->next_bridge)
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 11/26] drm/bridge: thc63lvd1024: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (9 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 10/26] drm/bridge: tpd12s015: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 12/26] drm/bridge: imx8qxp-pxl2dpi: use devm_drm_of_find_bridge() to put the next and companion bridges Luca Ceresoli
` (14 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/thc63lvd1024.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
index 2cb7cd0c0608..bc658883c813 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -132,7 +132,7 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
return -ENODEV;
}
- thc63->next = of_drm_find_bridge(remote);
+ thc63->next = devm_drm_of_find_bridge(thc63->dev, remote);
of_node_put(remote);
if (!thc63->next)
return -EPROBE_DEFER;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 12/26] drm/bridge: imx8qxp-pxl2dpi: use devm_drm_of_find_bridge() to put the next and companion bridges
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (10 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 11/26] drm/bridge: thc63lvd1024: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 13/26] drm/bridge: lt8912b: use devm_drm_of_find_bridge() to put the hdmi bridge Luca Ceresoli
` (13 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index 111310acab2c..82c407525c01 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -279,7 +279,7 @@ imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
goto out;
}
- next_bridge = of_drm_find_bridge(remote);
+ next_bridge = devm_drm_of_find_bridge(p2d->dev, remote);
if (!next_bridge) {
next_bridge = ERR_PTR(-EPROBE_DEFER);
goto out;
@@ -347,7 +347,7 @@ static int imx8qxp_pxl2dpi_parse_dt_companion(struct imx8qxp_pxl2dpi *p2d)
goto out;
}
- p2d->companion = of_drm_find_bridge(companion);
+ p2d->companion = devm_drm_of_find_bridge(dev, companion);
if (!p2d->companion) {
ret = -EPROBE_DEFER;
DRM_DEV_DEBUG_DRIVER(p2d->dev,
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 13/26] drm/bridge: lt8912b: use devm_drm_of_find_bridge() to put the hdmi bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (11 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 12/26] drm/bridge: imx8qxp-pxl2dpi: use devm_drm_of_find_bridge() to put the next and companion bridges Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 14/26] drm/bridge: tfp410: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
` (12 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 342374cb8fc6..eb2b607948a7 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -723,7 +723,7 @@ static int lt8912_parse_dt(struct lt8912 *lt)
goto err_free_host_node;
}
- lt->hdmi_port = of_drm_find_bridge(port_node);
+ lt->hdmi_port = devm_drm_of_find_bridge(lt->dev, port_node);
if (!lt->hdmi_port) {
ret = -EPROBE_DEFER;
dev_err_probe(lt->dev, ret, "%s: Failed to get hdmi port\n", __func__);
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 14/26] drm/bridge: tfp410: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (12 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 13/26] drm/bridge: lt8912b: use devm_drm_of_find_bridge() to put the hdmi bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 15/26] drm/bridge: imx8qxp-ldb: use devm_drm_of_find_bridge() to put the companion bridge Luca Ceresoli
` (11 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-tfp410.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
index b80ee089f880..f6074e78a772 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -362,7 +362,7 @@ static int tfp410_init(struct device *dev, bool i2c)
if (!node)
return -ENODEV;
- dvi->next_bridge = of_drm_find_bridge(node);
+ dvi->next_bridge = devm_drm_of_find_bridge(dev, node);
of_node_put(node);
if (!dvi->next_bridge)
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 15/26] drm/bridge: imx8qxp-ldb: use devm_drm_of_find_bridge() to put the companion bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (13 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 14/26] drm/bridge: tfp410: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 16/26] drm/rcar-du: lvds: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
` (10 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
index 122502968927..e0bd227fd47a 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
@@ -552,7 +552,7 @@ static int imx8qxp_ldb_parse_dt_companion(struct imx8qxp_ldb *imx8qxp_ldb)
goto out;
}
- imx8qxp_ldb->companion = of_drm_find_bridge(companion_port);
+ imx8qxp_ldb->companion = devm_drm_of_find_bridge(dev, companion_port);
if (!imx8qxp_ldb->companion) {
ret = -EPROBE_DEFER;
DRM_DEV_DEBUG_DRIVER(dev,
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 16/26] drm/rcar-du: lvds: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (14 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 15/26] drm/bridge: imx8qxp-ldb: use devm_drm_of_find_bridge() to put the companion bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 17/26] drm/meson: encoder_*: " Luca Ceresoli
` (9 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c b/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
index 001b3543924a..8eb73ca25eaa 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
@@ -740,7 +740,7 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds)
goto done;
}
- lvds->companion = of_drm_find_bridge(companion);
+ lvds->companion = devm_drm_of_find_bridge(dev, companion);
if (!lvds->companion) {
ret = -EPROBE_DEFER;
goto done;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 17/26] drm/meson: encoder_*: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (15 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 16/26] drm/rcar-du: lvds: use devm_drm_of_find_bridge() to put the next bridge Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 18/26] drm/bridge: sii902x: " Luca Ceresoli
` (8 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 2 +-
drivers/gpu/drm/meson/meson_encoder_dsi.c | 2 +-
drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
index dc374bfc5951..577f6b1e162f 100644
--- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
@@ -241,7 +241,7 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
return 0;
}
- meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote);
+ meson_encoder_cvbs->next_bridge = devm_drm_of_find_bridge(priv->dev, remote);
of_node_put(remote);
if (!meson_encoder_cvbs->next_bridge)
return dev_err_probe(priv->dev, -EPROBE_DEFER,
diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
index 6c6624f9ba24..dd5d6e6a7cb0 100644
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -120,7 +120,7 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
return 0;
}
- meson_encoder_dsi->next_bridge = of_drm_find_bridge(remote);
+ meson_encoder_dsi->next_bridge = devm_drm_of_find_bridge(priv->dev, remote);
if (!meson_encoder_dsi->next_bridge)
return dev_err_probe(priv->dev, -EPROBE_DEFER,
"Failed to find DSI transceiver bridge\n");
diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 8205ee56a691..e2d861239eda 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -390,7 +390,7 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
return 0;
}
- meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote);
+ meson_encoder_hdmi->next_bridge = devm_drm_of_find_bridge(priv->dev, remote);
if (!meson_encoder_hdmi->next_bridge) {
ret = dev_err_probe(priv->dev, -EPROBE_DEFER,
"Failed to find HDMI transceiver bridge\n");
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 18/26] drm/bridge: sii902x: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (16 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 17/26] drm/meson: encoder_*: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 19/26] drm/mediatek: " Luca Ceresoli
` (7 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/sii902x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index d537b1d036fb..ca3ef23683a3 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -1208,7 +1208,7 @@ static int sii902x_probe(struct i2c_client *client)
return -ENODEV;
}
- sii902x->next_bridge = of_drm_find_bridge(remote);
+ sii902x->next_bridge = devm_drm_of_find_bridge(dev, remote);
of_node_put(remote);
if (!sii902x->next_bridge)
return dev_err_probe(dev, -EPROBE_DEFER,
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 19/26] drm/mediatek: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (17 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 18/26] drm/bridge: sii902x: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 20/26] drm/kmb: dsi: " Luca Ceresoli
` (6 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index b766dd5e6c8d..57a926bdf8b4 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1405,7 +1405,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
return -EINVAL;
if (!of_device_is_compatible(remote, "hdmi-connector")) {
- hdmi->next_bridge = of_drm_find_bridge(remote);
+ hdmi->next_bridge = devm_drm_of_find_bridge(dev, remote);
if (!hdmi->next_bridge) {
dev_err(dev, "Waiting for external bridge\n");
of_node_put(remote);
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 20/26] drm/kmb: dsi: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (18 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 19/26] drm/mediatek: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 21/26] drm/imx/ipuv3: " Luca Ceresoli
` (5 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Note: this driver stores the bridge pointer in the adv_bridge global
variable, which could hold a value from a previous probe. However the code
flow always sets the adv_bridge value in the probe function before it is
read, so the change is safe.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/kmb/kmb_dsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
index faf38ca9e44c..05a6ccc1bd22 100644
--- a/drivers/gpu/drm/kmb/kmb_dsi.c
+++ b/drivers/gpu/drm/kmb/kmb_dsi.c
@@ -251,7 +251,7 @@ int kmb_dsi_host_bridge_init(struct device *dev)
return -EINVAL;
}
/* Locate drm bridge from the hdmi encoder DT node */
- adv_bridge = of_drm_find_bridge(encoder_node);
+ adv_bridge = devm_drm_of_find_bridge(dev, encoder_node);
of_node_put(dsi_out);
of_node_put(encoder_node);
if (!adv_bridge) {
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 21/26] drm/imx/ipuv3: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (19 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 20/26] drm/kmb: dsi: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 22/26] drm/exynos: hdmi: " Luca Ceresoli
` (4 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c b/drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c
index 07e5f96202d4..1e6be89c3815 100644
--- a/drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c
+++ b/drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c
@@ -241,7 +241,7 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)
if (IS_ERR(hdmi->hdmi))
return PTR_ERR(hdmi->hdmi);
- hdmi->bridge = of_drm_find_bridge(np);
+ hdmi->bridge = devm_drm_of_find_bridge(&pdev->dev, np);
if (!hdmi->bridge) {
dev_err(hdmi->dev, "Unable to find bridge\n");
dw_hdmi_remove(hdmi->hdmi);
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 22/26] drm/exynos: hdmi: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (20 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 21/26] drm/imx/ipuv3: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 23/26] drm/bridge: dw-hdmi: " Luca Ceresoli
` (3 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/exynos/exynos_hdmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 01813e11e6c6..3fe32093f0c7 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -1779,7 +1779,7 @@ static int hdmi_bridge_init(struct hdmi_context *hdata)
return -EINVAL;
}
- hdata->bridge = of_drm_find_bridge(np);
+ hdata->bridge = devm_drm_of_find_bridge(dev, np);
of_node_put(np);
if (!hdata->bridge)
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 23/26] drm/bridge: dw-hdmi: use devm_drm_of_find_bridge() to put the next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (21 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 22/26] drm/exynos: hdmi: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 24/26] drm/bridge: imx8qxp-pixel-link: simplify logic to find " Luca Ceresoli
` (2 subsequent siblings)
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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 devm_drm_of_find_bridge() which puts the bridge
reference on remove or on probe failure.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 3b77e73ac0ea..8cf72305dcdc 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -3318,7 +3318,7 @@ static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi)
if (!remote)
return -ENODEV;
- hdmi->next_bridge = of_drm_find_bridge(remote);
+ hdmi->next_bridge = devm_drm_of_find_bridge(hdmi->dev, remote);
of_node_put(remote);
if (!hdmi->next_bridge)
return -EPROBE_DEFER;
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 24/26] drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (22 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 23/26] drm/bridge: dw-hdmi: " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 25/26] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node Luca Ceresoli
2025-11-19 13:05 ` [PATCH 26/26] drm/bridge: imx8qxp-pixel-link: convert to drm_of_find_bridge() Luca Ceresoli
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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>
---
Cc: Liu Ying <victor.liu@nxp.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.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 25/26] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (23 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 24/26] drm/bridge: imx8qxp-pixel-link: simplify logic to find " Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 26/26] drm/bridge: imx8qxp-pixel-link: convert to drm_of_find_bridge() Luca Ceresoli
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, 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>
---
Cc: Liu Ying <victor.liu@nxp.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.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread* [PATCH 26/26] drm/bridge: imx8qxp-pixel-link: convert to drm_of_find_bridge()
2025-11-19 13:05 [PATCH 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Luca Ceresoli
` (24 preceding siblings ...)
2025-11-19 13:05 ` [PATCH 25/26] drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node Luca Ceresoli
@ 2025-11-19 13:05 ` Luca Ceresoli
25 siblings, 0 replies; 43+ messages in thread
From: Luca Ceresoli @ 2025-11-19 13:05 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, Adrien Grassein,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Chun-Kuang Hu, Philipp Zabel,
Matthias Brugger, AngeloGioacchino Del Regno, Anitha Chrisanthus,
Edmund Dea, Inki Dae, Seung-Woo Kim, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: Hui Pu, Thomas Petazzoni, dri-devel, linux-kernel, linux-doc, imx,
linux-arm-kernel, linux-renesas-soc, linux-amlogic,
linux-mediatek, linux-samsung-soc, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
drm_of_find_bridge() which gets a bridge reference, and put it when done.
This needs to be handled in various steps:
* the bridge returned drm_of_find_bridge() is stored in 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 is useful here too
* however on successful return selected_bridge must be returned and
ultimately stored, so it should not be put in that case: use
return_ptr() to defuse the cleanup action on successful return
* finally, put the bridge reference on device remove
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Liu Ying <victor.liu@nxp.com>
---
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 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..9818239cf6e7 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -256,12 +256,13 @@ static int imx8qxp_pixel_link_disable_all_controls(struct imx8qxp_pixel_link *pl
return imx8qxp_pixel_link_disable_sync(pl);
}
+/* The returned bridge has its refcount incremented */
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;
- 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;
@@ -298,7 +299,7 @@ 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) = drm_of_find_bridge(remote);
if (!next_bridge)
return ERR_PTR(-EPROBE_DEFER);
@@ -306,13 +307,15 @@ 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;
- return selected_bridge;
+ return_ptr(selected_bridge);
}
static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
@@ -392,6 +395,7 @@ static void imx8qxp_pixel_link_bridge_remove(struct platform_device *pdev)
struct imx8qxp_pixel_link *pl = platform_get_drvdata(pdev);
drm_bridge_remove(&pl->bridge);
+ drm_bridge_put(pl->next_bridge);
}
static const struct of_device_id imx8qxp_pixel_link_dt_ids[] = {
--
2.51.1
^ permalink raw reply related [flat|nested] 43+ messages in thread