mbox series

[v2,00/34] drm: convert all bridges to devm_drm_bridge_alloc()

Message ID 20250424-drm-bridge-convert-to-alloc-api-v2-0-8f91a404d86b@bootlin.com
Headers show
Series drm: convert all bridges to devm_drm_bridge_alloc() | expand

Message

Luca Ceresoli April 24, 2025, 6:59 p.m. UTC
devm_drm_bridge_alloc() [0] is the new API to allocate and initialize a DRM
bridge, and the only one supported from now on. It is also necessary for
implementing reference counting and thus needed to support removal of
bridges from a still existing DRM pipeline without use-after-free.

This series converts all DRM bridges to the new API.

Patch 1 uses a coccinelle semantic patch to mass-convert some of those
drivers -- thanks Maxime for having suggested the patch that served as a
starting point for me. I was unable to come up with a better patch
converting more drivers though, so I converted all others manually. Most of
them were trivial. I left the non-trivial ones at the end of the series to
help reviewers know where to look at more carefully.

Due to the large number of touched files, the list of recipients generated
by get_maintainers (b4 actually) was huge, 60~70 people (not counting
mailing lists), so I took the liberty of trimming the list as reasonably as
I could to DRM maintainers and frequent contributors, and added all other
recipients individually per-patch. I hope this is fine. Don't hesitate to
suggest more people which should be Cc-ed in a future series, or a better
Cc policy.

Current plan and status of the DRM bridge refcounting work:

 A. ✔ add new alloc API and refcounting -> (now in drm-misc-next)
 B. ➜ convert all bridge drivers to new API (this series)
 C. … documentation, kunit tests, debugfs improvements (v1 under discussion)
 D. after (B), add get/put to drm_bridge_add/remove() + attach/detech()
 E. after (B), convert accessors; this is a large work and can be done
    in chunks

Luca

[0] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/0cc6aadd7fc1e629b715ea3d1ba537ef2da95eec

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v2:
- Improved cover letter with link to commit adding devm_drm_bridge_alloc()
- add review tags
- fix bugs in zynqmp, vc4 patches 
- fix patch 1 error code checking
- Link to v1: https://lore.kernel.org/r/20250407-drm-bridge-convert-to-alloc-api-v1-0-42113ff8d9c0@bootlin.com

---
Luca Ceresoli (34):
      drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
      platform: arm64: acer-aspire1-ec: convert to devm_drm_bridge_alloc() API
      drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
      drm/bridge: anx7625: convert to devm_drm_bridge_alloc() API
      drm/bridge: cdns-dsi: convert to devm_drm_bridge_alloc() API
      drm/bridge: display-connector: convert to devm_drm_bridge_alloc() API
      drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
      drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: convert to devm_drm_bridge_alloc() API
      drm/bridge: nxp-ptn3460: convert to devm_drm_bridge_alloc() API
      drm/bridge: sii902x: convert to devm_drm_bridge_alloc() API
      drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
      drm/bridge: tda998x: convert to devm_drm_bridge_alloc() API
      drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
      drm/exynos: mic: convert to devm_drm_bridge_alloc() API
      drm/mcde: convert to devm_drm_bridge_alloc() API
      drm/msm/dp: convert to devm_drm_bridge_alloc() API
      drm/msm/dsi: convert to devm_drm_bridge_alloc() API
      drm/msm/hdmi: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: dpi: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: dsi: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: hdmi4: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: hdmi5: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: sdi: convert to devm_drm_bridge_alloc() API
      drm/omap: dss: venc: convert to devm_drm_bridge_alloc() API
      drm/rcar-du: dsi: convert to devm_drm_bridge_alloc() API
      drm/bridge: stm_lvds: convert to devm_drm_bridge_alloc() API
      drm/vc4: convert to devm_drm_bridge_alloc() API
      drm/sti: dvo: convert to devm_drm_bridge_alloc() API
      drm: zynqmp_dp: convert to devm_drm_bridge_alloc() API
      drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
      drm/bridge: imx8*-ldb: convert to devm_drm_bridge_alloc() API
      drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API
      drm/bridge: add devm_drm_put_bridge()
      drm/bridge: panel: convert to devm_drm_bridge_alloc() API

 drivers/gpu/drm/adp/adp-mipi.c                     |  8 ++--
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c       |  9 ++--
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c |  8 ++--
 drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c |  9 ++--
 drivers/gpu/drm/bridge/analogix/anx7625.c          |  7 ++-
 drivers/gpu/drm/bridge/aux-bridge.c                |  9 ++--
 drivers/gpu/drm/bridge/aux-hpd-bridge.c            |  9 ++--
 drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c     |  8 ++--
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c    |  8 ++--
 drivers/gpu/drm/bridge/chipone-icn6211.c           |  9 ++--
 drivers/gpu/drm/bridge/chrontel-ch7033.c           |  8 ++--
 drivers/gpu/drm/bridge/cros-ec-anx7688.c           |  9 ++--
 drivers/gpu/drm/bridge/display-connector.c         |  8 ++--
 drivers/gpu/drm/bridge/fsl-ldb.c                   |  7 ++-
 drivers/gpu/drm/bridge/imx/imx-ldb-helper.c        |  4 +-
 drivers/gpu/drm/bridge/imx/imx-ldb-helper.h        |  3 +-
 drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c     |  9 ++--
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c       | 10 ++--
 drivers/gpu/drm/bridge/imx/imx8qm-ldb.c            | 32 ++++++++-----
 drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c           | 20 +++++---
 .../gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c    | 18 ++++---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c    |  8 ++--
 drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c       |  8 ++--
 drivers/gpu/drm/bridge/ite-it6263.c                |  9 ++--
 drivers/gpu/drm/bridge/ite-it6505.c                |  9 ++--
 drivers/gpu/drm/bridge/ite-it66121.c               |  9 ++--
 drivers/gpu/drm/bridge/lontium-lt8912b.c           |  9 ++--
 drivers/gpu/drm/bridge/lontium-lt9211.c            |  8 ++--
 drivers/gpu/drm/bridge/lontium-lt9611.c            |  9 ++--
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c         |  7 ++-
 drivers/gpu/drm/bridge/lvds-codec.c                |  9 ++--
 .../drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c   | 11 ++---
 drivers/gpu/drm/bridge/microchip-lvds.c            |  8 ++--
 drivers/gpu/drm/bridge/nwl-dsi.c                   |  8 ++--
 drivers/gpu/drm/bridge/nxp-ptn3460.c               |  9 ++--
 drivers/gpu/drm/bridge/panel.c                     | 11 ++---
 drivers/gpu/drm/bridge/parade-ps8622.c             |  9 ++--
 drivers/gpu/drm/bridge/parade-ps8640.c             |  9 ++--
 drivers/gpu/drm/bridge/sii902x.c                   |  7 ++-
 drivers/gpu/drm/bridge/sii9234.c                   |  9 ++--
 drivers/gpu/drm/bridge/sil-sii8620.c               |  9 ++--
 drivers/gpu/drm/bridge/simple-bridge.c             | 10 ++--
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c       |  8 ++--
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c          |  7 ++-
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c      |  8 ++--
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c     |  8 ++--
 drivers/gpu/drm/bridge/tc358762.c                  |  9 ++--
 drivers/gpu/drm/bridge/tc358764.c                  |  9 ++--
 drivers/gpu/drm/bridge/tc358767.c                  | 56 +++++++++++++++-------
 drivers/gpu/drm/bridge/tc358768.c                  |  9 ++--
 drivers/gpu/drm/bridge/tc358775.c                  |  9 ++--
 drivers/gpu/drm/bridge/tda998x_drv.c               |  7 ++-
 drivers/gpu/drm/bridge/thc63lvd1024.c              |  8 ++--
 drivers/gpu/drm/bridge/ti-dlpc3433.c               |  9 ++--
 drivers/gpu/drm/bridge/ti-sn65dsi86.c              |  7 ++-
 drivers/gpu/drm/bridge/ti-tdp158.c                 |  8 ++--
 drivers/gpu/drm/bridge/ti-tfp410.c                 |  9 ++--
 drivers/gpu/drm/bridge/ti-tpd12s015.c              |  9 ++--
 drivers/gpu/drm/drm_bridge.c                       | 14 ++++++
 drivers/gpu/drm/exynos/exynos_drm_mic.c            |  7 ++-
 drivers/gpu/drm/mcde/mcde_dsi.c                    |  7 ++-
 drivers/gpu/drm/mediatek/mtk_dp.c                  |  9 ++--
 drivers/gpu/drm/mediatek/mtk_dpi.c                 |  9 ++--
 drivers/gpu/drm/mediatek/mtk_dsi.c                 |  9 ++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c                |  9 ++--
 drivers/gpu/drm/meson/meson_encoder_cvbs.c         | 12 ++---
 drivers/gpu/drm/meson/meson_encoder_dsi.c          | 12 ++---
 drivers/gpu/drm/meson/meson_encoder_hdmi.c         | 12 ++---
 drivers/gpu/drm/msm/dp/dp_drm.c                    |  9 ++--
 drivers/gpu/drm/msm/dsi/dsi_manager.c              |  9 ++--
 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c             |  9 ++--
 drivers/gpu/drm/omapdrm/dss/dpi.c                  |  7 ++-
 drivers/gpu/drm/omapdrm/dss/dsi.c                  |  7 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c                | 26 ++++------
 drivers/gpu/drm/omapdrm/dss/hdmi5.c                | 26 ++++------
 drivers/gpu/drm/omapdrm/dss/sdi.c                  | 25 ++++------
 drivers/gpu/drm/omapdrm/dss/venc.c                 | 23 ++++-----
 drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c        |  9 ++--
 drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c    |  8 ++--
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c     | 10 ++--
 drivers/gpu/drm/sti/sti_dvo.c                      | 29 +++++------
 drivers/gpu/drm/stm/lvds.c                         |  7 ++-
 drivers/gpu/drm/vc4/vc4_dsi.c                      | 34 ++-----------
 drivers/gpu/drm/xlnx/zynqmp_dp.c                   | 31 +++++-------
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c                |  1 -
 drivers/platform/arm64/acer-aspire1-ec.c           |  7 ++-
 include/drm/drm_bridge.h                           |  4 ++
 87 files changed, 448 insertions(+), 510 deletions(-)
---
base-commit: 82d6ce3a9e828e73ef43b8072a89d94608ae1554
change-id: 20250404-drm-bridge-convert-to-alloc-api-614becf62294

Best regards,

Comments

Luca Ceresoli April 28, 2025, 3:24 p.m. UTC | #1
Hi Maxime, other DRM maintainers,

On Thu, 24 Apr 2025 20:59:07 +0200
Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:

> devm_drm_bridge_alloc() [0] is the new API to allocate and initialize a DRM
> bridge, and the only one supported from now on. It is also necessary for
> implementing reference counting and thus needed to support removal of
> bridges from a still existing DRM pipeline without use-after-free.
> 
> This series converts all DRM bridges to the new API.
> 
> Patch 1 uses a coccinelle semantic patch to mass-convert some of those
> drivers -- thanks Maxime for having suggested the patch that served as a
> starting point for me. I was unable to come up with a better patch
> converting more drivers though, so I converted all others manually. Most of
> them were trivial. I left the non-trivial ones at the end of the series to
> help reviewers know where to look at more carefully.
> 
> Due to the large number of touched files, the list of recipients generated
> by get_maintainers (b4 actually) was huge, 60~70 people (not counting
> mailing lists), so I took the liberty of trimming the list as reasonably as
> I could to DRM maintainers and frequent contributors, and added all other
> recipients individually per-patch. I hope this is fine. Don't hesitate to
> suggest more people which should be Cc-ed in a future series, or a better
> Cc policy.
> 
> Current plan and status of the DRM bridge refcounting work:
> 
>  A. ✔ add new alloc API and refcounting -> (now in drm-misc-next)
>  B. ➜ convert all bridge drivers to new API (this series)
>  C. … documentation, kunit tests, debugfs improvements (v1 under discussion)
>  D. after (B), add get/put to drm_bridge_add/remove() + attach/detech()
>  E. after (B), convert accessors; this is a large work and can be done
>     in chunks
> 
> Luca
> 
> [0] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/0cc6aadd7fc1e629b715ea3d1ba537ef2da95eec
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

Maintaining this long series is quite painful. Do you think at least
patches with a R-by or T-by tag could be merged before I send v3, so we
can relieve the maintenance effort, mail servers, and everybody's
inboxes?

Otherwise I could split this series in parts somewhat arbitrarily, but
that is an additional work on its own and is not a perfect solution as
it would not provide the big picture.

Best regards,
Luca
Maxime Ripard April 28, 2025, 3:42 p.m. UTC | #2
On Mon, Apr 28, 2025 at 05:24:57PM +0200, Luca Ceresoli wrote:
> Hi Maxime, other DRM maintainers,
> 
> On Thu, 24 Apr 2025 20:59:07 +0200
> Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> 
> > devm_drm_bridge_alloc() [0] is the new API to allocate and initialize a DRM
> > bridge, and the only one supported from now on. It is also necessary for
> > implementing reference counting and thus needed to support removal of
> > bridges from a still existing DRM pipeline without use-after-free.
> > 
> > This series converts all DRM bridges to the new API.
> > 
> > Patch 1 uses a coccinelle semantic patch to mass-convert some of those
> > drivers -- thanks Maxime for having suggested the patch that served as a
> > starting point for me. I was unable to come up with a better patch
> > converting more drivers though, so I converted all others manually. Most of
> > them were trivial. I left the non-trivial ones at the end of the series to
> > help reviewers know where to look at more carefully.
> > 
> > Due to the large number of touched files, the list of recipients generated
> > by get_maintainers (b4 actually) was huge, 60~70 people (not counting
> > mailing lists), so I took the liberty of trimming the list as reasonably as
> > I could to DRM maintainers and frequent contributors, and added all other
> > recipients individually per-patch. I hope this is fine. Don't hesitate to
> > suggest more people which should be Cc-ed in a future series, or a better
> > Cc policy.
> > 
> > Current plan and status of the DRM bridge refcounting work:
> > 
> >  A. ✔ add new alloc API and refcounting -> (now in drm-misc-next)
> >  B. ➜ convert all bridge drivers to new API (this series)
> >  C. … documentation, kunit tests, debugfs improvements (v1 under discussion)
> >  D. after (B), add get/put to drm_bridge_add/remove() + attach/detech()
> >  E. after (B), convert accessors; this is a large work and can be done
> >     in chunks
>
> Maintaining this long series is quite painful. Do you think at least
> patches with a R-by or T-by tag could be merged before I send v3, so
> we can relieve the maintenance effort, mail servers, and everybody's
> inboxes?

Yes?

What's stopping you though? You have at least a colleague that can apply
them, and you could just as well apply for commit rights yourself.

Maxime
Luca Ceresoli April 28, 2025, 4:33 p.m. UTC | #3
Hi Maxime,

On Mon, 28 Apr 2025 17:42:46 +0200
Maxime Ripard <mripard@kernel.org> wrote:

> On Mon, Apr 28, 2025 at 05:24:57PM +0200, Luca Ceresoli wrote:
> > Hi Maxime, other DRM maintainers,
> > 
> > On Thu, 24 Apr 2025 20:59:07 +0200
> > Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> >   
> > > devm_drm_bridge_alloc() [0] is the new API to allocate and initialize a DRM
> > > bridge, and the only one supported from now on. It is also necessary for
> > > implementing reference counting and thus needed to support removal of
> > > bridges from a still existing DRM pipeline without use-after-free.
> > > 
> > > This series converts all DRM bridges to the new API.
> > > 
> > > Patch 1 uses a coccinelle semantic patch to mass-convert some of those
> > > drivers -- thanks Maxime for having suggested the patch that served as a
> > > starting point for me. I was unable to come up with a better patch
> > > converting more drivers though, so I converted all others manually. Most of
> > > them were trivial. I left the non-trivial ones at the end of the series to
> > > help reviewers know where to look at more carefully.
> > > 
> > > Due to the large number of touched files, the list of recipients generated
> > > by get_maintainers (b4 actually) was huge, 60~70 people (not counting
> > > mailing lists), so I took the liberty of trimming the list as reasonably as
> > > I could to DRM maintainers and frequent contributors, and added all other
> > > recipients individually per-patch. I hope this is fine. Don't hesitate to
> > > suggest more people which should be Cc-ed in a future series, or a better
> > > Cc policy.
> > > 
> > > Current plan and status of the DRM bridge refcounting work:
> > > 
> > >  A. ✔ add new alloc API and refcounting -> (now in drm-misc-next)
> > >  B. ➜ convert all bridge drivers to new API (this series)
> > >  C. … documentation, kunit tests, debugfs improvements (v1 under discussion)
> > >  D. after (B), add get/put to drm_bridge_add/remove() + attach/detech()
> > >  E. after (B), convert accessors; this is a large work and can be done
> > >     in chunks  
> >
> > Maintaining this long series is quite painful. Do you think at least
> > patches with a R-by or T-by tag could be merged before I send v3, so
> > we can relieve the maintenance effort, mail servers, and everybody's
> > inboxes?  
> 
> Yes?
> 
> What's stopping you though? You have at least a colleague that can apply
> them, and you could just as well apply for commit rights yourself.

OK, thanks. Will do.

The reason I haven't done it is this policy in DRM still appears a bit
unusual to me, but if it works for DRM I'm OK with it. Only, in case of
doubt, I didn't want to risk abusing of the commit rights.

Best regards,
Luca
Dmitry Baryshkov April 29, 2025, 2:42 p.m. UTC | #4
On Tue, Apr 29, 2025 at 11:27:51AM +0200, Louis Chauvet wrote:
> 
> On Thu, 24 Apr 2025 20:59:07 +0200, Luca Ceresoli wrote:
> > devm_drm_bridge_alloc() [0] is the new API to allocate and initialize a DRM
> > bridge, and the only one supported from now on. It is also necessary for
> > implementing reference counting and thus needed to support removal of
> > bridges from a still existing DRM pipeline without use-after-free.
> > 
> > This series converts all DRM bridges to the new API.
> > 
> > [...]
> 
> Applied, thanks!
> 

[...]

> [16/34] drm/msm/dp: convert to devm_drm_bridge_alloc() API
>         commit: b2aabe5c6b65516d88214aba4b12ce2ca78bac6c
> [17/34] drm/msm/dsi: convert to devm_drm_bridge_alloc() API
>         commit: fffc8847743e45604c4478f554d628481b985556
> [18/34] drm/msm/hdmi: convert to devm_drm_bridge_alloc() API
>         commit: e11532be87e437648521a8ed5358c56df11933b4

Why? These drivers are explicitly handled outside of drm-misc. Please be
more careful next time.