mbox series

[v3,00/22] drm: convert all bridges to devm_drm_bridge_alloc()

Message ID 20250509-drm-bridge-convert-to-alloc-api-v3-0-b8bc1f16d7aa@bootlin.com
Headers show
Series drm: convert all bridges to devm_drm_bridge_alloc() | expand

Message

Luca Ceresoli May 9, 2025, 1:53 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 the first milestone
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 -> (now in drm-misc-next)
 B. ➜ convert all bridge drivers to new API (this series)
 C. … documentation, kunit tests (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
 F. debugfs improvements

More info about this series in the v2 cover [2].

Luca

[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/lkml/20250424-drm-bridge-convert-to-alloc-api-v2-0-8f91a404d86b@bootlin.com/

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v3:
- Fixed issues reported for some patches
- Added review tags
- Removed patches that have been applied
- Added revert for the exynos patch, applied by mistake
- Update cover with grand plan info and trim some of it
- Updated bouncing e-mail address in Cc list
- Link to v2: https://lore.kernel.org/lkml/20250424-drm-bridge-convert-to-alloc-api-v2-0-8f91a404d86b@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 (22):
      Revert "drm/exynos: mic: convert to devm_drm_bridge_alloc() API"
      drm: convert many bridge drivers from devm_kzalloc() 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: 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/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/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: 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
      drm/todo: add entry to remove devm_drm_put_bridge()

 Documentation/gpu/todo.rst                         | 15 ++++++
 drivers/gpu/drm/adp/adp-mipi.c                     |  8 ++--
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.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                |  8 ++--
 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           |  8 ++--
 drivers/gpu/drm/bridge/chrontel-ch7033.c           |  8 ++--
 drivers/gpu/drm/bridge/cros-ec-anx7688.c           |  8 ++--
 drivers/gpu/drm/bridge/fsl-ldb.c                   |  7 ++-
 drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c     |  8 ++--
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c       |  8 ++--
 .../gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c    | 27 ++++++-----
 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                |  8 ++--
 drivers/gpu/drm/bridge/ite-it6505.c                |  8 ++--
 drivers/gpu/drm/bridge/ite-it66121.c               |  8 ++--
 drivers/gpu/drm/bridge/lontium-lt8912b.c           |  8 ++--
 drivers/gpu/drm/bridge/lontium-lt9211.c            |  7 ++-
 drivers/gpu/drm/bridge/lontium-lt9611.c            |  8 ++--
 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                     | 12 ++---
 drivers/gpu/drm/bridge/parade-ps8622.c             |  8 ++--
 drivers/gpu/drm/bridge/parade-ps8640.c             |  8 ++--
 drivers/gpu/drm/bridge/sii902x.c                   |  7 ++-
 drivers/gpu/drm/bridge/sii9234.c                   |  8 ++--
 drivers/gpu/drm/bridge/sil-sii8620.c               |  8 ++--
 drivers/gpu/drm/bridge/simple-bridge.c             |  8 ++--
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c       |  8 ++--
 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                  |  8 ++--
 drivers/gpu/drm/bridge/tc358764.c                  |  8 ++--
 drivers/gpu/drm/bridge/tc358767.c                  | 56 +++++++++++++++-------
 drivers/gpu/drm/bridge/tc358768.c                  |  8 ++--
 drivers/gpu/drm/bridge/tc358775.c                  |  8 ++--
 drivers/gpu/drm/bridge/thc63lvd1024.c              |  8 ++--
 drivers/gpu/drm/bridge/ti-dlpc3433.c               |  8 ++--
 drivers/gpu/drm/bridge/ti-tdp158.c                 |  8 ++--
 drivers/gpu/drm/bridge/ti-tfp410.c                 |  8 ++--
 drivers/gpu/drm/bridge/ti-tpd12s015.c              |  8 ++--
 drivers/gpu/drm/drm_bridge.c                       | 17 +++++++
 drivers/gpu/drm/exynos/exynos_drm_mic.c            |  7 +--
 drivers/gpu/drm/mediatek/mtk_dp.c                  |  8 ++--
 drivers/gpu/drm/mediatek/mtk_dpi.c                 |  8 ++--
 drivers/gpu/drm/mediatek/mtk_dsi.c                 |  8 ++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c                |  8 ++--
 drivers/gpu/drm/meson/meson_encoder_cvbs.c         | 10 ++--
 drivers/gpu/drm/meson/meson_encoder_dsi.c          | 10 ++--
 drivers/gpu/drm/meson/meson_encoder_hdmi.c         | 10 ++--
 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        |  8 ++--
 drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c    |  8 ++--
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c     |  8 ++--
 drivers/gpu/drm/sti/sti_dvo.c                      | 29 +++++------
 drivers/gpu/drm/stm/lvds.c                         |  7 ++-
 drivers/gpu/drm/xlnx/zynqmp_dp.c                   | 31 +++++-------
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c                |  1 -
 include/drm/drm_bridge.h                           |  4 ++
 72 files changed, 390 insertions(+), 379 deletions(-)
---
base-commit: 94c60d3c1079fc044e356a78ffc68ca7b0603039
change-id: 20250404-drm-bridge-convert-to-alloc-api-614becf62294

Best regards,

Comments

Luca Ceresoli May 21, 2025, 2:22 p.m. UTC | #1
Hello Maxime, Shawn, Liu, all,

On Fri, 09 May 2025 15:53:26 +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 the first milestone
> towards removal of bridges from a still existing DRM pipeline without
> use-after-free.

I applied on drm-misc-next patches 3-17,20-21 as they match all the
criteria:
 - At least a Acked-by (or R-by maintainers)
 - patch is for drm-misc

Being my very first commits to drm-misc, I tried to be careful, and
double checked all the patches with Louis (thanks!).

Here are the pending questions and plan for the remaining patches.

>       Revert "drm/exynos: mic: convert to devm_drm_bridge_alloc() API"

This reverts the commit applied my mistake:
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/91c5c7b5bb2dd09b43b025bce6d790d3c79f4518

Neither the  original patch nor the revert has been reviewed/acked.

As the commit was a mistake, I'm applying the revert by the end of this
week (i.e. on Friday) unless there are better instructions.

>       drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API

This patch affects multiple drivers. Running get_maintainers.pl
points at Shawn Guo's repository. After reviewing the MAINTAINERS file,
this looks like due to the 'N:' line in:

ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
M:	Shawn Guo <shawnguo@kernel.org>
M:	Sascha Hauer <s.hauer@pengutronix.de>
R:	Pengutronix Kernel Team <kernel@pengutronix.de>
...
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git
N:	imx
...

(https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/MAINTAINERS?ref_type=heads#L2511-2528)

Here 'imx' matches the 'drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c'
file that is touched by the patch. That regexp appears overly generic to me.

Shawn, can it be fixed by making it less generic?

If not, can we at least add a band-aid 'X:' entry for
drivers/gpu/drm/bridge/imx?

I think the other matching entry is the one to consider:

DRM DRIVERS FOR FREESCALE IMX BRIDGE
M:	Liu Ying <victor.liu@nxp.com>
L:	dri-devel@lists.freedesktop.org
S:	Maintained
F:	Documentation/devicetree/bindings/display/bridge/fsl,imx8qxp-ldb.yaml
F:	Documentation/devicetree/bindings/display/bridge/fsl,imx8qxp-pixel-combiner.yaml
F:	Documentation/devicetree/bindings/display/bridge/fsl,imx8qxp-pixel-link.yaml
F:	Documentation/devicetree/bindings/display/bridge/fsl,imx8qxp-pxl2dpi.yaml
F:	drivers/gpu/drm/bridge/imx/

(https://gitlab.freedesktop.org/drm/misc/kernel/-/blob/drm-misc-next/MAINTAINERS?ref_type=heads#L7940-7948)

However it does not list any trees. I _guess_ drm-misc applies here as
a fallback as well as common sense.

Liu, should this entry have a 'T:' line for drm/misc?

>       drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API

Not acked/reviewed, some discussion happened. I am resending it in v4,
possibly with updates based on the discussion.

But it has the same issue discussed above, with get_maintiners.pl
pointing at Shawn Guo's tree, so in the future I'm assuming this goes
to drm-misc unless there are news about that.

>       drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API

No feedback, resending in v4.

>       drm/todo: add entry to remove devm_drm_put_bridge()

This involves documentation maintained on another tree. Where should it
be applied? There are two matching entries in MAINTAINERS:

 * DRM DRIVERS -> the drm tree
 * DRM DRIVERS AND MISC GPU PATCHES -> the drm-misc tree

To me it looks like the second is obviously the closest match as we are
dealing with DRM bridges, so I'm applying this as well on Friday unless
there are better instructions.

Best regards,
Luca