From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Maxime Ripard" <mripard@kernel.org>,
"Louis Chauvet" <louis.chauvet@bootlin.com>
Cc: "Andrzej Hajda" <andrzej.hajda@intel.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Robert Foss" <rfoss@kernel.org>,
"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
"Jonas Karlman" <jonas@kwiboo.se>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jonathan Corbet" <corbet@lwn.net>,
"Alexey Brodkin" <abrodkin@synopsys.com>,
"Phong LE" <ple@baylibre.com>, "Liu Ying" <victor.liu@nxp.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Adrien Grassein" <adrien.grassein@gmail.com>,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
"Tomi Valkeinen" <tomi.valkeinen+renesas@ideasonboard.com>,
"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Chun-Kuang Hu" <chunkuang.hu@kernel.org>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Anitha Chrisanthus" <anitha.chrisanthus@intel.com>,
"Edmund Dea" <edmund.j.dea@intel.com>,
"Inki Dae" <inki.dae@samsung.com>,
"Seung-Woo Kim" <sw0312.kim@samsung.com>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Alim Akhtar" <alim.akhtar@samsung.com>,
"Hui Pu" <Hui.Pu@gehealthcare.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <imx@lists.linux.dev>,
<linux-arm-kernel@lists.infradead.org>,
<linux-renesas-soc@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-samsung-soc@vger.kernel.org>
Subject: Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()
Date: Mon, 24 Nov 2025 17:23:34 +0100 [thread overview]
Message-ID: <DEH2BAF6NRPG.3S6GKB2PR1465@bootlin.com> (raw)
In-Reply-To: <x6uch6cyjgbwnmac7fyjxdbi56gnhmilezfjdhqpakbz5hogt3@q72fex3ssh6u>
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
next prev parent reply other threads:[~2025-11-24 16:23 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
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 14:22 ` Louis Chauvet
2025-11-19 14:29 ` Luca Ceresoli
2025-11-24 10:15 ` Maxime Ripard
2025-11-24 16:03 ` Luca Ceresoli
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
2025-11-24 16:23 ` Luca Ceresoli [this message]
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
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
2025-12-01 16:34 ` Maxime Ripard
2025-12-11 17:48 ` Luca Ceresoli
2025-11-19 13:05 ` [PATCH 05/26] drm/arcpgu: convert to drm_of_find_bridge() Luca Ceresoli
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
2025-11-24 16:25 ` Luca Ceresoli
2025-12-01 16:51 ` Maxime Ripard
2025-12-11 17:47 ` Luca Ceresoli
2025-12-12 11:10 ` Luca Ceresoli
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
2025-11-19 13:05 ` [PATCH 08/26] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 09/26] drm/bridge: simple-bridge: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 10/26] drm/bridge: tpd12s015: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 11/26] drm/bridge: thc63lvd1024: " 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
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 ` [PATCH 14/26] drm/bridge: tfp410: use devm_drm_of_find_bridge() to put the next bridge 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
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 ` [PATCH 17/26] drm/meson: encoder_*: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 18/26] drm/bridge: sii902x: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 19/26] drm/mediatek: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 20/26] drm/kmb: dsi: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 21/26] drm/imx/ipuv3: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 22/26] drm/exynos: hdmi: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 23/26] drm/bridge: dw-hdmi: " Luca Ceresoli
2025-11-19 13:05 ` [PATCH 24/26] drm/bridge: imx8qxp-pixel-link: simplify logic to find " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DEH2BAF6NRPG.3S6GKB2PR1465@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=Hui.Pu@gehealthcare.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=abrodkin@synopsys.com \
--cc=adrien.grassein@gmail.com \
--cc=airlied@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=andrzej.hajda@intel.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=anitha.chrisanthus@intel.com \
--cc=chunkuang.hu@kernel.org \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=edmund.j.dea@intel.com \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=imx@lists.linux.dev \
--cc=inki.dae@samsung.com \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=magnus.damm@gmail.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=ple@baylibre.com \
--cc=rfoss@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=simona@ffwll.ch \
--cc=sw0312.kim@samsung.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tomi.valkeinen+renesas@ideasonboard.com \
--cc=tzimmermann@suse.de \
--cc=victor.liu@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).