* [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4
@ 2026-04-02 16:27 Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
` (5 more replies)
0 siblings, 6 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-02 16:27 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel, Luca Ceresoli
This series converts many DRM drivers from the now deprecated
of_drm_find_bridge() to its replacement of_drm_find_and_get_bridge() which
allows correct bridge refcounting.
This is part of the work to support hotplug of DRM bridges. The grand plan
was discussed in [0].
Here's the work breakdown (➜ marks the current series):
1. ➜ add refcounting to DRM bridges struct drm_bridge,
based on devm_drm_bridge_alloc()
A. ✔ add new alloc API and refcounting (v6.16)
B. ✔ convert all bridge drivers to new API (v6.17)
C. ✔ kunit tests (v6.17)
D. ✔ add get/put to drm_bridge_add/remove() + attach/detach()
and warn on old allocation pattern (v6.17)
E. ➜ add get/put on drm_bridge accessors
1. ✔ drm_bridge_chain_get_first_bridge(), add cleanup action (v6.18)
2. ✔ drm_bridge_get_prev_bridge() (v6.18)
3. ✔ drm_bridge_get_next_bridge() (v6.19)
4. ✔ drm_for_each_bridge_in_chain() (v6.19)
5. ✔ drm_bridge_connector_init (v6.19)
6. … protect encoder bridge chain with a mutex
7. ➜ of_drm_find_bridge
a. ✔ add of_drm_get_bridge() (v7.0),
convert basic direct users (v7.0-v7.1)
b. ✔ convert direct of_drm_get_bridge() users, part 2 (v7.0)
c. ✔ convert direct of_drm_get_bridge() users, part 3 (v7.0)
d. ➜ convert direct of_drm_get_bridge() users, part 4
(some v7.1, some pending)
e. convert bridge-only drm_of_find_panel_or_bridge() users
8. drm_of_find_panel_or_bridge, *_of_get_bridge
9. ✔ enforce drm_bridge_add before drm_bridge_attach (v6.19)
F. ✔ debugfs improvements
1. ✔ add top-level 'bridges' file (v6.16)
2. ✔ show refcount and list lingering bridges (v6.19)
2. … handle gracefully atomic updates during bridge removal
A. ✔ Add drm_bridge_enter/exit() to protect device resources (v7.0)
B. … protect private_obj removal from list
C. ✔ Add drm_bridge_clear_and_put() (v7.1)
3. … DSI host-device driver interaction
4. ✔ removing the need for the "always-disconnected" connector
5. … Migrate i.MX LCDIF driver to bridge-connector
6. DRM bridge hotplug
A. Bridge hotplug management in the DRM core
B. Device tree description
[0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/#t
This work is a continuation of the work to correctly handle bridge
refcounting for existing of_drm_find_bridge(). The ground work is in:
- commit 293a8fd7721a ("drm/bridge: add of_drm_find_and_get_bridge()")
- commit 9da0e06abda8 ("drm/bridge: deprecate of_drm_find_bridge()")
- commit 3fdeae134ba9 ("drm/bridge: add next_bridge pointer to struct drm_bridge")
The whole conversion is split in multiple series to make the review process
a bit smoother:
- Part 2: mostly drivers in drivers/gpu/drm/bridge [2], applied
- Part 3: other drivers, low-medium complexity [3], applied
- Part 4: other drivers, converting the most complex cases [this series]
[2] https://lore.kernel.org/lkml/20260109-drm-bridge-alloc-getput-drm_of_find_bridge-2-v2-0-8bad3ef90b9f@bootlin.com/
[3] https://lore.kernel.org/lkml/20260109-drm-bridge-alloc-getput-drm_of_find_bridge-3-v2-0-8d7a3dbacdf4@bootlin.com/
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v4:
- Patch 3: many improvements as suggested by Laurent
- Patch 1: add comment after Laurent's suggestion on patch 3
- Link to v3: https://lore.kernel.org/r/20260318-drm-bridge-alloc-getput-drm_of_find_bridge-4-v3-0-10f502520357@bootlin.com
Changes in v3:
- Rebased on current drm-misc-next (on v7.0-rc3)
- Dropped patches already applied
- Link to v2: https://lore.kernel.org/r/20260131-drm-bridge-alloc-getput-drm_of_find_bridge-4-v2-0-e081bcdc1467@bootlin.com
Changes in v2:
- Removed bouncing recipient: Edmund Dea <edmund.j.dea@intel.com>
- used break instead of a warning patch 3, adapted patch 4 as a
consequence
- Link to v1: https://lore.kernel.org/r/20260116-drm-bridge-alloc-getput-drm_of_find_bridge-4-v1-0-e34b38f50d27@bootlin.com
---
Luca Ceresoli (4):
drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
drm/kmb/dsi: convert to of_drm_find_and_get_bridge()
drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge()
drm/omap: dss: convert to of_drm_find_and_get_bridge()
drivers/gpu/drm/kmb/kmb_dsi.c | 2 +-
drivers/gpu/drm/omapdrm/dss/output.c | 11 +++++--
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 35 +++++++++++++++++++----
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 +
drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++
drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c | 19 +++++++++---
6 files changed, 56 insertions(+), 14 deletions(-)
---
base-commit: 3bb828758df6ad0fd40e63fa2372eb896c9a7199
change-id: 20260107-drm-bridge-alloc-getput-drm_of_find_bridge-4-0a92b361fe9d
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
@ 2026-04-02 16:27 ` Luca Ceresoli
2026-04-08 15:44 ` Louis Chauvet
2026-04-02 16:27 ` [PATCH v4 2/4] drm/kmb/dsi: " Luca Ceresoli
` (4 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-02 16:27 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put when done.
This is made somewhat simpler by the fact that 'bridge' is a local
variable.
However we need to handle both branches of the main if().
In the 'else' case, just switch to of_drm_find_and_get_bridge() to ensure
the bridge is not freed while in use in the function tail
(drm_bridge_attach() mainly).
In the 'then' case, devm_drm_panel_bridge_add_typed() already increments
the refcount using devres which ties the bridge allocation lifetime to the
device lifetime, so we would not need to do anything. However to have the
same behaviour in both branches take an additional reference here, so that
the bridge needs to be put whichever branch is taken without more
complicated logic. Ensure to clear the bridge pointer however, to avoid
calling drm_bridge_put() on an ERR_PTR.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v4:
- Added comment to clarify the additional drm_bridge_get() in the
panel_bridge case (keeping the R-by and T-by tags as it's just a comment)
---
drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
index 5e6dd16705e6..9edb90059830 100644
--- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
+++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
@@ -67,7 +67,7 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
{
struct rzg2l_du_encoder *renc;
struct drm_connector *connector;
- struct drm_bridge *bridge;
+ struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
int ret;
/*
@@ -83,10 +83,21 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
DRM_MODE_CONNECTOR_DPI);
- if (IS_ERR(bridge))
- return PTR_ERR(bridge);
+ if (IS_ERR(bridge)) {
+ // Inhibit the cleanup action on an ERR_PTR
+ ret = PTR_ERR(bridge);
+ bridge = NULL;
+ return ret;
+ }
+
+ /*
+ * The reference taken by devm_drm_panel_bridge_add_typed() is
+ * released automatically. Take a second one for the __free()
+ * when this function will return.
+ */
+ drm_bridge_get(bridge);
} else {
- bridge = of_drm_find_bridge(enc_node);
+ bridge = of_drm_find_and_get_bridge(enc_node);
if (!bridge)
return -EPROBE_DEFER;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 2/4] drm/kmb/dsi: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
@ 2026-04-02 16:27 ` Luca Ceresoli
2026-04-08 15:44 ` Louis Chauvet
2026-04-02 16:27 ` [PATCH v4 3/4] drm: rcar-du: encoder: " Luca Ceresoli
` (3 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-02 16:27 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference.
This driver has global variables for the DSI host and DSI device, and code
to allocate them on probe but no code to free them when on remove. So it
does not at all support removal, and not even multiple instances. For this
reason putting the reference would be pointless here.
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 aeb2f9f98f23..febca939bd01 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 = of_drm_find_and_get_bridge(encoder_node);
of_node_put(dsi_out);
of_node_put(encoder_node);
if (!adv_bridge) {
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 3/4] drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 2/4] drm/kmb/dsi: " Luca Ceresoli
@ 2026-04-02 16:27 ` Luca Ceresoli
2026-04-08 16:03 ` Louis Chauvet
2026-04-02 16:27 ` [PATCH v4 4/4] drm/omap: dss: " Luca Ceresoli
` (2 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-02 16:27 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put when done.
We need to handle the two cases: when a panel_bridge is added and when it
isn't. So:
* in the 'else' case a panel_bridge is not added and bridge is found: use
of_drm_find_and_get_bridge() to get a reference to the found bridge
* in the 'then' case a panel_bridge is found using a devm function which
already takes a refcount and will put it on removal, but we need to take
another so the following code in this function always get exactly one
reference that it needs to put
In order to put the reference, add the needed drm_bridge_put() calls in the
existing cleanup function.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v4:
- fixed conflict after commit 3bce3fdd1ff2 ("drm: rcar-du: Don't leak
device_link to CMM")
- Use ARRAY_SIZE() instead of define
- Unsigned variable for never-negative variable
- Added comment to clarify the additional drm_bridge_get() in the
panel_bridge case
- Coding style (C comments, line wrap at 80)
---
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 35 +++++++++++++++++++----
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 +
drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
index 7ecec7b04a8d..0ae06edf3066 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
@@ -51,7 +51,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
{
struct rcar_du_encoder *renc;
struct drm_connector *connector;
- struct drm_bridge *bridge;
+ struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
int ret;
/*
@@ -69,20 +69,33 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
DRM_MODE_CONNECTOR_DPI);
- if (IS_ERR(bridge))
- return PTR_ERR(bridge);
+ if (IS_ERR(bridge)) {
+ /* Inhibit the cleanup action on an ERR_PTR */
+ ret = PTR_ERR(bridge);
+ bridge = NULL;
+ return ret;
+ }
+
+ /*
+ * The reference taken by devm_drm_panel_bridge_add_typed() is
+ * released automatically. Take a second one for the __free()
+ * when this function will return.
+ */
+ drm_bridge_get(bridge);
} else {
- bridge = of_drm_find_bridge(enc_node);
+ bridge = of_drm_find_and_get_bridge(enc_node);
if (!bridge)
return -EPROBE_DEFER;
if (output == RCAR_DU_OUTPUT_LVDS0 ||
output == RCAR_DU_OUTPUT_LVDS1)
- rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge;
+ rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =
+ drm_bridge_get(bridge);
if (output == RCAR_DU_OUTPUT_DSI0 ||
output == RCAR_DU_OUTPUT_DSI1)
- rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] = bridge;
+ rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] =
+ drm_bridge_get(bridge);
}
/*
@@ -135,3 +148,13 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
return drm_connector_attach_encoder(connector, &renc->base);
}
+
+void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(rcdu->lvds); i++)
+ drm_bridge_put(rcdu->lvds[i]);
+ for (i = 0; i < ARRAY_SIZE(rcdu->dsi); i++)
+ drm_bridge_put(rcdu->dsi[i]);
+}
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
index e5ec8fbb3979..b2b5e93f30f8 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
@@ -25,5 +25,6 @@ struct rcar_du_encoder {
int rcar_du_encoder_init(struct rcar_du_device *rcdu,
enum rcar_du_output output,
struct device_node *enc_node);
+void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu);
#endif /* __RCAR_DU_ENCODER_H__ */
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
index b2d0e4651e35..1119c84e5fe9 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
@@ -832,6 +832,8 @@ static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res)
put_device(cmm->dev);
}
+
+ rcar_du_encoder_cleanup(rcdu);
}
int rcar_du_modeset_init(struct rcar_du_device *rcdu)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 4/4] drm/omap: dss: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
` (2 preceding siblings ...)
2026-04-02 16:27 ` [PATCH v4 3/4] drm: rcar-du: encoder: " Luca Ceresoli
@ 2026-04-02 16:27 ` Luca Ceresoli
2026-04-08 16:14 ` Louis Chauvet
2026-04-07 9:40 ` [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Linus Walleij
2026-04-09 12:59 ` (subset) " Luca Ceresoli
5 siblings, 1 reply; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-02 16:27 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel, Luca Ceresoli
of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put when done.
omapdss_device_init_output() can take one bridge pointer in out->bridge or
two pointers in out->bridge and out->next_bridge. Ensure each has a
corresponding drm_bridge_get() and add drm_bridge_put() calls in the
cleanup code.
Also slightly change the initial code assigning out->panel and out->bridge
to ensure and clarify that either out->panel or out->bridge is set in the
function prologue, not both. If both were set, the 'if (out->panel){...}'
code that follows would overwrite out->bridge without having put the
reference.
Finally, take a reference in case a panel_bridge is added using
drm_panel_bridge_add(). This ensures we always need to put a reference,
which came either from of_drm_find_and_get_bridge() or by the
drm_panel_bridge_add+drm_bridge_get() branch.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/omapdrm/dss/output.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 7378e855c278..ca891aba3820 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -30,11 +30,13 @@ int omapdss_device_init_output(struct omap_dss_device *out,
return 0;
}
- out->bridge = of_drm_find_bridge(remote_node);
out->panel = of_drm_find_panel(remote_node);
if (IS_ERR(out->panel))
out->panel = NULL;
+ if (!out->panel)
+ out->bridge = of_drm_find_and_get_bridge(remote_node);
+
of_node_put(remote_node);
if (out->panel) {
@@ -49,7 +51,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
goto error;
}
- out->bridge = bridge;
+ out->bridge = drm_bridge_get(bridge);
}
if (local_bridge) {
@@ -59,7 +61,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
}
out->next_bridge = out->bridge;
- out->bridge = local_bridge;
+ out->bridge = drm_bridge_get(local_bridge);
}
if (!out->bridge) {
@@ -79,6 +81,9 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
if (out->bridge && out->panel)
drm_panel_bridge_remove(out->next_bridge ?
out->next_bridge : out->bridge);
+
+ drm_bridge_put(out->next_bridge);
+ drm_bridge_put(out->bridge);
}
void dss_mgr_set_timings(struct omap_dss_device *dssdev,
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
` (3 preceding siblings ...)
2026-04-02 16:27 ` [PATCH v4 4/4] drm/omap: dss: " Luca Ceresoli
@ 2026-04-07 9:40 ` Linus Walleij
2026-04-09 12:59 ` (subset) " Luca Ceresoli
5 siblings, 0 replies; 15+ messages in thread
From: Linus Walleij @ 2026-04-07 9:40 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen, Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel,
linux-renesas-soc, linux-kernel
On Thu, Apr 2, 2026 at 6:27 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> This series converts many DRM drivers from the now deprecated
> of_drm_find_bridge() to its replacement of_drm_find_and_get_bridge() which
> allows correct bridge refcounting.
>
> This is part of the work to support hotplug of DRM bridges. The grand plan
> was discussed in [0].
All makes sense to me. The series:
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 ` [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
@ 2026-04-08 15:44 ` Louis Chauvet
2026-04-08 17:39 ` Luca Ceresoli
0 siblings, 1 reply; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 15:44 UTC (permalink / raw)
To: Luca Ceresoli, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
On 4/2/26 18:27, Luca Ceresoli wrote:
> of_drm_find_bridge() is deprecated. Move to its replacement
> of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
> is put when done.
>
> This is made somewhat simpler by the fact that 'bridge' is a local
> variable.
>
> However we need to handle both branches of the main if().
>
> In the 'else' case, just switch to of_drm_find_and_get_bridge() to ensure
> the bridge is not freed while in use in the function tail
> (drm_bridge_attach() mainly).
>
> In the 'then' case, devm_drm_panel_bridge_add_typed() already increments
> the refcount using devres which ties the bridge allocation lifetime to the
> device lifetime, so we would not need to do anything. However to have the
> same behaviour in both branches take an additional reference here, so that
> the bridge needs to be put whichever branch is taken without more
> complicated logic. Ensure to clear the bridge pointer however, to avoid
> calling drm_bridge_put() on an ERR_PTR.
>
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Changes in v4:
> - Added comment to clarify the additional drm_bridge_get() in the
> panel_bridge case (keeping the R-by and T-by tags as it's just a comment)
> ---
> drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
> index 5e6dd16705e6..9edb90059830 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c
> @@ -67,7 +67,7 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
> {
> struct rzg2l_du_encoder *renc;
> struct drm_connector *connector;
> - struct drm_bridge *bridge;
> + struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
> int ret;
>
> /*
> @@ -83,10 +83,21 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
>
> bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
> DRM_MODE_CONNECTOR_DPI);
> - if (IS_ERR(bridge))
> - return PTR_ERR(bridge);
> + if (IS_ERR(bridge)) {
> + // Inhibit the cleanup action on an ERR_PTR
> + ret = PTR_ERR(bridge);
> + bridge = NULL;
> + return ret;
> + }
Can't you use
https://elixir.bootlin.com/linux/v6.19.11/source/include/linux/cleanup.h#L230?
return PTR_ERR(no_free_ptr(bridge));
With or without this modification:
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> +
> + /*
> + * The reference taken by devm_drm_panel_bridge_add_typed() is
> + * released automatically. Take a second one for the __free()
> + * when this function will return.
> + */
> + drm_bridge_get(bridge);
> } else {
> - bridge = of_drm_find_bridge(enc_node);
> + bridge = of_drm_find_and_get_bridge(enc_node);
> if (!bridge)
> return -EPROBE_DEFER;
> }
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 2/4] drm/kmb/dsi: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 ` [PATCH v4 2/4] drm/kmb/dsi: " Luca Ceresoli
@ 2026-04-08 15:44 ` Louis Chauvet
0 siblings, 0 replies; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 15:44 UTC (permalink / raw)
To: Luca Ceresoli, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
On 4/2/26 18:27, Luca Ceresoli wrote:
> of_drm_find_bridge() is deprecated. Move to its replacement
> of_drm_find_and_get_bridge() which gets a bridge reference.
>
> This driver has global variables for the DSI host and DSI device, and code
> to allocate them on probe but no code to free them when on remove. So it
> does not at all support removal, and not even multiple instances. For this
> reason putting the reference would be pointless here.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Louis Chauvet <louis.chauvet@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 aeb2f9f98f23..febca939bd01 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 = of_drm_find_and_get_bridge(encoder_node);
> of_node_put(dsi_out);
> of_node_put(encoder_node);
> if (!adv_bridge) {
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 3/4] drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 ` [PATCH v4 3/4] drm: rcar-du: encoder: " Luca Ceresoli
@ 2026-04-08 16:03 ` Louis Chauvet
2026-04-08 21:31 ` Laurent Pinchart
0 siblings, 1 reply; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 16:03 UTC (permalink / raw)
To: Luca Ceresoli, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
On 4/2/26 18:27, Luca Ceresoli wrote:
> of_drm_find_bridge() is deprecated. Move to its replacement
> of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
> is put when done.
>
> We need to handle the two cases: when a panel_bridge is added and when it
> isn't. So:
>
> * in the 'else' case a panel_bridge is not added and bridge is found: use
> of_drm_find_and_get_bridge() to get a reference to the found bridge
> * in the 'then' case a panel_bridge is found using a devm function which
> already takes a refcount and will put it on removal, but we need to take
> another so the following code in this function always get exactly one
> reference that it needs to put
>
> In order to put the reference, add the needed drm_bridge_put() calls in the
> existing cleanup function.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Changes in v4:
> - fixed conflict after commit 3bce3fdd1ff2 ("drm: rcar-du: Don't leak
> device_link to CMM")
> - Use ARRAY_SIZE() instead of define
> - Unsigned variable for never-negative variable
> - Added comment to clarify the additional drm_bridge_get() in the
> panel_bridge case
> - Coding style (C comments, line wrap at 80)
> ---
> drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 35 +++++++++++++++++++----
> drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 +
> drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++
> 3 files changed, 32 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> index 7ecec7b04a8d..0ae06edf3066 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> @@ -51,7 +51,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> {
> struct rcar_du_encoder *renc;
> struct drm_connector *connector;
> - struct drm_bridge *bridge;
> + struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
> int ret;
>
> /*
> @@ -69,20 +69,33 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>
> bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
> DRM_MODE_CONNECTOR_DPI);
> - if (IS_ERR(bridge))
> - return PTR_ERR(bridge);
> + if (IS_ERR(bridge)) {
> + /* Inhibit the cleanup action on an ERR_PTR */
> + ret = PTR_ERR(bridge);
> + bridge = NULL;
> + return ret;
Same as before, can you use no_free_ptr?
With or without this modification:
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> + }
> +
> + /*
> + * The reference taken by devm_drm_panel_bridge_add_typed() is
> + * released automatically. Take a second one for the __free()
> + * when this function will return.
> + */
> + drm_bridge_get(bridge);
> } else {
> - bridge = of_drm_find_bridge(enc_node);
> + bridge = of_drm_find_and_get_bridge(enc_node);
> if (!bridge)
> return -EPROBE_DEFER;
>
> if (output == RCAR_DU_OUTPUT_LVDS0 ||
> output == RCAR_DU_OUTPUT_LVDS1)
> - rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge;
> + rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =
> + drm_bridge_get(bridge);
>
> if (output == RCAR_DU_OUTPUT_DSI0 ||
> output == RCAR_DU_OUTPUT_DSI1)
> - rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] = bridge;
> + rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] =
> + drm_bridge_get(bridge);
> }
>
> /*
> @@ -135,3 +148,13 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>
> return drm_connector_attach_encoder(connector, &renc->base);
> }
> +
> +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(rcdu->lvds); i++)
> + drm_bridge_put(rcdu->lvds[i]);
> + for (i = 0; i < ARRAY_SIZE(rcdu->dsi); i++)
> + drm_bridge_put(rcdu->dsi[i]);
> +}
> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> index e5ec8fbb3979..b2b5e93f30f8 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> @@ -25,5 +25,6 @@ struct rcar_du_encoder {
> int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> enum rcar_du_output output,
> struct device_node *enc_node);
> +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu);
>
> #endif /* __RCAR_DU_ENCODER_H__ */
> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> index b2d0e4651e35..1119c84e5fe9 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> @@ -832,6 +832,8 @@ static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res)
>
> put_device(cmm->dev);
> }
> +
> + rcar_du_encoder_cleanup(rcdu);
> }
>
> int rcar_du_modeset_init(struct rcar_du_device *rcdu)
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 4/4] drm/omap: dss: convert to of_drm_find_and_get_bridge()
2026-04-02 16:27 ` [PATCH v4 4/4] drm/omap: dss: " Luca Ceresoli
@ 2026-04-08 16:14 ` Louis Chauvet
0 siblings, 0 replies; 15+ messages in thread
From: Louis Chauvet @ 2026-04-08 16:14 UTC (permalink / raw)
To: Luca Ceresoli, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
On 4/2/26 18:27, Luca Ceresoli wrote:
> of_drm_find_bridge() is deprecated. Move to its replacement
> of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
> is put when done.
>
> omapdss_device_init_output() can take one bridge pointer in out->bridge or
> two pointers in out->bridge and out->next_bridge. Ensure each has a
> corresponding drm_bridge_get() and add drm_bridge_put() calls in the
> cleanup code.
>
> Also slightly change the initial code assigning out->panel and out->bridge
> to ensure and clarify that either out->panel or out->bridge is set in the
> function prologue, not both. If both were set, the 'if (out->panel){...}'
> code that follows would overwrite out->bridge without having put the
> reference.
>
> Finally, take a reference in case a panel_bridge is added using
> drm_panel_bridge_add(). This ensures we always need to put a reference,
> which came either from of_drm_find_and_get_bridge() or by the
> drm_panel_bridge_add+drm_bridge_get() branch.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
> drivers/gpu/drm/omapdrm/dss/output.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 7378e855c278..ca891aba3820 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -30,11 +30,13 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> return 0;
> }
>
> - out->bridge = of_drm_find_bridge(remote_node);
> out->panel = of_drm_find_panel(remote_node);
> if (IS_ERR(out->panel))
> out->panel = NULL;
>
> + if (!out->panel)
> + out->bridge = of_drm_find_and_get_bridge(remote_node);
> +
> of_node_put(remote_node);
>
> if (out->panel) {
> @@ -49,7 +51,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> goto error;
> }
>
> - out->bridge = bridge;
> + out->bridge = drm_bridge_get(bridge);
> }
>
> if (local_bridge) {
> @@ -59,7 +61,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> }
>
> out->next_bridge = out->bridge;
> - out->bridge = local_bridge;
> + out->bridge = drm_bridge_get(local_bridge);
> }
>
> if (!out->bridge) {
> @@ -79,6 +81,9 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
> if (out->bridge && out->panel)
> drm_panel_bridge_remove(out->next_bridge ?
> out->next_bridge : out->bridge);
> +
> + drm_bridge_put(out->next_bridge);
> + drm_bridge_put(out->bridge);
> }
>
> void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
2026-04-08 15:44 ` Louis Chauvet
@ 2026-04-08 17:39 ` Luca Ceresoli
2026-04-08 21:33 ` Laurent Pinchart
0 siblings, 1 reply; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-08 17:39 UTC (permalink / raw)
To: Louis Chauvet, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Laurent Pinchart,
Tomi Valkeinen, Kieran Bingham, Geert Uytterhoeven, Magnus Damm,
Tomi Valkeinen
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
Hi Louis,
On Wed Apr 8, 2026 at 5:44 PM CEST, Louis Chauvet wrote:
>> @@ -83,10 +83,21 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
>>
>> bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
>> DRM_MODE_CONNECTOR_DPI);
>> - if (IS_ERR(bridge))
>> - return PTR_ERR(bridge);
>> + if (IS_ERR(bridge)) {
>> + // Inhibit the cleanup action on an ERR_PTR
>> + ret = PTR_ERR(bridge);
>> + bridge = NULL;
>> + return ret;
>> + }
>
> Can't you use
> https://elixir.bootlin.com/linux/v6.19.11/source/include/linux/cleanup.h#L230?
>
> return PTR_ERR(no_free_ptr(bridge));
Ah, nice cleanup indeed! However, being this patch already reviewed ans
tested, I'll postpone this cleanup to a later series.
> With or without this modification:
>
> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Thanks!
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 3/4] drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge()
2026-04-08 16:03 ` Louis Chauvet
@ 2026-04-08 21:31 ` Laurent Pinchart
0 siblings, 0 replies; 15+ messages in thread
From: Laurent Pinchart @ 2026-04-08 21:31 UTC (permalink / raw)
To: Louis Chauvet
Cc: Luca Ceresoli, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen, Hui Pu, Ian Ray,
Thomas Petazzoni, dri-devel, linux-renesas-soc, linux-kernel
On Wed, Apr 08, 2026 at 06:03:01PM +0200, Louis Chauvet wrote:
> On 4/2/26 18:27, Luca Ceresoli wrote:
> > of_drm_find_bridge() is deprecated. Move to its replacement
> > of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
> > is put when done.
> >
> > We need to handle the two cases: when a panel_bridge is added and when it
> > isn't. So:
> >
> > * in the 'else' case a panel_bridge is not added and bridge is found: use
> > of_drm_find_and_get_bridge() to get a reference to the found bridge
> > * in the 'then' case a panel_bridge is found using a devm function which
> > already takes a refcount and will put it on removal, but we need to take
> > another so the following code in this function always get exactly one
> > reference that it needs to put
> >
> > In order to put the reference, add the needed drm_bridge_put() calls in the
> > existing cleanup function.
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> >
> > ---
> >
> > Changes in v4:
> > - fixed conflict after commit 3bce3fdd1ff2 ("drm: rcar-du: Don't leak
> > device_link to CMM")
> > - Use ARRAY_SIZE() instead of define
> > - Unsigned variable for never-negative variable
> > - Added comment to clarify the additional drm_bridge_get() in the
> > panel_bridge case
> > - Coding style (C comments, line wrap at 80)
> > ---
> > drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 35 +++++++++++++++++++----
> > drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 +
> > drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++
> > 3 files changed, 32 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> > index 7ecec7b04a8d..0ae06edf3066 100644
> > --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> > +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c
> > @@ -51,7 +51,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> > {
> > struct rcar_du_encoder *renc;
> > struct drm_connector *connector;
> > - struct drm_bridge *bridge;
> > + struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
> > int ret;
> >
> > /*
> > @@ -69,20 +69,33 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> >
> > bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
> > DRM_MODE_CONNECTOR_DPI);
> > - if (IS_ERR(bridge))
> > - return PTR_ERR(bridge);
> > + if (IS_ERR(bridge)) {
> > + /* Inhibit the cleanup action on an ERR_PTR */
> > + ret = PTR_ERR(bridge);
> > + bridge = NULL;
> > + return ret;
>
> Same as before, can you use no_free_ptr?
That would be nice. You could then drop the comment, as no_free_ptr
makes it explicit.
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> With or without this modification:
>
> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
>
> > + }
> > +
> > + /*
> > + * The reference taken by devm_drm_panel_bridge_add_typed() is
> > + * released automatically. Take a second one for the __free()
> > + * when this function will return.
> > + */
> > + drm_bridge_get(bridge);
> > } else {
> > - bridge = of_drm_find_bridge(enc_node);
> > + bridge = of_drm_find_and_get_bridge(enc_node);
> > if (!bridge)
> > return -EPROBE_DEFER;
> >
> > if (output == RCAR_DU_OUTPUT_LVDS0 ||
> > output == RCAR_DU_OUTPUT_LVDS1)
> > - rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge;
> > + rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =
> > + drm_bridge_get(bridge);
> >
> > if (output == RCAR_DU_OUTPUT_DSI0 ||
> > output == RCAR_DU_OUTPUT_DSI1)
> > - rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] = bridge;
> > + rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] =
> > + drm_bridge_get(bridge);
> > }
> >
> > /*
> > @@ -135,3 +148,13 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> >
> > return drm_connector_attach_encoder(connector, &renc->base);
> > }
> > +
> > +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu)
> > +{
> > + unsigned int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(rcdu->lvds); i++)
> > + drm_bridge_put(rcdu->lvds[i]);
> > + for (i = 0; i < ARRAY_SIZE(rcdu->dsi); i++)
> > + drm_bridge_put(rcdu->dsi[i]);
> > +}
> > diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> > index e5ec8fbb3979..b2b5e93f30f8 100644
> > --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> > +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h
> > @@ -25,5 +25,6 @@ struct rcar_du_encoder {
> > int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> > enum rcar_du_output output,
> > struct device_node *enc_node);
> > +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu);
> >
> > #endif /* __RCAR_DU_ENCODER_H__ */
> > diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> > index b2d0e4651e35..1119c84e5fe9 100644
> > --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> > +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> > @@ -832,6 +832,8 @@ static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res)
> >
> > put_device(cmm->dev);
> > }
> > +
> > + rcar_du_encoder_cleanup(rcdu);
> > }
> >
> > int rcar_du_modeset_init(struct rcar_du_device *rcdu)
> >
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
2026-04-08 17:39 ` Luca Ceresoli
@ 2026-04-08 21:33 ` Laurent Pinchart
2026-04-09 12:32 ` Luca Ceresoli
0 siblings, 1 reply; 15+ messages in thread
From: Laurent Pinchart @ 2026-04-08 21:33 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Louis Chauvet, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen, Hui Pu, Ian Ray,
Thomas Petazzoni, dri-devel, linux-renesas-soc, linux-kernel
On Wed, Apr 08, 2026 at 07:39:03PM +0200, Luca Ceresoli wrote:
> On Wed Apr 8, 2026 at 5:44 PM CEST, Louis Chauvet wrote:
>
> >> @@ -83,10 +83,21 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
> >>
> >> bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
> >> DRM_MODE_CONNECTOR_DPI);
> >> - if (IS_ERR(bridge))
> >> - return PTR_ERR(bridge);
> >> + if (IS_ERR(bridge)) {
> >> + // Inhibit the cleanup action on an ERR_PTR
> >> + ret = PTR_ERR(bridge);
> >> + bridge = NULL;
> >> + return ret;
> >> + }
> >
> > Can't you use
> > https://elixir.bootlin.com/linux/v6.19.11/source/include/linux/cleanup.h#L230?
> >
> > return PTR_ERR(no_free_ptr(bridge));
>
> Ah, nice cleanup indeed! However, being this patch already reviewed ans
> tested, I'll postpone this cleanup to a later series.
I think this modification is minor enough to keep the tags.
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > With or without this modification:
> >
> > Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge()
2026-04-08 21:33 ` Laurent Pinchart
@ 2026-04-09 12:32 ` Luca Ceresoli
0 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-09 12:32 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Louis Chauvet, Biju Das, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Anitha Chrisanthus, Linus Walleij, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen, Hui Pu, Ian Ray,
Thomas Petazzoni, dri-devel, linux-renesas-soc, linux-kernel
Hi Laurent, Louis,
On Wed Apr 8, 2026 at 11:33 PM CEST, Laurent Pinchart wrote:
> On Wed, Apr 08, 2026 at 07:39:03PM +0200, Luca Ceresoli wrote:
>> On Wed Apr 8, 2026 at 5:44 PM CEST, Louis Chauvet wrote:
>>
>> >> @@ -83,10 +83,21 @@ int rzg2l_du_encoder_init(struct rzg2l_du_device *rcdu,
>> >>
>> >> bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel,
>> >> DRM_MODE_CONNECTOR_DPI);
>> >> - if (IS_ERR(bridge))
>> >> - return PTR_ERR(bridge);
>> >> + if (IS_ERR(bridge)) {
>> >> + // Inhibit the cleanup action on an ERR_PTR
>> >> + ret = PTR_ERR(bridge);
>> >> + bridge = NULL;
>> >> + return ret;
>> >> + }
>> >
>> > Can't you use
>> > https://elixir.bootlin.com/linux/v6.19.11/source/include/linux/cleanup.h#L230?
>> >
>> > return PTR_ERR(no_free_ptr(bridge));
>>
>> Ah, nice cleanup indeed! However, being this patch already reviewed ans
>> tested, I'll postpone this cleanup to a later series.
>
> I think this modification is minor enough to keep the tags.
OK, thanks for sharing your opinion! I'm sending a v5 of this patch and
patch 3 with that change and keeping the review tags, and apply them in ~1w
unless there is new feedback suggesting otherwise.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (subset) [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
` (4 preceding siblings ...)
2026-04-07 9:40 ` [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Linus Walleij
@ 2026-04-09 12:59 ` Luca Ceresoli
5 siblings, 0 replies; 15+ messages in thread
From: Luca Ceresoli @ 2026-04-09 12:59 UTC (permalink / raw)
To: Biju Das, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Anitha Chrisanthus, Linus Walleij,
Laurent Pinchart, Tomi Valkeinen, Kieran Bingham,
Geert Uytterhoeven, Magnus Damm, Tomi Valkeinen, Luca Ceresoli
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-renesas-soc,
linux-kernel
On Thu, 02 Apr 2026 18:27:16 +0200, Luca Ceresoli wrote:
> This series converts many DRM drivers from the now deprecated
> of_drm_find_bridge() to its replacement of_drm_find_and_get_bridge() which
> allows correct bridge refcounting.
>
> This is part of the work to support hotplug of DRM bridges. The grand plan
> was discussed in [0].
>
> [...]
Applied, thanks!
[2/4] drm/kmb/dsi: convert to of_drm_find_and_get_bridge()
commit: abbe7f8144d532354723dd1c5ab0daf41aa9706e
[4/4] drm/omap: dss: convert to of_drm_find_and_get_bridge()
commit: 0a7f39ba3ffcb810150d95237ee4e089fa522a93
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-04-09 12:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 16:27 [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 1/4] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
2026-04-08 15:44 ` Louis Chauvet
2026-04-08 17:39 ` Luca Ceresoli
2026-04-08 21:33 ` Laurent Pinchart
2026-04-09 12:32 ` Luca Ceresoli
2026-04-02 16:27 ` [PATCH v4 2/4] drm/kmb/dsi: " Luca Ceresoli
2026-04-08 15:44 ` Louis Chauvet
2026-04-02 16:27 ` [PATCH v4 3/4] drm: rcar-du: encoder: " Luca Ceresoli
2026-04-08 16:03 ` Louis Chauvet
2026-04-08 21:31 ` Laurent Pinchart
2026-04-02 16:27 ` [PATCH v4 4/4] drm/omap: dss: " Luca Ceresoli
2026-04-08 16:14 ` Louis Chauvet
2026-04-07 9:40 ` [PATCH v4 0/4] drm/bridge: convert users of of_drm_find_bridge(), part 4 Linus Walleij
2026-04-09 12:59 ` (subset) " Luca Ceresoli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox