* [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern
@ 2025-06-20 15:59 Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove() Luca Ceresoli
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-20 15:59 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
Cc: Dmitry Baryshkov, Anusha Srivatsa, dri-devel, linux-kernel,
Hui Pu, Thomas Petazzoni, Luca Ceresoli
This small series adds drm_bridge_get/put() calls where applicable in the
bridge core code, and adds a warning when the old allocation patter is
used.
This is part of the work towards removal of bridges from a still existing
DRM pipeline without use-after-free.
The steps in the grand plan [1] are:
1. ➜ add refcounting to DRM bridges (struct drm_bridge)
2. handle gracefully atomic updates during bridge removal
3. avoid DSI host drivers to have dangling pointers to DSI devices
4. finish the hotplug bridge work, removing the "always-disconnected"
connector, moving code to the core and potentially removing the
hotplug-bridge itself (this needs to be clarified as points 1-3 are
developed)
This series is part of step 1 of the grand plan.
Current tasks in step 1 of the grand plan:
A. ✔ add new alloc API and refcounting (in v6.16-rc1)
B. ✔ convert all bridge drivers to new API (now in drm-misc-next)
C. ✔ kunit tests (now in drm-misc-next)
D. ➜ after (B), add get/put to drm_bridge_add/remove() + attach/detech()
and warn on old allocation pattern (this series)
E. after (B), convert accessors; this is a large work and can be done
in chunks
F. debugfs improvements
Specifically, this series does two things related to the recently
introduced devm_drm_bridge_alloc() [0]:
A) add drm_bridge_get/put() in the two places within drm_bridge.c where a
bridge reference is taken/relased
B) add a warning on bridges using the old allocation pattern instead of
devm_drm_bridge_alloc()
These are loosely related topics, but I'm sending them in a single series
to avoid trivial patch conflicts, as they touch the same lines. This will
holefully help getting the patches applied more efficiently and quickly. I
hope this is fine being 3 small patches.
Part A) is made of patches 1 and 2. Those have been previously sent in
"[PATCH v7 00/11] drm/bridge: add devm_drm_bridge_alloc() with bridge
refcount" [2] (as patches 3 and 4), and already Reviewed-by Maxime at that
time. However they could not be applied until the conversion of all bridge
drivers to devm_drm_bridge_alloc(), which got completed a few days
ago. Hence the reason this is v8.
[0] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/0cc6aadd7fc1e629b715ea3d1ba537ef2da95eec
[1] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/t/#u
[2] https://lore.kernel.org/all/20250314-drm-bridge-refcount-v7-0-152571f8c694@bootlin.com/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v9:
- patch 3: change warning trigger from "refcount != 1" to "container not NULL"
- Link to v8 (counted as v1 by mistake): https://lore.kernel.org/r/20250620-drm-bridge-alloc-getput-drm-bridge-c-v1-0-bad7eba5d117@bootlin.com
---
Luca Ceresoli (3):
drm/bridge: get/put the bridge reference in drm_bridge_add/remove()
drm/bridge: get/put the bridge reference in drm_bridge_attach/detach()
drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
drivers/gpu/drm/drm_bridge.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
---
base-commit: a59a271769149f0b8258507276f3d2a24370cbdb
change-id: 20250620-drm-bridge-alloc-getput-drm-bridge-c-0ab2ca481c37
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v9 1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove()
2025-06-20 15:59 [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
@ 2025-06-20 15:59 ` Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 2/3] drm/bridge: get/put the bridge reference in drm_bridge_attach/detach() Luca Ceresoli
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-20 15:59 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
Cc: Dmitry Baryshkov, Anusha Srivatsa, dri-devel, linux-kernel,
Hui Pu, Thomas Petazzoni, Luca Ceresoli
drm_bridge_add() adds the bridge to the global bridge_list, so take a
reference for that. Vice versa in drm_bridge_remove().
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v9: none
Changes in v8: none
Changes in v7:
- in v6 this was part of "drm/bridge: add support for refcounted DRM
bridges", now split to a separate patch
---
drivers/gpu/drm/drm_bridge.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index d6ce7b4c019f415400bab8aa3d032638cba6cdc5..fa2b2457b16e145e3ace70c53984937096d310d0 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -295,6 +295,8 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
*/
void drm_bridge_add(struct drm_bridge *bridge)
{
+ drm_bridge_get(bridge);
+
mutex_init(&bridge->hpd_mutex);
if (bridge->ops & DRM_BRIDGE_OP_HDMI)
@@ -342,6 +344,8 @@ void drm_bridge_remove(struct drm_bridge *bridge)
mutex_unlock(&bridge_lock);
mutex_destroy(&bridge->hpd_mutex);
+
+ drm_bridge_put(bridge);
}
EXPORT_SYMBOL(drm_bridge_remove);
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v9 2/3] drm/bridge: get/put the bridge reference in drm_bridge_attach/detach()
2025-06-20 15:59 [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove() Luca Ceresoli
@ 2025-06-20 15:59 ` Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc() Luca Ceresoli
2025-06-26 13:16 ` [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
3 siblings, 0 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-20 15:59 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
Cc: Dmitry Baryshkov, Anusha Srivatsa, dri-devel, linux-kernel,
Hui Pu, Thomas Petazzoni, Luca Ceresoli
drm_bridge_attach() adds the bridge to the encoder chain, so take a
reference for that. Vice versa in drm_bridge_detach().
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v9: none
Changes in v8: none
Changes in v7:
- in v6 this was part of "drm/bridge: add support for refcounted DRM
bridges", now split to a separate patch
---
drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index fa2b2457b16e145e3ace70c53984937096d310d0..f001bbe95559aabf0aac9f25f89250ad4e1ad9c8 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -411,11 +411,17 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
if (!encoder || !bridge)
return -EINVAL;
- if (previous && (!previous->dev || previous->encoder != encoder))
- return -EINVAL;
+ drm_bridge_get(bridge);
- if (bridge->dev)
- return -EBUSY;
+ if (previous && (!previous->dev || previous->encoder != encoder)) {
+ ret = -EINVAL;
+ goto err_put_bridge;
+ }
+
+ if (bridge->dev) {
+ ret = -EBUSY;
+ goto err_put_bridge;
+ }
bridge->dev = encoder->dev;
bridge->encoder = encoder;
@@ -464,6 +470,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
"failed to attach bridge %pOF to encoder %s\n",
bridge->of_node, encoder->name);
+err_put_bridge:
+ drm_bridge_put(bridge);
return ret;
}
EXPORT_SYMBOL(drm_bridge_attach);
@@ -484,6 +492,7 @@ void drm_bridge_detach(struct drm_bridge *bridge)
list_del(&bridge->chain_node);
bridge->dev = NULL;
+ drm_bridge_put(bridge);
}
/**
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
2025-06-20 15:59 [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove() Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 2/3] drm/bridge: get/put the bridge reference in drm_bridge_attach/detach() Luca Ceresoli
@ 2025-06-20 15:59 ` Luca Ceresoli
2025-06-23 6:40 ` Maxime Ripard
2025-06-23 11:06 ` Dmitry Baryshkov
2025-06-26 13:16 ` [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
3 siblings, 2 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-20 15:59 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
Cc: Dmitry Baryshkov, Anusha Srivatsa, dri-devel, linux-kernel,
Hui Pu, Thomas Petazzoni, Luca Ceresoli
To the best of my knowledge, all drivers in the mainline kernel adding a
DRM bridge are now converted to using devm_drm_bridge_alloc() for
allocation and initialization. Among others this ensures initialization of
the bridge refcount, allowing dynamic allocation lifetime.
devm_drm_bridge_alloc() is now mandatory for all new bridges. Code using
the old pattern ([devm_]kzalloc + filling the struct fields +
drm_bridge_add) is not allowed anymore.
Any drivers that might have been missed during the conversion, patches in
flight towards mainline and out-of-tre drivers still using the old pattern
will already be caught by a warning looking like:
------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 2 PID: 83 at lib/refcount.c:25 refcount_warn_saturate+0x120/0x148
[...]
Call trace:
refcount_warn_saturate+0x120/0x148 (P)
drm_bridge_get.part.0+0x70/0x98 [drm]
drm_bridge_add+0x34/0x108 [drm]
sn65dsi83_probe+0x200/0x480 [ti_sn65dsi83]
[...]
This warning comes from the refcount code and happens because
drm_bridge_add() is increasing the refcount, which is uninitialized and
thus initially zero.
Having a warning and the corresponding stack trace is surely useful, but
the warning text does not clarify the root problem nor how to fix it.
Add a DRM_WARN() just before increasing the refcount, so the log will be
much more readable:
[drm] DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()
------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
[...etc...]
A DRM_WARN is used because drm_warn and drm_WARN require a struct
drm_device pointer which is not yet available when adding a bridge.
Do not print the dev_name() in the warning because struct drm_bridge has no
pointer to the struct device. The affected driver should be easy to catch
based on the following stack trace however.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v9:
- change warning trigger from "refcount != 1" to "container not NULL"
This patch was added in v8
---
drivers/gpu/drm/drm_bridge.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index f001bbe95559aabf0aac9f25f89250ad4e1ad9c8..0b450b334afd82e0460f18fdd248f79d0a2b153d 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -295,6 +295,9 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
*/
void drm_bridge_add(struct drm_bridge *bridge)
{
+ if (!bridge->container)
+ DRM_WARN("DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()\n");
+
drm_bridge_get(bridge);
mutex_init(&bridge->hpd_mutex);
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
2025-06-20 15:59 ` [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc() Luca Ceresoli
@ 2025-06-23 6:40 ` Maxime Ripard
2025-06-23 11:06 ` Dmitry Baryshkov
1 sibling, 0 replies; 8+ messages in thread
From: Maxime Ripard @ 2025-06-23 6:40 UTC (permalink / raw)
To: Luca Ceresoli
Cc: dri-devel, linux-kernel, Andrzej Hajda, Anusha Srivatsa,
David Airlie, Dmitry Baryshkov, Hui Pu, Jernej Skrabec,
Jonas Karlman, Laurent Pinchart, Maarten Lankhorst, Maxime Ripard,
Neil Armstrong, Robert Foss, Simona Vetter, Thomas Petazzoni,
Thomas Zimmermann
On Fri, 20 Jun 2025 17:59:55 +0200, Luca Ceresoli wrote:
> To the best of my knowledge, all drivers in the mainline kernel adding a
> DRM bridge are now converted to using devm_drm_bridge_alloc() for
> allocation and initialization. Among others this ensures initialization of
> the bridge refcount, allowing dynamic allocation lifetime.
>
>
> [ ... ]
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Thanks!
Maxime
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
2025-06-20 15:59 ` [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc() Luca Ceresoli
2025-06-23 6:40 ` Maxime Ripard
@ 2025-06-23 11:06 ` Dmitry Baryshkov
2025-06-23 11:57 ` Luca Ceresoli
1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Baryshkov @ 2025-06-23 11:06 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
Cc: Anusha Srivatsa, dri-devel, linux-kernel, Hui Pu,
Thomas Petazzoni
On 20/06/2025 18:59, Luca Ceresoli wrote:
> To the best of my knowledge, all drivers in the mainline kernel adding a
> DRM bridge are now converted to using devm_drm_bridge_alloc() for
> allocation and initialization. Among others this ensures initialization of
> the bridge refcount, allowing dynamic allocation lifetime.
>
> devm_drm_bridge_alloc() is now mandatory for all new bridges. Code using
> the old pattern ([devm_]kzalloc + filling the struct fields +
> drm_bridge_add) is not allowed anymore.
>
> Any drivers that might have been missed during the conversion, patches in
> flight towards mainline and out-of-tre drivers still using the old pattern
> will already be caught by a warning looking like:
>
> ------------[ cut here ]------------
> refcount_t: addition on 0; use-after-free.
> WARNING: CPU: 2 PID: 83 at lib/refcount.c:25 refcount_warn_saturate+0x120/0x148
> [...]
> Call trace:
> refcount_warn_saturate+0x120/0x148 (P)
> drm_bridge_get.part.0+0x70/0x98 [drm]
> drm_bridge_add+0x34/0x108 [drm]
> sn65dsi83_probe+0x200/0x480 [ti_sn65dsi83]
> [...]
>
> This warning comes from the refcount code and happens because
> drm_bridge_add() is increasing the refcount, which is uninitialized and
> thus initially zero.
>
> Having a warning and the corresponding stack trace is surely useful, but
> the warning text does not clarify the root problem nor how to fix it.
>
> Add a DRM_WARN() just before increasing the refcount, so the log will be
> much more readable:
>
> [drm] DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()
> ------------[ cut here ]------------
> refcount_t: addition on 0; use-after-free.
> [...etc...]
>
> A DRM_WARN is used because drm_warn and drm_WARN require a struct
> drm_device pointer which is not yet available when adding a bridge.
>
> Do not print the dev_name() in the warning because struct drm_bridge has no
> pointer to the struct device. The affected driver should be easy to catch
> based on the following stack trace however.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Changes in v9:
> - change warning trigger from "refcount != 1" to "container not NULL"
>
> This patch was added in v8
> ---
> drivers/gpu/drm/drm_bridge.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index f001bbe95559aabf0aac9f25f89250ad4e1ad9c8..0b450b334afd82e0460f18fdd248f79d0a2b153d 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -295,6 +295,9 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
> */
> void drm_bridge_add(struct drm_bridge *bridge)
Can we rename this function, making sure that noone can call it
directly? E.g. adding two underscores might point out that is is an
internal API.
> {
> + if (!bridge->container)
> + DRM_WARN("DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()\n");
> +
> drm_bridge_get(bridge);
>
> mutex_init(&bridge->hpd_mutex);
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
2025-06-23 11:06 ` Dmitry Baryshkov
@ 2025-06-23 11:57 ` Luca Ceresoli
0 siblings, 0 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-23 11:57 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Anusha Srivatsa,
dri-devel, linux-kernel, Hui Pu, Thomas Petazzoni
Hello Dmitry,
thanks for reviewing!
On Mon, 23 Jun 2025 14:06:43 +0300
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote:
> On 20/06/2025 18:59, Luca Ceresoli wrote:
> > To the best of my knowledge, all drivers in the mainline kernel adding a
> > DRM bridge are now converted to using devm_drm_bridge_alloc() for
> > allocation and initialization. Among others this ensures initialization of
> > the bridge refcount, allowing dynamic allocation lifetime.
> >
> > devm_drm_bridge_alloc() is now mandatory for all new bridges. Code using
> > the old pattern ([devm_]kzalloc + filling the struct fields +
> > drm_bridge_add) is not allowed anymore.
> >
> > Any drivers that might have been missed during the conversion, patches in
> > flight towards mainline and out-of-tre drivers still using the old pattern
> > will already be caught by a warning looking like:
> >
> > ------------[ cut here ]------------
> > refcount_t: addition on 0; use-after-free.
> > WARNING: CPU: 2 PID: 83 at lib/refcount.c:25 refcount_warn_saturate+0x120/0x148
> > [...]
> > Call trace:
> > refcount_warn_saturate+0x120/0x148 (P)
> > drm_bridge_get.part.0+0x70/0x98 [drm]
> > drm_bridge_add+0x34/0x108 [drm]
> > sn65dsi83_probe+0x200/0x480 [ti_sn65dsi83]
> > [...]
> >
> > This warning comes from the refcount code and happens because
> > drm_bridge_add() is increasing the refcount, which is uninitialized and
> > thus initially zero.
> >
> > Having a warning and the corresponding stack trace is surely useful, but
> > the warning text does not clarify the root problem nor how to fix it.
> >
> > Add a DRM_WARN() just before increasing the refcount, so the log will be
> > much more readable:
> >
> > [drm] DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()
> > ------------[ cut here ]------------
> > refcount_t: addition on 0; use-after-free.
> > [...etc...]
> >
> > A DRM_WARN is used because drm_warn and drm_WARN require a struct
> > drm_device pointer which is not yet available when adding a bridge.
> >
> > Do not print the dev_name() in the warning because struct drm_bridge has no
> > pointer to the struct device. The affected driver should be easy to catch
> > based on the following stack trace however.
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> >
> > ---
> >
> > Changes in v9:
> > - change warning trigger from "refcount != 1" to "container not NULL"
> >
> > This patch was added in v8
> > ---
> > drivers/gpu/drm/drm_bridge.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> > index f001bbe95559aabf0aac9f25f89250ad4e1ad9c8..0b450b334afd82e0460f18fdd248f79d0a2b153d 100644
> > --- a/drivers/gpu/drm/drm_bridge.c
> > +++ b/drivers/gpu/drm/drm_bridge.c
> > @@ -295,6 +295,9 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
> > */
> > void drm_bridge_add(struct drm_bridge *bridge)
>
> Can we rename this function, making sure that noone can call it
> directly? E.g. adding two underscores might point out that is is an
> internal API.
I'm afraid I don't think this would be correct. Every bridge driver is
expected to call drm_bridge_add() at the end of probe/initialization,
to make the DRM subsystem aware that this bridge is ready for being
used.
The point of this patch, which is a completion to [1], is to ensure
that all drivers use the "new" process:
1. bridge = devm_drm_bridge_alloc()
2. drm_bridge_add(bridge)
and there are no users of the old process:
1. bridge = [devm_]kzalloc()
2. drm_bridge_add(bridge)
Does this addresses your concern?
[1] https://cgit.freedesktop.org/drm/drm-misc/commit/?id=b3f13e00a8de351832df7d628a15ca4db49ca94f
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern
2025-06-20 15:59 [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
` (2 preceding siblings ...)
2025-06-20 15:59 ` [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc() Luca Ceresoli
@ 2025-06-26 13:16 ` Luca Ceresoli
3 siblings, 0 replies; 8+ messages in thread
From: Luca Ceresoli @ 2025-06-26 13:16 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, Luca Ceresoli
Cc: Dmitry Baryshkov, Anusha Srivatsa, dri-devel, linux-kernel,
Hui Pu, Thomas Petazzoni
On Fri, 20 Jun 2025 17:59:52 +0200, Luca Ceresoli wrote:
> This small series adds drm_bridge_get/put() calls where applicable in the
> bridge core code, and adds a warning when the old allocation patter is
> used.
>
> This is part of the work towards removal of bridges from a still existing
> DRM pipeline without use-after-free.
>
> [...]
Applied, thanks!
[1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove()
commit: a7748dd127ea8d9cd2d9d942ef21c85e5569bb73
[2/3] drm/bridge: get/put the bridge reference in drm_bridge_attach/detach()
commit: 94d50c1a2ca31d80f12d9c2bdbc41437751e320c
[3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc()
commit: e6565e76e977422cb9e51fe872a2bcfdbc321b7b
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-26 13:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 15:59 [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 1/3] drm/bridge: get/put the bridge reference in drm_bridge_add/remove() Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 2/3] drm/bridge: get/put the bridge reference in drm_bridge_attach/detach() Luca Ceresoli
2025-06-20 15:59 ` [PATCH v9 3/3] drm/bridge: add warning for bridges not using devm_drm_bridge_alloc() Luca Ceresoli
2025-06-23 6:40 ` Maxime Ripard
2025-06-23 11:06 ` Dmitry Baryshkov
2025-06-23 11:57 ` Luca Ceresoli
2025-06-26 13:16 ` [PATCH v9 0/3] drm/bridge: get/put the bridge reference in drm_bridge.c, warn on old alloc pattern Luca Ceresoli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).