* [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
@ 2025-04-24 18:59 Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
` (35 more replies)
0 siblings, 36 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Adam Ford,
Adrien Grassein, Aleksandr Mishin, Andy Yan,
AngeloGioacchino Del Regno, Benson Leung, Biju Das,
Christoph Fritz, Cristian Ciocaltea, Detlev Casanova,
Dharma Balasubiramani, Guenter Roeck, Heiko Stuebner, Jani Nikula,
Janne Grunau, Jerome Brunet, Jesse Van Gavere, Kevin Hilman,
Kieran Bingham, Liu Ying, Manikandan Muralidharan,
Martin Blumenstingl, Matthias Brugger, Philipp Zabel, Phong LE,
Sasha Finkelstein, Sugar Zhang, Sui Jingfeng, Tomi Valkeinen,
Vitalii Mordan, Ilpo Järvinen, Bryan O'Donoghue,
Hans de Goede, Uwe Kleine-König, Dmitry Baryshkov,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Laurent Pinchart, Michal Simek
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,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
^ permalink raw reply [flat|nested] 81+ messages in thread
* [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-28 12:44 ` Andy Yan
` (3 more replies)
2025-04-24 18:59 ` [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
` (34 subsequent siblings)
35 siblings, 4 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Adam Ford,
Adrien Grassein, Aleksandr Mishin, Andy Yan,
AngeloGioacchino Del Regno, Benson Leung, Biju Das,
Christoph Fritz, Cristian Ciocaltea, Detlev Casanova,
Dharma Balasubiramani, Guenter Roeck, Heiko Stuebner, Jani Nikula,
Janne Grunau, Jerome Brunet, Jesse Van Gavere, Kevin Hilman,
Kieran Bingham, Liu Ying, Manikandan Muralidharan,
Martin Blumenstingl, Matthias Brugger, Philipp Zabel, Phong LE,
Sasha Finkelstein, Sugar Zhang, Sui Jingfeng, Tomi Valkeinen,
Vitalii Mordan
devm_drm_bridge_alloc() is the new API to be used for allocating (and
partially initializing) a private driver struct embedding a struct
drm_bridge.
For many drivers having a simple code flow in the probe function, this
commit does a mass conversion automatically with the following semantic
patch. The changes have been reviewed manually for correctness as well as
to find any false positives.
@@
type T;
identifier C;
identifier BR;
expression DEV;
expression FUNCS;
@@
-T *C;
+T *C;
...
(
-C = devm_kzalloc(DEV, ...);
-if (!C)
- return -ENOMEM;
+C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
+if (IS_ERR(C))
+ return PTR_ERR(C);
|
-C = devm_kzalloc(DEV, ...);
-if (!C)
- return ERR_PTR(-ENOMEM);
+C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
+if (IS_ERR(C))
+ return PTR_ERR(C);
)
...
-C->BR.funcs = FUNCS;
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Adam Ford <aford173@gmail.com>
Cc: Adrien Grassein <adrien.grassein@gmail.com>
Cc: Aleksandr Mishin <amishin@t-argos.ru>
Cc: Andy Yan <andy.yan@rock-chips.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Benson Leung <bleung@chromium.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Christoph Fritz <chf.fritz@googlemail.com>
Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Cc: Detlev Casanova <detlev.casanova@collabora.com>
Cc: Dharma Balasubiramani <dharma.b@microchip.com>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Janne Grunau <j@jannau.net>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Jesse Van Gavere <jesseevg@gmail.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Liu Ying <victor.liu@nxp.com>
Cc: Manikandan Muralidharan <manikandan.m@microchip.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Phong LE <ple@baylibre.com>
Cc: Sasha Finkelstein <fnkl.kernel@gmail.com>
Cc: Sugar Zhang <sugar.zhang@rock-chips.com>
Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Cc: Vitalii Mordan <mordan@ispras.ru>
Changed in v2:
- added missing PTR_ERR() in the second spatch alternative
---
drivers/gpu/drm/adp/adp-mipi.c | 8 ++++----
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 9 ++++-----
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 9 ++++-----
drivers/gpu/drm/bridge/aux-bridge.c | 9 ++++-----
drivers/gpu/drm/bridge/aux-hpd-bridge.c | 9 +++++----
drivers/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/fsl-ldb.c | 7 +++----
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/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/lvds-codec.c | 9 ++++-----
drivers/gpu/drm/bridge/microchip-lvds.c | 8 ++++----
drivers/gpu/drm/bridge/nwl-dsi.c | 8 ++++----
drivers/gpu/drm/bridge/parade-ps8622.c | 9 ++++-----
drivers/gpu/drm/bridge/parade-ps8640.c | 9 ++++-----
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-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/tc358768.c | 9 ++++-----
drivers/gpu/drm/bridge/tc358775.c | 9 ++++-----
drivers/gpu/drm/bridge/thc63lvd1024.c | 8 ++++----
drivers/gpu/drm/bridge/ti-dlpc3433.c | 9 ++++-----
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/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/renesas/rcar-du/rcar_lvds.c | 9 ++++-----
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 10 ++++------
49 files changed, 201 insertions(+), 237 deletions(-)
diff --git a/drivers/gpu/drm/adp/adp-mipi.c b/drivers/gpu/drm/adp/adp-mipi.c
index 2b60128e2c693e9f85affff569cc57cdb6f47909..cba7d32150a98d78d07a25b1822dec6bf2f08f65 100644
--- a/drivers/gpu/drm/adp/adp-mipi.c
+++ b/drivers/gpu/drm/adp/adp-mipi.c
@@ -229,9 +229,10 @@ static int adp_mipi_probe(struct platform_device *pdev)
{
struct adp_mipi_drv_private *adp;
- adp = devm_kzalloc(&pdev->dev, sizeof(*adp), GFP_KERNEL);
- if (!adp)
- return -ENOMEM;
+ adp = devm_drm_bridge_alloc(&pdev->dev, struct adp_mipi_drv_private,
+ bridge, &adp_dsi_bridge_funcs);
+ if (IS_ERR(adp))
+ return PTR_ERR(adp);
adp->mipi = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(adp->mipi)) {
@@ -241,7 +242,6 @@ static int adp_mipi_probe(struct platform_device *pdev)
adp->dsi.dev = &pdev->dev;
adp->dsi.ops = &adp_dsi_host_ops;
- adp->bridge.funcs = &adp_dsi_bridge_funcs;
adp->bridge.of_node = pdev->dev.of_node;
adp->bridge.type = DRM_MODE_CONNECTOR_DSI;
dev_set_drvdata(&pdev->dev, adp);
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 1257009e850c1b20184cfaea5b6a4440e75e10d7..4411987cd85109b83e3d4d45e842ee9cf8d21aab 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -1224,9 +1224,10 @@ static int adv7511_probe(struct i2c_client *i2c)
if (!dev->of_node)
return -EINVAL;
- adv7511 = devm_kzalloc(dev, sizeof(*adv7511), GFP_KERNEL);
- if (!adv7511)
- return -ENOMEM;
+ adv7511 = devm_drm_bridge_alloc(dev, struct adv7511, bridge,
+ &adv7511_bridge_funcs);
+ if (IS_ERR(adv7511))
+ return PTR_ERR(adv7511);
adv7511->i2c_main = i2c;
adv7511->powered = false;
@@ -1326,8 +1327,6 @@ static int adv7511_probe(struct i2c_client *i2c)
ret = adv7511_cec_init(dev, adv7511);
if (ret)
goto err_unregister_cec;
-
- adv7511->bridge.funcs = &adv7511_bridge_funcs;
adv7511->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
if (adv7511->i2c_main->irq)
adv7511->bridge.ops |= DRM_BRIDGE_OP_HPD;
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
index a83020d6576f78372056069947783a626acf64b1..ba0fc149a9e722a53da6027a851bf62262ba64b2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
@@ -1193,9 +1193,10 @@ static int anx78xx_i2c_probe(struct i2c_client *client)
bool found = false;
int err;
- anx78xx = devm_kzalloc(&client->dev, sizeof(*anx78xx), GFP_KERNEL);
- if (!anx78xx)
- return -ENOMEM;
+ anx78xx = devm_drm_bridge_alloc(&client->dev, struct anx78xx, bridge,
+ &anx78xx_bridge_funcs);
+ if (IS_ERR(anx78xx))
+ return PTR_ERR(anx78xx);
pdata = &anx78xx->pdata;
@@ -1306,8 +1307,6 @@ static int anx78xx_i2c_probe(struct i2c_client *client)
goto err_poweroff;
}
- anx78xx->bridge.funcs = &anx78xx_bridge_funcs;
-
drm_bridge_add(&anx78xx->bridge);
/* If cable is pulled out, just poweroff and wait for HPD event */
diff --git a/drivers/gpu/drm/bridge/aux-bridge.c b/drivers/gpu/drm/bridge/aux-bridge.c
index c179b86d208f70d95b41e6f2157b78f97bac4d8d..ea9109bdbe088da4ea3411845bf6f27a50e2cebf 100644
--- a/drivers/gpu/drm/bridge/aux-bridge.c
+++ b/drivers/gpu/drm/bridge/aux-bridge.c
@@ -109,17 +109,16 @@ static int drm_aux_bridge_probe(struct auxiliary_device *auxdev,
{
struct drm_aux_bridge_data *data;
- data = devm_kzalloc(&auxdev->dev, sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
+ data = devm_drm_bridge_alloc(&auxdev->dev, struct drm_aux_bridge_data,
+ bridge, &drm_aux_bridge_funcs);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
data->dev = &auxdev->dev;
data->next_bridge = devm_drm_of_get_bridge(&auxdev->dev, auxdev->dev.of_node, 0, 0);
if (IS_ERR(data->next_bridge))
return dev_err_probe(&auxdev->dev, PTR_ERR(data->next_bridge),
"failed to acquire drm_bridge\n");
-
- data->bridge.funcs = &drm_aux_bridge_funcs;
data->bridge.of_node = data->dev->of_node;
/* passthrough data, allow everything */
diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c
index b3f588b71a7d7ad5c2ee7b07c39079bc5ba34cee..3eb411f874e41b322f732649bd2074c5d8422566 100644
--- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c
+++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c
@@ -171,12 +171,13 @@ static int drm_aux_hpd_bridge_probe(struct auxiliary_device *auxdev,
{
struct drm_aux_hpd_bridge_data *data;
- data = devm_kzalloc(&auxdev->dev, sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
+ data = devm_drm_bridge_alloc(&auxdev->dev,
+ struct drm_aux_hpd_bridge_data, bridge,
+ &drm_aux_hpd_bridge_funcs);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
data->dev = &auxdev->dev;
- data->bridge.funcs = &drm_aux_hpd_bridge_funcs;
data->bridge.of_node = dev_get_platdata(data->dev);
data->bridge.ops = DRM_BRIDGE_OP_HPD;
data->bridge.type = id->driver_data;
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index b431e7efd1f0d749320ea15b6f1f5ca13fc72800..cb5f5a8c539a471290df8435d4c2e3ed696b38d4 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -2389,9 +2389,10 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
int ret;
int irq;
- mhdp = devm_kzalloc(dev, sizeof(*mhdp), GFP_KERNEL);
- if (!mhdp)
- return -ENOMEM;
+ mhdp = devm_drm_bridge_alloc(dev, struct cdns_mhdp_device, bridge,
+ &cdns_mhdp_bridge_funcs);
+ if (IS_ERR(mhdp))
+ return PTR_ERR(mhdp);
clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(clk)) {
@@ -2481,7 +2482,6 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
mhdp->display_fmt.bpc = 8;
mhdp->bridge.of_node = pdev->dev.of_node;
- mhdp->bridge.funcs = &cdns_mhdp_bridge_funcs;
mhdp->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HPD;
mhdp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
diff --git a/drivers/gpu/drm/bridge/chipone-icn6211.c b/drivers/gpu/drm/bridge/chipone-icn6211.c
index 634c5b0306679d2e68798c2b9013aae4491dd44c..9989c6a6f3414295788e77d561ee5b807abc602e 100644
--- a/drivers/gpu/drm/bridge/chipone-icn6211.c
+++ b/drivers/gpu/drm/bridge/chipone-icn6211.c
@@ -691,17 +691,16 @@ static int chipone_common_probe(struct device *dev, struct chipone **icnr)
struct chipone *icn;
int ret;
- icn = devm_kzalloc(dev, sizeof(struct chipone), GFP_KERNEL);
- if (!icn)
- return -ENOMEM;
+ icn = devm_drm_bridge_alloc(dev, struct chipone, bridge,
+ &chipone_bridge_funcs);
+ if (IS_ERR(icn))
+ return PTR_ERR(icn);
icn->dev = dev;
ret = chipone_parse_dt(icn);
if (ret)
return ret;
-
- icn->bridge.funcs = &chipone_bridge_funcs;
icn->bridge.type = DRM_MODE_CONNECTOR_DPI;
icn->bridge.of_node = dev->of_node;
diff --git a/drivers/gpu/drm/bridge/chrontel-ch7033.c b/drivers/gpu/drm/bridge/chrontel-ch7033.c
index 210c45c1efd48f5b541bf73da66a169c27e110b2..ab92747933568bfba77da45219e019408029f297 100644
--- a/drivers/gpu/drm/bridge/chrontel-ch7033.c
+++ b/drivers/gpu/drm/bridge/chrontel-ch7033.c
@@ -536,9 +536,10 @@ static int ch7033_probe(struct i2c_client *client)
unsigned int val;
int ret;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
+ priv = devm_drm_bridge_alloc(dev, struct ch7033_priv, bridge,
+ &ch7033_bridge_funcs);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
dev_set_drvdata(dev, priv);
@@ -575,7 +576,6 @@ static int ch7033_probe(struct i2c_client *client)
}
INIT_LIST_HEAD(&priv->bridge.list);
- priv->bridge.funcs = &ch7033_bridge_funcs;
priv->bridge.of_node = dev->of_node;
drm_bridge_add(&priv->bridge);
diff --git a/drivers/gpu/drm/bridge/cros-ec-anx7688.c b/drivers/gpu/drm/bridge/cros-ec-anx7688.c
index c8abd9920fee956cf049bcb09827d658b7939333..ab539143f71059e202baced47091cfc1c9174b7c 100644
--- a/drivers/gpu/drm/bridge/cros-ec-anx7688.c
+++ b/drivers/gpu/drm/bridge/cros-ec-anx7688.c
@@ -103,9 +103,10 @@ static int cros_ec_anx7688_bridge_probe(struct i2c_client *client)
u8 buffer[4];
int ret;
- anx7688 = devm_kzalloc(dev, sizeof(*anx7688), GFP_KERNEL);
- if (!anx7688)
- return -ENOMEM;
+ anx7688 = devm_drm_bridge_alloc(dev, struct cros_ec_anx7688, bridge,
+ &cros_ec_anx7688_bridge_funcs);
+ if (IS_ERR(anx7688))
+ return PTR_ERR(anx7688);
anx7688->client = client;
i2c_set_clientdata(client, anx7688);
@@ -152,8 +153,6 @@ static int cros_ec_anx7688_bridge_probe(struct i2c_client *client)
/* Warn, but not fail, for backwards compatibility */
DRM_WARN("Old ANX7688 FW version (0x%04x), not filtering\n",
fw_version);
-
- anx7688->bridge.funcs = &cros_ec_anx7688_bridge_funcs;
drm_bridge_add(&anx7688->bridge);
return 0;
diff --git a/drivers/gpu/drm/bridge/fsl-ldb.c b/drivers/gpu/drm/bridge/fsl-ldb.c
index 2cb6dfc7a6d3dbdd620a35345204f8fb9cae6651..5c3cf37200bcee1db285c97e2b463c9355ee6acb 100644
--- a/drivers/gpu/drm/bridge/fsl-ldb.c
+++ b/drivers/gpu/drm/bridge/fsl-ldb.c
@@ -298,16 +298,15 @@ static int fsl_ldb_probe(struct platform_device *pdev)
struct fsl_ldb *fsl_ldb;
int dual_link;
- fsl_ldb = devm_kzalloc(dev, sizeof(*fsl_ldb), GFP_KERNEL);
- if (!fsl_ldb)
- return -ENOMEM;
+ fsl_ldb = devm_drm_bridge_alloc(dev, struct fsl_ldb, bridge, &funcs);
+ if (IS_ERR(fsl_ldb))
+ return PTR_ERR(fsl_ldb);
fsl_ldb->devdata = of_device_get_match_data(dev);
if (!fsl_ldb->devdata)
return -EINVAL;
fsl_ldb->dev = &pdev->dev;
- fsl_ldb->bridge.funcs = &funcs;
fsl_ldb->bridge.of_node = dev->of_node;
fsl_ldb->clk = devm_clk_get(dev, "ldb");
diff --git a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
index f072c6ed39ef183b10518b43bd6d979bc89e36f9..8069c4881e9058f5462f99116799b589bd52b19e 100644
--- a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
+++ b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
@@ -59,9 +59,10 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
struct imx_legacy_bridge *imx_bridge;
int ret;
- imx_bridge = devm_kzalloc(dev, sizeof(*imx_bridge), GFP_KERNEL);
- if (!imx_bridge)
- return ERR_PTR(-ENOMEM);
+ imx_bridge = devm_drm_bridge_alloc(dev, struct imx_legacy_bridge,
+ base, &imx_legacy_bridge_funcs);
+ if (IS_ERR(imx_bridge))
+ return PTR_ERR(imx_bridge);
ret = of_get_drm_display_mode(np,
&imx_bridge->mode,
@@ -71,8 +72,6 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
return ERR_PTR(ret);
imx_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
-
- imx_bridge->base.funcs = &imx_legacy_bridge_funcs;
imx_bridge->base.of_node = np;
imx_bridge->base.ops = DRM_BRIDGE_OP_MODES;
imx_bridge->base.type = type;
diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c
index 8a4fd7d77a8d516b3b46f41cf07d2633d23bde12..18b60bb60e0042a1d031283fecf95c4b7a9312e1 100644
--- a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pvi.c
@@ -140,9 +140,10 @@ static int imx8mp_hdmi_pvi_probe(struct platform_device *pdev)
struct device_node *remote;
struct imx8mp_hdmi_pvi *pvi;
- pvi = devm_kzalloc(&pdev->dev, sizeof(*pvi), GFP_KERNEL);
- if (!pvi)
- return -ENOMEM;
+ pvi = devm_drm_bridge_alloc(&pdev->dev, struct imx8mp_hdmi_pvi,
+ bridge, &imx_hdmi_pvi_bridge_funcs);
+ if (IS_ERR(pvi))
+ return PTR_ERR(pvi);
platform_set_drvdata(pdev, pvi);
pvi->dev = &pdev->dev;
@@ -164,9 +165,6 @@ static int imx8mp_hdmi_pvi_probe(struct platform_device *pdev)
"could not find next bridge\n");
pm_runtime_enable(&pdev->dev);
-
- /* Register the bridge. */
- pvi->bridge.funcs = &imx_hdmi_pvi_bridge_funcs;
pvi->bridge.of_node = pdev->dev.of_node;
pvi->bridge.timings = pvi->next_bridge->timings;
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index e092c9ea99b0224802919ff84b448acb53508951..e5943506981dfb8f113c94ad52ddbba52e00ec3f 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -327,9 +327,10 @@ static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
int ret;
- pl = devm_kzalloc(dev, sizeof(*pl), GFP_KERNEL);
- if (!pl)
- return -ENOMEM;
+ pl = devm_drm_bridge_alloc(dev, struct imx8qxp_pixel_link, bridge,
+ &imx8qxp_pixel_link_bridge_funcs);
+ if (IS_ERR(pl))
+ return PTR_ERR(pl);
ret = imx_scu_get_handle(&pl->ipc_handle);
if (ret) {
@@ -384,7 +385,6 @@ static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pl);
pl->bridge.driver_private = pl;
- pl->bridge.funcs = &imx8qxp_pixel_link_bridge_funcs;
pl->bridge.of_node = np;
drm_bridge_add(&pl->bridge);
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index da138ab51b3bd2c6ebd3780c09818891d5320092..111310acab2ce403a62a47ecbe9d9dd372c75ecd 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -392,9 +392,10 @@ static int imx8qxp_pxl2dpi_bridge_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
int ret;
- p2d = devm_kzalloc(dev, sizeof(*p2d), GFP_KERNEL);
- if (!p2d)
- return -ENOMEM;
+ p2d = devm_drm_bridge_alloc(dev, struct imx8qxp_pxl2dpi, bridge,
+ &imx8qxp_pxl2dpi_bridge_funcs);
+ if (IS_ERR(p2d))
+ return PTR_ERR(p2d);
p2d->regmap = syscon_node_to_regmap(np->parent);
if (IS_ERR(p2d->regmap)) {
@@ -441,7 +442,6 @@ static int imx8qxp_pxl2dpi_bridge_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
p2d->bridge.driver_private = p2d;
- p2d->bridge.funcs = &imx8qxp_pxl2dpi_bridge_funcs;
p2d->bridge.of_node = np;
drm_bridge_add(&p2d->bridge);
diff --git a/drivers/gpu/drm/bridge/ite-it6263.c b/drivers/gpu/drm/bridge/ite-it6263.c
index a3a63a977b0a8487ad38fc08e0eed08672f4d41a..a417b25a65e8369177d4bb09d179a865f6187adc 100644
--- a/drivers/gpu/drm/bridge/ite-it6263.c
+++ b/drivers/gpu/drm/bridge/ite-it6263.c
@@ -816,9 +816,10 @@ static int it6263_probe(struct i2c_client *client)
struct it6263 *it;
int ret;
- it = devm_kzalloc(dev, sizeof(*it), GFP_KERNEL);
- if (!it)
- return -ENOMEM;
+ it = devm_drm_bridge_alloc(dev, struct it6263, bridge,
+ &it6263_bridge_funcs);
+ if (IS_ERR(it))
+ return PTR_ERR(it);
it->dev = dev;
it->hdmi_i2c = client;
@@ -865,8 +866,6 @@ static int it6263_probe(struct i2c_client *client)
it6263_hdmi_config(it);
i2c_set_clientdata(client, it);
-
- it->bridge.funcs = &it6263_bridge_funcs;
it->bridge.of_node = dev->of_node;
/* IT6263 chip doesn't support HPD interrupt. */
it->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 1383d1e21afea1acb46b7bd28860908b58832dbc..bf2e854210233bcecd1be582ef092370bd652412 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -3583,9 +3583,10 @@ static int it6505_i2c_probe(struct i2c_client *client)
struct extcon_dev *extcon;
int err;
- it6505 = devm_kzalloc(&client->dev, sizeof(*it6505), GFP_KERNEL);
- if (!it6505)
- return -ENOMEM;
+ it6505 = devm_drm_bridge_alloc(&client->dev, struct it6505, bridge,
+ &it6505_bridge_funcs);
+ if (IS_ERR(it6505))
+ return PTR_ERR(it6505);
mutex_init(&it6505->extcon_lock);
mutex_init(&it6505->mode_lock);
@@ -3659,8 +3660,6 @@ static int it6505_i2c_probe(struct i2c_client *client)
it6505->aux.dev = dev;
it6505->aux.transfer = it6505_aux_transfer;
drm_dp_aux_init(&it6505->aux);
-
- it6505->bridge.funcs = &it6505_bridge_funcs;
it6505->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
it6505->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HPD;
diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index 7b110ae532918d2d6f91ebc5f747c38e7e77dc07..aee88436d72e3c1c8d8f6b62ab04a8d9be10b413 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -1516,9 +1516,10 @@ static int it66121_probe(struct i2c_client *client)
return -ENXIO;
}
- ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct it66121_ctx, bridge,
+ &it66121_bridge_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
if (!ep)
@@ -1576,8 +1577,6 @@ static int it66121_probe(struct i2c_client *client)
(device_ids[1] << 8 | device_ids[0]) != ctx->info->pid) {
return -ENODEV;
}
-
- ctx->bridge.funcs = &it66121_bridge_funcs;
ctx->bridge.of_node = dev->of_node;
ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
ctx->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 3e49d855b3648880cea9bce5f3f04fbb6f838a45..c2a07f7c83fa1e0aefbbbcc855367adc6140f34d 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -761,9 +761,10 @@ static int lt8912_probe(struct i2c_client *client)
int ret = 0;
struct device *dev = &client->dev;
- lt = devm_kzalloc(dev, sizeof(struct lt8912), GFP_KERNEL);
- if (!lt)
- return -ENOMEM;
+ lt = devm_drm_bridge_alloc(dev, struct lt8912, bridge,
+ <8912_bridge_funcs);
+ if (IS_ERR(lt))
+ return PTR_ERR(lt);
lt->dev = dev;
lt->i2c_client[0] = client;
@@ -777,8 +778,6 @@ static int lt8912_probe(struct i2c_client *client)
goto err_i2c;
i2c_set_clientdata(client, lt);
-
- lt->bridge.funcs = <8912_bridge_funcs;
lt->bridge.of_node = dev->of_node;
lt->bridge.ops = (DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_DETECT);
diff --git a/drivers/gpu/drm/bridge/lontium-lt9211.c b/drivers/gpu/drm/bridge/lontium-lt9211.c
index 9b2dac9bd63c5afd4ffbafafdbbb1230549bc36f..97026fa66c5d39d49cf50ad69f707a84d584b76d 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9211.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9211.c
@@ -727,9 +727,9 @@ static int lt9211_probe(struct i2c_client *client)
struct lt9211 *ctx;
int ret;
- ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct lt9211, bridge, <9211_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
ctx->dev = dev;
@@ -754,8 +754,6 @@ static int lt9211_probe(struct i2c_client *client)
dev_set_drvdata(dev, ctx);
i2c_set_clientdata(client, ctx);
-
- ctx->bridge.funcs = <9211_funcs;
ctx->bridge.of_node = dev->of_node;
drm_bridge_add(&ctx->bridge);
diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c
index a35a8b8ca89c2cc138a7cb4de01c796c6211d655..dc82c8db9012bdd46691a5ea7f252d0b99697b9b 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611.c
@@ -1072,9 +1072,10 @@ static int lt9611_probe(struct i2c_client *client)
return -ENODEV;
}
- lt9611 = devm_kzalloc(dev, sizeof(*lt9611), GFP_KERNEL);
- if (!lt9611)
- return -ENOMEM;
+ lt9611 = devm_drm_bridge_alloc(dev, struct lt9611, bridge,
+ <9611_bridge_funcs);
+ if (IS_ERR(lt9611))
+ return PTR_ERR(lt9611);
lt9611->dev = dev;
lt9611->client = client;
@@ -1126,8 +1127,6 @@ static int lt9611_probe(struct i2c_client *client)
/* Disable Audio InfoFrame, enabled by default */
regmap_update_bits(lt9611->regmap, 0x843d, LT9611_INFOFRAME_AUDIO, 0);
-
- lt9611->bridge.funcs = <9611_bridge_funcs;
lt9611->bridge.of_node = client->dev.of_node;
lt9611->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HPD | DRM_BRIDGE_OP_MODES |
diff --git a/drivers/gpu/drm/bridge/lvds-codec.c b/drivers/gpu/drm/bridge/lvds-codec.c
index 1646e454e0b0b558d00f9421f15bb7084e2aa45a..e6a7147e141b64fc77dfef03a737ee599a0ecd10 100644
--- a/drivers/gpu/drm/bridge/lvds-codec.c
+++ b/drivers/gpu/drm/bridge/lvds-codec.c
@@ -118,9 +118,10 @@ static int lvds_codec_probe(struct platform_device *pdev)
u32 val;
int ret;
- lvds_codec = devm_kzalloc(dev, sizeof(*lvds_codec), GFP_KERNEL);
- if (!lvds_codec)
- return -ENOMEM;
+ lvds_codec = devm_drm_bridge_alloc(dev, struct lvds_codec, bridge,
+ &funcs);
+ if (IS_ERR(lvds_codec))
+ return PTR_ERR(lvds_codec);
lvds_codec->dev = &pdev->dev;
lvds_codec->connector_type = (uintptr_t)of_device_get_match_data(dev);
@@ -156,8 +157,6 @@ static int lvds_codec_probe(struct platform_device *pdev)
if (IS_ERR(lvds_codec->panel_bridge))
return PTR_ERR(lvds_codec->panel_bridge);
- lvds_codec->bridge.funcs = &funcs;
-
/*
* Decoder input LVDS format is a property of the decoder chip or even
* its strapping. Handle data-mapping the same way lvds-panel does. In
diff --git a/drivers/gpu/drm/bridge/microchip-lvds.c b/drivers/gpu/drm/bridge/microchip-lvds.c
index 1d4ae0097df847d9f93c79eecff0c4587ae331ba..9f4ff82bc6b49010f8727da3b367f5a744a28edc 100644
--- a/drivers/gpu/drm/bridge/microchip-lvds.c
+++ b/drivers/gpu/drm/bridge/microchip-lvds.c
@@ -157,9 +157,10 @@ static int mchp_lvds_probe(struct platform_device *pdev)
if (!dev->of_node)
return -ENODEV;
- lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
- if (!lvds)
- return -ENOMEM;
+ lvds = devm_drm_bridge_alloc(&pdev->dev, struct mchp_lvds, bridge,
+ &mchp_lvds_bridge_funcs);
+ if (IS_ERR(lvds))
+ return PTR_ERR(lvds);
lvds->dev = dev;
@@ -192,7 +193,6 @@ static int mchp_lvds_probe(struct platform_device *pdev)
lvds->bridge.of_node = dev->of_node;
lvds->bridge.type = DRM_MODE_CONNECTOR_LVDS;
- lvds->bridge.funcs = &mchp_lvds_bridge_funcs;
dev_set_drvdata(dev, lvds);
ret = devm_pm_runtime_enable(dev);
diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
index 55912ae11f46a1d551e11f93a306a8a00ef3f7d8..2f7429b24fc20db104dec17182f1119c6c75e600 100644
--- a/drivers/gpu/drm/bridge/nwl-dsi.c
+++ b/drivers/gpu/drm/bridge/nwl-dsi.c
@@ -1149,9 +1149,10 @@ static int nwl_dsi_probe(struct platform_device *pdev)
struct nwl_dsi *dsi;
int ret;
- dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(dev, struct nwl_dsi, bridge,
+ &nwl_dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
dsi->dev = dev;
@@ -1180,7 +1181,6 @@ static int nwl_dsi_probe(struct platform_device *pdev)
dsi->quirks = (uintptr_t)attr->data;
dsi->bridge.driver_private = dsi;
- dsi->bridge.funcs = &nwl_dsi_bridge_funcs;
dsi->bridge.of_node = dev->of_node;
dsi->bridge.timings = &nwl_dsi_timings;
dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c b/drivers/gpu/drm/bridge/parade-ps8622.c
index 8726fefc5c654e49bce029d943d241789ca4f802..81aa8dc8ee12af8b55f42d4786b44b3b90266491 100644
--- a/drivers/gpu/drm/bridge/parade-ps8622.c
+++ b/drivers/gpu/drm/bridge/parade-ps8622.c
@@ -449,9 +449,10 @@ static int ps8622_probe(struct i2c_client *client)
struct drm_bridge *panel_bridge;
int ret;
- ps8622 = devm_kzalloc(dev, sizeof(*ps8622), GFP_KERNEL);
- if (!ps8622)
- return -ENOMEM;
+ ps8622 = devm_drm_bridge_alloc(dev, struct ps8622_bridge, bridge,
+ &ps8622_bridge_funcs);
+ if (IS_ERR(ps8622))
+ return PTR_ERR(ps8622);
panel_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
if (IS_ERR(panel_bridge))
@@ -508,8 +509,6 @@ static int ps8622_probe(struct i2c_client *client)
ps8622->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS;
ps8622->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
}
-
- ps8622->bridge.funcs = &ps8622_bridge_funcs;
ps8622->bridge.type = DRM_MODE_CONNECTOR_LVDS;
ps8622->bridge.of_node = dev->of_node;
drm_bridge_add(&ps8622->bridge);
diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c
index 2422ff68c1042bd8eaa6821ff387d4faad47c550..d58ff094ddc7536acf04211367b9482e487b877a 100644
--- a/drivers/gpu/drm/bridge/parade-ps8640.c
+++ b/drivers/gpu/drm/bridge/parade-ps8640.c
@@ -636,9 +636,10 @@ static int ps8640_probe(struct i2c_client *client)
int ret;
u32 i;
- ps_bridge = devm_kzalloc(dev, sizeof(*ps_bridge), GFP_KERNEL);
- if (!ps_bridge)
- return -ENOMEM;
+ ps_bridge = devm_drm_bridge_alloc(dev, struct ps8640, bridge,
+ &ps8640_bridge_funcs);
+ if (IS_ERR(ps_bridge))
+ return PTR_ERR(ps_bridge);
mutex_init(&ps_bridge->aux_lock);
@@ -661,8 +662,6 @@ static int ps8640_probe(struct i2c_client *client)
GPIOD_OUT_HIGH);
if (IS_ERR(ps_bridge->gpio_reset))
return PTR_ERR(ps_bridge->gpio_reset);
-
- ps_bridge->bridge.funcs = &ps8640_bridge_funcs;
ps_bridge->bridge.of_node = dev->of_node;
ps_bridge->bridge.type = DRM_MODE_CONNECTOR_eDP;
diff --git a/drivers/gpu/drm/bridge/sii9234.c b/drivers/gpu/drm/bridge/sii9234.c
index cd7837c9a6e00b572a3fb65e5e0c9fa884555a73..487f355144a0e615298a3dd176b936885c2a8f33 100644
--- a/drivers/gpu/drm/bridge/sii9234.c
+++ b/drivers/gpu/drm/bridge/sii9234.c
@@ -888,9 +888,10 @@ static int sii9234_probe(struct i2c_client *client)
struct device *dev = &client->dev;
int ret;
- ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct sii9234, bridge,
+ &sii9234_bridge_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
ctx->dev = dev;
mutex_init(&ctx->lock);
@@ -920,8 +921,6 @@ static int sii9234_probe(struct i2c_client *client)
return ret;
i2c_set_clientdata(client, ctx);
-
- ctx->bridge.funcs = &sii9234_bridge_funcs;
ctx->bridge.of_node = dev->of_node;
drm_bridge_add(&ctx->bridge);
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
index 3af650dc92a1612ca88fe378319519546b79901f..7de6f0ec4ec2372f633cf1d73853c73fd9caf175 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -2291,9 +2291,10 @@ static int sii8620_probe(struct i2c_client *client)
struct sii8620 *ctx;
int ret;
- ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct sii8620, bridge,
+ &sii8620_bridge_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
ctx->dev = dev;
mutex_init(&ctx->lock);
@@ -2335,8 +2336,6 @@ static int sii8620_probe(struct i2c_client *client)
}
i2c_set_clientdata(client, ctx);
-
- ctx->bridge.funcs = &sii8620_bridge_funcs;
ctx->bridge.of_node = dev->of_node;
drm_bridge_add(&ctx->bridge);
diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 70db5b99e5bb84f099ec54cf62abbda53475311d..f9be4eafadfd1e4229161375e47da95a3075b090 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -168,9 +168,10 @@ static int simple_bridge_probe(struct platform_device *pdev)
struct simple_bridge *sbridge;
struct device_node *remote;
- sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL);
- if (!sbridge)
- return -ENOMEM;
+ sbridge = devm_drm_bridge_alloc(&pdev->dev, struct simple_bridge,
+ bridge, &simple_bridge_bridge_funcs);
+ if (IS_ERR(sbridge))
+ return PTR_ERR(sbridge);
sbridge->info = of_device_get_match_data(&pdev->dev);
@@ -202,9 +203,6 @@ static int simple_bridge_probe(struct platform_device *pdev)
if (IS_ERR(sbridge->enable))
return dev_err_probe(&pdev->dev, PTR_ERR(sbridge->enable),
"Unable to retrieve enable GPIO\n");
-
- /* Register the bridge. */
- sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
sbridge->bridge.of_node = pdev->dev.of_node;
sbridge->bridge.timings = sbridge->info->timings;
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
index 5e5f8c2f95be1f5c4633f1093b17a00f9425bb37..9b1dfdb5e7ee528c876c01916c9821d550cad679 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
@@ -1045,9 +1045,10 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
return ERR_PTR(-ENODEV);
}
- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
- if (!hdmi)
- return ERR_PTR(-ENOMEM);
+ hdmi = devm_drm_bridge_alloc(dev, struct dw_hdmi_qp, bridge,
+ &dw_hdmi_qp_bridge_funcs);
+ if (IS_ERR(hdmi))
+ return PTR_ERR(hdmi);
hdmi->dev = dev;
@@ -1073,7 +1074,6 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
return ERR_PTR(ret);
hdmi->bridge.driver_private = hdmi;
- hdmi->bridge.funcs = &dw_hdmi_qp_bridge_funcs;
hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
DRM_BRIDGE_OP_EDID |
DRM_BRIDGE_OP_HDMI |
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index b08ada920a501d6a62f39581944a87019f5e5c15..87886235b8d3a85e0711f7763d048ad9eefd159a 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -1194,9 +1194,10 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
struct dw_mipi_dsi *dsi;
int ret;
- dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return ERR_PTR(-ENOMEM);
+ dsi = devm_drm_bridge_alloc(dev, struct dw_mipi_dsi, bridge,
+ &dw_mipi_dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
dsi->dev = dev;
dsi->plat_data = plat_data;
@@ -1265,7 +1266,6 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
}
dsi->bridge.driver_private = dsi;
- dsi->bridge.funcs = &dw_mipi_dsi_bridge_funcs;
dsi->bridge.of_node = pdev->dev.of_node;
return dsi;
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
index c76f5f2e74d14bd372f969c6c7832aa57f80772b..9f694f72b521912f5d4af46f2df2fc0fe3f776ea 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
@@ -914,9 +914,10 @@ __dw_mipi_dsi2_probe(struct platform_device *pdev,
struct dw_mipi_dsi2 *dsi2;
int ret;
- dsi2 = devm_kzalloc(dev, sizeof(*dsi2), GFP_KERNEL);
- if (!dsi2)
- return ERR_PTR(-ENOMEM);
+ dsi2 = devm_drm_bridge_alloc(dev, struct dw_mipi_dsi2, bridge,
+ &dw_mipi_dsi2_bridge_funcs);
+ if (IS_ERR(dsi2))
+ return PTR_ERR(dsi2);
dsi2->dev = dev;
dsi2->plat_data = plat_data;
@@ -981,7 +982,6 @@ __dw_mipi_dsi2_probe(struct platform_device *pdev,
}
dsi2->bridge.driver_private = dsi2;
- dsi2->bridge.funcs = &dw_mipi_dsi2_bridge_funcs;
dsi2->bridge.of_node = pdev->dev.of_node;
return dsi2;
diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index edf01476f2ef6e05ef2c144ff4467e7f6babc4c6..690f4c5a6fb113a6d5947a364922605d28d33edf 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -265,9 +265,10 @@ static int tc358762_probe(struct mipi_dsi_device *dsi)
struct tc358762 *ctx;
int ret;
- ctx = devm_kzalloc(dev, sizeof(struct tc358762), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct tc358762, bridge,
+ &tc358762_bridge_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
mipi_dsi_set_drvdata(dsi, ctx);
@@ -287,8 +288,6 @@ static int tc358762_probe(struct mipi_dsi_device *dsi)
ret = tc358762_configure_regulators(ctx);
if (ret < 0)
return ret;
-
- ctx->bridge.funcs = &tc358762_bridge_funcs;
ctx->bridge.type = DRM_MODE_CONNECTOR_DPI;
ctx->bridge.of_node = dev->of_node;
ctx->bridge.pre_enable_prev_first = true;
diff --git a/drivers/gpu/drm/bridge/tc358764.c b/drivers/gpu/drm/bridge/tc358764.c
index 3f76c890fad9ffa50dc02f289a37378332830516..c54a6e571daccfbce8eeb34e6e38faa7895642df 100644
--- a/drivers/gpu/drm/bridge/tc358764.c
+++ b/drivers/gpu/drm/bridge/tc358764.c
@@ -347,9 +347,10 @@ static int tc358764_probe(struct mipi_dsi_device *dsi)
struct tc358764 *ctx;
int ret;
- ctx = devm_kzalloc(dev, sizeof(struct tc358764), GFP_KERNEL);
- if (!ctx)
- return -ENOMEM;
+ ctx = devm_drm_bridge_alloc(dev, struct tc358764, bridge,
+ &tc358764_bridge_funcs);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
mipi_dsi_set_drvdata(dsi, ctx);
@@ -367,8 +368,6 @@ static int tc358764_probe(struct mipi_dsi_device *dsi)
ret = tc358764_configure_regulators(ctx);
if (ret < 0)
return ret;
-
- ctx->bridge.funcs = &tc358764_bridge_funcs;
ctx->bridge.of_node = dev->of_node;
ctx->bridge.pre_enable_prev_first = true;
diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
index 063f217a17b6cf32e9793b8a96a5ac6128584098..1868026b3ee012edc700f1994c88777765161651 100644
--- a/drivers/gpu/drm/bridge/tc358768.c
+++ b/drivers/gpu/drm/bridge/tc358768.c
@@ -1287,9 +1287,10 @@ static int tc358768_i2c_probe(struct i2c_client *client)
if (!np)
return -ENODEV;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
+ priv = devm_drm_bridge_alloc(dev, struct tc358768_priv, bridge,
+ &tc358768_bridge_funcs);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
dev_set_drvdata(dev, priv);
priv->dev = dev;
@@ -1320,8 +1321,6 @@ static int tc358768_i2c_probe(struct i2c_client *client)
priv->dsi_host.dev = dev;
priv->dsi_host.ops = &tc358768_dsi_host_ops;
-
- priv->bridge.funcs = &tc358768_bridge_funcs;
priv->bridge.timings = &default_tc358768_timings;
priv->bridge.of_node = np;
diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c
index 1b10e6ee1724ffb4bb8946f86d2f18e53428381a..b7d5ef377049656efeaca96abc5f68e61de1ee1e 100644
--- a/drivers/gpu/drm/bridge/tc358775.c
+++ b/drivers/gpu/drm/bridge/tc358775.c
@@ -659,9 +659,10 @@ static int tc_probe(struct i2c_client *client)
struct tc_data *tc;
int ret;
- tc = devm_kzalloc(dev, sizeof(*tc), GFP_KERNEL);
- if (!tc)
- return -ENOMEM;
+ tc = devm_drm_bridge_alloc(dev, struct tc_data, bridge,
+ &tc_bridge_funcs);
+ if (IS_ERR(tc))
+ return PTR_ERR(tc);
tc->dev = dev;
tc->i2c = client;
@@ -700,8 +701,6 @@ static int tc_probe(struct i2c_client *client)
dev_err(dev, "cannot get reset-gpios %d\n", ret);
return ret;
}
-
- tc->bridge.funcs = &tc_bridge_funcs;
tc->bridge.of_node = dev->of_node;
tc->bridge.pre_enable_prev_first = true;
drm_bridge_add(&tc->bridge);
diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
index e2fc78adebcf22f0d8cdb484078e37b748b776c6..2cb7cd0c060824256bbfa511f833cc00437d318b 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -181,9 +181,10 @@ static int thc63_probe(struct platform_device *pdev)
struct thc63_dev *thc63;
int ret;
- thc63 = devm_kzalloc(&pdev->dev, sizeof(*thc63), GFP_KERNEL);
- if (!thc63)
- return -ENOMEM;
+ thc63 = devm_drm_bridge_alloc(&pdev->dev, struct thc63_dev, bridge,
+ &thc63_bridge_func);
+ if (IS_ERR(thc63))
+ return PTR_ERR(thc63);
thc63->dev = &pdev->dev;
platform_set_drvdata(pdev, thc63);
@@ -208,7 +209,6 @@ static int thc63_probe(struct platform_device *pdev)
thc63->bridge.driver_private = thc63;
thc63->bridge.of_node = pdev->dev.of_node;
- thc63->bridge.funcs = &thc63_bridge_func;
thc63->bridge.timings = &thc63->timings;
drm_bridge_add(&thc63->bridge);
diff --git a/drivers/gpu/drm/bridge/ti-dlpc3433.c b/drivers/gpu/drm/bridge/ti-dlpc3433.c
index 47638d1c96ec5ad999604c8c7e8839ff85936d98..fdde52208c7c1f17b5fb2ac306fd3011cb1bb427 100644
--- a/drivers/gpu/drm/bridge/ti-dlpc3433.c
+++ b/drivers/gpu/drm/bridge/ti-dlpc3433.c
@@ -348,9 +348,10 @@ static int dlpc3433_probe(struct i2c_client *client)
struct dlpc *dlpc;
int ret;
- dlpc = devm_kzalloc(dev, sizeof(*dlpc), GFP_KERNEL);
- if (!dlpc)
- return -ENOMEM;
+ dlpc = devm_drm_bridge_alloc(dev, struct dlpc, bridge,
+ &dlpc_bridge_funcs);
+ if (IS_ERR(dlpc))
+ return PTR_ERR(dlpc);
dlpc->dev = dev;
@@ -364,8 +365,6 @@ static int dlpc3433_probe(struct i2c_client *client)
dev_set_drvdata(dev, dlpc);
i2c_set_clientdata(client, dlpc);
-
- dlpc->bridge.funcs = &dlpc_bridge_funcs;
dlpc->bridge.of_node = dev->of_node;
drm_bridge_add(&dlpc->bridge);
diff --git a/drivers/gpu/drm/bridge/ti-tdp158.c b/drivers/gpu/drm/bridge/ti-tdp158.c
index cca75443f0121e39527a6cecf711eff2c0d507b5..27053d020df7c6fabbd5ce631b46c3f2358f12b2 100644
--- a/drivers/gpu/drm/bridge/ti-tdp158.c
+++ b/drivers/gpu/drm/bridge/ti-tdp158.c
@@ -68,9 +68,10 @@ static int tdp158_probe(struct i2c_client *client)
struct tdp158 *tdp158;
struct device *dev = &client->dev;
- tdp158 = devm_kzalloc(dev, sizeof(*tdp158), GFP_KERNEL);
- if (!tdp158)
- return -ENOMEM;
+ tdp158 = devm_drm_bridge_alloc(dev, struct tdp158, bridge,
+ &tdp158_bridge_funcs);
+ if (IS_ERR(tdp158))
+ return PTR_ERR(tdp158);
tdp158->next = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);
if (IS_ERR(tdp158->next))
@@ -89,7 +90,6 @@ static int tdp158_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(tdp158->enable), "enable");
tdp158->bridge.of_node = dev->of_node;
- tdp158->bridge.funcs = &tdp158_bridge_funcs;
tdp158->bridge.driver_private = tdp158;
tdp158->dev = dev;
diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
index e15d232ddbac55c6f5f966471a6c63f9c29a06c1..a62c43fba854032790055751b713abb012ee0cc6 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -341,14 +341,13 @@ static int tfp410_init(struct device *dev, bool i2c)
return -ENXIO;
}
- dvi = devm_kzalloc(dev, sizeof(*dvi), GFP_KERNEL);
- if (!dvi)
- return -ENOMEM;
+ dvi = devm_drm_bridge_alloc(dev, struct tfp410, bridge,
+ &tfp410_bridge_funcs);
+ if (IS_ERR(dvi))
+ return PTR_ERR(dvi);
dvi->dev = dev;
dev_set_drvdata(dev, dvi);
-
- dvi->bridge.funcs = &tfp410_bridge_funcs;
dvi->bridge.of_node = dev->of_node;
dvi->bridge.timings = &dvi->timings;
dvi->bridge.type = DRM_MODE_CONNECTOR_DVID;
diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c b/drivers/gpu/drm/bridge/ti-tpd12s015.c
index 1c289051a5987e0aec4c286ef4c01ee1a2f9421f..f4d63171da54776e5b314595b6a028fdb819e4a8 100644
--- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
+++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
@@ -116,13 +116,12 @@ static int tpd12s015_probe(struct platform_device *pdev)
struct gpio_desc *gpio;
int ret;
- tpd = devm_kzalloc(&pdev->dev, sizeof(*tpd), GFP_KERNEL);
- if (!tpd)
- return -ENOMEM;
+ tpd = devm_drm_bridge_alloc(&pdev->dev, struct tpd12s015_device,
+ bridge, &tpd12s015_bridge_funcs);
+ if (IS_ERR(tpd))
+ return PTR_ERR(tpd);
platform_set_drvdata(pdev, tpd);
-
- tpd->bridge.funcs = &tpd12s015_bridge_funcs;
tpd->bridge.of_node = pdev->dev.of_node;
tpd->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
tpd->bridge.ops = DRM_BRIDGE_OP_DETECT;
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index b2408abb9d491bf25773d4dcc1be73c89cf208ce..f69a58942d88637d2451c1a3ce49eb568dc5fa2e 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2725,9 +2725,10 @@ static int mtk_dp_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;
- mtk_dp = devm_kzalloc(dev, sizeof(*mtk_dp), GFP_KERNEL);
- if (!mtk_dp)
- return -ENOMEM;
+ mtk_dp = devm_drm_bridge_alloc(dev, struct mtk_dp, bridge,
+ &mtk_dp_bridge_funcs);
+ if (IS_ERR(mtk_dp))
+ return PTR_ERR(mtk_dp);
mtk_dp->dev = dev;
mtk_dp->data = (struct mtk_dp_data *)of_device_get_match_data(dev);
@@ -2784,8 +2785,6 @@ static int mtk_dp_probe(struct platform_device *pdev)
ret = mtk_dp_register_phy(mtk_dp);
if (ret)
return ret;
-
- mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs;
mtk_dp->bridge.of_node = dev->of_node;
mtk_dp->bridge.type = mtk_dp->data->bridge_type;
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index 0f3b1ef8e497354edaf0a56e24660bf356fe01ac..d56beeda2e875cfd8060c87b0281ac457b80c51c 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -1179,9 +1179,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
struct mtk_dpi *dpi;
int ret;
- dpi = devm_kzalloc(dev, sizeof(*dpi), GFP_KERNEL);
- if (!dpi)
- return -ENOMEM;
+ dpi = devm_drm_bridge_alloc(dev, struct mtk_dpi, bridge,
+ &mtk_dpi_bridge_funcs);
+ if (IS_ERR(dpi))
+ return PTR_ERR(dpi);
dpi->dev = dev;
dpi->conf = (struct mtk_dpi_conf *)of_device_get_match_data(dev);
@@ -1232,8 +1233,6 @@ static int mtk_dpi_probe(struct platform_device *pdev)
return dpi->irq;
platform_set_drvdata(pdev, dpi);
-
- dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
dpi->bridge.of_node = dev->of_node;
dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 4fe1f38a3c4b7fcbbdbf7f6a82f66c9e2b546c02..e4edf17413ef3d022c3402f3abecb4f93adef2cf 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -1196,9 +1196,10 @@ static int mtk_dsi_probe(struct platform_device *pdev)
int irq_num;
int ret;
- dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(dev, struct mtk_dsi, bridge,
+ &mtk_dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
dsi->driver_data = of_device_get_match_data(dev);
@@ -1245,8 +1246,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)
init_waitqueue_head(&dsi->irq_wait_queue);
platform_set_drvdata(pdev, dsi);
-
- dsi->bridge.funcs = &mtk_dsi_bridge_funcs;
dsi->bridge.of_node = dev->of_node;
dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index c9d0c335c519d405d480ffdc2feaa5b847c0e1bb..fa8c752d96381a8593f8c9d20c76db37adae5ab3 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1690,9 +1690,10 @@ static int mtk_hdmi_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;
- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
- if (!hdmi)
- return -ENOMEM;
+ hdmi = devm_drm_bridge_alloc(dev, struct mtk_hdmi, bridge,
+ &mtk_hdmi_bridge_funcs);
+ if (IS_ERR(hdmi))
+ return PTR_ERR(hdmi);
hdmi->dev = dev;
hdmi->conf = of_device_get_match_data(dev);
@@ -1718,8 +1719,6 @@ static int mtk_hdmi_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret,
"Failed to register audio driver\n");
-
- hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs;
hdmi->bridge.of_node = pdev->dev.of_node;
hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
| DRM_BRIDGE_OP_HPD;
diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
index c9678dc68fa142882e2beb24fe81185fbdef733b..24a96b0a9e31de8f23192fd36c9515c65c4d87d3 100644
--- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
@@ -227,9 +227,12 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
struct device_node *remote;
int ret;
- meson_encoder_cvbs = devm_kzalloc(priv->dev, sizeof(*meson_encoder_cvbs), GFP_KERNEL);
- if (!meson_encoder_cvbs)
- return -ENOMEM;
+ meson_encoder_cvbs = devm_drm_bridge_alloc(priv->dev,
+ struct meson_encoder_cvbs,
+ bridge,
+ &meson_encoder_cvbs_bridge_funcs);
+ if (IS_ERR(meson_encoder_cvbs))
+ return PTR_ERR(meson_encoder_cvbs);
/* CVBS Connector Bridge */
remote = of_graph_get_remote_node(priv->dev->of_node, 0, 0);
@@ -243,9 +246,6 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
if (!meson_encoder_cvbs->next_bridge)
return dev_err_probe(priv->dev, -EPROBE_DEFER,
"Failed to find CVBS Connector bridge\n");
-
- /* CVBS Encoder Bridge */
- meson_encoder_cvbs->bridge.funcs = &meson_encoder_cvbs_bridge_funcs;
meson_encoder_cvbs->bridge.of_node = priv->dev->of_node;
meson_encoder_cvbs->bridge.type = DRM_MODE_CONNECTOR_Composite;
meson_encoder_cvbs->bridge.ops = DRM_BRIDGE_OP_MODES;
diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
index 3db518e5f95d324c218b730e0948c3dc845382bd..b98264801ee6ec45a1b9af1c5082d605b9b34aa4 100644
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -106,9 +106,12 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
struct device_node *remote;
int ret;
- meson_encoder_dsi = devm_kzalloc(priv->dev, sizeof(*meson_encoder_dsi), GFP_KERNEL);
- if (!meson_encoder_dsi)
- return -ENOMEM;
+ meson_encoder_dsi = devm_drm_bridge_alloc(priv->dev,
+ struct meson_encoder_dsi,
+ bridge,
+ &meson_encoder_dsi_bridge_funcs);
+ if (IS_ERR(meson_encoder_dsi))
+ return PTR_ERR(meson_encoder_dsi);
/* DSI Transceiver Bridge */
remote = of_graph_get_remote_node(priv->dev->of_node, 2, 0);
@@ -121,9 +124,6 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
if (!meson_encoder_dsi->next_bridge)
return dev_err_probe(priv->dev, -EPROBE_DEFER,
"Failed to find DSI transceiver bridge\n");
-
- /* DSI Encoder Bridge */
- meson_encoder_dsi->bridge.funcs = &meson_encoder_dsi_bridge_funcs;
meson_encoder_dsi->bridge.of_node = priv->dev->of_node;
meson_encoder_dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 5f02695aafd1aa8444cd936a36e8f3a8010881a0..abb335ec469576817f5095dd02a58b3fe63827dd 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -373,9 +373,12 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
struct device_node *remote;
int ret;
- meson_encoder_hdmi = devm_kzalloc(priv->dev, sizeof(*meson_encoder_hdmi), GFP_KERNEL);
- if (!meson_encoder_hdmi)
- return -ENOMEM;
+ meson_encoder_hdmi = devm_drm_bridge_alloc(priv->dev,
+ struct meson_encoder_hdmi,
+ bridge,
+ &meson_encoder_hdmi_bridge_funcs);
+ if (IS_ERR(meson_encoder_hdmi))
+ return PTR_ERR(meson_encoder_hdmi);
/* HDMI Transceiver Bridge */
remote = of_graph_get_remote_node(priv->dev->of_node, 1, 0);
@@ -390,9 +393,6 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
"Failed to find HDMI transceiver bridge\n");
goto err_put_node;
}
-
- /* HDMI Encoder Bridge */
- meson_encoder_hdmi->bridge.funcs = &meson_encoder_hdmi_bridge_funcs;
meson_encoder_hdmi->bridge.of_node = priv->dev->of_node;
meson_encoder_hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
meson_encoder_hdmi->bridge.interlace_allowed = true;
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c b/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
index a9145253294fcaef6bae4e1406a781f6d710d357..b90c90f31e86ef81bf60827ae9bcb9d3f8fca6e4 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c
@@ -878,9 +878,10 @@ static int rcar_lvds_probe(struct platform_device *pdev)
struct rcar_lvds *lvds;
int ret;
- lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
- if (lvds == NULL)
- return -ENOMEM;
+ lvds = devm_drm_bridge_alloc(&pdev->dev, struct rcar_lvds, bridge,
+ &rcar_lvds_bridge_ops);
+ if (IS_ERR(lvds))
+ return PTR_ERR(lvds);
platform_set_drvdata(pdev, lvds);
@@ -894,8 +895,6 @@ static int rcar_lvds_probe(struct platform_device *pdev)
ret = rcar_lvds_parse_dt(lvds);
if (ret < 0)
return ret;
-
- lvds->bridge.funcs = &rcar_lvds_bridge_ops;
lvds->bridge.of_node = pdev->dev.of_node;
lvds->mmio = devm_platform_ioremap_resource(pdev, 0);
diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
index dc6ab012cdb69f92a33da69638aef3fc6fdfa46c..cfece6f03afad9fac12e5c54d319b07d008ceb11 100644
--- a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
+++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
@@ -701,9 +701,10 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
u32 txsetr;
int ret;
- dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(&pdev->dev, struct rzg2l_mipi_dsi, bridge,
+ &rzg2l_mipi_dsi_bridge_ops);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
platform_set_drvdata(pdev, dsi);
dsi->dev = &pdev->dev;
@@ -759,9 +760,6 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
dsi->num_data_lanes = min(((txsetr >> 16) & 3) + 1, num_data_lanes);
rzg2l_mipi_dsi_dphy_exit(dsi);
pm_runtime_put(dsi->dev);
-
- /* Initialize the DRM bridge. */
- dsi->bridge.funcs = &rzg2l_mipi_dsi_bridge_ops;
dsi->bridge.of_node = dsi->dev->of_node;
/* Init host device */
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
` (33 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Ilpo Järvinen, Bryan O'Donoghue, Hans de Goede
This is the new API for allocating DRM bridges.
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/arm64/acer-aspire1-ec.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/arm64/acer-aspire1-ec.c b/drivers/platform/arm64/acer-aspire1-ec.c
index 958fe1bf5f85bb69ac7962f217de9f0b40cde9a1..438532a047e68799ac53a16a4c813fc16be997b9 100644
--- a/drivers/platform/arm64/acer-aspire1-ec.c
+++ b/drivers/platform/arm64/acer-aspire1-ec.c
@@ -452,9 +452,9 @@ static int aspire_ec_probe(struct i2c_client *client)
int ret;
u8 tmp;
- ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
- if (!ec)
- return -ENOMEM;
+ ec = devm_drm_bridge_alloc(dev, struct aspire_ec, bridge, &aspire_ec_bridge_funcs);
+ if (IS_ERR(ec))
+ return PTR_ERR(ec);
ec->client = client;
i2c_set_clientdata(client, ec);
@@ -497,7 +497,6 @@ static int aspire_ec_probe(struct i2c_client *client)
fwnode = device_get_named_child_node(dev, "connector");
if (fwnode) {
INIT_WORK(&ec->work, aspire_ec_bridge_update_hpd_work);
- ec->bridge.funcs = &aspire_ec_bridge_funcs;
ec->bridge.of_node = to_of_node(fwnode);
ec->bridge.ops = DRM_BRIDGE_OP_HPD;
ec->bridge.type = DRM_MODE_CONNECTOR_USB;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 03/34] drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-28 12:29 ` Andy Yan
2025-04-24 18:59 ` [PATCH v2 04/34] drm/bridge: anx7625: " Luca Ceresoli
` (32 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Uwe Kleine-König, Andy Yan, Dmitry Baryshkov, Jani Nikula,
Sui Jingfeng
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Andy Yan <andy.yan@rock-chips.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
---
drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index f2bafa6cf77956ecafc87aae3a2b6890bdb36cfa..f3fe47b12edca1f92ddd306d152be144df5649b5 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -664,9 +664,10 @@ static int anx6345_i2c_probe(struct i2c_client *client)
struct device *dev;
int i, err;
- anx6345 = devm_kzalloc(&client->dev, sizeof(*anx6345), GFP_KERNEL);
- if (!anx6345)
- return -ENOMEM;
+ anx6345 = devm_drm_bridge_alloc(&client->dev, struct anx6345, bridge,
+ &anx6345_bridge_funcs);
+ if (IS_ERR(anx6345))
+ return PTR_ERR(anx6345);
mutex_init(&anx6345->lock);
@@ -738,7 +739,6 @@ static int anx6345_i2c_probe(struct i2c_client *client)
/* Look for supported chip ID */
anx6345_poweron(anx6345);
if (anx6345_get_chip_id(anx6345)) {
- anx6345->bridge.funcs = &anx6345_bridge_funcs;
drm_bridge_add(&anx6345->bridge);
return 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 04/34] drm/bridge: anx7625: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (2 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
` (31 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Rob Herring (Arm), Hsin-Te Yuan, Jani Nikula, Pin-yen Lin,
Sui Jingfeng, Xin Ji
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Rob Herring (Arm)" <robh@kernel.org>
Cc: Hsin-Te Yuan <yuanhsinte@chromium.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Pin-yen Lin <treapking@chromium.org>
Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
Cc: Xin Ji <xji@analogixsemi.com>
---
drivers/gpu/drm/bridge/analogix/anx7625.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 8bfe477c476c045f8a08b6d646da7bae77693fdf..bdf8f7762e0c19d19e4c60ca0841edfc3625592c 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -2581,7 +2581,6 @@ static int anx7625_link_bridge(struct drm_dp_aux *aux)
return ret;
}
- platform->bridge.funcs = &anx7625_bridge_funcs;
platform->bridge.of_node = dev->of_node;
if (!anx7625_of_panel_on_aux_bus(dev))
platform->bridge.ops |= DRM_BRIDGE_OP_EDID;
@@ -2616,10 +2615,10 @@ static int anx7625_i2c_probe(struct i2c_client *client)
return -ENODEV;
}
- platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
- if (!platform) {
+ platform = devm_drm_bridge_alloc(dev, struct anx7625_data, bridge, &anx7625_bridge_funcs);
+ if (IS_ERR(platform)) {
DRM_DEV_ERROR(dev, "fail to allocate driver data\n");
- return -ENOMEM;
+ return PTR_ERR(platform);
}
pdata = &platform->pdata;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 05/34] drm/bridge: cdns-dsi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (3 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 04/34] drm/bridge: anx7625: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 06/34] drm/bridge: display-connector: " Luca Ceresoli
` (30 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Aradhya Bhatia, Tomi Valkeinen
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Aradhya Bhatia <a-bhatia1@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
index b022dd6e6b6e9e43bf11583806e1a8d1e7431ae8..7604574da66606c103cc035dd94b0e211b64ebdc 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
@@ -1289,9 +1289,10 @@ static int cdns_dsi_drm_probe(struct platform_device *pdev)
int ret, irq;
u32 val;
- dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(&pdev->dev, struct cdns_dsi, input.bridge,
+ &cdns_dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
platform_set_drvdata(pdev, dsi);
@@ -1349,7 +1350,6 @@ static int cdns_dsi_drm_probe(struct platform_device *pdev)
* CDNS_DPI_INPUT.
*/
input->id = CDNS_DPI_INPUT;
- input->bridge.funcs = &cdns_dsi_bridge_funcs;
input->bridge.of_node = pdev->dev.of_node;
/* Mask all interrupts before registering the IRQ handler. */
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 06/34] drm/bridge: display-connector: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (4 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
` (29 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/display-connector.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
index 09c08a53d5bdc5c48f5d520472f5a311289d4862..badd2c7f91a186e9a47c5a4ddc870d269f3798ab 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -210,9 +210,10 @@ static int display_connector_probe(struct platform_device *pdev)
const char *label = NULL;
int ret;
- conn = devm_kzalloc(&pdev->dev, sizeof(*conn), GFP_KERNEL);
- if (!conn)
- return -ENOMEM;
+ conn = devm_drm_bridge_alloc(&pdev->dev, struct display_connector, bridge,
+ &display_connector_bridge_funcs);
+ if (IS_ERR(conn))
+ return PTR_ERR(conn);
platform_set_drvdata(pdev, conn);
@@ -362,7 +363,6 @@ static int display_connector_probe(struct platform_device *pdev)
}
}
- conn->bridge.funcs = &display_connector_bridge_funcs;
conn->bridge.of_node = pdev->dev.of_node;
if (conn->bridge.ddc)
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 07/34] drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (5 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 06/34] drm/bridge: display-connector: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-29 12:09 ` Dmitry Baryshkov
2025-04-24 18:59 ` [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
` (28 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index bb33c30d3f88878736815b270813a035222aead1..766da2cb45a7e2a79256185b8e2d3bd1eff3648f 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -775,9 +775,9 @@ static int lt9611uxc_probe(struct i2c_client *client)
return -ENODEV;
}
- lt9611uxc = devm_kzalloc(dev, sizeof(*lt9611uxc), GFP_KERNEL);
- if (!lt9611uxc)
- return -ENOMEM;
+ lt9611uxc = devm_drm_bridge_alloc(dev, struct lt9611uxc, bridge, <9611uxc_bridge_funcs);
+ if (IS_ERR(lt9611uxc))
+ return PTR_ERR(lt9611uxc);
lt9611uxc->dev = dev;
lt9611uxc->client = client;
@@ -856,7 +856,6 @@ static int lt9611uxc_probe(struct i2c_client *client)
i2c_set_clientdata(client, lt9611uxc);
- lt9611uxc->bridge.funcs = <9611uxc_bridge_funcs;
lt9611uxc->bridge.of_node = client->dev.of_node;
lt9611uxc->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
if (lt9611uxc->hpd_supported)
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (6 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
` (27 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Ian Ray,
Martyn Welch, Peter Senna Tschudin
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Ian Ray <ian.ray@ge.com>
Cc: Martyn Welch <martyn.welch@collabora.co.uk>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
---
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
index 15a5a1f644fc10182c55bc9e489ccb81d4f924f9..81dde9ed7bcf7cacae000d9da31a3a5c347ce037 100644
--- a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
@@ -225,13 +225,11 @@ static int ge_b850v3_lvds_init(struct device *dev)
if (ge_b850v3_lvds_ptr)
goto success;
- ge_b850v3_lvds_ptr = devm_kzalloc(dev,
- sizeof(*ge_b850v3_lvds_ptr),
- GFP_KERNEL);
-
- if (!ge_b850v3_lvds_ptr) {
+ ge_b850v3_lvds_ptr = devm_drm_bridge_alloc(dev, struct ge_b850v3_lvds, bridge,
+ &ge_b850v3_lvds_funcs);
+ if (IS_ERR(ge_b850v3_lvds_ptr)) {
mutex_unlock(&ge_b850v3_lvds_dev_mutex);
- return -ENOMEM;
+ return PTR_ERR(ge_b850v3_lvds_ptr);
}
success:
@@ -264,7 +262,6 @@ static int ge_b850v3_register(void)
struct device *dev = &stdp4028_i2c->dev;
/* drm bridge initialization */
- ge_b850v3_lvds_ptr->bridge.funcs = &ge_b850v3_lvds_funcs;
ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
DRM_BRIDGE_OP_EDID;
ge_b850v3_lvds_ptr->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 09/34] drm/bridge: nxp-ptn3460: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (7 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 10/34] drm/bridge: sii902x: " Luca Ceresoli
` (26 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/nxp-ptn3460.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c b/drivers/gpu/drm/bridge/nxp-ptn3460.c
index 25d7c415478b14ef634bff4185a8dd8e866be0c6..7acb11f16dc19e87a84cc765b1cebef158662c00 100644
--- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -261,10 +261,10 @@ static int ptn3460_probe(struct i2c_client *client)
struct drm_bridge *panel_bridge;
int ret;
- ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL);
- if (!ptn_bridge) {
- return -ENOMEM;
- }
+ ptn_bridge = devm_drm_bridge_alloc(dev, struct ptn3460_bridge, bridge,
+ &ptn3460_bridge_funcs);
+ if (IS_ERR(ptn_bridge))
+ return PTR_ERR(ptn_bridge);
panel_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
if (IS_ERR(panel_bridge))
@@ -300,7 +300,6 @@ static int ptn3460_probe(struct i2c_client *client)
return ret;
}
- ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs;
ptn_bridge->bridge.ops = DRM_BRIDGE_OP_EDID;
ptn_bridge->bridge.type = DRM_MODE_CONNECTOR_LVDS;
ptn_bridge->bridge.of_node = dev->of_node;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 10/34] drm/bridge: sii902x: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (8 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
` (25 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/sii902x.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 6de61d9fe06487856e8b3c32db3c8d8c25633fd8..882973e900628c0d972d32cd4ff3588432daa8e9 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -1135,7 +1135,6 @@ static int sii902x_init(struct sii902x *sii902x)
if (ret)
goto err_unreg_audio;
- sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
sii902x->bridge.timings = &default_sii902x_timings;
sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
@@ -1170,9 +1169,9 @@ static int sii902x_probe(struct i2c_client *client)
return -EIO;
}
- sii902x = devm_kzalloc(dev, sizeof(*sii902x), GFP_KERNEL);
- if (!sii902x)
- return -ENOMEM;
+ sii902x = devm_drm_bridge_alloc(dev, struct sii902x, bridge, &sii902x_bridge_funcs);
+ if (IS_ERR(sii902x))
+ return PTR_ERR(sii902x);
sii902x->i2c = client;
sii902x->regmap = devm_regmap_init_i2c(client, &sii902x_regmap_config);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 11/34] drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (9 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 10/34] drm/bridge: sii902x: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 19:16 ` Cristian Ciocaltea
2025-04-24 18:59 ` [PATCH v2 12/34] drm/bridge: tda998x: " Luca Ceresoli
` (24 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Cristian Ciocaltea
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index deaba3b6f99789067d14b76d228b58816a09b395..8791408dd1ff2d3c3b223b4f7f6f00edb275abf0 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -3333,9 +3333,9 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
u8 config0;
u8 config3;
- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
- if (!hdmi)
- return ERR_PTR(-ENOMEM);
+ hdmi = devm_drm_bridge_alloc(dev, struct dw_hdmi, bridge, &dw_hdmi_bridge_funcs);
+ if (IS_ERR(hdmi))
+ return hdmi;
hdmi->plat_data = plat_data;
hdmi->dev = dev;
@@ -3495,7 +3495,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
}
hdmi->bridge.driver_private = hdmi;
- hdmi->bridge.funcs = &dw_hdmi_bridge_funcs;
hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
| DRM_BRIDGE_OP_HPD;
hdmi->bridge.interlace_allowed = true;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 12/34] drm/bridge: tda998x: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (10 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
` (23 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov, Russell King
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Russell King <linux@armlinux.org.uk>
---
drivers/gpu/drm/bridge/tda998x_drv.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index ac87033ba5372e32cb8dc3abafc8cf1ff8273103..850909f78a7bc0fab54a60880f9a0657e99056f3 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -1781,9 +1781,9 @@ static int tda998x_create(struct device *dev)
u32 video;
int rev_lo, rev_hi, ret;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
+ priv = devm_drm_bridge_alloc(dev, struct tda998x_priv, bridge, &tda998x_bridge_funcs);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
dev_set_drvdata(dev, priv);
@@ -1948,7 +1948,6 @@ static int tda998x_create(struct device *dev)
tda998x_audio_codec_init(priv, &client->dev);
}
- priv->bridge.funcs = &tda998x_bridge_funcs;
#ifdef CONFIG_OF
priv->bridge.of_node = dev->of_node;
#endif
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (11 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 12/34] drm/bridge: tda998x: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-28 20:53 ` Doug Anderson
2025-04-24 18:59 ` [PATCH v2 14/34] drm/exynos: mic: " Luca Ceresoli
` (22 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Herve Codina
This is the new API for allocating DRM bridges.
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi86.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index f72675766e01108d72033b8b83c25d3e4d8fd1a7..60224f476e1d048c693ab36a0a79b6897c6101a8 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -1317,7 +1317,6 @@ static int ti_sn_bridge_probe(struct auxiliary_device *adev,
if (ret)
return ret;
- pdata->bridge.funcs = &ti_sn_bridge_funcs;
pdata->bridge.of_node = np;
pdata->bridge.type = pdata->next_bridge->type == DRM_MODE_CONNECTOR_DisplayPort
? DRM_MODE_CONNECTOR_DisplayPort : DRM_MODE_CONNECTOR_eDP;
@@ -1907,9 +1906,9 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
return -ENODEV;
}
- pdata = devm_kzalloc(dev, sizeof(struct ti_sn65dsi86), GFP_KERNEL);
- if (!pdata)
- return -ENOMEM;
+ pdata = devm_drm_bridge_alloc(dev, struct ti_sn65dsi86, bridge, &ti_sn_bridge_funcs);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
dev_set_drvdata(dev, pdata);
pdata->dev = dev;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 14/34] drm/exynos: mic: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (12 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
` (21 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_mic.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index b34ec67283370e3fa836c7df06e12e2fba524622..29a8366513fa70655c6ceec9a09db0158e7bb169 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -379,11 +379,11 @@ static int exynos_mic_probe(struct platform_device *pdev)
struct resource res;
int ret, i;
- mic = devm_kzalloc(dev, sizeof(*mic), GFP_KERNEL);
- if (!mic) {
+ mic = devm_drm_bridge_alloc(dev, struct exynos_mic, bridge, &mic_bridge_funcs);
+ if (IS_ERR(mic)) {
DRM_DEV_ERROR(dev,
"mic: Failed to allocate memory for MIC object\n");
- ret = -ENOMEM;
+ ret = PTR_ERR(mic);
goto err;
}
@@ -421,7 +421,6 @@ static int exynos_mic_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mic);
- mic->bridge.funcs = &mic_bridge_funcs;
mic->bridge.of_node = dev->of_node;
drm_bridge_add(&mic->bridge);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 15/34] drm/mcde: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (13 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 14/34] drm/exynos: mic: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-29 8:40 ` Linus Walleij
2025-04-24 18:59 ` [PATCH v2 16/34] drm/msm/dp: " Luca Ceresoli
` (20 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Linus Walleij
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpu/drm/mcde/mcde_dsi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index b302d8ec3ad0e82ace9c10194ae37948ebb8e753..a3423459dd7ac8395b77d0479a02ebb3a9ba259c 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1138,7 +1138,6 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
d->bridge_out = bridge;
/* Create a bridge for this DSI channel */
- d->bridge.funcs = &mcde_dsi_bridge_funcs;
d->bridge.of_node = dev->of_node;
drm_bridge_add(&d->bridge);
@@ -1174,9 +1173,9 @@ static int mcde_dsi_probe(struct platform_device *pdev)
u32 dsi_id;
int ret;
- d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
- if (!d)
- return -ENOMEM;
+ d = devm_drm_bridge_alloc(dev, struct mcde_dsi, bridge, &mcde_dsi_bridge_funcs);
+ if (IS_ERR(d))
+ return PTR_ERR(d);
d->dev = dev;
platform_set_drvdata(pdev, d);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 16/34] drm/msm/dp: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (14 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 17/34] drm/msm/dsi: " Luca Ceresoli
` (19 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov, Abhinav Kumar, Bjorn Andersson, Marijn Suijten,
Rob Clark, Sean Paul
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Bjorn Andersson <quic_bjorande@quicinc.com>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
---
drivers/gpu/drm/msm/dp/dp_drm.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index cca57e56c906255a315e759e85a5af5982c80e9c..293f4745f1e20ba67da1d3fc218da3d90e1be588 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -296,14 +296,15 @@ int msm_dp_bridge_init(struct msm_dp *msm_dp_display, struct drm_device *dev,
struct msm_dp_bridge *msm_dp_bridge;
struct drm_bridge *bridge;
- msm_dp_bridge = devm_kzalloc(dev->dev, sizeof(*msm_dp_bridge), GFP_KERNEL);
- if (!msm_dp_bridge)
- return -ENOMEM;
+ msm_dp_bridge = devm_drm_bridge_alloc(dev->dev, struct msm_dp_bridge, bridge,
+ msm_dp_display->is_edp ? &msm_edp_bridge_ops :
+ &msm_dp_bridge_ops);
+ if (IS_ERR(msm_dp_bridge))
+ return PTR_ERR(msm_dp_bridge);
msm_dp_bridge->msm_dp_display = msm_dp_display;
bridge = &msm_dp_bridge->bridge;
- bridge->funcs = msm_dp_display->is_edp ? &msm_edp_bridge_ops : &msm_dp_bridge_ops;
bridge->type = msm_dp_display->connector_type;
bridge->ycbcr_420_allowed = yuv_supported;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 17/34] drm/msm/dsi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (15 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 16/34] drm/msm/dp: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 18/34] drm/msm/hdmi: " Luca Ceresoli
` (18 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov, Abhinav Kumar, Marijn Suijten, Rob Clark,
Sean Paul
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
---
drivers/gpu/drm/msm/dsi/dsi_manager.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 72ada9f2f043d2278e3ff2ff499fb52502330c68..ca400924d4eea89732905997d087e442ba9f336e 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -462,15 +462,14 @@ int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
struct drm_connector *connector;
int ret;
- dsi_bridge = devm_kzalloc(msm_dsi->dev->dev,
- sizeof(*dsi_bridge), GFP_KERNEL);
- if (!dsi_bridge)
- return -ENOMEM;
+ dsi_bridge = devm_drm_bridge_alloc(msm_dsi->dev->dev, struct dsi_bridge, base,
+ &dsi_mgr_bridge_funcs);
+ if (IS_ERR(dsi_bridge))
+ return PTR_ERR(dsi_bridge);
dsi_bridge->id = msm_dsi->id;
bridge = &dsi_bridge->base;
- bridge->funcs = &dsi_mgr_bridge_funcs;
ret = devm_drm_bridge_add(msm_dsi->dev->dev, bridge);
if (ret)
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 18/34] drm/msm/hdmi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (16 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 17/34] drm/msm/dsi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 19/34] drm/omap: dss: dpi: " Luca Ceresoli
` (17 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Dmitry Baryshkov, Abhinav Kumar, Marijn Suijten, Rob Clark,
Sean Paul
This is the new API for allocating DRM bridges.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
---
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
index ab6c8bc4a30b681f7de8ca7031f833795d1f7d94..7f71956806a25a1ab23293284da83ed4a8759c98 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
@@ -498,16 +498,15 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi)
struct hdmi_bridge *hdmi_bridge;
int ret;
- hdmi_bridge = devm_kzalloc(hdmi->dev->dev,
- sizeof(*hdmi_bridge), GFP_KERNEL);
- if (!hdmi_bridge)
- return -ENOMEM;
+ hdmi_bridge = devm_drm_bridge_alloc(hdmi->dev->dev, struct hdmi_bridge, base,
+ &msm_hdmi_bridge_funcs);
+ if (IS_ERR(hdmi_bridge))
+ return PTR_ERR(hdmi_bridge);
hdmi_bridge->hdmi = hdmi;
INIT_WORK(&hdmi_bridge->hpd_work, msm_hdmi_hotplug_work);
bridge = &hdmi_bridge->base;
- bridge->funcs = &msm_hdmi_bridge_funcs;
bridge->ddc = hdmi->i2c;
bridge->type = DRM_MODE_CONNECTOR_HDMIA;
bridge->vendor = "Qualcomm";
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 19/34] drm/omap: dss: dpi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (17 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 18/34] drm/msm/hdmi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 20/34] drm/omap: dss: dsi: " Luca Ceresoli
` (16 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Rob Herring (Arm), Helge Deller, Kuninori Morimoto,
Tomi Valkeinen
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Rob Herring (Arm)" <robh@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/dpi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 6eff97a091602f6d137095b3b7bf54fce17e8d3e..9f86db774c395db7e3396cbf2694748fc23c309d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -562,7 +562,6 @@ static const struct drm_bridge_funcs dpi_bridge_funcs = {
static void dpi_bridge_init(struct dpi_data *dpi)
{
- dpi->bridge.funcs = &dpi_bridge_funcs;
dpi->bridge.of_node = dpi->pdev->dev.of_node;
dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
@@ -707,9 +706,9 @@ int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
u32 datalines;
int r;
- dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL);
- if (!dpi)
- return -ENOMEM;
+ dpi = devm_drm_bridge_alloc(&pdev->dev, struct dpi_data, bridge, &dpi_bridge_funcs);
+ if (IS_ERR(dpi))
+ return PTR_ERR(dpi);
ep = of_graph_get_next_port_endpoint(port, NULL);
if (!ep)
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 20/34] drm/omap: dss: dsi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (18 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 19/34] drm/omap: dss: dpi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
` (15 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Tomi Valkeinen
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 91ee63bfe0bc73e28877d0383812225867e167a4..b129e5a8d791507098c7b8d1bc54f54c4b453954 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4701,7 +4701,6 @@ static const struct drm_bridge_funcs dsi_bridge_funcs = {
static void dsi_bridge_init(struct dsi_data *dsi)
{
- dsi->bridge.funcs = &dsi_bridge_funcs;
dsi->bridge.of_node = dsi->host.dev->of_node;
dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
@@ -4894,9 +4893,9 @@ static int dsi_probe(struct platform_device *pdev)
unsigned int i;
int r;
- dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(dev, struct dsi_data, bridge, &dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
dsi->dev = dev;
dev_set_drvdata(dev, dsi);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 21/34] drm/omap: dss: hdmi4: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (19 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 20/34] drm/omap: dss: dsi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
` (14 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Tomi Valkeinen
This is the new API for allocating DRM bridges.
Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/hdmi4.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index a3b22952fdc32b5899dae82d413108c5c0a1c3c8..3cd612af24498b057c33eaecb3d43c8df76cd23e 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -505,7 +505,6 @@ static const struct drm_bridge_funcs hdmi4_bridge_funcs = {
static void hdmi4_bridge_init(struct omap_hdmi *hdmi)
{
- hdmi->bridge.funcs = &hdmi4_bridge_funcs;
hdmi->bridge.of_node = hdmi->pdev->dev.of_node;
hdmi->bridge.ops = DRM_BRIDGE_OP_EDID;
hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
@@ -761,9 +760,9 @@ static int hdmi4_probe(struct platform_device *pdev)
int irq;
int r;
- hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
- if (!hdmi)
- return -ENOMEM;
+ hdmi = devm_drm_bridge_alloc(&pdev->dev, struct omap_hdmi, bridge, &hdmi4_bridge_funcs);
+ if (IS_ERR(hdmi))
+ return PTR_ERR(hdmi);
hdmi->pdev = pdev;
@@ -774,25 +773,24 @@ static int hdmi4_probe(struct platform_device *pdev)
r = hdmi4_probe_of(hdmi);
if (r)
- goto err_free;
+ return r;
r = hdmi_wp_init(pdev, &hdmi->wp, 4);
if (r)
- goto err_free;
+ return r;
r = hdmi_phy_init(pdev, &hdmi->phy, 4);
if (r)
- goto err_free;
+ return r;
r = hdmi4_core_init(pdev, &hdmi->core);
if (r)
- goto err_free;
+ return r;
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
DSSERR("platform_get_irq failed\n");
- r = -ENODEV;
- goto err_free;
+ return -ENODEV;
}
r = devm_request_threaded_irq(&pdev->dev, irq,
@@ -800,7 +798,7 @@ static int hdmi4_probe(struct platform_device *pdev)
IRQF_ONESHOT, "OMAP HDMI", hdmi);
if (r) {
DSSERR("HDMI IRQ request failed\n");
- goto err_free;
+ return r;
}
hdmi->vdda_reg = devm_regulator_get(&pdev->dev, "vdda");
@@ -808,7 +806,7 @@ static int hdmi4_probe(struct platform_device *pdev)
r = PTR_ERR(hdmi->vdda_reg);
if (r != -EPROBE_DEFER)
DSSERR("can't get VDDA regulator\n");
- goto err_free;
+ return r;
}
pm_runtime_enable(&pdev->dev);
@@ -827,8 +825,6 @@ static int hdmi4_probe(struct platform_device *pdev)
hdmi4_uninit_output(hdmi);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
-err_free:
- kfree(hdmi);
return r;
}
@@ -841,8 +837,6 @@ static void hdmi4_remove(struct platform_device *pdev)
hdmi4_uninit_output(hdmi);
pm_runtime_disable(&pdev->dev);
-
- kfree(hdmi);
}
static const struct of_device_id hdmi_of_match[] = {
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 22/34] drm/omap: dss: hdmi5: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (20 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 23/34] drm/omap: dss: sdi: " Luca Ceresoli
` (13 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Tomi Valkeinen
This is the new API for allocating DRM bridges.
Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/hdmi5.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 0c98444d39a93d8336b4d8dbd45aa4521181c3b4..5636b3dfec1c9581118b20adecd268c03e882efb 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -480,7 +480,6 @@ static const struct drm_bridge_funcs hdmi5_bridge_funcs = {
static void hdmi5_bridge_init(struct omap_hdmi *hdmi)
{
- hdmi->bridge.funcs = &hdmi5_bridge_funcs;
hdmi->bridge.of_node = hdmi->pdev->dev.of_node;
hdmi->bridge.ops = DRM_BRIDGE_OP_EDID;
hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
@@ -727,9 +726,9 @@ static int hdmi5_probe(struct platform_device *pdev)
int irq;
int r;
- hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
- if (!hdmi)
- return -ENOMEM;
+ hdmi = devm_drm_bridge_alloc(&pdev->dev, struct omap_hdmi, bridge, &hdmi5_bridge_funcs);
+ if (IS_ERR(hdmi))
+ return PTR_ERR(hdmi);
hdmi->pdev = pdev;
@@ -740,25 +739,24 @@ static int hdmi5_probe(struct platform_device *pdev)
r = hdmi5_probe_of(hdmi);
if (r)
- goto err_free;
+ return r;
r = hdmi_wp_init(pdev, &hdmi->wp, 5);
if (r)
- goto err_free;
+ return r;
r = hdmi_phy_init(pdev, &hdmi->phy, 5);
if (r)
- goto err_free;
+ return r;
r = hdmi5_core_init(pdev, &hdmi->core);
if (r)
- goto err_free;
+ return r;
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
DSSERR("platform_get_irq failed\n");
- r = -ENODEV;
- goto err_free;
+ return -ENODEV;
}
r = devm_request_threaded_irq(&pdev->dev, irq,
@@ -766,7 +764,7 @@ static int hdmi5_probe(struct platform_device *pdev)
IRQF_ONESHOT, "OMAP HDMI", hdmi);
if (r) {
DSSERR("HDMI IRQ request failed\n");
- goto err_free;
+ return r;
}
hdmi->vdda_reg = devm_regulator_get(&pdev->dev, "vdda");
@@ -774,7 +772,7 @@ static int hdmi5_probe(struct platform_device *pdev)
r = PTR_ERR(hdmi->vdda_reg);
if (r != -EPROBE_DEFER)
DSSERR("can't get VDDA regulator\n");
- goto err_free;
+ return r;
}
pm_runtime_enable(&pdev->dev);
@@ -793,8 +791,6 @@ static int hdmi5_probe(struct platform_device *pdev)
hdmi5_uninit_output(hdmi);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
-err_free:
- kfree(hdmi);
return r;
}
@@ -807,8 +803,6 @@ static void hdmi5_remove(struct platform_device *pdev)
hdmi5_uninit_output(hdmi);
pm_runtime_disable(&pdev->dev);
-
- kfree(hdmi);
}
static const struct of_device_id hdmi_of_match[] = {
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 23/34] drm/omap: dss: sdi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (21 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 24/34] drm/omap: dss: venc: " Luca Ceresoli
` (12 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Rob Herring (Arm), Kuninori Morimoto, Tomi Valkeinen
This is the new API for allocating DRM bridges.
Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Rob Herring (Arm)" <robh@kernel.org>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/sdi.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index e78826e4b560a2b9af2d8a5a38e181bd3e44d250..df4cbc683e2ca27ef5fc45f79b77dcdcd9ca529a 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -284,7 +284,6 @@ static const struct drm_bridge_funcs sdi_bridge_funcs = {
static void sdi_bridge_init(struct sdi_device *sdi)
{
- sdi->bridge.funcs = &sdi_bridge_funcs;
sdi->bridge.of_node = sdi->pdev->dev.of_node;
sdi->bridge.type = DRM_MODE_CONNECTOR_LVDS;
@@ -344,21 +343,19 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
u32 datapairs;
int r;
- sdi = kzalloc(sizeof(*sdi), GFP_KERNEL);
- if (!sdi)
- return -ENOMEM;
+ sdi = devm_drm_bridge_alloc(&pdev->dev, struct sdi_device, bridge, &sdi_bridge_funcs);
+ if (IS_ERR(sdi))
+ return PTR_ERR(sdi);
ep = of_graph_get_next_port_endpoint(port, NULL);
- if (!ep) {
- r = 0;
- goto err_free;
- }
+ if (!ep)
+ return 0;
r = of_property_read_u32(ep, "datapairs", &datapairs);
of_node_put(ep);
if (r) {
DSSERR("failed to parse datapairs\n");
- goto err_free;
+ return r;
}
sdi->datapairs = datapairs;
@@ -372,19 +369,14 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
r = PTR_ERR(sdi->vdds_sdi_reg);
if (r != -EPROBE_DEFER)
DSSERR("can't get VDDS_SDI regulator\n");
- goto err_free;
+ return r;
}
r = sdi_init_output(sdi);
if (r)
- goto err_free;
+ return r;
return 0;
-
-err_free:
- kfree(sdi);
-
- return r;
}
void sdi_uninit_port(struct device_node *port)
@@ -395,5 +387,4 @@ void sdi_uninit_port(struct device_node *port)
return;
sdi_uninit_output(sdi);
- kfree(sdi);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 24/34] drm/omap: dss: venc: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (22 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 23/34] drm/omap: dss: sdi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 25/34] drm/rcar-du: dsi: " Luca Ceresoli
` (11 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Tomi Valkeinen
This is the new API for allocating DRM bridges.
Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/gpu/drm/omapdrm/dss/venc.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 50349518eda1630400529caf27ca4469bb09fc82..9b5d53dc361e654a2e4009c3c81b726f9ef76ced 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -664,7 +664,6 @@ static const struct drm_bridge_funcs venc_bridge_funcs = {
static void venc_bridge_init(struct venc_device *venc)
{
- venc->bridge.funcs = &venc_bridge_funcs;
venc->bridge.of_node = venc->pdev->dev.of_node;
venc->bridge.ops = DRM_BRIDGE_OP_MODES;
venc->bridge.type = DRM_MODE_CONNECTOR_SVIDEO;
@@ -809,9 +808,9 @@ static int venc_probe(struct platform_device *pdev)
struct venc_device *venc;
int r;
- venc = kzalloc(sizeof(*venc), GFP_KERNEL);
- if (!venc)
- return -ENOMEM;
+ venc = devm_drm_bridge_alloc(&pdev->dev, struct venc_device, bridge, &venc_bridge_funcs);
+ if (IS_ERR(venc))
+ return PTR_ERR(venc);
venc->pdev = pdev;
@@ -824,26 +823,24 @@ static int venc_probe(struct platform_device *pdev)
venc->config = &venc_config_pal_trm;
venc->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(venc->base)) {
- r = PTR_ERR(venc->base);
- goto err_free;
- }
+ if (IS_ERR(venc->base))
+ return PTR_ERR(venc->base);
venc->vdda_dac_reg = devm_regulator_get(&pdev->dev, "vdda");
if (IS_ERR(venc->vdda_dac_reg)) {
r = PTR_ERR(venc->vdda_dac_reg);
if (r != -EPROBE_DEFER)
DSSERR("can't get VDDA_DAC regulator\n");
- goto err_free;
+ return r;
}
r = venc_get_clocks(venc);
if (r)
- goto err_free;
+ return r;
r = venc_probe_of(venc);
if (r)
- goto err_free;
+ return r;
pm_runtime_enable(&pdev->dev);
@@ -861,8 +858,6 @@ static int venc_probe(struct platform_device *pdev)
venc_uninit_output(venc);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
-err_free:
- kfree(venc);
return r;
}
@@ -875,8 +870,6 @@ static void venc_remove(struct platform_device *pdev)
venc_uninit_output(venc);
pm_runtime_disable(&pdev->dev);
-
- kfree(venc);
}
static __maybe_unused int venc_runtime_suspend(struct device *dev)
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 25/34] drm/rcar-du: dsi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (23 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 24/34] drm/omap: dss: venc: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
` (10 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Kieran Bingham, Laurent Pinchart, Tomi Valkeinen
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
index 7ab8be46c7f6547f29b4d45af7ac704283da9dcd..1af4c73f7a887712aef8c8176b0d0338d9ca9727 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
@@ -918,7 +918,6 @@ static int rcar_mipi_dsi_host_attach(struct mipi_dsi_host *host,
}
/* Initialize the DRM bridge. */
- dsi->bridge.funcs = &rcar_mipi_dsi_bridge_ops;
dsi->bridge.of_node = dsi->dev->of_node;
drm_bridge_add(&dsi->bridge);
@@ -1004,9 +1003,10 @@ static int rcar_mipi_dsi_probe(struct platform_device *pdev)
struct rcar_mipi_dsi *dsi;
int ret;
- dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
- if (dsi == NULL)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(&pdev->dev, struct rcar_mipi_dsi, bridge,
+ &rcar_mipi_dsi_bridge_ops);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
platform_set_drvdata(pdev, dsi);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 26/34] drm/bridge: stm_lvds: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (24 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 25/34] drm/rcar-du: dsi: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
` (9 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre
This is the new API for allocating DRM bridges.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Philippe Cornu <philippe.cornu@foss.st.com>
Cc: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
Cc: Yannick Fertre <yannick.fertre@foss.st.com>
---
drivers/gpu/drm/stm/lvds.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/stm/lvds.c b/drivers/gpu/drm/stm/lvds.c
index a3ae9a93ce6670eb2c4dd36b3e572fcbca791a1c..07788e8d3d8302a3951e97d64736b721033998d3 100644
--- a/drivers/gpu/drm/stm/lvds.c
+++ b/drivers/gpu/drm/stm/lvds.c
@@ -1049,9 +1049,9 @@ static int lvds_probe(struct platform_device *pdev)
dev_dbg(dev, "Probing LVDS driver...\n");
- lvds = devm_kzalloc(dev, sizeof(*lvds), GFP_KERNEL);
- if (!lvds)
- return -ENOMEM;
+ lvds = devm_drm_bridge_alloc(dev, struct stm_lvds, lvds_bridge, &lvds_bridge_funcs);
+ if (IS_ERR(lvds))
+ return PTR_ERR(lvds);
lvds->dev = dev;
@@ -1164,7 +1164,6 @@ static int lvds_probe(struct platform_device *pdev)
goto err_lvds_probe;
}
- lvds->lvds_bridge.funcs = &lvds_bridge_funcs;
lvds->lvds_bridge.of_node = dev->of_node;
lvds->hw_version = lvds_read(lvds, LVDS_VERR);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 27/34] drm/vc4: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (25 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-28 15:45 ` Dave Stevenson
2025-04-24 18:59 ` [PATCH v2 28/34] drm/sti: dvo: " Luca Ceresoli
` (8 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance
This is the new API for allocating DRM bridges.
This driver already implements refcounting of the struct vc4_dsi, which
embeds struct drm_bridge. Now this is a duplicate of the refcounting
implemented by the DRM bridge core, so convert the vc4_dsi_get/put() calls
into drm_bridge_get/put() calls and get rid of the driver-specific
refcounting implementation.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: "Maíra Canal" <mcanal@igalia.com>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
Changed in v2:
- fix error code checking
---
drivers/gpu/drm/vc4/vc4_dsi.c | 34 +++++-----------------------------
1 file changed, 5 insertions(+), 29 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index efc6f6078b026764c59cfb2a33b28a88b7018c3a..458e5d9879645f18bcbcaeeb71b5f1038f9581da 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -552,8 +552,6 @@ struct vc4_dsi {
struct vc4_encoder encoder;
struct mipi_dsi_host dsi_host;
- struct kref kref;
-
struct platform_device *pdev;
struct drm_bridge *out_bridge;
@@ -1622,29 +1620,11 @@ static void vc4_dsi_dma_chan_release(void *ptr)
dsi->reg_dma_chan = NULL;
}
-static void vc4_dsi_release(struct kref *kref)
-{
- struct vc4_dsi *dsi =
- container_of(kref, struct vc4_dsi, kref);
-
- kfree(dsi);
-}
-
-static void vc4_dsi_get(struct vc4_dsi *dsi)
-{
- kref_get(&dsi->kref);
-}
-
-static void vc4_dsi_put(struct vc4_dsi *dsi)
-{
- kref_put(&dsi->kref, &vc4_dsi_release);
-}
-
static void vc4_dsi_release_action(struct drm_device *drm, void *ptr)
{
struct vc4_dsi *dsi = ptr;
- vc4_dsi_put(dsi);
+ drm_bridge_put(&dsi->bridge);
}
static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
@@ -1655,7 +1635,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
struct drm_encoder *encoder = &dsi->encoder.base;
int ret;
- vc4_dsi_get(dsi);
+ drm_bridge_get(&dsi->bridge);
ret = drmm_add_action_or_reset(drm, vc4_dsi_release_action, dsi);
if (ret)
@@ -1810,15 +1790,12 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct vc4_dsi *dsi;
- dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
- if (!dsi)
- return -ENOMEM;
+ dsi = devm_drm_bridge_alloc(&pdev->dev, struct vc4_dsi, bridge, &vc4_dsi_bridge_funcs);
+ if (IS_ERR(dsi))
+ return PTR_ERR(dsi);
dev_set_drvdata(dev, dsi);
- kref_init(&dsi->kref);
-
dsi->pdev = pdev;
- dsi->bridge.funcs = &vc4_dsi_bridge_funcs;
#ifdef CONFIG_OF
dsi->bridge.of_node = dev->of_node;
#endif
@@ -1836,7 +1813,6 @@ static void vc4_dsi_dev_remove(struct platform_device *pdev)
struct vc4_dsi *dsi = dev_get_drvdata(dev);
mipi_dsi_host_unregister(&dsi->dsi_host);
- vc4_dsi_put(dsi);
}
struct platform_driver vc4_dsi_driver = {
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 28/34] drm/sti: dvo: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (26 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 29/34] drm: zynqmp_dp: " Luca Ceresoli
` (7 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Alain Volmat, Raphael Gallais-Pou
This is the new API for allocating DRM bridges.
This driver allocates the DRM bridge separately from the main driver
private struct, which prevents using the new devm_drm_bridge_alloc()
API. Simplify the code by replacing the struct drm_bridge pointer with an
embedded struct drm_bridge inside the private struct, to make use of the
new API with the same code flow.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Raphael Gallais-Pou <rgallaispou@gmail.com>
Changed in v2:
- fix typos in commit message
---
drivers/gpu/drm/sti/sti_dvo.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 74a1eef4674eeabc445b53b380e325f785242024..7484d3c3f4ed5fac7eab408e30cbe2f6b87f27e5 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -97,7 +97,7 @@ struct sti_dvo {
struct dvo_config *config;
bool enabled;
struct drm_encoder *encoder;
- struct drm_bridge *bridge;
+ struct drm_bridge bridge;
};
struct sti_dvo_connector {
@@ -439,7 +439,6 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
struct drm_encoder *encoder;
struct sti_dvo_connector *connector;
struct drm_connector *drm_connector;
- struct drm_bridge *bridge;
int err;
/* Set the drm device handle */
@@ -455,20 +454,14 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
connector->dvo = dvo;
- bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
- if (!bridge)
- return -ENOMEM;
-
- bridge->driver_private = dvo;
- bridge->funcs = &sti_dvo_bridge_funcs;
- bridge->of_node = dvo->dev.of_node;
- drm_bridge_add(bridge);
+ dvo->bridge.driver_private = dvo;
+ dvo->bridge.of_node = dvo->dev.of_node;
+ drm_bridge_add(&dvo->bridge);
- err = drm_bridge_attach(encoder, bridge, NULL, 0);
+ err = drm_bridge_attach(encoder, &dvo->bridge, NULL, 0);
if (err)
return err;
- dvo->bridge = bridge;
connector->encoder = encoder;
dvo->encoder = encoder;
@@ -490,7 +483,7 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
return 0;
err_sysfs:
- drm_bridge_remove(bridge);
+ drm_bridge_remove(&dvo->bridge);
return -EINVAL;
}
@@ -499,7 +492,7 @@ static void sti_dvo_unbind(struct device *dev,
{
struct sti_dvo *dvo = dev_get_drvdata(dev);
- drm_bridge_remove(dvo->bridge);
+ drm_bridge_remove(&dvo->bridge);
}
static const struct component_ops sti_dvo_ops = {
@@ -515,10 +508,10 @@ static int sti_dvo_probe(struct platform_device *pdev)
DRM_INFO("%s\n", __func__);
- dvo = devm_kzalloc(dev, sizeof(*dvo), GFP_KERNEL);
- if (!dvo) {
- DRM_ERROR("Failed to allocate memory for DVO\n");
- return -ENOMEM;
+ dvo = devm_drm_bridge_alloc(dev, struct sti_dvo, bridge, &sti_dvo_bridge_funcs);
+ if (IS_ERR(dvo)) {
+ DRM_ERROR("Failed to allocate DVO\n");
+ return PTR_ERR(dvo);
}
dvo->dev = pdev->dev;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 29/34] drm: zynqmp_dp: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (27 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 28/34] drm/sti: dvo: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
` (6 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli,
Laurent Pinchart, Michal Simek, Tomi Valkeinen
This is the new API for allocating DRM bridges.
This driver has a peculiar structure. zynqmp_dpsub.c is the actual driver,
which delegates to a submodule (zynqmp_dp.c) the allocation of a
sub-structure embedding the drm_bridge and its initialization, however it
does not delegate the drm_bridge_add(). Hence, following carefully the code
flow, it is correct to change the allocation function and .funcs assignment
in the submodule, while the drm_bridge_add() is not in that submodule.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Michal Simek <michal.simek@amd.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Changes in v2:
- rebased on current drm-misc-next
- remove the kfree() calls too, as we are converting from kzalloc+kfree,
not from devm_kzalloc
---
drivers/gpu/drm/xlnx/zynqmp_dp.c | 31 +++++++++++--------------------
drivers/gpu/drm/xlnx/zynqmp_dpsub.c | 1 -
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 238cbb49963efa6e8cc737d8a6e76250f6531276..02e1feaa611596a24217136ee8ce7f5d2f1900a2 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -2439,9 +2439,9 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
struct zynqmp_dp *dp;
int ret;
- dp = kzalloc(sizeof(*dp), GFP_KERNEL);
- if (!dp)
- return -ENOMEM;
+ dp = devm_drm_bridge_alloc(&pdev->dev, struct zynqmp_dp, bridge, &zynqmp_dp_bridge_funcs);
+ if (IS_ERR(dp))
+ return PTR_ERR(dp);
dp->dev = &pdev->dev;
dp->dpsub = dpsub;
@@ -2454,31 +2454,25 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
/* Acquire all resources (IOMEM, IRQ and PHYs). */
dp->iomem = devm_platform_ioremap_resource_byname(pdev, "dp");
- if (IS_ERR(dp->iomem)) {
- ret = PTR_ERR(dp->iomem);
- goto err_free;
- }
+ if (IS_ERR(dp->iomem))
+ return PTR_ERR(dp->iomem);
dp->irq = platform_get_irq(pdev, 0);
- if (dp->irq < 0) {
- ret = dp->irq;
- goto err_free;
- }
+ if (dp->irq < 0)
+ return dp->irq;
dp->reset = devm_reset_control_get(dp->dev, NULL);
- if (IS_ERR(dp->reset)) {
- ret = dev_err_probe(dp->dev, PTR_ERR(dp->reset),
+ if (IS_ERR(dp->reset))
+ return dev_err_probe(dp->dev, PTR_ERR(dp->reset),
"failed to get reset\n");
- goto err_free;
- }
ret = zynqmp_dp_reset(dp, true);
if (ret < 0)
- goto err_free;
+ return ret;
ret = zynqmp_dp_reset(dp, false);
if (ret < 0)
- goto err_free;
+ return ret;
ret = zynqmp_dp_phy_probe(dp);
if (ret)
@@ -2486,7 +2480,6 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
/* Initialize the bridge. */
bridge = &dp->bridge;
- bridge->funcs = &zynqmp_dp_bridge_funcs;
bridge->ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
| DRM_BRIDGE_OP_HPD;
bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
@@ -2539,8 +2532,6 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
zynqmp_dp_phy_exit(dp);
err_reset:
zynqmp_dp_reset(dp, true);
-err_free:
- kfree(dp);
return ret;
}
diff --git a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
index 3a9544b97bc5311f9adeb57c08c837a04b6922fa..2764c4b17c5e49611db8adf41dd09e3134c2d524 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
@@ -180,7 +180,6 @@ static int zynqmp_dpsub_parse_dt(struct zynqmp_dpsub *dpsub)
void zynqmp_dpsub_release(struct zynqmp_dpsub *dpsub)
{
kfree(dpsub->disp);
- kfree(dpsub->dp);
kfree(dpsub);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (28 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 29/34] drm: zynqmp_dp: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-29 2:10 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
` (5 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Liu Ying
This is the new API for allocating DRM bridges.
This driver embeds an array of channels in the main struct, and each
channel embeds a drm_bridge. This prevents dynamic, refcount-based
deallocation of the bridges.
To make the new, dynamic bridge allocation possible:
* change the array of channels into an array of channel pointers
* allocate each channel using devm_drm_bridge_alloc()
* adapt the code wherever using the channels
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Liu Ying <victor.liu@nxp.com>
---
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
index 1f6fd488e7039e943351006d3373009f0c15cb08..40a8a5a53a781137e722309ff91692cf90d881da 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
@@ -68,7 +68,7 @@ struct imx8qxp_pc_channel {
struct imx8qxp_pc {
struct device *dev;
- struct imx8qxp_pc_channel ch[2];
+ struct imx8qxp_pc_channel *ch[2];
struct clk *clk_apb;
void __iomem *base;
};
@@ -307,7 +307,14 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
goto free_child;
}
- ch = &pc->ch[i];
+ ch = devm_drm_bridge_alloc(dev, struct imx8qxp_pc_channel, bridge,
+ &imx8qxp_pc_bridge_funcs);
+ if (IS_ERR(ch)) {
+ ret = PTR_ERR(ch);
+ goto free_child;
+ }
+
+ pc->ch[i] = ch;
ch->pc = pc;
ch->stream_id = i;
@@ -333,7 +340,6 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
of_node_put(remote);
ch->bridge.driver_private = ch;
- ch->bridge.funcs = &imx8qxp_pc_bridge_funcs;
ch->bridge.of_node = child;
ch->is_available = true;
@@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
free_child:
of_node_put(child);
- if (i == 1 && pc->ch[0].next_bridge)
- drm_bridge_remove(&pc->ch[0].bridge);
+ if (i == 1 && pc->ch[0]->next_bridge)
+ drm_bridge_remove(&pc->ch[0]->bridge);
pm_runtime_disable(dev);
return ret;
@@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
int i;
for (i = 0; i < 2; i++) {
- ch = &pc->ch[i];
+ ch = pc->ch[i];
if (!ch->is_available)
continue;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 31/34] drm/bridge: imx8*-ldb: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (29 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-29 2:35 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 32/34] drm/bridge: tc358767: " Luca Ceresoli
` (4 subsequent siblings)
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli, Liu Ying
This is the new API for allocating DRM bridges.
These two drivers are tangled together by the ldb_add_bridge_helper(), so
they are converted at once.
They also have a similar design, each embedding an array of channels in
their main struct, and each channel embeds a drm_bridge. This prevents
dynamic, refcount-based deallocation of the bridges.
To make the new, dynamic bridge allocation possible:
* change the array of channels into an array of channel pointers
* allocate each channel using devm_drm_bridge_alloc()
* adapt ldb_add_bridge_helper() to not set the funcs pointer
(now done by devm_drm_bridge_alloc())
* adapt the code wherever using the channels
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Cc: Liu Ying <victor.liu@nxp.com>
---
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/imx8qm-ldb.c | 32 ++++++++++++++++++-----------
drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 20 ++++++++++++------
4 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/bridge/imx/imx-ldb-helper.c b/drivers/gpu/drm/bridge/imx/imx-ldb-helper.c
index 61347f6ec33d906264f7e06902b0d915d263f3f8..6149ba141a389a04b3c347a67f13e049328c07ff 100644
--- a/drivers/gpu/drm/bridge/imx/imx-ldb-helper.c
+++ b/drivers/gpu/drm/bridge/imx/imx-ldb-helper.c
@@ -190,8 +190,7 @@ int ldb_find_next_bridge_helper(struct ldb *ldb)
}
EXPORT_SYMBOL_GPL(ldb_find_next_bridge_helper);
-void ldb_add_bridge_helper(struct ldb *ldb,
- const struct drm_bridge_funcs *bridge_funcs)
+void ldb_add_bridge_helper(struct ldb *ldb)
{
struct ldb_channel *ldb_ch;
int i;
@@ -203,7 +202,6 @@ void ldb_add_bridge_helper(struct ldb *ldb,
continue;
ldb_ch->bridge.driver_private = ldb_ch;
- ldb_ch->bridge.funcs = bridge_funcs;
ldb_ch->bridge.of_node = ldb_ch->np;
drm_bridge_add(&ldb_ch->bridge);
diff --git a/drivers/gpu/drm/bridge/imx/imx-ldb-helper.h b/drivers/gpu/drm/bridge/imx/imx-ldb-helper.h
index 38a8a54b37a60e1be942aaa60b1d1bc375a7a131..de187e3269996d284ecad451dd857271056812e1 100644
--- a/drivers/gpu/drm/bridge/imx/imx-ldb-helper.h
+++ b/drivers/gpu/drm/bridge/imx/imx-ldb-helper.h
@@ -88,8 +88,7 @@ int ldb_init_helper(struct ldb *ldb);
int ldb_find_next_bridge_helper(struct ldb *ldb);
-void ldb_add_bridge_helper(struct ldb *ldb,
- const struct drm_bridge_funcs *bridge_funcs);
+void ldb_add_bridge_helper(struct ldb *ldb);
void ldb_remove_bridge_helper(struct ldb *ldb);
diff --git a/drivers/gpu/drm/bridge/imx/imx8qm-ldb.c b/drivers/gpu/drm/bridge/imx/imx8qm-ldb.c
index 524aac751359f5cd377807508cbeeb6a597529e1..47aa65938e6a521cd6f111535f6feb3920a0dfb7 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qm-ldb.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qm-ldb.c
@@ -47,7 +47,7 @@ struct imx8qm_ldb_channel {
struct imx8qm_ldb {
struct ldb base;
struct device *dev;
- struct imx8qm_ldb_channel channel[MAX_LDB_CHAN_NUM];
+ struct imx8qm_ldb_channel *channel[MAX_LDB_CHAN_NUM];
struct clk *clk_pixel;
struct clk *clk_bypass;
int active_chno;
@@ -107,7 +107,7 @@ static int imx8qm_ldb_bridge_atomic_check(struct drm_bridge *bridge,
if (is_split) {
imx8qm_ldb_ch =
- &imx8qm_ldb->channel[imx8qm_ldb->active_chno ^ 1];
+ imx8qm_ldb->channel[imx8qm_ldb->active_chno ^ 1];
imx8qm_ldb_set_phy_cfg(imx8qm_ldb, di_clk, is_split, true,
phy_cfg);
ret = phy_validate(imx8qm_ldb_ch->phy, PHY_MODE_LVDS, 0, &opts);
@@ -158,7 +158,7 @@ imx8qm_ldb_bridge_mode_set(struct drm_bridge *bridge,
if (is_split) {
imx8qm_ldb_ch =
- &imx8qm_ldb->channel[imx8qm_ldb->active_chno ^ 1];
+ imx8qm_ldb->channel[imx8qm_ldb->active_chno ^ 1];
imx8qm_ldb_set_phy_cfg(imx8qm_ldb, di_clk, is_split, true,
phy_cfg);
ret = phy_configure(imx8qm_ldb_ch->phy, &opts);
@@ -226,13 +226,13 @@ static void imx8qm_ldb_bridge_atomic_enable(struct drm_bridge *bridge,
}
if (is_split) {
- ret = phy_power_on(imx8qm_ldb->channel[0].phy);
+ ret = phy_power_on(imx8qm_ldb->channel[0]->phy);
if (ret)
DRM_DEV_ERROR(dev,
"failed to power on channel0 PHY: %d\n",
ret);
- ret = phy_power_on(imx8qm_ldb->channel[1].phy);
+ ret = phy_power_on(imx8qm_ldb->channel[1]->phy);
if (ret)
DRM_DEV_ERROR(dev,
"failed to power on channel1 PHY: %d\n",
@@ -261,12 +261,12 @@ static void imx8qm_ldb_bridge_atomic_disable(struct drm_bridge *bridge,
ldb_bridge_disable_helper(bridge);
if (is_split) {
- ret = phy_power_off(imx8qm_ldb->channel[0].phy);
+ ret = phy_power_off(imx8qm_ldb->channel[0]->phy);
if (ret)
DRM_DEV_ERROR(dev,
"failed to power off channel0 PHY: %d\n",
ret);
- ret = phy_power_off(imx8qm_ldb->channel[1].phy);
+ ret = phy_power_off(imx8qm_ldb->channel[1]->phy);
if (ret)
DRM_DEV_ERROR(dev,
"failed to power off channel1 PHY: %d\n",
@@ -412,7 +412,7 @@ static int imx8qm_ldb_get_phy(struct imx8qm_ldb *imx8qm_ldb)
int i, ret;
for (i = 0; i < MAX_LDB_CHAN_NUM; i++) {
- imx8qm_ldb_ch = &imx8qm_ldb->channel[i];
+ imx8qm_ldb_ch = imx8qm_ldb->channel[i];
ldb_ch = &imx8qm_ldb_ch->base;
if (!ldb_ch->is_available)
@@ -448,6 +448,14 @@ static int imx8qm_ldb_probe(struct platform_device *pdev)
if (!imx8qm_ldb)
return -ENOMEM;
+ for (i = 0; i < MAX_LDB_CHAN_NUM; i++) {
+ imx8qm_ldb->channel[i] =
+ devm_drm_bridge_alloc(dev, struct imx8qm_ldb_channel, base.bridge,
+ &imx8qm_ldb_bridge_funcs);
+ if (IS_ERR(imx8qm_ldb->channel[i]))
+ return PTR_ERR(imx8qm_ldb->channel[i]);
+ }
+
imx8qm_ldb->clk_pixel = devm_clk_get(dev, "pixel");
if (IS_ERR(imx8qm_ldb->clk_pixel)) {
ret = PTR_ERR(imx8qm_ldb->clk_pixel);
@@ -473,7 +481,7 @@ static int imx8qm_ldb_probe(struct platform_device *pdev)
ldb->ctrl_reg = 0xe0;
for (i = 0; i < MAX_LDB_CHAN_NUM; i++)
- ldb->channel[i] = &imx8qm_ldb->channel[i].base;
+ ldb->channel[i] = &imx8qm_ldb->channel[i]->base;
ret = ldb_init_helper(ldb);
if (ret)
@@ -499,12 +507,12 @@ static int imx8qm_ldb_probe(struct platform_device *pdev)
}
imx8qm_ldb->active_chno = 0;
- imx8qm_ldb_ch = &imx8qm_ldb->channel[0];
+ imx8qm_ldb_ch = imx8qm_ldb->channel[0];
ldb_ch = &imx8qm_ldb_ch->base;
ldb_ch->link_type = pixel_order;
} else {
for (i = 0; i < MAX_LDB_CHAN_NUM; i++) {
- imx8qm_ldb_ch = &imx8qm_ldb->channel[i];
+ imx8qm_ldb_ch = imx8qm_ldb->channel[i];
ldb_ch = &imx8qm_ldb_ch->base;
if (ldb_ch->is_available) {
@@ -525,7 +533,7 @@ static int imx8qm_ldb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, imx8qm_ldb);
pm_runtime_enable(dev);
- ldb_add_bridge_helper(ldb, &imx8qm_ldb_bridge_funcs);
+ ldb_add_bridge_helper(ldb);
return ret;
}
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
index d4f3492ca5abf65a3327d7fa62214832946eb218..5d272916e200980f7253a032701dcd990e0e34f2 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
@@ -44,7 +44,7 @@ struct imx8qxp_ldb_channel {
struct imx8qxp_ldb {
struct ldb base;
struct device *dev;
- struct imx8qxp_ldb_channel channel[MAX_LDB_CHAN_NUM];
+ struct imx8qxp_ldb_channel *channel[MAX_LDB_CHAN_NUM];
struct clk *clk_pixel;
struct clk *clk_bypass;
struct drm_bridge *companion;
@@ -410,7 +410,7 @@ static const struct drm_bridge_funcs imx8qxp_ldb_bridge_funcs = {
static int imx8qxp_ldb_set_di_id(struct imx8qxp_ldb *imx8qxp_ldb)
{
struct imx8qxp_ldb_channel *imx8qxp_ldb_ch =
- &imx8qxp_ldb->channel[imx8qxp_ldb->active_chno];
+ imx8qxp_ldb->channel[imx8qxp_ldb->active_chno];
struct ldb_channel *ldb_ch = &imx8qxp_ldb_ch->base;
struct device_node *ep, *remote;
struct device *dev = imx8qxp_ldb->dev;
@@ -456,7 +456,7 @@ imx8qxp_ldb_check_chno_and_dual_link(struct ldb_channel *ldb_ch, int link)
static int imx8qxp_ldb_parse_dt_companion(struct imx8qxp_ldb *imx8qxp_ldb)
{
struct imx8qxp_ldb_channel *imx8qxp_ldb_ch =
- &imx8qxp_ldb->channel[imx8qxp_ldb->active_chno];
+ imx8qxp_ldb->channel[imx8qxp_ldb->active_chno];
struct ldb_channel *ldb_ch = &imx8qxp_ldb_ch->base;
struct ldb_channel *companion_ldb_ch;
struct device_node *companion;
@@ -586,6 +586,14 @@ static int imx8qxp_ldb_probe(struct platform_device *pdev)
if (!imx8qxp_ldb)
return -ENOMEM;
+ for (i = 0; i < MAX_LDB_CHAN_NUM; i++) {
+ imx8qxp_ldb->channel[i] =
+ devm_drm_bridge_alloc(dev, struct imx8qxp_ldb_channel, base.bridge,
+ &imx8qxp_ldb_bridge_funcs);
+ if (IS_ERR(imx8qxp_ldb->channel[i]))
+ return PTR_ERR(imx8qxp_ldb->channel[i]);
+ }
+
imx8qxp_ldb->clk_pixel = devm_clk_get(dev, "pixel");
if (IS_ERR(imx8qxp_ldb->clk_pixel)) {
ret = PTR_ERR(imx8qxp_ldb->clk_pixel);
@@ -611,7 +619,7 @@ static int imx8qxp_ldb_probe(struct platform_device *pdev)
ldb->ctrl_reg = 0xe0;
for (i = 0; i < MAX_LDB_CHAN_NUM; i++)
- ldb->channel[i] = &imx8qxp_ldb->channel[i].base;
+ ldb->channel[i] = &imx8qxp_ldb->channel[i]->base;
ret = ldb_init_helper(ldb);
if (ret)
@@ -627,7 +635,7 @@ static int imx8qxp_ldb_probe(struct platform_device *pdev)
}
for (i = 0; i < MAX_LDB_CHAN_NUM; i++) {
- imx8qxp_ldb_ch = &imx8qxp_ldb->channel[i];
+ imx8qxp_ldb_ch = imx8qxp_ldb->channel[i];
ldb_ch = &imx8qxp_ldb_ch->base;
if (ldb_ch->is_available) {
@@ -660,7 +668,7 @@ static int imx8qxp_ldb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, imx8qxp_ldb);
pm_runtime_enable(dev);
- ldb_add_bridge_helper(ldb, &imx8qxp_ldb_bridge_funcs);
+ ldb_add_bridge_helper(ldb);
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 32/34] drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (30 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
` (3 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli
This is the new API for allocating DRM bridges.
Converting this driver is a bit convoluted because the drm_bridge funcs
pointer differs based on the bridge mode. So the current code does:
* tc_probe()
* devm_kzalloc() private struct embedding drm_bridge
* call tc_probe_bridge_endpoint() which
* parses DT description into struct fields
* computes the mode
* calls different bridge init functions based on the mode
* each sets a different bridge.funcs pointer
The new API expects the funcs pointer to be known at alloc time, which does
not fit in the current code structure.
Solve this by moving the part of tc_probe_bridge_endpoint() computing the
mode into a separate function, tc_probe_get_mode(), which does not need the
private driver structure. So now the mode is known before allocation and so
is the funcs pointer, while all other operations are still happening after
allocation, directly into the private struct data, as they used to.
This solution is chosen to minimize the changes in the driver logical code
flow. The drawback is we now iterate twice over the endpoints.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/tc358767.c | 56 ++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 7e5449fb86a3fcdae8255bc490d12c543ef3f8ae..61559467e2d22b4b1b4223c97766ca3bf58908fd 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -344,6 +344,14 @@
#define COLOR_BAR_MODE_BARS 2
#define PLL_DBG 0x0a04
+enum tc_mode {
+ mode_dpi_to_edp = BIT(1) | BIT(2),
+ mode_dpi_to_dp = BIT(1),
+ mode_dsi_to_edp = BIT(0) | BIT(2),
+ mode_dsi_to_dp = BIT(0),
+ mode_dsi_to_dpi = BIT(0) | BIT(1),
+};
+
static bool tc_test_pattern;
module_param_named(test, tc_test_pattern, bool, 0644);
@@ -2327,7 +2335,6 @@ static int tc_probe_dpi_bridge_endpoint(struct tc_data *tc)
if (bridge) {
tc->panel_bridge = bridge;
tc->bridge.type = DRM_MODE_CONNECTOR_DPI;
- tc->bridge.funcs = &tc_dpi_bridge_funcs;
return 0;
}
@@ -2360,7 +2367,6 @@ static int tc_probe_edp_bridge_endpoint(struct tc_data *tc)
tc->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
}
- tc->bridge.funcs = &tc_edp_bridge_funcs;
if (tc->hpd_pin >= 0)
tc->bridge.ops |= DRM_BRIDGE_OP_DETECT;
tc->bridge.ops |= DRM_BRIDGE_OP_EDID;
@@ -2368,17 +2374,11 @@ static int tc_probe_edp_bridge_endpoint(struct tc_data *tc)
return 0;
}
-static int tc_probe_bridge_endpoint(struct tc_data *tc)
+static enum tc_mode tc_probe_get_mode(struct device *dev)
{
- struct device *dev = tc->dev;
struct of_endpoint endpoint;
struct device_node *node = NULL;
- const u8 mode_dpi_to_edp = BIT(1) | BIT(2);
- const u8 mode_dpi_to_dp = BIT(1);
- const u8 mode_dsi_to_edp = BIT(0) | BIT(2);
- const u8 mode_dsi_to_dp = BIT(0);
- const u8 mode_dsi_to_dpi = BIT(0) | BIT(1);
- u8 mode = 0;
+ enum tc_mode mode = 0;
/*
* Determine bridge configuration.
@@ -2401,7 +2401,27 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
return -EINVAL;
}
mode |= BIT(endpoint.port);
+ }
+
+ if (mode != mode_dpi_to_edp &&
+ mode != mode_dpi_to_dp &&
+ mode != mode_dsi_to_dpi &&
+ mode != mode_dsi_to_edp &&
+ mode != mode_dsi_to_dp) {
+ dev_warn(dev, "Invalid mode (0x%x) is not supported!\n", mode);
+ return -EINVAL;
+ }
+
+ return mode;
+}
+static int tc_probe_bridge_endpoint(struct tc_data *tc, enum tc_mode mode)
+{
+ struct device *dev = tc->dev;
+ struct of_endpoint endpoint;
+ struct device_node *node = NULL;
+
+ for_each_endpoint_of_node(dev->of_node, node) {
if (endpoint.port == 2) {
of_property_read_u8_array(node, "toshiba,pre-emphasis",
tc->pre_emphasis,
@@ -2427,24 +2447,28 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
return tc_probe_edp_bridge_endpoint(tc);
}
- dev_warn(dev, "Invalid mode (0x%x) is not supported!\n", mode);
-
+ /* Should never happen, mode was validated by tc_probe_get_mode() */
return -EINVAL;
}
static int tc_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
+ const struct drm_bridge_funcs *funcs;
struct tc_data *tc;
+ int mode;
int ret;
- tc = devm_kzalloc(dev, sizeof(*tc), GFP_KERNEL);
- if (!tc)
- return -ENOMEM;
+ mode = tc_probe_get_mode(dev);
+ funcs = (mode == mode_dsi_to_dpi) ? &tc_dpi_bridge_funcs : &tc_edp_bridge_funcs;
+
+ tc = devm_drm_bridge_alloc(dev, struct tc_data, bridge, funcs);
+ if (IS_ERR(tc))
+ return PTR_ERR(tc);
tc->dev = dev;
- ret = tc_probe_bridge_endpoint(tc);
+ ret = tc_probe_bridge_endpoint(tc, mode);
if (ret)
return ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge()
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (31 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 32/34] drm/bridge: tc358767: " Luca Ceresoli
@ 2025-04-24 18:59 ` Luca Ceresoli
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
` (2 subsequent siblings)
35 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 18:59 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Luca Ceresoli
Bridges obtained via devm_drm_bridge_alloc(dev, ...) will be put when the
requesting device (@dev) is removed.
However drivers which obtained them may need to put the obtained reference
explicitly. One such case is if they bind the devm removal action to a
different device than the one implemented by the driver itself and which
might be removed at a different time, such as bridge/panel.c.
Add devm_drm_put_bridge() to manually release a devm-obtained bridge in
such cases.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_bridge.c | 14 ++++++++++++++
include/drm/drm_bridge.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index b4c89ec01998b849018ce031c7cd84614e65e710..456363d86080b2a55035c3108c16afa4f9e57e06 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1392,6 +1392,20 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np)
EXPORT_SYMBOL(of_drm_find_bridge);
#endif
+/**
+ * devm_drm_put_bridge - Release a bridge reference obtained via devm
+ * @dev: device that got the bridge via devm
+ * @bridge: pointer to a struct drm_bridge obtained via devm
+ *
+ * Same as drm_bridge_put() for bridge pointers obtained via devm functions
+ * such as devm_drm_bridge_alloc().
+ */
+void devm_drm_put_bridge(struct device *dev, struct drm_bridge *bridge)
+{
+ devm_release_action(dev, drm_bridge_put_void, bridge);
+}
+EXPORT_SYMBOL(devm_drm_put_bridge);
+
static void drm_bridge_debugfs_show_bridge(struct drm_printer *p,
struct drm_bridge *bridge,
unsigned int idx)
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 4e418a29a9ff9d014d6ac0910a5d9bcf7118195e..6f00a3998ed6d026332b0f1e3bb5bee3cb5158e0 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1265,6 +1265,8 @@ static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev,
return ERR_PTR(-ENODEV);
}
+static inline void devm_drm_put_bridge(struct device *dev, struct drm_bridge *bridge) {}
+
static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
struct device_node *node,
u32 port,
@@ -1274,6 +1276,8 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
}
#endif
+void devm_drm_put_bridge(struct device *dev, struct drm_bridge *bridge);
+
void drm_bridge_debugfs_params(struct dentry *root);
void drm_bridge_debugfs_encoder_params(struct dentry *root, struct drm_encoder *encoder);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* Re: [PATCH v2 11/34] drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
@ 2025-04-24 19:16 ` Cristian Ciocaltea
0 siblings, 0 replies; 81+ messages in thread
From: Cristian Ciocaltea @ 2025-04-24 19:16 UTC (permalink / raw)
To: Luca Ceresoli, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 4/24/25 9:59 PM, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
Reviewed-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
^ permalink raw reply [flat|nested] 81+ messages in thread
* [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (32 preceding siblings ...)
2025-04-24 18:59 ` [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
@ 2025-04-24 20:05 ` Luca Ceresoli
2025-04-28 11:39 ` Maxime Ripard
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-29 9:27 ` (subset) " Louis Chauvet
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-24 20:05 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Luca Ceresoli, Anusha Srivatsa, Paul Kocialkowski,
Dmitry Baryshkov, Hui Pu, Thomas Petazzoni, dri-devel, asahi,
linux-kernel, chrome-platform, imx, linux-arm-kernel,
linux-mediatek, linux-amlogic, linux-renesas-soc,
platform-driver-x86, linux-samsung-soc, linux-arm-msm, freedreno,
linux-stm32
This is the new API for allocating DRM bridges.
The devm lifetime management of this driver is peculiar. The underlying
device for the panel_bridge is the panel, and the devm lifetime is tied the
panel device (panel->dev). However the panel_bridge allocation is not
performed by the panel driver, but rather by a separate entity (typically
the previous bridge in the encoder chain).
Thus when that separate entoty is destroyed, the panel_bridge is not
removed automatically by devm, so it is rather done explicitly by calling
drm_panel_bridge_remove(). This is the function that does devm_kfree() the
panel_bridge in current code, so update it as well to put the bridge
reference instead.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/panel.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index 79b009ab9396048eac57ad47631a902e949d77c6..ddd1e91970d09b93aa64f50cd9155939a12a2c6f 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -287,15 +287,14 @@ struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,
if (!panel)
return ERR_PTR(-EINVAL);
- panel_bridge = devm_kzalloc(panel->dev, sizeof(*panel_bridge),
- GFP_KERNEL);
- if (!panel_bridge)
- return ERR_PTR(-ENOMEM);
+ panel_bridge = devm_drm_bridge_alloc(panel->dev, struct panel_bridge, bridge,
+ &panel_bridge_bridge_funcs);
+ if (IS_ERR(panel_bridge))
+ return (void *)panel_bridge;
panel_bridge->connector_type = connector_type;
panel_bridge->panel = panel;
- panel_bridge->bridge.funcs = &panel_bridge_bridge_funcs;
panel_bridge->bridge.of_node = panel->dev->of_node;
panel_bridge->bridge.ops = DRM_BRIDGE_OP_MODES;
panel_bridge->bridge.type = connector_type;
@@ -327,7 +326,7 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge)
panel_bridge = drm_bridge_to_panel_bridge(bridge);
drm_bridge_remove(bridge);
- devm_kfree(panel_bridge->panel->dev, bridge);
+ devm_drm_put_bridge(panel_bridge->panel->dev, bridge);
}
EXPORT_SYMBOL(drm_panel_bridge_remove);
--
2.49.0
^ permalink raw reply related [flat|nested] 81+ messages in thread
* Re: [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
@ 2025-04-28 11:39 ` Maxime Ripard
2025-04-28 15:25 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Maxime Ripard @ 2025-04-28 11:39 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
On Thu, Apr 24, 2025 at 10:05:49PM +0200, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> The devm lifetime management of this driver is peculiar. The underlying
> device for the panel_bridge is the panel, and the devm lifetime is tied the
> panel device (panel->dev). However the panel_bridge allocation is not
> performed by the panel driver, but rather by a separate entity (typically
> the previous bridge in the encoder chain).
>
> Thus when that separate entoty is destroyed, the panel_bridge is not
> removed automatically by devm, so it is rather done explicitly by calling
> drm_panel_bridge_remove(). This is the function that does devm_kfree() the
> panel_bridge in current code, so update it as well to put the bridge
> reference instead.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
This looks fine, but we need a TODO entry to clean this up later on, and
a comment on devm_drm_put_bridge that this is inherently unsafe and
must not be used.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re:[PATCH v2 03/34] drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
@ 2025-04-28 12:29 ` Andy Yan
0 siblings, 0 replies; 81+ messages in thread
From: Andy Yan @ 2025-04-28 12:29 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Uwe Kleine-König,
Andy Yan, Dmitry Baryshkov, Jani Nikula, Sui Jingfeng
Hi,
At 2025-04-25 02:59:10, "Luca Ceresoli" <luca.ceresoli@bootlin.com> wrote:
>This is the new API for allocating DRM bridges.
>
>Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Andy Yan <andyshrk@163.com>
>
>---
>
>Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
>Cc: Andy Yan <andy.yan@rock-chips.com>
>Cc: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
>Cc: Jani Nikula <jani.nikula@intel.com>
>Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
>---
> drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>index f2bafa6cf77956ecafc87aae3a2b6890bdb36cfa..f3fe47b12edca1f92ddd306d152be144df5649b5 100644
>--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>@@ -664,9 +664,10 @@ static int anx6345_i2c_probe(struct i2c_client *client)
> struct device *dev;
> int i, err;
>
>- anx6345 = devm_kzalloc(&client->dev, sizeof(*anx6345), GFP_KERNEL);
>- if (!anx6345)
>- return -ENOMEM;
>+ anx6345 = devm_drm_bridge_alloc(&client->dev, struct anx6345, bridge,
>+ &anx6345_bridge_funcs);
>+ if (IS_ERR(anx6345))
>+ return PTR_ERR(anx6345);
>
> mutex_init(&anx6345->lock);
>
>@@ -738,7 +739,6 @@ static int anx6345_i2c_probe(struct i2c_client *client)
> /* Look for supported chip ID */
> anx6345_poweron(anx6345);
> if (anx6345_get_chip_id(anx6345)) {
>- anx6345->bridge.funcs = &anx6345_bridge_funcs;
> drm_bridge_add(&anx6345->bridge);
>
> return 0;
>
>--
>2.49.0
>
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re:[PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
@ 2025-04-28 12:44 ` Andy Yan
2025-04-28 15:00 ` [PATCH " Luca Ceresoli
2025-04-28 20:59 ` Doug Anderson
` (2 subsequent siblings)
3 siblings, 1 reply; 81+ messages in thread
From: Andy Yan @ 2025-04-28 12:44 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hi ,
At 2025-04-25 02:59:08, "Luca Ceresoli" <luca.ceresoli@bootlin.com> wrote:
>devm_drm_bridge_alloc() is the new API to be used for allocating (and
>partially initializing) a private driver struct embedding a struct
>drm_bridge.
>
>For many drivers having a simple code flow in the probe function, this
>commit does a mass conversion automatically with the following semantic
>patch. The changes have been reviewed manually for correctness as well as
>to find any false positives.
>
> @@
> type T;
> identifier C;
> identifier BR;
> expression DEV;
> expression FUNCS;
> @@
> -T *C;
> +T *C;
> ...
> (
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return -ENOMEM;
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> |
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return ERR_PTR(-ENOMEM);
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> )
> ...
> -C->BR.funcs = FUNCS;
>
>Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
>---
>
>Cc: Adam Ford <aford173@gmail.com>
>Cc: Adrien Grassein <adrien.grassein@gmail.com>
>Cc: Aleksandr Mishin <amishin@t-argos.ru>
>Cc: Andy Yan <andy.yan@rock-chips.com>
>Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>Cc: Benson Leung <bleung@chromium.org>
>Cc: Biju Das <biju.das.jz@bp.renesas.com>
>Cc: Christoph Fritz <chf.fritz@googlemail.com>
>Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>Cc: Detlev Casanova <detlev.casanova@collabora.com>
>Cc: Dharma Balasubiramani <dharma.b@microchip.com>
>Cc: Guenter Roeck <groeck@chromium.org>
>Cc: Heiko Stuebner <heiko@sntech.de>
>Cc: Jani Nikula <jani.nikula@intel.com>
>Cc: Janne Grunau <j@jannau.net>
>Cc: Jerome Brunet <jbrunet@baylibre.com>
>Cc: Jesse Van Gavere <jesseevg@gmail.com>
>Cc: Kevin Hilman <khilman@baylibre.com>
>Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>Cc: Liu Ying <victor.liu@nxp.com>
>Cc: Manikandan Muralidharan <manikandan.m@microchip.com>
>Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>Cc: Matthias Brugger <matthias.bgg@gmail.com>
>Cc: Philipp Zabel <p.zabel@pengutronix.de>
>Cc: Phong LE <ple@baylibre.com>
>Cc: Sasha Finkelstein <fnkl.kernel@gmail.com>
>Cc: Sugar Zhang <sugar.zhang@rock-chips.com>
>Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
>Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>Cc: Vitalii Mordan <mordan@ispras.ru>
>
>Changed in v2:
>- added missing PTR_ERR() in the second spatch alternative
>---
> drivers/gpu/drm/adp/adp-mipi.c | 8 ++++----
> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 9 ++++-----
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-bridge.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-hpd-bridge.c | 9 +++++----
> drivers/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/fsl-ldb.c | 7 +++----
> 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/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/lvds-codec.c | 9 ++++-----
> drivers/gpu/drm/bridge/microchip-lvds.c | 8 ++++----
> drivers/gpu/drm/bridge/nwl-dsi.c | 8 ++++----
> drivers/gpu/drm/bridge/parade-ps8622.c | 9 ++++-----
> drivers/gpu/drm/bridge/parade-ps8640.c | 9 ++++-----
> 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-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/tc358768.c | 9 ++++-----
> drivers/gpu/drm/bridge/tc358775.c | 9 ++++-----
> drivers/gpu/drm/bridge/thc63lvd1024.c | 8 ++++----
> drivers/gpu/drm/bridge/ti-dlpc3433.c | 9 ++++-----
> 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/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/renesas/rcar-du/rcar_lvds.c | 9 ++++-----
> drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 10 ++++------
> 49 files changed, 201 insertions(+), 237 deletions(-)
>
......
>
>@@ -202,9 +203,6 @@ static int simple_bridge_probe(struct platform_device *pdev)
> if (IS_ERR(sbridge->enable))
> return dev_err_probe(&pdev->dev, PTR_ERR(sbridge->enable),
> "Unable to retrieve enable GPIO\n");
>-
>- /* Register the bridge. */
>- sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
> sbridge->bridge.of_node = pdev->dev.of_node;
> sbridge->bridge.timings = sbridge->info->timings;
>
>diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
>index 5e5f8c2f95be1f5c4633f1093b17a00f9425bb37..9b1dfdb5e7ee528c876c01916c9821d550cad679 100644
>--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
>+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
>@@ -1045,9 +1045,10 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
> return ERR_PTR(-ENODEV);
> }
>
>- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
>- if (!hdmi)
>- return ERR_PTR(-ENOMEM);
>+ hdmi = devm_drm_bridge_alloc(dev, struct dw_hdmi_qp, bridge,
>+ &dw_hdmi_qp_bridge_funcs);
>+ if (IS_ERR(hdmi))
>+ return PTR_ERR(hdmi);
This should return hdmi or ERR_CAST(hdmi);
>
> hdmi->dev = dev;
>
>@@ -1073,7 +1074,6 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
> return ERR_PTR(ret);
>
> hdmi->bridge.driver_private = hdmi;
>- hdmi->bridge.funcs = &dw_hdmi_qp_bridge_funcs;
> hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
> DRM_BRIDGE_OP_EDID |
> DRM_BRIDGE_OP_HDMI |
>diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>index b08ada920a501d6a62f39581944a87019f5e5c15..87886235b8d3a85e0711f7763d048ad9eefd159a 100644
>--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>@@ -1194,9 +1194,10 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
> struct dw_mipi_dsi *dsi;
> int ret;
>
>- dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
>- if (!dsi)
>- return ERR_PTR(-ENOMEM);
>+ dsi = devm_drm_bridge_alloc(dev, struct dw_mipi_dsi, bridge,
>+ &dw_mipi_dsi_bridge_funcs);
>+ if (IS_ERR(dsi))
>+ return PTR_ERR(dsi);
This shoud return dsi or ERR_CAST(dsi);
>
> dsi->dev = dev;
> dsi->plat_data = plat_data;
>@@ -1265,7 +1266,6 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
> }
>
> dsi->bridge.driver_private = dsi;
>- dsi->bridge.funcs = &dw_mipi_dsi_bridge_funcs;
> dsi->bridge.of_node = pdev->dev.of_node;
>
> return dsi;
>diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
>index c76f5f2e74d14bd372f969c6c7832aa57f80772b..9f694f72b521912f5d4af46f2df2fc0fe3f776ea 100644
>--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
>+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c
>@@ -914,9 +914,10 @@ __dw_mipi_dsi2_probe(struct platform_device *pdev,
> struct dw_mipi_dsi2 *dsi2;
> int ret;
>
>- dsi2 = devm_kzalloc(dev, sizeof(*dsi2), GFP_KERNEL);
>- if (!dsi2)
>- return ERR_PTR(-ENOMEM);
>+ dsi2 = devm_drm_bridge_alloc(dev, struct dw_mipi_dsi2, bridge,
>+ &dw_mipi_dsi2_bridge_funcs);
>+ if (IS_ERR(dsi2))
>+ return PTR_ERR(dsi2);
This should return dsi2 or ERR_CAST(dis2);
>
> dsi2->dev = dev;
> dsi2->plat_data = plat_data;
>@@ -981,7 +982,6 @@ __dw_mipi_dsi2_probe(struct platform_device *pdev,
> }
>
> dsi2->bridge.driver_private = dsi2;
>- dsi2->bridge.funcs = &dw_mipi_dsi2_bridge_funcs;
> dsi2->bridge.of_node = pdev->dev.of_node;
>
> return dsi2;
>
> /* Init host device */
>
>--
>2.49.0
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-28 12:44 ` Andy Yan
@ 2025-04-28 15:00 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-28 15:00 UTC (permalink / raw)
To: Andy Yan
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hallo Andy,
On Mon, 28 Apr 2025 20:44:03 +0800 (CST)
"Andy Yan" <andyshrk@163.com> wrote:
> Hi ,
>
> At 2025-04-25 02:59:08, "Luca Ceresoli" <luca.ceresoli@bootlin.com> wrote:
> >devm_drm_bridge_alloc() is the new API to be used for allocating (and
> >partially initializing) a private driver struct embedding a struct
> >drm_bridge.
> >
> >For many drivers having a simple code flow in the probe function, this
> >commit does a mass conversion automatically with the following semantic
> >patch. The changes have been reviewed manually for correctness as well as
> >to find any false positives.
> >
> > @@
> > type T;
> > identifier C;
> > identifier BR;
> > expression DEV;
> > expression FUNCS;
> > @@
> > -T *C;
> > +T *C;
> > ...
> > (
> > -C = devm_kzalloc(DEV, ...);
> > -if (!C)
> > - return -ENOMEM;
> > +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> > +if (IS_ERR(C))
> > + return PTR_ERR(C);
> > |
> > -C = devm_kzalloc(DEV, ...);
> > -if (!C)
> > - return ERR_PTR(-ENOMEM);
> > +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> > +if (IS_ERR(C))
> > + return PTR_ERR(C);
> > )
> > ...
> > -C->BR.funcs = FUNCS;
> >
> >Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
[...]
> >diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> >index 5e5f8c2f95be1f5c4633f1093b17a00f9425bb37..9b1dfdb5e7ee528c876c01916c9821d550cad679 100644
> >--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> >+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> >@@ -1045,9 +1045,10 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
> > return ERR_PTR(-ENODEV);
> > }
> >
> >- hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
> >- if (!hdmi)
> >- return ERR_PTR(-ENOMEM);
> >+ hdmi = devm_drm_bridge_alloc(dev, struct dw_hdmi_qp, bridge,
> >+ &dw_hdmi_qp_bridge_funcs);
> >+ if (IS_ERR(hdmi))
> >+ return PTR_ERR(hdmi);
>
> This should return hdmi or ERR_CAST(hdmi);
Indeed, thanks!
My coccinelle patch is clearly not clever enough. I'll see whether I
can fix it, otherwise I'll handle these 3 special cases manually, along
with another similar one (imx/imx-legacy-bridge.c) I just spotted after
your report.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (33 preceding siblings ...)
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
@ 2025-04-28 15:24 ` Luca Ceresoli
2025-04-28 15:42 ` Maxime Ripard
2025-04-29 9:27 ` (subset) " Louis Chauvet
35 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-28 15:24 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Michal Simek
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
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API
2025-04-28 11:39 ` Maxime Ripard
@ 2025-04-28 15:25 ` Luca Ceresoli
2025-05-05 6:23 ` Maxime Ripard
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-28 15:25 UTC (permalink / raw)
To: Maxime Ripard
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hi Maxime,
On Mon, 28 Apr 2025 13:39:23 +0200
Maxime Ripard <mripard@kernel.org> wrote:
> On Thu, Apr 24, 2025 at 10:05:49PM +0200, Luca Ceresoli wrote:
> > This is the new API for allocating DRM bridges.
> >
> > The devm lifetime management of this driver is peculiar. The underlying
> > device for the panel_bridge is the panel, and the devm lifetime is tied the
> > panel device (panel->dev). However the panel_bridge allocation is not
> > performed by the panel driver, but rather by a separate entity (typically
> > the previous bridge in the encoder chain).
> >
> > Thus when that separate entoty is destroyed, the panel_bridge is not
> > removed automatically by devm, so it is rather done explicitly by calling
> > drm_panel_bridge_remove(). This is the function that does devm_kfree() the
> > panel_bridge in current code, so update it as well to put the bridge
> > reference instead.
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> This looks fine, but we need a TODO entry to clean this up later on, and
> a comment on devm_drm_put_bridge that this is inherently unsafe and
> must not be used.
Ah, I see, OK.
Quick draft:
/**
* devm_drm_put_bridge - Release a bridge reference obtained via devm
* @dev: device that got the bridge via devm
* @bridge: pointer to a struct drm_bridge obtained via devm
*
* Same as drm_bridge_put() for bridge pointers obtained via devm functions
* such as devm_drm_bridge_alloc().
+ *
+ * This function is a temporary workaround and MUST NOT be used. Manual
+ * handling of bridge lifetime is inherently unsafe.
*/
and:
- devm_kfree(panel_bridge->panel->dev, bridge);
+ /* TODO remove this after reworking panel_bridge lifetime */
+ devm_drm_put_bridge(panel_bridge->panel->dev, bridge);
}
Does it look good enough?
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
@ 2025-04-28 15:42 ` Maxime Ripard
2025-04-28 16:33 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Maxime Ripard @ 2025-04-28 15:42 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Michal Simek
[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 27/34] drm/vc4: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
@ 2025-04-28 15:45 ` Dave Stevenson
0 siblings, 0 replies; 81+ messages in thread
From: Dave Stevenson @ 2025-04-28 15:45 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Maíra Canal,
Raspberry Pi Kernel Maintenance
On Thu, 24 Apr 2025 at 20:01, Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> This is the new API for allocating DRM bridges.
>
> This driver already implements refcounting of the struct vc4_dsi, which
> embeds struct drm_bridge. Now this is a duplicate of the refcounting
> implemented by the DRM bridge core, so convert the vc4_dsi_get/put() calls
> into drm_bridge_get/put() calls and get rid of the driver-specific
> refcounting implementation.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Thanks.
> ---
>
> Cc: "Maíra Canal" <mcanal@igalia.com>
> Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
>
> Changed in v2:
> - fix error code checking
> ---
> drivers/gpu/drm/vc4/vc4_dsi.c | 34 +++++-----------------------------
> 1 file changed, 5 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
> index efc6f6078b026764c59cfb2a33b28a88b7018c3a..458e5d9879645f18bcbcaeeb71b5f1038f9581da 100644
> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
> @@ -552,8 +552,6 @@ struct vc4_dsi {
> struct vc4_encoder encoder;
> struct mipi_dsi_host dsi_host;
>
> - struct kref kref;
> -
> struct platform_device *pdev;
>
> struct drm_bridge *out_bridge;
> @@ -1622,29 +1620,11 @@ static void vc4_dsi_dma_chan_release(void *ptr)
> dsi->reg_dma_chan = NULL;
> }
>
> -static void vc4_dsi_release(struct kref *kref)
> -{
> - struct vc4_dsi *dsi =
> - container_of(kref, struct vc4_dsi, kref);
> -
> - kfree(dsi);
> -}
> -
> -static void vc4_dsi_get(struct vc4_dsi *dsi)
> -{
> - kref_get(&dsi->kref);
> -}
> -
> -static void vc4_dsi_put(struct vc4_dsi *dsi)
> -{
> - kref_put(&dsi->kref, &vc4_dsi_release);
> -}
> -
> static void vc4_dsi_release_action(struct drm_device *drm, void *ptr)
> {
> struct vc4_dsi *dsi = ptr;
>
> - vc4_dsi_put(dsi);
> + drm_bridge_put(&dsi->bridge);
> }
>
> static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
> @@ -1655,7 +1635,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
> struct drm_encoder *encoder = &dsi->encoder.base;
> int ret;
>
> - vc4_dsi_get(dsi);
> + drm_bridge_get(&dsi->bridge);
>
> ret = drmm_add_action_or_reset(drm, vc4_dsi_release_action, dsi);
> if (ret)
> @@ -1810,15 +1790,12 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct vc4_dsi *dsi;
>
> - dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
> - if (!dsi)
> - return -ENOMEM;
> + dsi = devm_drm_bridge_alloc(&pdev->dev, struct vc4_dsi, bridge, &vc4_dsi_bridge_funcs);
> + if (IS_ERR(dsi))
> + return PTR_ERR(dsi);
> dev_set_drvdata(dev, dsi);
>
> - kref_init(&dsi->kref);
> -
> dsi->pdev = pdev;
> - dsi->bridge.funcs = &vc4_dsi_bridge_funcs;
> #ifdef CONFIG_OF
> dsi->bridge.of_node = dev->of_node;
> #endif
> @@ -1836,7 +1813,6 @@ static void vc4_dsi_dev_remove(struct platform_device *pdev)
> struct vc4_dsi *dsi = dev_get_drvdata(dev);
>
> mipi_dsi_host_unregister(&dsi->dsi_host);
> - vc4_dsi_put(dsi);
> }
>
> struct platform_driver vc4_dsi_driver = {
>
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-28 15:42 ` Maxime Ripard
@ 2025-04-28 16:33 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-28 16:33 UTC (permalink / raw)
To: Maxime Ripard
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Michal Simek
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
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
@ 2025-04-28 20:53 ` Doug Anderson
0 siblings, 0 replies; 81+ messages in thread
From: Doug Anderson @ 2025-04-28 20:53 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Herve Codina
Hi,
On Thu, Apr 24, 2025 at 12:00 PM Luca Ceresoli
<luca.ceresoli@bootlin.com> wrote:
>
> This is the new API for allocating DRM bridges.
>
> Reviewed-by: Herve Codina <herve.codina@bootlin.com>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/ti-sn65dsi86.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
Reviewed-by: Douglas Anderson <dianders@chromium.org>
I can confirm that I can still build/boot on a board with ti-sn65dsi86
after this patch. Thus, happy with:
Tested-by: Douglas Anderson <dianders@chromium.org>
Happy to have someone else land this through drm-misc-next or I can
land it there myself.
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 12:44 ` Andy Yan
@ 2025-04-28 20:59 ` Doug Anderson
2025-04-30 10:35 ` Luca Ceresoli
2025-04-29 2:19 ` Liu Ying
2025-04-30 9:42 ` Manikandan.M
3 siblings, 1 reply; 81+ messages in thread
From: Doug Anderson @ 2025-04-28 20:59 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hi,
On Thu, Apr 24, 2025 at 11:59 AM Luca Ceresoli
<luca.ceresoli@bootlin.com> wrote:
>
> devm_drm_bridge_alloc() is the new API to be used for allocating (and
> partially initializing) a private driver struct embedding a struct
> drm_bridge.
>
> For many drivers having a simple code flow in the probe function, this
> commit does a mass conversion automatically with the following semantic
> patch. The changes have been reviewed manually for correctness as well as
> to find any false positives.
>
> @@
> type T;
> identifier C;
> identifier BR;
> expression DEV;
> expression FUNCS;
> @@
> -T *C;
> +T *C;
> ...
> (
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return -ENOMEM;
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> |
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return ERR_PTR(-ENOMEM);
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> )
> ...
> -C->BR.funcs = FUNCS;
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Adam Ford <aford173@gmail.com>
> Cc: Adrien Grassein <adrien.grassein@gmail.com>
> Cc: Aleksandr Mishin <amishin@t-argos.ru>
> Cc: Andy Yan <andy.yan@rock-chips.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Christoph Fritz <chf.fritz@googlemail.com>
> Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> Cc: Detlev Casanova <detlev.casanova@collabora.com>
> Cc: Dharma Balasubiramani <dharma.b@microchip.com>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Janne Grunau <j@jannau.net>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Cc: Jesse Van Gavere <jesseevg@gmail.com>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: Liu Ying <victor.liu@nxp.com>
> Cc: Manikandan Muralidharan <manikandan.m@microchip.com>
> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Phong LE <ple@baylibre.com>
> Cc: Sasha Finkelstein <fnkl.kernel@gmail.com>
> Cc: Sugar Zhang <sugar.zhang@rock-chips.com>
> Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
> Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> Cc: Vitalii Mordan <mordan@ispras.ru>
>
> Changed in v2:
> - added missing PTR_ERR() in the second spatch alternative
> ---
> drivers/gpu/drm/adp/adp-mipi.c | 8 ++++----
> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 9 ++++-----
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-bridge.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-hpd-bridge.c | 9 +++++----
> drivers/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/fsl-ldb.c | 7 +++----
> 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/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/lvds-codec.c | 9 ++++-----
> drivers/gpu/drm/bridge/microchip-lvds.c | 8 ++++----
> drivers/gpu/drm/bridge/nwl-dsi.c | 8 ++++----
> drivers/gpu/drm/bridge/parade-ps8622.c | 9 ++++-----
> drivers/gpu/drm/bridge/parade-ps8640.c | 9 ++++-----
> 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-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/tc358768.c | 9 ++++-----
> drivers/gpu/drm/bridge/tc358775.c | 9 ++++-----
> drivers/gpu/drm/bridge/thc63lvd1024.c | 8 ++++----
> drivers/gpu/drm/bridge/ti-dlpc3433.c | 9 ++++-----
> 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/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/renesas/rcar-du/rcar_lvds.c | 9 ++++-----
> drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 10 ++++------
> 49 files changed, 201 insertions(+), 237 deletions(-)
Reviewed-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
Tested-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
@ 2025-04-29 2:10 ` Liu Ying
2025-04-30 9:29 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-04-29 2:10 UTC (permalink / raw)
To: Luca Ceresoli, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hi,
On 04/25/2025, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> This driver embeds an array of channels in the main struct, and each
> channel embeds a drm_bridge. This prevents dynamic, refcount-based
> deallocation of the bridges.
>
> To make the new, dynamic bridge allocation possible:
>
> * change the array of channels into an array of channel pointers
> * allocate each channel using devm_drm_bridge_alloc()
> * adapt the code wherever using the channels
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Liu Ying <victor.liu@nxp.com>
> ---
> drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> index 1f6fd488e7039e943351006d3373009f0c15cb08..40a8a5a53a781137e722309ff91692cf90d881da 100644
> --- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> @@ -68,7 +68,7 @@ struct imx8qxp_pc_channel {
>
> struct imx8qxp_pc {
> struct device *dev;
> - struct imx8qxp_pc_channel ch[2];
> + struct imx8qxp_pc_channel *ch[2];
> struct clk *clk_apb;
> void __iomem *base;
> };
> @@ -307,7 +307,14 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> goto free_child;
> }
>
> - ch = &pc->ch[i];
> + ch = devm_drm_bridge_alloc(dev, struct imx8qxp_pc_channel, bridge,
> + &imx8qxp_pc_bridge_funcs);
> + if (IS_ERR(ch)) {
> + ret = PTR_ERR(ch);
> + goto free_child;
> + }
> +
> + pc->ch[i] = ch;
> ch->pc = pc;
> ch->stream_id = i;
>
> @@ -333,7 +340,6 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> of_node_put(remote);
>
> ch->bridge.driver_private = ch;
> - ch->bridge.funcs = &imx8qxp_pc_bridge_funcs;
> ch->bridge.of_node = child;
> ch->is_available = true;
>
> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> free_child:
> of_node_put(child);
>
> - if (i == 1 && pc->ch[0].next_bridge)
> - drm_bridge_remove(&pc->ch[0].bridge);
> + if (i == 1 && pc->ch[0]->next_bridge)
Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
dereference here...
> + drm_bridge_remove(&pc->ch[0]->bridge);
>
> pm_runtime_disable(dev);
> return ret;
> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
> int i;
>
> for (i = 0; i < 2; i++) {
> - ch = &pc->ch[i];
> + ch = pc->ch[i];
>
> if (!ch->is_available)
...and here too.
This is what I get when removing the imx8qxp_pixel_combiner module.
-8<-
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000144
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=000000089e613000
[0000000000000144] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] SMP
Modules linked in: mpl3115 isl29018 industrialio_triggered_buffer kfifo_buf cdns3 cdns_usb_common snd_soc_imx_audmix rtc_imx_sc imx_sc_wdt imx_sc_thermal imx_sc_key imx8qxp_pixel_link6
CPU: 1 UID: 0 PID: 528 Comm: modprobe Not tainted 6.15.0-rc3-next-20250424-00059-gee51752c256e #217 PREEMPT
Hardware name: Freescale i.MX8QXP MEK (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : imx8qxp_pc_bridge_remove+0x38/0x6c [imx8qxp_pixel_combiner]
lr : imx8qxp_pc_bridge_remove+0x30/0x6c [imx8qxp_pixel_combiner]
sp : ffff8000840f3c40
x29: ffff8000840f3c40 x28: ffff00081e75d780 x27: 0000000000000000
x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
x23: ffff0008100fc090 x22: ffff0008100fe490 x21: ffff00081e69de00
x20: 0000000000000000 x19: ffff0008100fe410 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
x14: 0000000000000013 x13: ffff000810049010 x12: 0000000000000000
x11: ffff0008182bc550 x10: ffff0008182bc490 x9 : ffff000810049010
x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff6364626d
x5 : 8080808000000000 x4 : 0000000000000000 x3 : 0000000000000000
x2 : ffff00081e75d780 x1 : ffff00081e75d780 x0 : ffff80007af9bdc0
Call trace:
imx8qxp_pc_bridge_remove+0x38/0x6c [imx8qxp_pixel_combiner] (P)
platform_remove+0x28/0x44
device_remove+0x4c/0x80
device_release_driver_internal+0x1c8/0x224
driver_detach+0x50/0x98
bus_remove_driver+0x6c/0xbc
driver_unregister+0x30/0x60
platform_driver_unregister+0x14/0x20
imx8qxp_pc_bridge_driver_exit+0x18/0x814 [imx8qxp_pixel_combiner]
__arm64_sys_delete_module+0x184/0x264
invoke_syscall+0x48/0x110
el0_svc_common.constprop.0+0xc8/0xe8
do_el0_svc+0x20/0x2c
el0_svc+0x30/0xd0
el0t_64_sync_handler+0x144/0x168
el0t_64_sync+0x198/0x19c
Code: aa1503e0 97f547f8 390512bf f9400a94 (39451280)
---[ end trace 0000000000000000 ]---
-8<-
On top of this patch series, this issue doesn't happen if I apply the below
change:
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
index 40a8a5a53a78..2eb0ade65d89 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
@@ -63,7 +63,6 @@ struct imx8qxp_pc_channel {
struct drm_bridge *next_bridge;
struct imx8qxp_pc *pc;
unsigned int stream_id;
- bool is_available;
};
struct imx8qxp_pc {
@@ -341,7 +340,6 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
ch->bridge.driver_private = ch;
ch->bridge.of_node = child;
- ch->is_available = true;
drm_bridge_add(&ch->bridge);
}
@@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
free_child:
of_node_put(child);
- if (i == 1 && pc->ch[0]->next_bridge)
+ if (i == 1 && pc->ch[0])
drm_bridge_remove(&pc->ch[0]->bridge);
pm_runtime_disable(dev);
@@ -367,11 +365,8 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
for (i = 0; i < 2; i++) {
ch = pc->ch[i];
- if (!ch->is_available)
- continue;
-
- drm_bridge_remove(&ch->bridge);
- ch->is_available = false;
+ if (ch)
+ drm_bridge_remove(&ch->bridge);
}
pm_runtime_disable(&pdev->dev);
> continue;
>
--
Regards,
Liu Ying
^ permalink raw reply related [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 12:44 ` Andy Yan
2025-04-28 20:59 ` Doug Anderson
@ 2025-04-29 2:19 ` Liu Ying
2025-04-29 7:07 ` Luca Ceresoli
2025-04-30 9:42 ` Manikandan.M
3 siblings, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-04-29 2:19 UTC (permalink / raw)
To: Luca Ceresoli, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hi,
On 04/25/2025, Luca Ceresoli wrote:
> devm_drm_bridge_alloc() is the new API to be used for allocating (and
> partially initializing) a private driver struct embedding a struct
> drm_bridge.
>
> For many drivers having a simple code flow in the probe function, this
> commit does a mass conversion automatically with the following semantic
> patch. The changes have been reviewed manually for correctness as well as
> to find any false positives.
>
> @@
> type T;
> identifier C;
> identifier BR;
> expression DEV;
> expression FUNCS;
> @@
> -T *C;
> +T *C;
> ...
> (
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return -ENOMEM;
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> |
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return ERR_PTR(-ENOMEM);
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> )
> ...
> -C->BR.funcs = FUNCS;
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Adam Ford <aford173@gmail.com>
> Cc: Adrien Grassein <adrien.grassein@gmail.com>
> Cc: Aleksandr Mishin <amishin@t-argos.ru>
> Cc: Andy Yan <andy.yan@rock-chips.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Christoph Fritz <chf.fritz@googlemail.com>
> Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> Cc: Detlev Casanova <detlev.casanova@collabora.com>
> Cc: Dharma Balasubiramani <dharma.b@microchip.com>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Janne Grunau <j@jannau.net>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Cc: Jesse Van Gavere <jesseevg@gmail.com>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: Liu Ying <victor.liu@nxp.com>
> Cc: Manikandan Muralidharan <manikandan.m@microchip.com>
> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Phong LE <ple@baylibre.com>
> Cc: Sasha Finkelstein <fnkl.kernel@gmail.com>
> Cc: Sugar Zhang <sugar.zhang@rock-chips.com>
> Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
> Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> Cc: Vitalii Mordan <mordan@ispras.ru>
>
> Changed in v2:
> - added missing PTR_ERR() in the second spatch alternative
> ---
> drivers/gpu/drm/adp/adp-mipi.c | 8 ++++----
> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 9 ++++-----
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-bridge.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-hpd-bridge.c | 9 +++++----
> drivers/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/fsl-ldb.c | 7 +++----
> 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/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/lvds-codec.c | 9 ++++-----
> drivers/gpu/drm/bridge/microchip-lvds.c | 8 ++++----
> drivers/gpu/drm/bridge/nwl-dsi.c | 8 ++++----
> drivers/gpu/drm/bridge/parade-ps8622.c | 9 ++++-----
> drivers/gpu/drm/bridge/parade-ps8640.c | 9 ++++-----
> 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-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/tc358768.c | 9 ++++-----
> drivers/gpu/drm/bridge/tc358775.c | 9 ++++-----
> drivers/gpu/drm/bridge/thc63lvd1024.c | 8 ++++----
> drivers/gpu/drm/bridge/ti-dlpc3433.c | 9 ++++-----
> 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/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/renesas/rcar-du/rcar_lvds.c | 9 ++++-----
> drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 10 ++++------
> 49 files changed, 201 insertions(+), 237 deletions(-)
[...]
> diff --git a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> index f072c6ed39ef183b10518b43bd6d979bc89e36f9..8069c4881e9058f5462f99116799b589bd52b19e 100644
> --- a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> +++ b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> @@ -59,9 +59,10 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
> struct imx_legacy_bridge *imx_bridge;
> int ret;
>
> - imx_bridge = devm_kzalloc(dev, sizeof(*imx_bridge), GFP_KERNEL);
> - if (!imx_bridge)
> - return ERR_PTR(-ENOMEM);
> + imx_bridge = devm_drm_bridge_alloc(dev, struct imx_legacy_bridge,
> + base, &imx_legacy_bridge_funcs);
> + if (IS_ERR(imx_bridge))
> + return PTR_ERR(imx_bridge);
>
> ret = of_get_drm_display_mode(np,
> &imx_bridge->mode,
> @@ -71,8 +72,6 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
> return ERR_PTR(ret);
>
> imx_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
> -
Nit: Can you please leave this blank line undeleted? And I see similar
situations where lines are unnecessarily deleted by this patch, so this applies
to the entire patch.
> - imx_bridge->base.funcs = &imx_legacy_bridge_funcs;
> imx_bridge->base.of_node = np;
> imx_bridge->base.ops = DRM_BRIDGE_OP_MODES;
> imx_bridge->base.type = type;
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 31/34] drm/bridge: imx8*-ldb: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
@ 2025-04-29 2:35 ` Liu Ying
0 siblings, 0 replies; 81+ messages in thread
From: Liu Ying @ 2025-04-29 2:35 UTC (permalink / raw)
To: Luca Ceresoli, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 04/25/2025, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> These two drivers are tangled together by the ldb_add_bridge_helper(), so
> they are converted at once.
>
> They also have a similar design, each embedding an array of channels in
> their main struct, and each channel embeds a drm_bridge. This prevents
> dynamic, refcount-based deallocation of the bridges.
>
> To make the new, dynamic bridge allocation possible:
>
> * change the array of channels into an array of channel pointers
> * allocate each channel using devm_drm_bridge_alloc()
> * adapt ldb_add_bridge_helper() to not set the funcs pointer
> (now done by devm_drm_bridge_alloc())
> * adapt the code wherever using the channels
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Liu Ying <victor.liu@nxp.com>
> ---
> 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/imx8qm-ldb.c | 32 ++++++++++++++++++-----------
> drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 20 ++++++++++++------
> 4 files changed, 36 insertions(+), 23 deletions(-)
Acked-by: Liu Ying <victor.liu@nxp.com>
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-29 2:19 ` Liu Ying
@ 2025-04-29 7:07 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-29 7:07 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hello Liu,
On Tue, 29 Apr 2025 10:19:27 +0800
Liu Ying <victor.liu@nxp.com> wrote:
[...]
> > diff --git a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> > index f072c6ed39ef183b10518b43bd6d979bc89e36f9..8069c4881e9058f5462f99116799b589bd52b19e 100644
> > --- a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> > +++ b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
> > @@ -59,9 +59,10 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
> > struct imx_legacy_bridge *imx_bridge;
> > int ret;
> >
> > - imx_bridge = devm_kzalloc(dev, sizeof(*imx_bridge), GFP_KERNEL);
> > - if (!imx_bridge)
> > - return ERR_PTR(-ENOMEM);
> > + imx_bridge = devm_drm_bridge_alloc(dev, struct imx_legacy_bridge,
> > + base, &imx_legacy_bridge_funcs);
> > + if (IS_ERR(imx_bridge))
> > + return PTR_ERR(imx_bridge);
> >
> > ret = of_get_drm_display_mode(np,
> > &imx_bridge->mode,
> > @@ -71,8 +72,6 @@ struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
> > return ERR_PTR(ret);
> >
> > imx_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
> > -
>
> Nit: Can you please leave this blank line undeleted? And I see similar
> situations where lines are unnecessarily deleted by this patch, so this applies
> to the entire patch.
I agree some empty lines removals are not nice in this patch. However I
have no idea how to avoid that with spatch, so I'd have to redo [a part
of] the changes manually to avoid it. :-(
Anyway, those I spotted look quite innocuous. So I'll assume it is "OK
enough" as is, unless there are strong requests to do differently.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 15/34] drm/mcde: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
@ 2025-04-29 8:40 ` Linus Walleij
0 siblings, 0 replies; 81+ messages in thread
From: Linus Walleij @ 2025-04-29 8:40 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On Thu, Apr 24, 2025 at 9:00 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> This is the new API for allocating DRM bridges.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
` (34 preceding siblings ...)
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
@ 2025-04-29 9:27 ` Louis Chauvet
2025-04-29 12:41 ` Louis Chauvet
2025-04-29 14:42 ` Dmitry Baryshkov
35 siblings, 2 replies; 81+ messages in thread
From: Louis Chauvet @ 2025-04-29 9:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Luca Ceresoli
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Laurent Pinchart, Michal Simek
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!
[02/34] platform: arm64: acer-aspire1-ec: convert to devm_drm_bridge_alloc() API
commit: 411465d35bc56877c33e2498ac697acfcf484e6b
[03/34] drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
commit: 53ddeb25159781b029fda404226af600e76f975f
[06/34] drm/bridge: display-connector: convert to devm_drm_bridge_alloc() API
commit: 4e90a3d96a6185e143041273f9867a1092dd4a71
[07/34] drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
commit: 6287ffd9eff6eea65865e64b9d4c45e115fa5ecf
[11/34] drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
commit: ed6987b674185873ebed7a619a646da6dd1a78fa
[12/34] drm/bridge: tda998x: convert to devm_drm_bridge_alloc() API
commit: 7fe58bf1a9a24b533875c262a3222581a3f759e4
[13/34] drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
commit: a4754ae9cfa76fbce79f023c268a5bac56f36321
[14/34] drm/exynos: mic: convert to devm_drm_bridge_alloc() API
commit: 91c5c7b5bb2dd09b43b025bce6d790d3c79f4518
[15/34] drm/mcde: convert to devm_drm_bridge_alloc() API
commit: 40c25b9ec641f43ba17c7b788ac16ec23f8daaa8
[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
[27/34] drm/vc4: convert to devm_drm_bridge_alloc() API
commit: 9545c91ed75ff65e114761a7729de0e1b440aec6
[31/34] drm/bridge: imx8*-ldb: convert to devm_drm_bridge_alloc() API
commit: e74b84cd83962e357329a695ba348b3dfe37395c
Best regards,
--
Louis Chauvet <louis.chauvet@bootlin.com>
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 07/34] drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
@ 2025-04-29 12:09 ` Dmitry Baryshkov
0 siblings, 0 replies; 81+ messages in thread
From: Dmitry Baryshkov @ 2025-04-29 12:09 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On Thu, Apr 24, 2025 at 08:59:14PM +0200, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-29 9:27 ` (subset) " Louis Chauvet
@ 2025-04-29 12:41 ` Louis Chauvet
2025-04-30 8:08 ` Maxime Ripard
2025-04-29 14:42 ` Dmitry Baryshkov
1 sibling, 1 reply; 81+ messages in thread
From: Louis Chauvet @ 2025-04-29 12:41 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Luca Ceresoli
Cc: Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart,
Alexandre Torgue, Maxime Coquelin, Philippe Cornu,
Raphael Gallais-Pou, Yannick Fertre, Maíra Canal,
Dave Stevenson, Raspberry Pi Kernel Maintenance, Alain Volmat,
Raphael Gallais-Pou, Michal Simek
Le 29/04/2025 à 11:27, Louis Chauvet a écrit :
>
> 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!
>
> [02/34] platform: arm64: acer-aspire1-ec: convert to devm_drm_bridge_alloc() API
> commit: 411465d35bc56877c33e2498ac697acfcf484e6b
> [03/34] drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
> commit: 53ddeb25159781b029fda404226af600e76f975f
> [06/34] drm/bridge: display-connector: convert to devm_drm_bridge_alloc() API
> commit: 4e90a3d96a6185e143041273f9867a1092dd4a71
> [07/34] drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
> commit: 6287ffd9eff6eea65865e64b9d4c45e115fa5ecf
> [11/34] drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
> commit: ed6987b674185873ebed7a619a646da6dd1a78fa
> [12/34] drm/bridge: tda998x: convert to devm_drm_bridge_alloc() API
> commit: 7fe58bf1a9a24b533875c262a3222581a3f759e4
> [13/34] drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
> commit: a4754ae9cfa76fbce79f023c268a5bac56f36321
> [14/34] drm/exynos: mic: convert to devm_drm_bridge_alloc() API
> commit: 91c5c7b5bb2dd09b43b025bce6d790d3c79f4518
Hello all,
I made a mistake while applying those patches. Instead of taking
2-3,11-13,15-18,27,31, I took 2-3,11-18,27,31, which includes the patch 14.
This patch is not R-by/A-by/SoB by non-Bootlin people. For me, the patch
is correct, it does not break the build nor generate warnings.
What should I do? Is my SoB sufficient, or should I revert the patch and
wait for R/A-by before taking it again?
Sorry for this,
Louis Chauvet
> [15/34] drm/mcde: convert to devm_drm_bridge_alloc() API
> commit: 40c25b9ec641f43ba17c7b788ac16ec23f8daaa8
> [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
> [27/34] drm/vc4: convert to devm_drm_bridge_alloc() API
> commit: 9545c91ed75ff65e114761a7729de0e1b440aec6
> [31/34] drm/bridge: imx8*-ldb: convert to devm_drm_bridge_alloc() API
> commit: e74b84cd83962e357329a695ba348b3dfe37395c
>
> Best regards,
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-29 9:27 ` (subset) " Louis Chauvet
2025-04-29 12:41 ` Louis Chauvet
@ 2025-04-29 14:42 ` Dmitry Baryshkov
2025-04-30 8:21 ` Louis Chauvet
1 sibling, 1 reply; 81+ messages in thread
From: Dmitry Baryshkov @ 2025-04-29 14:42 UTC (permalink / raw)
To: Louis Chauvet
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Luca Ceresoli, Anusha Srivatsa, Paul Kocialkowski,
Dmitry Baryshkov, Hui Pu, Thomas Petazzoni, dri-devel, asahi,
linux-kernel, chrome-platform, imx, linux-arm-kernel,
linux-mediatek, linux-amlogic, linux-renesas-soc,
platform-driver-x86, linux-samsung-soc, linux-arm-msm, freedreno,
linux-stm32, Adam Ford, Adrien Grassein, Aleksandr Mishin,
Andy Yan, AngeloGioacchino Del Regno, Benson Leung, Biju Das,
Christoph Fritz, Cristian Ciocaltea, Detlev Casanova,
Dharma Balasubiramani, Guenter Roeck, Heiko Stuebner, Jani Nikula,
Janne Grunau, Jerome Brunet, Jesse Van Gavere, Kevin Hilman,
Kieran Bingham, Liu Ying, Manikandan Muralidharan,
Martin Blumenstingl, Matthias Brugger, Philipp Zabel, Phong LE,
Sasha Finkelstein, Sugar Zhang, Sui Jingfeng, Tomi Valkeinen,
Vitalii Mordan, Ilpo Järvinen, Bryan O'Donoghue,
Hans de Goede, Uwe Kleine-König, Rob Herring (Arm),
Hsin-Te Yuan, Pin-yen Lin, Xin Ji, Aradhya Bhatia, Tomi Valkeinen,
Ian Ray, Martyn Welch, Peter Senna Tschudin, Russell King,
Herve Codina, Alim Akhtar, Inki Dae, Kyungmin Park, Seung-Woo Kim,
Linus Walleij, Abhinav Kumar, Bjorn Andersson, Marijn Suijten,
Rob Clark, Sean Paul, Helge Deller, Kuninori Morimoto,
Laurent Pinchart
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.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-29 12:41 ` Louis Chauvet
@ 2025-04-30 8:08 ` Maxime Ripard
2025-05-05 11:06 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Maxime Ripard @ 2025-04-30 8:08 UTC (permalink / raw)
To: Louis Chauvet, Inki Dae, Kyungmin Park, Seung-Woo Kim
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Luca Ceresoli, Anusha Srivatsa, Paul Kocialkowski,
Dmitry Baryshkov, Hui Pu, Thomas Petazzoni, dri-devel, asahi,
linux-kernel, chrome-platform, imx, linux-arm-kernel,
linux-mediatek, linux-amlogic, linux-renesas-soc,
platform-driver-x86, linux-samsung-soc, linux-arm-msm, freedreno,
linux-stm32, Adam Ford, Adrien Grassein, Aleksandr Mishin,
Andy Yan, AngeloGioacchino Del Regno, Benson Leung, Biju Das,
Christoph Fritz, Cristian Ciocaltea, Detlev Casanova,
Dharma Balasubiramani, Guenter Roeck, Heiko Stuebner, Jani Nikula,
Janne Grunau, Jerome Brunet, Jesse Van Gavere, Kevin Hilman,
Kieran Bingham, Liu Ying, Manikandan Muralidharan,
Martin Blumenstingl, Matthias Brugger, Philipp Zabel, Phong LE,
Sasha Finkelstein, Sugar Zhang, Sui Jingfeng, Tomi Valkeinen,
Vitalii Mordan, Ilpo Järvinen, Bryan O'Donoghue,
Hans de Goede, Uwe Kleine-König, Dmitry Baryshkov,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Linus Walleij, Abhinav Kumar, Bjorn Andersson, Marijn Suijten,
Rob Clark, Sean Paul, Helge Deller, Kuninori Morimoto,
Laurent Pinchart, Alexandre Torgue, Maxime Coquelin,
Philippe Cornu, Raphael Gallais-Pou, Yannick Fertre,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Alain Volmat, Raphael Gallais-Pou, Michal Simek
[-- Attachment #1: Type: text/plain, Size: 2557 bytes --]
On Tue, Apr 29, 2025 at 02:41:42PM +0200, Louis Chauvet wrote:
> Le 29/04/2025 à 11:27, Louis Chauvet a écrit :
> >
> > 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!
> >
> > [02/34] platform: arm64: acer-aspire1-ec: convert to devm_drm_bridge_alloc() API
> > commit: 411465d35bc56877c33e2498ac697acfcf484e6b
> > [03/34] drm/bridge: analogix-anx6345: convert to devm_drm_bridge_alloc() API
> > commit: 53ddeb25159781b029fda404226af600e76f975f
> > [06/34] drm/bridge: display-connector: convert to devm_drm_bridge_alloc() API
> > commit: 4e90a3d96a6185e143041273f9867a1092dd4a71
> > [07/34] drm/bridge: lt9611uxc: convert to devm_drm_bridge_alloc() API
> > commit: 6287ffd9eff6eea65865e64b9d4c45e115fa5ecf
> > [11/34] drm/bridge: dw-hdmi: convert to devm_drm_bridge_alloc() API
> > commit: ed6987b674185873ebed7a619a646da6dd1a78fa
> > [12/34] drm/bridge: tda998x: convert to devm_drm_bridge_alloc() API
> > commit: 7fe58bf1a9a24b533875c262a3222581a3f759e4
> > [13/34] drm/bridge: ti-sn65dsi86: convert to devm_drm_bridge_alloc() API
> > commit: a4754ae9cfa76fbce79f023c268a5bac56f36321
> > [14/34] drm/exynos: mic: convert to devm_drm_bridge_alloc() API
> > commit: 91c5c7b5bb2dd09b43b025bce6d790d3c79f4518
>
> Hello all,
>
> I made a mistake while applying those patches. Instead of taking
> 2-3,11-13,15-18,27,31, I took 2-3,11-18,27,31, which includes the patch 14.
>
> This patch is not R-by/A-by/SoB by non-Bootlin people. For me, the patch is
> correct, it does not break the build nor generate warnings.
>
> What should I do? Is my SoB sufficient, or should I revert the patch and
> wait for R/A-by before taking it again?
It's worse: just like msm, it was never supposed to be applied in
drm-misc, exynos has its own git tree.
Inki, Kyungmin, Seung-Woo, sorry for the mishap. Do you agree with the
following patch, and it going through drm-misc?
https://lore.kernel.org/dri-devel/20250424-drm-bridge-convert-to-alloc-api-v2-14-8f91a404d86b@bootlin.com/
If not, we'll revert.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-29 14:42 ` Dmitry Baryshkov
@ 2025-04-30 8:21 ` Louis Chauvet
2025-04-30 10:39 ` Maxime Ripard
0 siblings, 1 reply; 81+ messages in thread
From: Louis Chauvet @ 2025-04-30 8:21 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Luca Ceresoli, Anusha Srivatsa, Paul Kocialkowski,
Dmitry Baryshkov, Hui Pu, Thomas Petazzoni, dri-devel, asahi,
linux-kernel, chrome-platform, imx, linux-arm-kernel,
linux-mediatek, linux-amlogic, linux-renesas-soc,
platform-driver-x86, linux-samsung-soc, linux-arm-msm, freedreno,
linux-stm32, Adam Ford, Adrien Grassein, Aleksandr Mishin,
Andy Yan, AngeloGioacchino Del Regno, Benson Leung, Biju Das,
Christoph Fritz, Cristian Ciocaltea, Detlev Casanova,
Dharma Balasubiramani, Guenter Roeck, Heiko Stuebner, Jani Nikula,
Janne Grunau, Jerome Brunet, Jesse Van Gavere, Kevin Hilman,
Kieran Bingham, Liu Ying, Manikandan Muralidharan,
Martin Blumenstingl, Matthias Brugger, Philipp Zabel, Phong LE,
Sasha Finkelstein, Sugar Zhang, Sui Jingfeng, Tomi Valkeinen,
Vitalii Mordan, Ilpo Järvinen, Bryan O'Donoghue,
Hans de Goede, Uwe Kleine-König, Rob Herring (Arm),
Hsin-Te Yuan, Pin-yen Lin, Xin Ji, Aradhya Bhatia, Tomi Valkeinen,
Ian Ray, Martyn Welch, Peter Senna Tschudin, Russell King,
Herve Codina, Alim Akhtar, Inki Dae, Kyungmin Park, Seung-Woo Kim,
Linus Walleij, Abhinav Kumar, Bjorn Andersson, Marijn Suijten,
Rob Clark, Sean Paul, Helge Deller, Kuninori Morimoto,
Laurent Pinchart
Le 29/04/2025 à 16:42, Dmitry Baryshkov a écrit :
> 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.
>
Sorry, I was not aware that msm also have his own repository.
TBH, I was not aware that other repositories existed for drm (I should
have looked at MAINTAINERS, it is totally my fault). DIM and doc[1] only
list drm, drm-misc, drm-xe, drm-intel, so I just tough "intel is
special", not "drm is divided in many repositories".
Again, sorry, for the future series I will double-check and only commit
what I should.
[1]:https://drm.pages.freedesktop.org/maintainer-tools/repositories/index.html
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-04-29 2:10 ` Liu Ying
@ 2025-04-30 9:29 ` Luca Ceresoli
2025-05-06 2:24 ` Liu Ying
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-30 9:29 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hello Liu,
On Tue, 29 Apr 2025 10:10:55 +0800
Liu Ying <victor.liu@nxp.com> wrote:
> Hi,
>
> On 04/25/2025, Luca Ceresoli wrote:
> > This is the new API for allocating DRM bridges.
> >
> > This driver embeds an array of channels in the main struct, and each
> > channel embeds a drm_bridge. This prevents dynamic, refcount-based
> > deallocation of the bridges.
> >
> > To make the new, dynamic bridge allocation possible:
> >
> > * change the array of channels into an array of channel pointers
> > * allocate each channel using devm_drm_bridge_alloc()
> > * adapt the code wherever using the channels
> >
> > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
[...]
> > @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> > free_child:
> > of_node_put(child);
> >
> > - if (i == 1 && pc->ch[0].next_bridge)
> > - drm_bridge_remove(&pc->ch[0].bridge);
> > + if (i == 1 && pc->ch[0]->next_bridge)
>
> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
> dereference here...
See below for this.
> > + drm_bridge_remove(&pc->ch[0]->bridge);
> >
> > pm_runtime_disable(dev);
> > return ret;
> > @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
> > int i;
> >
> > for (i = 0; i < 2; i++) {
> > - ch = &pc->ch[i];
> > + ch = pc->ch[i];
> >
> > if (!ch->is_available)
>
> ...and here too.
This is indeed a bug, I should have checked the pointer for being
non-NULL.
Looking at that more closely, I think the is_available flag can be
entirely removed now. The allocation itself (ch != NULL) now is
equivalent. Do you think my reasoning is correct?
Ouch! After writing the previous paragraph I realized you proposed this
a few lines below! OK, removing is_available. :)
[...]
> On top of this patch series, this issue doesn't happen if I apply the below
> change:
[...]
> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> free_child:
> of_node_put(child);
>
> - if (i == 1 && pc->ch[0]->next_bridge)
> + if (i == 1 && pc->ch[0])
> drm_bridge_remove(&pc->ch[0]->bridge);
Unrelated to this patch, but as I looked at it more in depth now, I'm
not sure this whole logic is robust, even in the original code.
The 'i == 1' check here seems to mean "if some error happened when
handling channel@1, that means channel@0 was successfully initialized,
so let's clean up channel 0".
However my understanding of the bindings is that device tree is allowed
to have the channel@1 node before the channel@0 node (or even channel@1
without channel@0, but that's less problematic here).
In such case (channel@1 before channel@0), this would happen:
1. alloc and init ch[1], all OK
2. alloc and init ch[0], an error happens
(e.g. of_graph_get_remote_node() fails)
So we'd reach the free_child: label, and we should call
drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
To be robust in such a case, I think both channels need to be checked
independently, as the status of one does not imply the status of the
other. E.g.:
for (i = 0; i < 2; i++)
if (pc->ch[i] && pc->ch[i]->next_bridge)
drm_bridge_remove(&pc->ch[i]->bridge);
(which is similar to what .remove() does after the changes discussed in
this thread, and which I have queued for v3)
What's your opinion? Do you think I missed anything?
Thanks for taking the time to dig into this!
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
` (2 preceding siblings ...)
2025-04-29 2:19 ` Liu Ying
@ 2025-04-30 9:42 ` Manikandan.M
2025-04-30 10:36 ` Luca Ceresoli
3 siblings, 1 reply; 81+ messages in thread
From: Manikandan.M @ 2025-04-30 9:42 UTC (permalink / raw)
To: luca.ceresoli, maarten.lankhorst, mripard, tzimmermann, airlied,
simona, andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart,
jonas, jernej.skrabec, jagan, shawnguo, s.hauer, kernel, festevam,
dianders, chunkuang.hu, krzk
Cc: asrivats, paulk, lumag, Hui.Pu, thomas.petazzoni, dri-devel,
asahi, linux-kernel, chrome-platform, imx, linux-arm-kernel,
linux-mediatek, linux-amlogic, linux-renesas-soc,
platform-driver-x86, linux-samsung-soc, linux-arm-msm, freedreno,
linux-stm32, aford173, adrien.grassein, amishin, andy.yan,
angelogioacchino.delregno, bleung, biju.das.jz, chf.fritz,
cristian.ciocaltea, detlev.casanova, Dharma.B, groeck, heiko,
jani.nikula, j, jbrunet, jesseevg, khilman,
kieran.bingham+renesas, victor.liu, martin.blumenstingl,
matthias.bgg, p.zabel, ple, fnkl.kernel, sugar.zhang,
sui.jingfeng, tomi.valkeinen+renesas, mordan
On 25/04/25 12:29 am, Luca Ceresoli wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> devm_drm_bridge_alloc() is the new API to be used for allocating (and
> partially initializing) a private driver struct embedding a struct
> drm_bridge.
>
> For many drivers having a simple code flow in the probe function, this
> commit does a mass conversion automatically with the following semantic
> patch. The changes have been reviewed manually for correctness as well as
> to find any false positives.
>
> @@
> type T;
> identifier C;
> identifier BR;
> expression DEV;
> expression FUNCS;
> @@
> -T *C;
> +T *C;
> ...
> (
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return -ENOMEM;
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> |
> -C = devm_kzalloc(DEV, ...);
> -if (!C)
> - return ERR_PTR(-ENOMEM);
> +C = devm_drm_bridge_alloc(DEV, T, BR, FUNCS);
> +if (IS_ERR(C))
> + return PTR_ERR(C);
> )
> ...
> -C->BR.funcs = FUNCS;
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> Cc: Adam Ford <aford173@gmail.com>
> Cc: Adrien Grassein <adrien.grassein@gmail.com>
> Cc: Aleksandr Mishin <amishin@t-argos.ru>
> Cc: Andy Yan <andy.yan@rock-chips.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Christoph Fritz <chf.fritz@googlemail.com>
> Cc: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> Cc: Detlev Casanova <detlev.casanova@collabora.com>
> Cc: Dharma Balasubiramani <dharma.b@microchip.com>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Janne Grunau <j@jannau.net>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Cc: Jesse Van Gavere <jesseevg@gmail.com>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: Liu Ying <victor.liu@nxp.com>
> Cc: Manikandan Muralidharan <manikandan.m@microchip.com>
> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Phong LE <ple@baylibre.com>
> Cc: Sasha Finkelstein <fnkl.kernel@gmail.com>
> Cc: Sugar Zhang <sugar.zhang@rock-chips.com>
> Cc: Sui Jingfeng <sui.jingfeng@linux.dev>
> Cc: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> Cc: Vitalii Mordan <mordan@ispras.ru>
>
> Changed in v2:
> - added missing PTR_ERR() in the second spatch alternative
> ---
> drivers/gpu/drm/adp/adp-mipi.c | 8 ++++----
> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 9 ++++-----
> drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-bridge.c | 9 ++++-----
> drivers/gpu/drm/bridge/aux-hpd-bridge.c | 9 +++++----
> drivers/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/fsl-ldb.c | 7 +++----
> 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/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/lvds-codec.c | 9 ++++-----
> drivers/gpu/drm/bridge/microchip-lvds.c | 8 ++++----
> drivers/gpu/drm/bridge/nwl-dsi.c | 8 ++++----
> drivers/gpu/drm/bridge/parade-ps8622.c | 9 ++++-----
> drivers/gpu/drm/bridge/parade-ps8640.c | 9 ++++-----
> 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-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/tc358768.c | 9 ++++-----
> drivers/gpu/drm/bridge/tc358775.c | 9 ++++-----
> drivers/gpu/drm/bridge/thc63lvd1024.c | 8 ++++----
> drivers/gpu/drm/bridge/ti-dlpc3433.c | 9 ++++-----
> 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/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/renesas/rcar-du/rcar_lvds.c | 9 ++++-----
> drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 10 ++++------
> 49 files changed, 201 insertions(+), 237 deletions(-)
>
[...]
> diff --git a/drivers/gpu/drm/bridge/microchip-lvds.c b/drivers/gpu/drm/bridge/microchip-lvds.c
> index 1d4ae0097df847d9f93c79eecff0c4587ae331ba..9f4ff82bc6b49010f8727da3b367f5a744a28edc 100644
> --- a/drivers/gpu/drm/bridge/microchip-lvds.c
> +++ b/drivers/gpu/drm/bridge/microchip-lvds.c
> @@ -157,9 +157,10 @@ static int mchp_lvds_probe(struct platform_device *pdev)
> if (!dev->of_node)
> return -ENODEV;
>
> - lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
> - if (!lvds)
> - return -ENOMEM;
> + lvds = devm_drm_bridge_alloc(&pdev->dev, struct mchp_lvds, bridge,
> + &mchp_lvds_bridge_funcs);
> + if (IS_ERR(lvds))
> + return PTR_ERR(lvds);
>
> lvds->dev = dev;
>
> @@ -192,7 +193,6 @@ static int mchp_lvds_probe(struct platform_device *pdev)
>
> lvds->bridge.of_node = dev->of_node;
> lvds->bridge.type = DRM_MODE_CONNECTOR_LVDS;
> - lvds->bridge.funcs = &mchp_lvds_bridge_funcs;
>
> dev_set_drvdata(dev, lvds);
> ret = devm_pm_runtime_enable(dev);
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
--
Thanks and Regards,
Manikandan M.
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-28 20:59 ` Doug Anderson
@ 2025-04-30 10:35 ` Luca Ceresoli
2025-04-30 15:51 ` Doug Anderson
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-30 10:35 UTC (permalink / raw)
To: Doug Anderson
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hello Doug,
On Mon, 28 Apr 2025 13:59:50 -0700
Doug Anderson <dianders@chromium.org> wrote:
[...]
> Reviewed-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
> Tested-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
Thank you for your review!
However I'll be sending v3 with some differences w.r.t. v2, in order to
fix the 3 bugs reported by Andy Yan plus a similar one I spotted. The
fix just is replacing PTR_ERR() with ERR_CAST() in the 4 cases where the
involved function is returning a pointer instead of an int.
Your review/test tags appear global to the whole patch, thus being the
patch different I think I cannot include your tags in v3.
Let me know if you think I should do differently.
Sorry about that.
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-30 9:42 ` Manikandan.M
@ 2025-04-30 10:36 ` Luca Ceresoli
2025-05-05 5:20 ` Manikandan.M
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-30 10:36 UTC (permalink / raw)
To: Manikandan.M
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart, jonas,
jernej.skrabec, jagan, shawnguo, s.hauer, kernel, festevam,
dianders, chunkuang.hu, krzk, asrivats, paulk, lumag, Hui.Pu,
thomas.petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, aford173, adrien.grassein,
amishin, andy.yan, angelogioacchino.delregno, bleung, biju.das.jz,
chf.fritz, cristian.ciocaltea, detlev.casanova, Dharma.B, groeck,
heiko, jani.nikula, j, jbrunet, jesseevg, khilman,
kieran.bingham+renesas, victor.liu, martin.blumenstingl,
matthias.bgg, p.zabel, ple, fnkl.kernel, sugar.zhang,
sui.jingfeng, tomi.valkeinen+renesas, mordan
Hello Manikandan,
On Wed, 30 Apr 2025 09:42:16 +0000
<Manikandan.M@microchip.com> wrote:
[...]
> > diff --git a/drivers/gpu/drm/bridge/microchip-lvds.c b/drivers/gpu/drm/bridge/microchip-lvds.c
> > index 1d4ae0097df847d9f93c79eecff0c4587ae331ba..9f4ff82bc6b49010f8727da3b367f5a744a28edc 100644
> > --- a/drivers/gpu/drm/bridge/microchip-lvds.c
> > +++ b/drivers/gpu/drm/bridge/microchip-lvds.c
> > @@ -157,9 +157,10 @@ static int mchp_lvds_probe(struct platform_device *pdev)
> > if (!dev->of_node)
> > return -ENODEV;
> >
> > - lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
> > - if (!lvds)
> > - return -ENOMEM;
> > + lvds = devm_drm_bridge_alloc(&pdev->dev, struct mchp_lvds, bridge,
> > + &mchp_lvds_bridge_funcs);
> > + if (IS_ERR(lvds))
> > + return PTR_ERR(lvds);
> >
> > lvds->dev = dev;
> >
> > @@ -192,7 +193,6 @@ static int mchp_lvds_probe(struct platform_device *pdev)
> >
> > lvds->bridge.of_node = dev->of_node;
> > lvds->bridge.type = DRM_MODE_CONNECTOR_LVDS;
> > - lvds->bridge.funcs = &mchp_lvds_bridge_funcs;
> >
> > dev_set_drvdata(dev, lvds);
> > ret = devm_pm_runtime_enable(dev);
>
> Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
Thanks for reviewing!
In v3 this patch will be slightly different from v2. See the reply I
just sent to Doug for the details.
If your Reviewed-by tag refers only to the microchip-lvds driver, for
which there will be no change in v3, I think it's correct to take your
tag and add a comment like:
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com> # microchip-lvds.c
Anything against this?
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-30 8:21 ` Louis Chauvet
@ 2025-04-30 10:39 ` Maxime Ripard
2025-04-30 15:30 ` Louis Chauvet
0 siblings, 1 reply; 81+ messages in thread
From: Maxime Ripard @ 2025-04-30 10:39 UTC (permalink / raw)
To: Louis Chauvet
Cc: Dmitry Baryshkov, Maarten Lankhorst, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Jagan Teki, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Douglas Anderson, Chun-Kuang Hu,
Krzysztof Kozlowski, Luca Ceresoli, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart
[-- Attachment #1: Type: text/plain, Size: 1955 bytes --]
On Wed, Apr 30, 2025 at 10:21:48AM +0200, Louis Chauvet wrote:
>
>
> Le 29/04/2025 à 16:42, Dmitry Baryshkov a écrit :
> > 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.
> >
>
> Sorry, I was not aware that msm also have his own repository.
>
> TBH, I was not aware that other repositories existed for drm (I should have
> looked at MAINTAINERS, it is totally my fault). DIM and doc[1] only list
> drm, drm-misc, drm-xe, drm-intel, so I just tough "intel is special", not
> "drm is divided in many repositories".
It's mentioned in the drm-misc section:
https://drm.pages.freedesktop.org/maintainer-tools/repositories/drm-misc.html
> This repository consists mostly of the core drm code as well as DRM
> drivers that do not have a dedicated repository.
Feel free to send a patch to improve the doc. If you missed it, someone
else will.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-30 10:39 ` Maxime Ripard
@ 2025-04-30 15:30 ` Louis Chauvet
0 siblings, 0 replies; 81+ messages in thread
From: Louis Chauvet @ 2025-04-30 15:30 UTC (permalink / raw)
To: Maxime Ripard
Cc: Dmitry Baryshkov, Maarten Lankhorst, Thomas Zimmermann,
David Airlie, Simona Vetter, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Jagan Teki, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Douglas Anderson, Chun-Kuang Hu,
Krzysztof Kozlowski, Luca Ceresoli, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Inki Dae, Kyungmin Park, Seung-Woo Kim, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark,
Sean Paul, Helge Deller, Kuninori Morimoto, Laurent Pinchart
Le 30/04/2025 à 12:39, Maxime Ripard a écrit :
> On Wed, Apr 30, 2025 at 10:21:48AM +0200, Louis Chauvet wrote:
>>
>>
>> Le 29/04/2025 à 16:42, Dmitry Baryshkov a écrit :
>>> 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.
>>>
>>
>> Sorry, I was not aware that msm also have his own repository.
>>
>> TBH, I was not aware that other repositories existed for drm (I should have
>> looked at MAINTAINERS, it is totally my fault). DIM and doc[1] only list
>> drm, drm-misc, drm-xe, drm-intel, so I just tough "intel is special", not
>> "drm is divided in many repositories".
>
> It's mentioned in the drm-misc section:
>
> https://drm.pages.freedesktop.org/maintainer-tools/repositories/drm-misc.html
>
>> This repository consists mostly of the core drm code as well as DRM
>> drivers that do not have a dedicated repository.
>
> Feel free to send a patch to improve the doc. If you missed it, someone
> else will.
Done :
https://gitlab.freedesktop.org/drm/maintainer-tools/-/merge_requests/77#c304368de02d740ca751f5812ddcd0cfac40d162
I added more details for the push process, clarified the existing drm
repositories and added a small check in dim to warn user if the pushed
commits does not belong to the targeted brach.
> Maxime
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-30 10:35 ` Luca Ceresoli
@ 2025-04-30 15:51 ` Doug Anderson
2025-04-30 16:42 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Doug Anderson @ 2025-04-30 15:51 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hi,
On Wed, Apr 30, 2025 at 3:36 AM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
> Hello Doug,
>
> On Mon, 28 Apr 2025 13:59:50 -0700
> Doug Anderson <dianders@chromium.org> wrote:
>
> [...]
>
> > Reviewed-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
> > Tested-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
>
> Thank you for your review!
>
> However I'll be sending v3 with some differences w.r.t. v2, in order to
> fix the 3 bugs reported by Andy Yan plus a similar one I spotted. The
> fix just is replacing PTR_ERR() with ERR_CAST() in the 4 cases where the
> involved function is returning a pointer instead of an int.
>
> Your review/test tags appear global to the whole patch, thus being the
> patch different I think I cannot include your tags in v3.
>
> Let me know if you think I should do differently.
>
> Sorry about that.
It's fine if you want to drop my tag. I didn't have time to review the
whole thing but I felt like I should at least review the drivers I'm
signed up as a reviewer for. That being said, I'm not counting tags or
anything so I'm not offended if they're dropped.
My understanding is that the hashtag at the end is at least a
semi-standard way to say that my tag only applies to a small part of
the patch, so it seems like it would be OK to carry it, though...
-Doug
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-30 15:51 ` Doug Anderson
@ 2025-04-30 16:42 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-04-30 16:42 UTC (permalink / raw)
To: Doug Anderson
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan
Hello Doug,
On Wed, 30 Apr 2025 08:51:52 -0700
Doug Anderson <dianders@chromium.org> wrote:
> Hi,
>
> On Wed, Apr 30, 2025 at 3:36 AM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> >
> > Hello Doug,
> >
> > On Mon, 28 Apr 2025 13:59:50 -0700
> > Doug Anderson <dianders@chromium.org> wrote:
> >
> > [...]
> >
> > > Reviewed-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
> > > Tested-by: Douglas Anderson <dianders@chromium.org> # parade-ps8640
> >
> > Thank you for your review!
> >
> > However I'll be sending v3 with some differences w.r.t. v2, in order to
> > fix the 3 bugs reported by Andy Yan plus a similar one I spotted. The
> > fix just is replacing PTR_ERR() with ERR_CAST() in the 4 cases where the
> > involved function is returning a pointer instead of an int.
> >
> > Your review/test tags appear global to the whole patch, thus being the
> > patch different I think I cannot include your tags in v3.
> >
> > Let me know if you think I should do differently.
> >
> > Sorry about that.
>
> It's fine if you want to drop my tag. I didn't have time to review the
> whole thing but I felt like I should at least review the drivers I'm
> signed up as a reviewer for. That being said, I'm not counting tags or
> anything so I'm not offended if they're dropped.
>
> My understanding is that the hashtag at the end is at least a
> semi-standard way to say that my tag only applies to a small part of
> the patch, so it seems like it would be OK to carry it, though...
Oh dear. I was so stupid. I had not seen the comment in your tag
lines... :-|
So it's fine, I'll keep your tags as the parade driver is not modified
in v3.
Sorry about the noise.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API
2025-04-30 10:36 ` Luca Ceresoli
@ 2025-05-05 5:20 ` Manikandan.M
0 siblings, 0 replies; 81+ messages in thread
From: Manikandan.M @ 2025-05-05 5:20 UTC (permalink / raw)
To: luca.ceresoli
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart, jonas,
jernej.skrabec, jagan, shawnguo, s.hauer, kernel, festevam,
dianders, chunkuang.hu, krzk, asrivats, paulk, lumag, Hui.Pu,
thomas.petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, aford173, adrien.grassein,
amishin, andy.yan, angelogioacchino.delregno, bleung, biju.das.jz,
chf.fritz, cristian.ciocaltea, detlev.casanova, Dharma.B, groeck,
heiko, jani.nikula, j, jbrunet, jesseevg, khilman,
kieran.bingham+renesas, victor.liu, martin.blumenstingl,
matthias.bgg, p.zabel, ple, fnkl.kernel, sugar.zhang,
sui.jingfeng, tomi.valkeinen+renesas, mordan
On 30/04/25 4:06 pm, Luca Ceresoli wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Hello Manikandan,
>
> On Wed, 30 Apr 2025 09:42:16 +0000
> <Manikandan.M@microchip.com> wrote:
>
> [...]
>
>>> diff --git a/drivers/gpu/drm/bridge/microchip-lvds.c b/drivers/gpu/drm/bridge/microchip-lvds.c
>>> index 1d4ae0097df847d9f93c79eecff0c4587ae331ba..9f4ff82bc6b49010f8727da3b367f5a744a28edc 100644
>>> --- a/drivers/gpu/drm/bridge/microchip-lvds.c
>>> +++ b/drivers/gpu/drm/bridge/microchip-lvds.c
>>> @@ -157,9 +157,10 @@ static int mchp_lvds_probe(struct platform_device *pdev)
>>> if (!dev->of_node)
>>> return -ENODEV;
>>>
>>> - lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
>>> - if (!lvds)
>>> - return -ENOMEM;
>>> + lvds = devm_drm_bridge_alloc(&pdev->dev, struct mchp_lvds, bridge,
>>> + &mchp_lvds_bridge_funcs);
>>> + if (IS_ERR(lvds))
>>> + return PTR_ERR(lvds);
>>>
>>> lvds->dev = dev;
>>>
>>> @@ -192,7 +193,6 @@ static int mchp_lvds_probe(struct platform_device *pdev)
>>>
>>> lvds->bridge.of_node = dev->of_node;
>>> lvds->bridge.type = DRM_MODE_CONNECTOR_LVDS;
>>> - lvds->bridge.funcs = &mchp_lvds_bridge_funcs;
>>>
>>> dev_set_drvdata(dev, lvds);
>>> ret = devm_pm_runtime_enable(dev);
>>
>> Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
>
> Thanks for reviewing!
>
> In v3 this patch will be slightly different from v2. See the reply I
> just sent to Doug for the details.
>
> If your Reviewed-by tag refers only to the microchip-lvds driver, for
> which there will be no change in v3, I think it's correct to take your
> tag and add a comment like:
>
> Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com> # microchip-lvds.c
>
> Anything against this?
>
No, Luca. Please proceed with the above mentioned tag # microchip-lvds.c
> Best regards,
> Luca
>
> --
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
--
Thanks and Regards,
Manikandan M.
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API
2025-04-28 15:25 ` Luca Ceresoli
@ 2025-05-05 6:23 ` Maxime Ripard
2025-05-05 15:20 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Maxime Ripard @ 2025-05-05 6:23 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]
On Mon, Apr 28, 2025 at 05:25:16PM +0200, Luca Ceresoli wrote:
> Hi Maxime,
>
> On Mon, 28 Apr 2025 13:39:23 +0200
> Maxime Ripard <mripard@kernel.org> wrote:
>
> > On Thu, Apr 24, 2025 at 10:05:49PM +0200, Luca Ceresoli wrote:
> > > This is the new API for allocating DRM bridges.
> > >
> > > The devm lifetime management of this driver is peculiar. The underlying
> > > device for the panel_bridge is the panel, and the devm lifetime is tied the
> > > panel device (panel->dev). However the panel_bridge allocation is not
> > > performed by the panel driver, but rather by a separate entity (typically
> > > the previous bridge in the encoder chain).
> > >
> > > Thus when that separate entoty is destroyed, the panel_bridge is not
> > > removed automatically by devm, so it is rather done explicitly by calling
> > > drm_panel_bridge_remove(). This is the function that does devm_kfree() the
> > > panel_bridge in current code, so update it as well to put the bridge
> > > reference instead.
> > >
> > > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> >
> > This looks fine, but we need a TODO entry to clean this up later on, and
> > a comment on devm_drm_put_bridge that this is inherently unsafe and
> > must not be used.
>
> Ah, I see, OK.
>
> Quick draft:
>
> /**
> * devm_drm_put_bridge - Release a bridge reference obtained via devm
> * @dev: device that got the bridge via devm
> * @bridge: pointer to a struct drm_bridge obtained via devm
> *
> * Same as drm_bridge_put() for bridge pointers obtained via devm functions
> * such as devm_drm_bridge_alloc().
> + *
> + * This function is a temporary workaround and MUST NOT be used. Manual
> + * handling of bridge lifetime is inherently unsafe.
> */
That part looks good to me
> and:
>
> - devm_kfree(panel_bridge->panel->dev, bridge);
> + /* TODO remove this after reworking panel_bridge lifetime */
> + devm_drm_put_bridge(panel_bridge->panel->dev, bridge);
> }
>
> Does it look good enough?
That too, but I was talking about an entry in
https://www.kernel.org/doc/html/latest/gpu/todo.html
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-04-30 8:08 ` Maxime Ripard
@ 2025-05-05 11:06 ` Luca Ceresoli
2025-05-05 11:58 ` Dmitry Baryshkov
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-05 11:06 UTC (permalink / raw)
To: Inki Dae, Kyungmin Park, Seung-Woo Kim, Alim Akhtar
Cc: Maxime Ripard, Louis Chauvet, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Dmitry Baryshkov, Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin,
Xin Ji, Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Alim Akhtar,
Linus Walleij, Abhinav Kumar, Bjorn Andersson, Marijn Suijten,
Rob Clark, Sean Paul, Helge Deller, Kuninori Morimoto,
Laurent Pinchart, Alexandre Torgue, Maxime Coquelin,
Philippe Cornu, Raphael Gallais-Pou, Yannick Fertre,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Alain Volmat, Raphael Gallais-Pou, Michal Simek
Inki, Kyungmin, Seung-Woo, Alim,
On Wed, 30 Apr 2025 10:08:14 +0200
Maxime Ripard <mripard@kernel.org> wrote:
> Inki, Kyungmin, Seung-Woo, sorry for the mishap. Do you agree with the
> following patch, and it going through drm-misc?
>
> https://lore.kernel.org/dri-devel/20250424-drm-bridge-convert-to-alloc-api-v2-14-8f91a404d86b@bootlin.com/
>
> If not, we'll revert.
Did you have a chance to have a look at the patch mentioned by Maxime?
It was applied to drm-misc-next by mistake. Not your mistake of course,
but now it's there so if you don't reply anything it will have to be
reverted, and then sent again to go through all the review process to
be hopefully re-applied in the future.
If you agree with keeping it in drm-misc-next, that would be less noise
for everybody.
I'm going to send v3 very soon, so it would be good to decide what to
do before that.
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-05-05 11:06 ` Luca Ceresoli
@ 2025-05-05 11:58 ` Dmitry Baryshkov
2025-05-05 12:31 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Dmitry Baryshkov @ 2025-05-05 11:58 UTC (permalink / raw)
To: Luca Ceresoli, Inki Dae, Kyungmin Park, Seung-Woo Kim,
Alim Akhtar
Cc: Maxime Ripard, Louis Chauvet, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark
On 05/05/2025 14:06, Luca Ceresoli wrote:
> Inki, Kyungmin, Seung-Woo, Alim,
>
> On Wed, 30 Apr 2025 10:08:14 +0200
> Maxime Ripard <mripard@kernel.org> wrote:
>
>> Inki, Kyungmin, Seung-Woo, sorry for the mishap. Do you agree with the
>> following patch, and it going through drm-misc?
>>
>> https://lore.kernel.org/dri-devel/20250424-drm-bridge-convert-to-alloc-api-v2-14-8f91a404d86b@bootlin.com/
>>
>> If not, we'll revert.
>
> Did you have a chance to have a look at the patch mentioned by Maxime?
>
> It was applied to drm-misc-next by mistake. Not your mistake of course,
> but now it's there so if you don't reply anything it will have to be
> reverted, and then sent again to go through all the review process to
> be hopefully re-applied in the future.
>
> If you agree with keeping it in drm-misc-next, that would be less noise
> for everybody.
>
> I'm going to send v3 very soon, so it would be good to decide what to
> do before that.
For the record: even though I'm not happy with msm-related patches going
through drm-misc without additional ack from our side, I think reverting
those and reapplying them later will create a bigger mess. So, I'm fine
with keeping drm/msm/* bridged patches in.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: (subset) [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc()
2025-05-05 11:58 ` Dmitry Baryshkov
@ 2025-05-05 12:31 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-05 12:31 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Inki Dae, Kyungmin Park, Seung-Woo Kim, Alim Akhtar,
Maxime Ripard, Louis Chauvet, Maarten Lankhorst,
Thomas Zimmermann, David Airlie, Simona Vetter, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Jagan Teki, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Douglas Anderson,
Chun-Kuang Hu, Krzysztof Kozlowski, Anusha Srivatsa,
Paul Kocialkowski, Dmitry Baryshkov, Hui Pu, Thomas Petazzoni,
dri-devel, asahi, linux-kernel, chrome-platform, imx,
linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32, Adam Ford, Adrien Grassein,
Aleksandr Mishin, Andy Yan, AngeloGioacchino Del Regno,
Benson Leung, Biju Das, Christoph Fritz, Cristian Ciocaltea,
Detlev Casanova, Dharma Balasubiramani, Guenter Roeck,
Heiko Stuebner, Jani Nikula, Janne Grunau, Jerome Brunet,
Jesse Van Gavere, Kevin Hilman, Kieran Bingham, Liu Ying,
Manikandan Muralidharan, Martin Blumenstingl, Matthias Brugger,
Philipp Zabel, Phong LE, Sasha Finkelstein, Sugar Zhang,
Sui Jingfeng, Tomi Valkeinen, Vitalii Mordan, Ilpo Järvinen,
Bryan O'Donoghue, Hans de Goede, Uwe Kleine-König,
Rob Herring (Arm), Hsin-Te Yuan, Pin-yen Lin, Xin Ji,
Aradhya Bhatia, Tomi Valkeinen, Ian Ray, Martyn Welch,
Peter Senna Tschudin, Russell King, Herve Codina, Linus Walleij,
Abhinav Kumar, Bjorn Andersson, Marijn Suijten, Rob Clark
Hi Dmitry,
On Mon, 5 May 2025 14:58:58 +0300
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote:
> On 05/05/2025 14:06, Luca Ceresoli wrote:
> > Inki, Kyungmin, Seung-Woo, Alim,
> >
> > On Wed, 30 Apr 2025 10:08:14 +0200
> > Maxime Ripard <mripard@kernel.org> wrote:
> >
> >> Inki, Kyungmin, Seung-Woo, sorry for the mishap. Do you agree with the
> >> following patch, and it going through drm-misc?
> >>
> >> https://lore.kernel.org/dri-devel/20250424-drm-bridge-convert-to-alloc-api-v2-14-8f91a404d86b@bootlin.com/
> >>
> >> If not, we'll revert.
> >
> > Did you have a chance to have a look at the patch mentioned by Maxime?
> >
> > It was applied to drm-misc-next by mistake. Not your mistake of course,
> > but now it's there so if you don't reply anything it will have to be
> > reverted, and then sent again to go through all the review process to
> > be hopefully re-applied in the future.
> >
> > If you agree with keeping it in drm-misc-next, that would be less noise
> > for everybody.
> >
> > I'm going to send v3 very soon, so it would be good to decide what to
> > do before that.
>
> For the record: even though I'm not happy with msm-related patches going
> through drm-misc without additional ack from our side, I think reverting
> those and reapplying them later will create a bigger mess. So, I'm fine
> with keeping drm/msm/* bridged patches in.
That was my understanding of your previous e-mail, but thanks for
having made it explicit.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API
2025-05-05 6:23 ` Maxime Ripard
@ 2025-05-05 15:20 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-05 15:20 UTC (permalink / raw)
To: Maxime Ripard
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Jagan Teki, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On Mon, 5 May 2025 08:23:26 +0200
Maxime Ripard <mripard@kernel.org> wrote:
> On Mon, Apr 28, 2025 at 05:25:16PM +0200, Luca Ceresoli wrote:
> > Hi Maxime,
> >
> > On Mon, 28 Apr 2025 13:39:23 +0200
> > Maxime Ripard <mripard@kernel.org> wrote:
> >
> > > On Thu, Apr 24, 2025 at 10:05:49PM +0200, Luca Ceresoli wrote:
> > > > This is the new API for allocating DRM bridges.
> > > >
> > > > The devm lifetime management of this driver is peculiar. The underlying
> > > > device for the panel_bridge is the panel, and the devm lifetime is tied the
> > > > panel device (panel->dev). However the panel_bridge allocation is not
> > > > performed by the panel driver, but rather by a separate entity (typically
> > > > the previous bridge in the encoder chain).
> > > >
> > > > Thus when that separate entoty is destroyed, the panel_bridge is not
> > > > removed automatically by devm, so it is rather done explicitly by calling
> > > > drm_panel_bridge_remove(). This is the function that does devm_kfree() the
> > > > panel_bridge in current code, so update it as well to put the bridge
> > > > reference instead.
> > > >
> > > > Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > >
> > > This looks fine, but we need a TODO entry to clean this up later on, and
> > > a comment on devm_drm_put_bridge that this is inherently unsafe and
> > > must not be used.
> >
> > Ah, I see, OK.
> >
> > Quick draft:
> >
> > /**
> > * devm_drm_put_bridge - Release a bridge reference obtained via devm
> > * @dev: device that got the bridge via devm
> > * @bridge: pointer to a struct drm_bridge obtained via devm
> > *
> > * Same as drm_bridge_put() for bridge pointers obtained via devm functions
> > * such as devm_drm_bridge_alloc().
> > + *
> > + * This function is a temporary workaround and MUST NOT be used. Manual
> > + * handling of bridge lifetime is inherently unsafe.
> > */
>
> That part looks good to me
>
> > and:
> >
> > - devm_kfree(panel_bridge->panel->dev, bridge);
> > + /* TODO remove this after reworking panel_bridge lifetime */
> > + devm_drm_put_bridge(panel_bridge->panel->dev, bridge);
> > }
> >
> > Does it look good enough?
>
> That too, but I was talking about an entry in
> https://www.kernel.org/doc/html/latest/gpu/todo.html
Ah, sure!
I queued this for v3, if you have better suggestions don't hesitate to
let me know:
-----8<-----
Remove devm_drm_put_bridge()
----------------------------
Due to how the panel bridge handles the drm_bridge object lifetime, special
care must be taken to dispose of the drm_bridge object when the
panel_bridge is removed. This is currently managed using
devm_drm_put_bridge(), but that is an unsafe, temporary workaround. To fix
that, the DRM panel lifetime needs to be reworked. After the rework is
done, remove devm_drm_put_bridge() and the TODO in drm_panel_bridge_remove().
Contact: Maxime Ripard <mripard@kernel.org>,
Luca Ceresoli <luca.ceresoli@bootlin.com>
Level: Intermediate
-----8<-----
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-04-30 9:29 ` Luca Ceresoli
@ 2025-05-06 2:24 ` Liu Ying
2025-05-06 20:47 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-05-06 2:24 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 04/30/2025, Luca Ceresoli wrote:
> Hello Liu,
Hi Luca,
>
> On Tue, 29 Apr 2025 10:10:55 +0800
> Liu Ying <victor.liu@nxp.com> wrote:
>
>> Hi,
>>
>> On 04/25/2025, Luca Ceresoli wrote:
>>> This is the new API for allocating DRM bridges.
>>>
>>> This driver embeds an array of channels in the main struct, and each
>>> channel embeds a drm_bridge. This prevents dynamic, refcount-based
>>> deallocation of the bridges.
>>>
>>> To make the new, dynamic bridge allocation possible:
>>>
>>> * change the array of channels into an array of channel pointers
>>> * allocate each channel using devm_drm_bridge_alloc()
>>> * adapt the code wherever using the channels
>>>
>>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> [...]
>
>>> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>>> free_child:
>>> of_node_put(child);
>>>
>>> - if (i == 1 && pc->ch[0].next_bridge)
>>> - drm_bridge_remove(&pc->ch[0].bridge);
>>> + if (i == 1 && pc->ch[0]->next_bridge)
>>
>> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
>> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
>> dereference here...
>
> See below for this.
>
>>> + drm_bridge_remove(&pc->ch[0]->bridge);
>>>
>>> pm_runtime_disable(dev);
>>> return ret;
>>> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
>>> int i;
>>>
>>> for (i = 0; i < 2; i++) {
>>> - ch = &pc->ch[i];
>>> + ch = pc->ch[i];
>>>
>>> if (!ch->is_available)
>>
>> ...and here too.
>
> This is indeed a bug, I should have checked the pointer for being
> non-NULL.
>
> Looking at that more closely, I think the is_available flag can be
> entirely removed now. The allocation itself (ch != NULL) now is
> equivalent. Do you think my reasoning is correct?
>
> Ouch! After writing the previous paragraph I realized you proposed this
> a few lines below! OK, removing is_available. :)
>
> [...]
>
>> On top of this patch series, this issue doesn't happen if I apply the below
>> change:
>
> [...]
>
>> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>> free_child:
>> of_node_put(child);
>>
>> - if (i == 1 && pc->ch[0]->next_bridge)
>> + if (i == 1 && pc->ch[0])
>> drm_bridge_remove(&pc->ch[0]->bridge);
>
> Unrelated to this patch, but as I looked at it more in depth now, I'm
> not sure this whole logic is robust, even in the original code.
>
> The 'i == 1' check here seems to mean "if some error happened when
> handling channel@1, that means channel@0 was successfully initialized,
> so let's clean up channel 0".
>
> However my understanding of the bindings is that device tree is allowed
> to have the channel@1 node before the channel@0 node (or even channel@1
> without channel@0, but that's less problematic here).
>
> In such case (channel@1 before channel@0), this would happen:
>
> 1. alloc and init ch[1], all OK
> 2. alloc and init ch[0], an error happens
> (e.g. of_graph_get_remote_node() fails)
>
> So we'd reach the free_child: label, and we should call
> drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
>
> To be robust in such a case, I think both channels need to be checked
> independently, as the status of one does not imply the status of the
> other. E.g.:
>
> for (i = 0; i < 2; i++)
> if (pc->ch[i] && pc->ch[i]->next_bridge)
> drm_bridge_remove(&pc->ch[i]->bridge);
>
> (which is similar to what .remove() does after the changes discussed in
> this thread, and which I have queued for v3)
>
> What's your opinion? Do you think I missed anything?
The pixel combiner DT node would be added in imx8-ss-dc{0,1}.dtsi, please
see the case for imx8-ss-dc0.dtsi introduced by an in-flight patch[1]. As
channel@{0,1} child nodes always exist(DT overlay cannot effectively delete
any of them) and channel@0 always comes first, there is no problematic case.
>
> Thanks for taking the time to dig into this!
After looking into this patch and patch 31(though I've already provided my A-b)
more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
should have the same life time with the embedded DRM bridges, because for
example the clk_apb clock in struct imx8qxp_pc would be accessed by the
imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
the life time for the embedded channel/bridge structures only, but not for the
main structures. What do you think ?
>
> Best regards,
> Luca
>
[1] https://lore.kernel.org/dri-devel/20250414035028.1561475-17-victor.liu@nxp.com/
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-06 2:24 ` Liu Ying
@ 2025-05-06 20:47 ` Luca Ceresoli
2025-05-07 2:10 ` Liu Ying
2025-05-22 3:01 ` Liu Ying
0 siblings, 2 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-06 20:47 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hello Liu,
thanks for your further feedback.
On Tue, 6 May 2025 10:24:18 +0800
Liu Ying <victor.liu@nxp.com> wrote:
> On 04/30/2025, Luca Ceresoli wrote:
> > Hello Liu,
>
> Hi Luca,
>
> >
> > On Tue, 29 Apr 2025 10:10:55 +0800
> > Liu Ying <victor.liu@nxp.com> wrote:
> >
> >> Hi,
> >>
> >> On 04/25/2025, Luca Ceresoli wrote:
> >>> This is the new API for allocating DRM bridges.
> >>>
> >>> This driver embeds an array of channels in the main struct, and each
> >>> channel embeds a drm_bridge. This prevents dynamic, refcount-based
> >>> deallocation of the bridges.
> >>>
> >>> To make the new, dynamic bridge allocation possible:
> >>>
> >>> * change the array of channels into an array of channel pointers
> >>> * allocate each channel using devm_drm_bridge_alloc()
> >>> * adapt the code wherever using the channels
> >>>
> >>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> >
> > [...]
> >
> >>> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> >>> free_child:
> >>> of_node_put(child);
> >>>
> >>> - if (i == 1 && pc->ch[0].next_bridge)
> >>> - drm_bridge_remove(&pc->ch[0].bridge);
> >>> + if (i == 1 && pc->ch[0]->next_bridge)
> >>
> >> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
> >> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
> >> dereference here...
> >
> > See below for this.
> >
> >>> + drm_bridge_remove(&pc->ch[0]->bridge);
> >>>
> >>> pm_runtime_disable(dev);
> >>> return ret;
> >>> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
> >>> int i;
> >>>
> >>> for (i = 0; i < 2; i++) {
> >>> - ch = &pc->ch[i];
> >>> + ch = pc->ch[i];
> >>>
> >>> if (!ch->is_available)
> >>
> >> ...and here too.
> >
> > This is indeed a bug, I should have checked the pointer for being
> > non-NULL.
> >
> > Looking at that more closely, I think the is_available flag can be
> > entirely removed now. The allocation itself (ch != NULL) now is
> > equivalent. Do you think my reasoning is correct?
> >
> > Ouch! After writing the previous paragraph I realized you proposed this
> > a few lines below! OK, removing is_available. :)
> >
> > [...]
> >
> >> On top of this patch series, this issue doesn't happen if I apply the below
> >> change:
> >
> > [...]
> >
> >> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> >> free_child:
> >> of_node_put(child);
> >>
> >> - if (i == 1 && pc->ch[0]->next_bridge)
> >> + if (i == 1 && pc->ch[0])
> >> drm_bridge_remove(&pc->ch[0]->bridge);
> >
> > Unrelated to this patch, but as I looked at it more in depth now, I'm
> > not sure this whole logic is robust, even in the original code.
> >
> > The 'i == 1' check here seems to mean "if some error happened when
> > handling channel@1, that means channel@0 was successfully initialized,
> > so let's clean up channel 0".
> >
> > However my understanding of the bindings is that device tree is allowed
> > to have the channel@1 node before the channel@0 node (or even channel@1
> > without channel@0, but that's less problematic here).
> >
> > In such case (channel@1 before channel@0), this would happen:
> >
> > 1. alloc and init ch[1], all OK
> > 2. alloc and init ch[0], an error happens
> > (e.g. of_graph_get_remote_node() fails)
> >
> > So we'd reach the free_child: label, and we should call
> > drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
> >
> > To be robust in such a case, I think both channels need to be checked
> > independently, as the status of one does not imply the status of the
> > other. E.g.:
> >
> > for (i = 0; i < 2; i++)
> > if (pc->ch[i] && pc->ch[i]->next_bridge)
> > drm_bridge_remove(&pc->ch[i]->bridge);
> >
> > (which is similar to what .remove() does after the changes discussed in
> > this thread, and which I have queued for v3)
> >
> > What's your opinion? Do you think I missed anything?
>
> The pixel combiner DT node would be added in imx8-ss-dc{0,1}.dtsi, please
> see the case for imx8-ss-dc0.dtsi introduced by an in-flight patch[1]. As
> channel@{0,1} child nodes always exist(DT overlay cannot effectively delete
> any of them) and channel@0 always comes first, there is no problematic case.
I'm not questioning what existing and future dts files (will) contain,
and surely I don't see a good reason someone would write channel@1
before channel@0.
My point is:
- the bindings _allow_ channel1 before channel@0
- the error management code after the free_child label won't work
correctly if channel1 is before channel@0 in the device tree
IOW the driver is not robust against all legal device tree descriptions,
and it could be easily made robust using the example code in my
previous e-mail (quoted a few lines above).
If you agree about this I'll be happy to send a patch doing that change.
If you think I'm wrong, I won't fight a battle. This topic is
orthogonal to the change I'm introducing in this patch, and I can
continue the conversion independently from this discussion.
> > Thanks for taking the time to dig into this!
>
> After looking into this patch and patch 31(though I've already provided my A-b)
> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
> should have the same life time with the embedded DRM bridges, because for
> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
> the life time for the embedded channel/bridge structures only, but not for the
> main structures. What do you think ?
I see you concern, but I'm sure the change I'm introducing is not
creating the problem you are concerned about.
The key aspect is that my patch is merely changing the lifetime of the
_allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
the bridge is removed from its encoder chain and it is completely not
reachable, both before and after my patch. With my patch it is not
freed immediately, but it's just a piece of "wasted" memory that is
still allocated until elsewhere in the kernel there are pointers to it,
to avoid use-after-free.
With this explanation, do you think my patch is correct (after fixing
the bug we already discussed of course)?
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-06 20:47 ` Luca Ceresoli
@ 2025-05-07 2:10 ` Liu Ying
2025-05-07 7:12 ` Luca Ceresoli
2025-05-22 3:01 ` Liu Ying
1 sibling, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-05-07 2:10 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 05/07/2025, Luca Ceresoli wrote:
> Hello Liu,
Hi Luca,
>
> thanks for your further feedback.
>
> On Tue, 6 May 2025 10:24:18 +0800
> Liu Ying <victor.liu@nxp.com> wrote:
>
>> On 04/30/2025, Luca Ceresoli wrote:
>>> Hello Liu,
>>
>> Hi Luca,
>>
>>>
>>> On Tue, 29 Apr 2025 10:10:55 +0800
>>> Liu Ying <victor.liu@nxp.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> On 04/25/2025, Luca Ceresoli wrote:
>>>>> This is the new API for allocating DRM bridges.
>>>>>
>>>>> This driver embeds an array of channels in the main struct, and each
>>>>> channel embeds a drm_bridge. This prevents dynamic, refcount-based
>>>>> deallocation of the bridges.
>>>>>
>>>>> To make the new, dynamic bridge allocation possible:
>>>>>
>>>>> * change the array of channels into an array of channel pointers
>>>>> * allocate each channel using devm_drm_bridge_alloc()
>>>>> * adapt the code wherever using the channels
>>>>>
>>>>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>>>
>>> [...]
>>>
>>>>> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>>>>> free_child:
>>>>> of_node_put(child);
>>>>>
>>>>> - if (i == 1 && pc->ch[0].next_bridge)
>>>>> - drm_bridge_remove(&pc->ch[0].bridge);
>>>>> + if (i == 1 && pc->ch[0]->next_bridge)
>>>>
>>>> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
>>>> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
>>>> dereference here...
>>>
>>> See below for this.
>>>
>>>>> + drm_bridge_remove(&pc->ch[0]->bridge);
>>>>>
>>>>> pm_runtime_disable(dev);
>>>>> return ret;
>>>>> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
>>>>> int i;
>>>>>
>>>>> for (i = 0; i < 2; i++) {
>>>>> - ch = &pc->ch[i];
>>>>> + ch = pc->ch[i];
>>>>>
>>>>> if (!ch->is_available)
>>>>
>>>> ...and here too.
>>>
>>> This is indeed a bug, I should have checked the pointer for being
>>> non-NULL.
>>>
>>> Looking at that more closely, I think the is_available flag can be
>>> entirely removed now. The allocation itself (ch != NULL) now is
>>> equivalent. Do you think my reasoning is correct?
>>>
>>> Ouch! After writing the previous paragraph I realized you proposed this
>>> a few lines below! OK, removing is_available. :)
>>>
>>> [...]
>>>
>>>> On top of this patch series, this issue doesn't happen if I apply the below
>>>> change:
>>>
>>> [...]
>>>
>>>> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>>>> free_child:
>>>> of_node_put(child);
>>>>
>>>> - if (i == 1 && pc->ch[0]->next_bridge)
>>>> + if (i == 1 && pc->ch[0])
>>>> drm_bridge_remove(&pc->ch[0]->bridge);
>>>
>>> Unrelated to this patch, but as I looked at it more in depth now, I'm
>>> not sure this whole logic is robust, even in the original code.
>>>
>>> The 'i == 1' check here seems to mean "if some error happened when
>>> handling channel@1, that means channel@0 was successfully initialized,
>>> so let's clean up channel 0".
>>>
>>> However my understanding of the bindings is that device tree is allowed
>>> to have the channel@1 node before the channel@0 node (or even channel@1
>>> without channel@0, but that's less problematic here).
>>>
>>> In such case (channel@1 before channel@0), this would happen:
>>>
>>> 1. alloc and init ch[1], all OK
>>> 2. alloc and init ch[0], an error happens
>>> (e.g. of_graph_get_remote_node() fails)
>>>
>>> So we'd reach the free_child: label, and we should call
>>> drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
>>>
>>> To be robust in such a case, I think both channels need to be checked
>>> independently, as the status of one does not imply the status of the
>>> other. E.g.:
>>>
>>> for (i = 0; i < 2; i++)
>>> if (pc->ch[i] && pc->ch[i]->next_bridge)
>>> drm_bridge_remove(&pc->ch[i]->bridge);
>>>
>>> (which is similar to what .remove() does after the changes discussed in
>>> this thread, and which I have queued for v3)
>>>
>>> What's your opinion? Do you think I missed anything?
>>
>> The pixel combiner DT node would be added in imx8-ss-dc{0,1}.dtsi, please
>> see the case for imx8-ss-dc0.dtsi introduced by an in-flight patch[1]. As
>> channel@{0,1} child nodes always exist(DT overlay cannot effectively delete
>> any of them) and channel@0 always comes first, there is no problematic case.
>
> I'm not questioning what existing and future dts files (will) contain,
> and surely I don't see a good reason someone would write channel@1
> before channel@0.
>
> My point is:
>
> - the bindings _allow_ channel1 before channel@0
> - the error management code after the free_child label won't work
> correctly if channel1 is before channel@0 in the device tree
>
> IOW the driver is not robust against all legal device tree descriptions,
> and it could be easily made robust using the example code in my
> previous e-mail (quoted a few lines above).
>
> If you agree about this I'll be happy to send a patch doing that change.
> If you think I'm wrong, I won't fight a battle. This topic is
> orthogonal to the change I'm introducing in this patch, and I can
> continue the conversion independently from this discussion.
I don't think it is necessary to do that change for now. When someone
really comes across this issue, we may make the error management code
robust.
>
>>> Thanks for taking the time to dig into this!
>>
>> After looking into this patch and patch 31(though I've already provided my A-b)
>> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
>> should have the same life time with the embedded DRM bridges, because for
>> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
>> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
>> the life time for the embedded channel/bridge structures only, but not for the
>> main structures. What do you think ?
>
> I see you concern, but I'm sure the change I'm introducing is not
> creating the problem you are concerned about.
>
> The key aspect is that my patch is merely changing the lifetime of the
> _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> the bridge is removed from its encoder chain and it is completely not
> reachable, both before and after my patch. With my patch it is not
> freed immediately, but it's just a piece of "wasted" memory that is
> still allocated until elsewhere in the kernel there are pointers to it,
> to avoid use-after-free.
>
> With this explanation, do you think my patch is correct (after fixing
> the bug we already discussed of course)?
I tend to say your patch is not correct because we'll eventually make sure
that removing a bridge module is safe when doing atomic commit, which means
the main structures should have the same life time with the DRM bridges.
>
> Best regards,
> Luca
>
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-07 2:10 ` Liu Ying
@ 2025-05-07 7:12 ` Luca Ceresoli
2025-05-07 10:16 ` Liu Ying
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-07 7:12 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hello Liu,
On Wed, 7 May 2025 10:10:53 +0800
Liu Ying <victor.liu@nxp.com> wrote:
> On 05/07/2025, Luca Ceresoli wrote:
> > Hello Liu,
>
> Hi Luca,
>
> >
> > thanks for your further feedback.
> >
> > On Tue, 6 May 2025 10:24:18 +0800
> > Liu Ying <victor.liu@nxp.com> wrote:
> >
> >> On 04/30/2025, Luca Ceresoli wrote:
> >>> Hello Liu,
> >>
> >> Hi Luca,
> >>
> >>>
> >>> On Tue, 29 Apr 2025 10:10:55 +0800
> >>> Liu Ying <victor.liu@nxp.com> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> On 04/25/2025, Luca Ceresoli wrote:
> >>>>> This is the new API for allocating DRM bridges.
> >>>>>
> >>>>> This driver embeds an array of channels in the main struct, and each
> >>>>> channel embeds a drm_bridge. This prevents dynamic, refcount-based
> >>>>> deallocation of the bridges.
> >>>>>
> >>>>> To make the new, dynamic bridge allocation possible:
> >>>>>
> >>>>> * change the array of channels into an array of channel pointers
> >>>>> * allocate each channel using devm_drm_bridge_alloc()
> >>>>> * adapt the code wherever using the channels
> >>>>>
> >>>>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> >>>
> >>> [...]
> >>>
> >>>>> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> >>>>> free_child:
> >>>>> of_node_put(child);
> >>>>>
> >>>>> - if (i == 1 && pc->ch[0].next_bridge)
> >>>>> - drm_bridge_remove(&pc->ch[0].bridge);
> >>>>> + if (i == 1 && pc->ch[0]->next_bridge)
> >>>>
> >>>> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
> >>>> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
> >>>> dereference here...
> >>>
> >>> See below for this.
> >>>
> >>>>> + drm_bridge_remove(&pc->ch[0]->bridge);
> >>>>>
> >>>>> pm_runtime_disable(dev);
> >>>>> return ret;
> >>>>> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
> >>>>> int i;
> >>>>>
> >>>>> for (i = 0; i < 2; i++) {
> >>>>> - ch = &pc->ch[i];
> >>>>> + ch = pc->ch[i];
> >>>>>
> >>>>> if (!ch->is_available)
> >>>>
> >>>> ...and here too.
> >>>
> >>> This is indeed a bug, I should have checked the pointer for being
> >>> non-NULL.
> >>>
> >>> Looking at that more closely, I think the is_available flag can be
> >>> entirely removed now. The allocation itself (ch != NULL) now is
> >>> equivalent. Do you think my reasoning is correct?
> >>>
> >>> Ouch! After writing the previous paragraph I realized you proposed this
> >>> a few lines below! OK, removing is_available. :)
> >>>
> >>> [...]
> >>>
> >>>> On top of this patch series, this issue doesn't happen if I apply the below
> >>>> change:
> >>>
> >>> [...]
> >>>
> >>>> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
> >>>> free_child:
> >>>> of_node_put(child);
> >>>>
> >>>> - if (i == 1 && pc->ch[0]->next_bridge)
> >>>> + if (i == 1 && pc->ch[0])
> >>>> drm_bridge_remove(&pc->ch[0]->bridge);
> >>>
> >>> Unrelated to this patch, but as I looked at it more in depth now, I'm
> >>> not sure this whole logic is robust, even in the original code.
> >>>
> >>> The 'i == 1' check here seems to mean "if some error happened when
> >>> handling channel@1, that means channel@0 was successfully initialized,
> >>> so let's clean up channel 0".
> >>>
> >>> However my understanding of the bindings is that device tree is allowed
> >>> to have the channel@1 node before the channel@0 node (or even channel@1
> >>> without channel@0, but that's less problematic here).
> >>>
> >>> In such case (channel@1 before channel@0), this would happen:
> >>>
> >>> 1. alloc and init ch[1], all OK
> >>> 2. alloc and init ch[0], an error happens
> >>> (e.g. of_graph_get_remote_node() fails)
> >>>
> >>> So we'd reach the free_child: label, and we should call
> >>> drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
> >>>
> >>> To be robust in such a case, I think both channels need to be checked
> >>> independently, as the status of one does not imply the status of the
> >>> other. E.g.:
> >>>
> >>> for (i = 0; i < 2; i++)
> >>> if (pc->ch[i] && pc->ch[i]->next_bridge)
> >>> drm_bridge_remove(&pc->ch[i]->bridge);
> >>>
> >>> (which is similar to what .remove() does after the changes discussed in
> >>> this thread, and which I have queued for v3)
> >>>
> >>> What's your opinion? Do you think I missed anything?
> >>
> >> The pixel combiner DT node would be added in imx8-ss-dc{0,1}.dtsi, please
> >> see the case for imx8-ss-dc0.dtsi introduced by an in-flight patch[1]. As
> >> channel@{0,1} child nodes always exist(DT overlay cannot effectively delete
> >> any of them) and channel@0 always comes first, there is no problematic case.
> >
> > I'm not questioning what existing and future dts files (will) contain,
> > and surely I don't see a good reason someone would write channel@1
> > before channel@0.
> >
> > My point is:
> >
> > - the bindings _allow_ channel1 before channel@0
> > - the error management code after the free_child label won't work
> > correctly if channel1 is before channel@0 in the device tree
> >
> > IOW the driver is not robust against all legal device tree descriptions,
> > and it could be easily made robust using the example code in my
> > previous e-mail (quoted a few lines above).
> >
> > If you agree about this I'll be happy to send a patch doing that change.
> > If you think I'm wrong, I won't fight a battle. This topic is
> > orthogonal to the change I'm introducing in this patch, and I can
> > continue the conversion independently from this discussion.
>
> I don't think it is necessary to do that change for now. When someone
> really comes across this issue, we may make the error management code
> robust.
>
> >
> >>> Thanks for taking the time to dig into this!
> >>
> >> After looking into this patch and patch 31(though I've already provided my A-b)
> >> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
> >> should have the same life time with the embedded DRM bridges, because for
> >> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
> >> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
> >> the life time for the embedded channel/bridge structures only, but not for the
> >> main structures. What do you think ?
> >
> > I see you concern, but I'm sure the change I'm introducing is not
> > creating the problem you are concerned about.
> >
> > The key aspect is that my patch is merely changing the lifetime of the
> > _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> > the bridge is removed from its encoder chain and it is completely not
> > reachable, both before and after my patch. With my patch it is not
> > freed immediately, but it's just a piece of "wasted" memory that is
> > still allocated until elsewhere in the kernel there are pointers to it,
> > to avoid use-after-free.
> >
> > With this explanation, do you think my patch is correct (after fixing
> > the bug we already discussed of course)?
>
> I tend to say your patch is not correct because we'll eventually make sure
> that removing a bridge module is safe when doing atomic commit,
I think your sentence can be rephrased as "your patch is correct with
the current code base where bridges are not (yet) removable, but there
will be a problem when they start to actually be removable".
Is my understanding correct? If it is, I agree on that sentence.
The work to have removable bridges is massive and non-trivial, so it
will need to be tackled in steps. The grand plan [0] is:
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)
I am at step 1 right now. Removal during atomic updates is step 2,
ideas about how to implement that are already being discussed [1],
there's a practical plan proposed by Maxime with the goal of reaching
removable bridges without breaking things along the path.
[0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/
[1] https://lore.kernel.org/all/20250106-vigorous-talented-viper-fa49d9@houat/
> which means
> the main structures should have the same life time with the DRM bridges.
The word "lifetime" mean two things for bridges:
* the time span during which memory is allocated for a struct
drm_bridge (along with the embedding struct)
* the time span during which a DRM bridge is active/used/usable as
part of a card
- i.e. when it is part of an encoder chain
- i.e. when drm_bridge_funcs callbacks can be called
- i.e. from drm_bridge_add() to drm_bridge_remove()
These two lifetimes used to be nearly the same. Now the "memory
allocation lifetime" is extended, but the "bridge existence" is
unchanged: drm_bridge_add() to drm_bridge_remove() are called in the
same place and do the same things, so the bridge will stop being in any
encoder chain at the exact same time. now we are just keeping a piece of
memory allocated for a longer time.
Seen in another way, the events used to be:
* probe:
- allocate bridge
- drm_bridge_add()
* remove
- drm_bridge_remove()
- now the bridge is not used, it's just some dead memory [*]
- kfree bridge (either in .remove() or just after by devm)
Now it becomes:
* probe:
- allocate bridge
- drm_bridge_add()
* remove
- drm_bridge_remove()
- now the bridge is not used, it's just some dead memory [*]
- maybe some more time, possibly long, until the last put [*]
- kfree bridge (by devm)
The duration of the [*] steps changes, but it's harmless because the
bridge is not used at all. No change except for memory allocation.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-07 7:12 ` Luca Ceresoli
@ 2025-05-07 10:16 ` Liu Ying
2025-05-07 14:13 ` Luca Ceresoli
0 siblings, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-05-07 10:16 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 05/07/2025, Luca Ceresoli wrote:
> Hello Liu,
>
> On Wed, 7 May 2025 10:10:53 +0800
> Liu Ying <victor.liu@nxp.com> wrote:
>
>> On 05/07/2025, Luca Ceresoli wrote:
>>> Hello Liu,
>>
>> Hi Luca,
>>
>>>
>>> thanks for your further feedback.
>>>
>>> On Tue, 6 May 2025 10:24:18 +0800
>>> Liu Ying <victor.liu@nxp.com> wrote:
>>>
>>>> On 04/30/2025, Luca Ceresoli wrote:
>>>>> Hello Liu,
>>>>
>>>> Hi Luca,
>>>>
>>>>>
>>>>> On Tue, 29 Apr 2025 10:10:55 +0800
>>>>> Liu Ying <victor.liu@nxp.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> On 04/25/2025, Luca Ceresoli wrote:
>>>>>>> This is the new API for allocating DRM bridges.
>>>>>>>
>>>>>>> This driver embeds an array of channels in the main struct, and each
>>>>>>> channel embeds a drm_bridge. This prevents dynamic, refcount-based
>>>>>>> deallocation of the bridges.
>>>>>>>
>>>>>>> To make the new, dynamic bridge allocation possible:
>>>>>>>
>>>>>>> * change the array of channels into an array of channel pointers
>>>>>>> * allocate each channel using devm_drm_bridge_alloc()
>>>>>>> * adapt the code wherever using the channels
>>>>>>>
>>>>>>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>>>>>
>>>>> [...]
>>>>>
>>>>>>> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>>>>>>> free_child:
>>>>>>> of_node_put(child);
>>>>>>>
>>>>>>> - if (i == 1 && pc->ch[0].next_bridge)
>>>>>>> - drm_bridge_remove(&pc->ch[0].bridge);
>>>>>>> + if (i == 1 && pc->ch[0]->next_bridge)
>>>>>>
>>>>>> Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
>>>>>> pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
>>>>>> dereference here...
>>>>>
>>>>> See below for this.
>>>>>
>>>>>>> + drm_bridge_remove(&pc->ch[0]->bridge);
>>>>>>>
>>>>>>> pm_runtime_disable(dev);
>>>>>>> return ret;
>>>>>>> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
>>>>>>> int i;
>>>>>>>
>>>>>>> for (i = 0; i < 2; i++) {
>>>>>>> - ch = &pc->ch[i];
>>>>>>> + ch = pc->ch[i];
>>>>>>>
>>>>>>> if (!ch->is_available)
>>>>>>
>>>>>> ...and here too.
>>>>>
>>>>> This is indeed a bug, I should have checked the pointer for being
>>>>> non-NULL.
>>>>>
>>>>> Looking at that more closely, I think the is_available flag can be
>>>>> entirely removed now. The allocation itself (ch != NULL) now is
>>>>> equivalent. Do you think my reasoning is correct?
>>>>>
>>>>> Ouch! After writing the previous paragraph I realized you proposed this
>>>>> a few lines below! OK, removing is_available. :)
>>>>>
>>>>> [...]
>>>>>
>>>>>> On top of this patch series, this issue doesn't happen if I apply the below
>>>>>> change:
>>>>>
>>>>> [...]
>>>>>
>>>>>> @@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>>>>>> free_child:
>>>>>> of_node_put(child);
>>>>>>
>>>>>> - if (i == 1 && pc->ch[0]->next_bridge)
>>>>>> + if (i == 1 && pc->ch[0])
>>>>>> drm_bridge_remove(&pc->ch[0]->bridge);
>>>>>
>>>>> Unrelated to this patch, but as I looked at it more in depth now, I'm
>>>>> not sure this whole logic is robust, even in the original code.
>>>>>
>>>>> The 'i == 1' check here seems to mean "if some error happened when
>>>>> handling channel@1, that means channel@0 was successfully initialized,
>>>>> so let's clean up channel 0".
>>>>>
>>>>> However my understanding of the bindings is that device tree is allowed
>>>>> to have the channel@1 node before the channel@0 node (or even channel@1
>>>>> without channel@0, but that's less problematic here).
>>>>>
>>>>> In such case (channel@1 before channel@0), this would happen:
>>>>>
>>>>> 1. alloc and init ch[1], all OK
>>>>> 2. alloc and init ch[0], an error happens
>>>>> (e.g. of_graph_get_remote_node() fails)
>>>>>
>>>>> So we'd reach the free_child: label, and we should call
>>>>> drm_bridge_remove() for ch[1]->bridge, but there's no code to do that.
>>>>>
>>>>> To be robust in such a case, I think both channels need to be checked
>>>>> independently, as the status of one does not imply the status of the
>>>>> other. E.g.:
>>>>>
>>>>> for (i = 0; i < 2; i++)
>>>>> if (pc->ch[i] && pc->ch[i]->next_bridge)
>>>>> drm_bridge_remove(&pc->ch[i]->bridge);
>>>>>
>>>>> (which is similar to what .remove() does after the changes discussed in
>>>>> this thread, and which I have queued for v3)
>>>>>
>>>>> What's your opinion? Do you think I missed anything?
>>>>
>>>> The pixel combiner DT node would be added in imx8-ss-dc{0,1}.dtsi, please
>>>> see the case for imx8-ss-dc0.dtsi introduced by an in-flight patch[1]. As
>>>> channel@{0,1} child nodes always exist(DT overlay cannot effectively delete
>>>> any of them) and channel@0 always comes first, there is no problematic case.
>>>
>>> I'm not questioning what existing and future dts files (will) contain,
>>> and surely I don't see a good reason someone would write channel@1
>>> before channel@0.
>>>
>>> My point is:
>>>
>>> - the bindings _allow_ channel1 before channel@0
>>> - the error management code after the free_child label won't work
>>> correctly if channel1 is before channel@0 in the device tree
>>>
>>> IOW the driver is not robust against all legal device tree descriptions,
>>> and it could be easily made robust using the example code in my
>>> previous e-mail (quoted a few lines above).
>>>
>>> If you agree about this I'll be happy to send a patch doing that change.
>>> If you think I'm wrong, I won't fight a battle. This topic is
>>> orthogonal to the change I'm introducing in this patch, and I can
>>> continue the conversion independently from this discussion.
>>
>> I don't think it is necessary to do that change for now. When someone
>> really comes across this issue, we may make the error management code
>> robust.
>>
>>>
>>>>> Thanks for taking the time to dig into this!
>>>>
>>>> After looking into this patch and patch 31(though I've already provided my A-b)
>>>> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
>>>> should have the same life time with the embedded DRM bridges, because for
>>>> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
>>>> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
>>>> the life time for the embedded channel/bridge structures only, but not for the
>>>> main structures. What do you think ?
>>>
>>> I see you concern, but I'm sure the change I'm introducing is not
>>> creating the problem you are concerned about.
>>>
>>> The key aspect is that my patch is merely changing the lifetime of the
>>> _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
>>> the bridge is removed from its encoder chain and it is completely not
>>> reachable, both before and after my patch. With my patch it is not
>>> freed immediately, but it's just a piece of "wasted" memory that is
>>> still allocated until elsewhere in the kernel there are pointers to it,
>>> to avoid use-after-free.
>>>
>>> With this explanation, do you think my patch is correct (after fixing
>>> the bug we already discussed of course)?
>>
>> I tend to say your patch is not correct because we'll eventually make sure
>> that removing a bridge module is safe when doing atomic commit,
>
> I think your sentence can be rephrased as "your patch is correct with
> the current code base where bridges are not (yet) removable, but there
> will be a problem when they start to actually be removable".
>
> Is my understanding correct? If it is, I agree on that sentence.
Nope, I meant your patch should align the life times of the main structures
and the DRM bridges, for the sake of the kinda long term goal - remove bridge
driver module safely when doing atomic commit.
>
> The work to have removable bridges is massive and non-trivial, so it
> will need to be tackled in steps. The grand plan [0] is:
>
> 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)
I'm busy with internal things these days and cannot look into the grand
plan and steps closely, sorry about that.
>
> I am at step 1 right now. Removal during atomic updates is step 2,
> ideas about how to implement that are already being discussed [1],
> there's a practical plan proposed by Maxime with the goal of reaching
> removable bridges without breaking things along the path.
>
> [0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/
> [1] https://lore.kernel.org/all/20250106-vigorous-talented-viper-fa49d9@houat/
>
>> which means
>> the main structures should have the same life time with the DRM bridges.
>
> The word "lifetime" mean two things for bridges:
>
> * the time span during which memory is allocated for a struct
> drm_bridge (along with the embedding struct)
Note that with your patch set the imx8*-ldb drivers and this bridge driver
won't allocate the DRM bridge along with the embedding struct. This makes
me worry, because maybe these drivers are the only "special" ones in this
patch set and I don't want them to be "special" after your patch set is
applied.
> * the time span during which a DRM bridge is active/used/usable as
> part of a card
> - i.e. when it is part of an encoder chain
> - i.e. when drm_bridge_funcs callbacks can be called
> - i.e. from drm_bridge_add() to drm_bridge_remove()
>
> These two lifetimes used to be nearly the same. Now the "memory
> allocation lifetime" is extended, but the "bridge existence" is
> unchanged: drm_bridge_add() to drm_bridge_remove() are called in the
> same place and do the same things, so the bridge will stop being in any
> encoder chain at the exact same time. now we are just keeping a piece of
> memory allocated for a longer time.
>
> Seen in another way, the events used to be:
>
> * probe:
> - allocate bridge
> - drm_bridge_add()
>
> * remove
> - drm_bridge_remove()
> - now the bridge is not used, it's just some dead memory [*]
> - kfree bridge (either in .remove() or just after by devm)
>
> Now it becomes:
>
> * probe:
> - allocate bridge
> - drm_bridge_add()
>
> * remove
> - drm_bridge_remove()
> - now the bridge is not used, it's just some dead memory [*]
> - maybe some more time, possibly long, until the last put [*]
> - kfree bridge (by devm)
>
> The duration of the [*] steps changes, but it's harmless because the
> bridge is not used at all. No change except for memory allocation.
>
> Luca
>
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-07 10:16 ` Liu Ying
@ 2025-05-07 14:13 ` Luca Ceresoli
0 siblings, 0 replies; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-07 14:13 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hello Liu,
On Wed, 7 May 2025 18:16:28 +0800
Liu Ying <victor.liu@nxp.com> wrote:
[...]
> >>>> After looking into this patch and patch 31(though I've already provided my A-b)
> >>>> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
> >>>> should have the same life time with the embedded DRM bridges, because for
> >>>> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
> >>>> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
> >>>> the life time for the embedded channel/bridge structures only, but not for the
> >>>> main structures. What do you think ?
> >>>
> >>> I see you concern, but I'm sure the change I'm introducing is not
> >>> creating the problem you are concerned about.
> >>>
> >>> The key aspect is that my patch is merely changing the lifetime of the
> >>> _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> >>> the bridge is removed from its encoder chain and it is completely not
> >>> reachable, both before and after my patch. With my patch it is not
> >>> freed immediately, but it's just a piece of "wasted" memory that is
> >>> still allocated until elsewhere in the kernel there are pointers to it,
> >>> to avoid use-after-free.
> >>>
> >>> With this explanation, do you think my patch is correct (after fixing
> >>> the bug we already discussed of course)?
> >>
> >> I tend to say your patch is not correct because we'll eventually make sure
> >> that removing a bridge module is safe when doing atomic commit,
> >
> > I think your sentence can be rephrased as "your patch is correct with
> > the current code base where bridges are not (yet) removable, but there
> > will be a problem when they start to actually be removable".
> >
> > Is my understanding correct? If it is, I agree on that sentence.
>
> Nope, I meant your patch should align the life times of the main structures
> and the DRM bridges, for the sake of the kinda long term goal - remove bridge
> driver module safely when doing atomic commit.
Again, I don't think there is any bug introduced by this patch (once
the NULL ptr deref bug we already discussed is fixed). No bridge can be
removed as of now, with or without this patch.
You concern that this patch would make things more complex in the
future, when bridges will actually become removable and they could be
during atomic updates. But about this...
> > The work to have removable bridges is massive and non-trivial, so it
> > will need to be tackled in steps. The grand plan [0] is:
> >
> > 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)
>
> I'm busy with internal things these days and cannot look into the grand
> plan and steps closely, sorry about that.
...I'll wait until you have time to look into that more closely. There
is just no way to understand this whole topic without some dedicated
attention, which takes time unavoidably.
In the meanwhile I am going to send v3 soon with the known bug fixed,
so the best version is available to continue this discussion.
> > I am at step 1 right now. Removal during atomic updates is step 2,
> > ideas about how to implement that are already being discussed [1],
> > there's a practical plan proposed by Maxime with the goal of reaching
> > removable bridges without breaking things along the path.
> >
> > [0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/
> > [1] https://lore.kernel.org/all/20250106-vigorous-talented-viper-fa49d9@houat/
> >
> >> which means
> >> the main structures should have the same life time with the DRM bridges.
> >
> > The word "lifetime" mean two things for bridges:
> >
> > * the time span during which memory is allocated for a struct
> > drm_bridge (along with the embedding struct)
>
> Note that with your patch set the imx8*-ldb drivers and this bridge driver
> won't allocate the DRM bridge along with the embedding struct.
By "embedding struct" I mean the struct imx8qxp_pc_channel that embeds
the struct drm_bridge. Sorry, I realize my wording was ambiguous.
> This makes
> me worry, because maybe these drivers are the only "special" ones in this
> patch set and I don't want them to be "special" after your patch set is
> applied.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-06 20:47 ` Luca Ceresoli
2025-05-07 2:10 ` Liu Ying
@ 2025-05-22 3:01 ` Liu Ying
2025-05-26 7:20 ` Luca Ceresoli
1 sibling, 1 reply; 81+ messages in thread
From: Liu Ying @ 2025-05-22 3:01 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 05/07/2025, Luca Ceresoli wrote:
[...]
>> After looking into this patch and patch 31(though I've already provided my A-b)
>> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
>> should have the same life time with the embedded DRM bridges, because for
>> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
>> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
>> the life time for the embedded channel/bridge structures only, but not for the
>> main structures. What do you think ?
>
> I see you concern, but I'm sure the change I'm introducing is not
> creating the problem you are concerned about.
>
> The key aspect is that my patch is merely changing the lifetime of the
> _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> the bridge is removed from its encoder chain and it is completely not
> reachable, both before and after my patch. With my patch it is not
drm_bridge_remove() only removes a bridge from the global bridge_list defined
in drm_bridge.c. drm_bridge_detach() is the one which removes a bridge from
it's encoder chain. It looks like you wrongly thought drm_bridge_remove()
is drm_bridge_detach(). So, even if drm_bridge_remove() is called, the removed
bridge could still be in it's encoder chain, hence an atomic commit could still
access the allocated bridge(with lifetime extended) and the clock_apb clock
for example in struct imx8qxp_pc could also be accessed. That's why I think
the main structures should have the same lifetime with the allocated bridge.
> freed immediately, but it's just a piece of "wasted" memory that is
> still allocated until elsewhere in the kernel there are pointers to it,
> to avoid use-after-free.
>
> With this explanation, do you think my patch is correct (after fixing
> the bug we already discussed of course)?
>
> Best regards,
> Luca
>
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-22 3:01 ` Liu Ying
@ 2025-05-26 7:20 ` Luca Ceresoli
2025-05-27 1:42 ` Liu Ying
0 siblings, 1 reply; 81+ messages in thread
From: Luca Ceresoli @ 2025-05-26 7:20 UTC (permalink / raw)
To: Liu Ying
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
Hello Liu,
On Thu, 22 May 2025 11:01:13 +0800
Liu Ying <victor.liu@nxp.com> wrote:
> On 05/07/2025, Luca Ceresoli wrote:
>
> [...]
>
> >> After looking into this patch and patch 31(though I've already provided my A-b)
> >> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
> >> should have the same life time with the embedded DRM bridges, because for
> >> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
> >> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
> >> the life time for the embedded channel/bridge structures only, but not for the
> >> main structures. What do you think ?
> >
> > I see you concern, but I'm sure the change I'm introducing is not
> > creating the problem you are concerned about.
> >
> > The key aspect is that my patch is merely changing the lifetime of the
> > _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> > the bridge is removed from its encoder chain and it is completely not
> > reachable, both before and after my patch. With my patch it is not
>
> drm_bridge_remove() only removes a bridge from the global bridge_list defined
> in drm_bridge.c. drm_bridge_detach() is the one which removes a bridge from
> it's encoder chain. It looks like you wrongly thought drm_bridge_remove()
> is drm_bridge_detach().
Indeed my sentence was inaccurate, sorry about that.
> So, even if drm_bridge_remove() is called, the removed
> bridge could still be in it's encoder chain, hence an atomic commit could still
> access the allocated bridge(with lifetime extended) and the clock_apb clock
> for example in struct imx8qxp_pc could also be accessed. That's why I think
> the main structures should have the same lifetime with the allocated bridge.
As the long-term goal is to allow bridges to be hot-removable,
decoupling the lifetime of the various components is a necessary step.
Definitely it will open other issues, and especially the removal during
atomic updates. This has been discussed already, and there is a
proposed plan to handle it.
First, here is the grand plan (mentioned in the v3 cover letter):
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. finally, let bridges be removable (depends on 1+2+3)
We are now at step 1. Your concern, as I understand it, will be
addressed at step 2. Bridges won't be removable until step 4, so the
current changes are not introducing a misbehavior but rather preparing
the ground with all the necessary infrastructure changes.
Step 2 was discussed in the past [0], and the idea proposed by Maxime
is to introduce a "gone" or "unplugged" flag and drm_bridge_enter() /
drm_bridge_exit() functions. The principle is the same as struct
drm_device.unplugged and drm_dev_enter/exit().
In a nutshell the idea is:
- drm_bridge.unplugged is initialized to false
- drm_bridge_enter() returns false if drm_bridge.unplugged == true
- any code holding a pointer to the bridge (including the bridge driver
itself) and operating on the bridge (including removal) needs to do:
if (drm_bridge_enter()) {
do something;
drm_bridge_exit();
}
- when the bridge is removed, the driver removal function sets
dev_bridge.unplugged = true
The "do something" above includes any access to device resources,
including clocks (and clk_apb).
In other words, two pieces of code can not access the bridge structure
at the same time. This includes bridge removal VS any atomic operations.
Do you think this addresses your concern?
For you to have a better picture of the path, here's an additional
clarification about drm_bridge_attach/detach() and
drm_bridge_add/remove(). As part of step 1 of the grand plan, both of
them will drm_bridge_get/put() the bridge, so that no bridge is freed
if it is either in the global bridge_list or in any encoder chain.
Patches for this are already approved by Maxime [1][2]. They cannot be
applied until all bridge drivers have been converted to the new
devm_drm_bridge_alloc() API, so they depend on this series to be
completely applied. We are getting pretty close: as of now the entire
series has been applied except for this and another driver.
[0] https://lore.kernel.org/all/20250129125153.35d0487a@booty/t/#u
[1] https://patchwork.freedesktop.org/patch/643095/
[2] https://patchwork.freedesktop.org/patch/643096/
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 81+ messages in thread
* Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
2025-05-26 7:20 ` Luca Ceresoli
@ 2025-05-27 1:42 ` Liu Ying
0 siblings, 0 replies; 81+ messages in thread
From: Liu Ying @ 2025-05-27 1:42 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Jagan Teki,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Douglas Anderson, Chun-Kuang Hu, Krzysztof Kozlowski,
Anusha Srivatsa, Paul Kocialkowski, Dmitry Baryshkov, Hui Pu,
Thomas Petazzoni, dri-devel, asahi, linux-kernel, chrome-platform,
imx, linux-arm-kernel, linux-mediatek, linux-amlogic,
linux-renesas-soc, platform-driver-x86, linux-samsung-soc,
linux-arm-msm, freedreno, linux-stm32
On 05/26/2025, Luca Ceresoli wrote:
> Hello Liu,
Hi Luca,
>
> On Thu, 22 May 2025 11:01:13 +0800
> Liu Ying <victor.liu@nxp.com> wrote:
>
>> On 05/07/2025, Luca Ceresoli wrote:
>>
>> [...]
>>
>>>> After looking into this patch and patch 31(though I've already provided my A-b)
>>>> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
>>>> should have the same life time with the embedded DRM bridges, because for
>>>> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
>>>> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
>>>> the life time for the embedded channel/bridge structures only, but not for the
>>>> main structures. What do you think ?
>>>
>>> I see you concern, but I'm sure the change I'm introducing is not
>>> creating the problem you are concerned about.
>>>
>>> The key aspect is that my patch is merely changing the lifetime of the
>>> _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
>>> the bridge is removed from its encoder chain and it is completely not
>>> reachable, both before and after my patch. With my patch it is not
>>
>> drm_bridge_remove() only removes a bridge from the global bridge_list defined
>> in drm_bridge.c. drm_bridge_detach() is the one which removes a bridge from
>> it's encoder chain. It looks like you wrongly thought drm_bridge_remove()
>> is drm_bridge_detach().
>
> Indeed my sentence was inaccurate, sorry about that.
>
>> So, even if drm_bridge_remove() is called, the removed
>> bridge could still be in it's encoder chain, hence an atomic commit could still
>> access the allocated bridge(with lifetime extended) and the clock_apb clock
>> for example in struct imx8qxp_pc could also be accessed. That's why I think
>> the main structures should have the same lifetime with the allocated bridge.
>
> As the long-term goal is to allow bridges to be hot-removable,
> decoupling the lifetime of the various components is a necessary step.
> Definitely it will open other issues, and especially the removal during
> atomic updates. This has been discussed already, and there is a
> proposed plan to handle it.
>
> First, here is the grand plan (mentioned in the v3 cover letter):
>
> 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. finally, let bridges be removable (depends on 1+2+3)
>
> We are now at step 1. Your concern, as I understand it, will be
> addressed at step 2. Bridges won't be removable until step 4, so the
> current changes are not introducing a misbehavior but rather preparing
> the ground with all the necessary infrastructure changes.
>
> Step 2 was discussed in the past [0], and the idea proposed by Maxime
> is to introduce a "gone" or "unplugged" flag and drm_bridge_enter() /
> drm_bridge_exit() functions. The principle is the same as struct
> drm_device.unplugged and drm_dev_enter/exit().
>
> In a nutshell the idea is:
>
> - drm_bridge.unplugged is initialized to false
> - drm_bridge_enter() returns false if drm_bridge.unplugged == true
> - any code holding a pointer to the bridge (including the bridge driver
> itself) and operating on the bridge (including removal) needs to do:
> if (drm_bridge_enter()) {
> do something;
> drm_bridge_exit();
> }
> - when the bridge is removed, the driver removal function sets
> dev_bridge.unplugged = true
>
> The "do something" above includes any access to device resources,
> including clocks (and clk_apb).
>
> In other words, two pieces of code can not access the bridge structure
> at the same time. This includes bridge removal VS any atomic operations.
>
> Do you think this addresses your concern?
Yes, drm_bridge_{enter,exit} address it.
>
>
> For you to have a better picture of the path, here's an additional
> clarification about drm_bridge_attach/detach() and
> drm_bridge_add/remove(). As part of step 1 of the grand plan, both of
> them will drm_bridge_get/put() the bridge, so that no bridge is freed
> if it is either in the global bridge_list or in any encoder chain.
>
> Patches for this are already approved by Maxime [1][2]. They cannot be
> applied until all bridge drivers have been converted to the new
> devm_drm_bridge_alloc() API, so they depend on this series to be
> completely applied. We are getting pretty close: as of now the entire
> series has been applied except for this and another driver.
>
> [0] https://lore.kernel.org/all/20250129125153.35d0487a@booty/t/#u
> [1] https://patchwork.freedesktop.org/patch/643095/
> [2] https://patchwork.freedesktop.org/patch/643096/
>
> Best regards,
> Luca
>
--
Regards,
Liu Ying
^ permalink raw reply [flat|nested] 81+ messages in thread
end of thread, other threads:[~2025-05-27 1:40 UTC | newest]
Thread overview: 81+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 12:44 ` Andy Yan
2025-04-28 15:00 ` [PATCH " Luca Ceresoli
2025-04-28 20:59 ` Doug Anderson
2025-04-30 10:35 ` Luca Ceresoli
2025-04-30 15:51 ` Doug Anderson
2025-04-30 16:42 ` Luca Ceresoli
2025-04-29 2:19 ` Liu Ying
2025-04-29 7:07 ` Luca Ceresoli
2025-04-30 9:42 ` Manikandan.M
2025-04-30 10:36 ` Luca Ceresoli
2025-05-05 5:20 ` Manikandan.M
2025-04-24 18:59 ` [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
2025-04-28 12:29 ` Andy Yan
2025-04-24 18:59 ` [PATCH v2 04/34] drm/bridge: anx7625: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 06/34] drm/bridge: display-connector: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
2025-04-29 12:09 ` Dmitry Baryshkov
2025-04-24 18:59 ` [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 10/34] drm/bridge: sii902x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
2025-04-24 19:16 ` Cristian Ciocaltea
2025-04-24 18:59 ` [PATCH v2 12/34] drm/bridge: tda998x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2025-04-28 20:53 ` Doug Anderson
2025-04-24 18:59 ` [PATCH v2 14/34] drm/exynos: mic: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
2025-04-29 8:40 ` Linus Walleij
2025-04-24 18:59 ` [PATCH v2 16/34] drm/msm/dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 17/34] drm/msm/dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 18/34] drm/msm/hdmi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 19/34] drm/omap: dss: dpi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 20/34] drm/omap: dss: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 23/34] drm/omap: dss: sdi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 24/34] drm/omap: dss: venc: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 25/34] drm/rcar-du: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
2025-04-28 15:45 ` Dave Stevenson
2025-04-24 18:59 ` [PATCH v2 28/34] drm/sti: dvo: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 29/34] drm: zynqmp_dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-04-29 2:10 ` Liu Ying
2025-04-30 9:29 ` Luca Ceresoli
2025-05-06 2:24 ` Liu Ying
2025-05-06 20:47 ` Luca Ceresoli
2025-05-07 2:10 ` Liu Ying
2025-05-07 7:12 ` Luca Ceresoli
2025-05-07 10:16 ` Liu Ying
2025-05-07 14:13 ` Luca Ceresoli
2025-05-22 3:01 ` Liu Ying
2025-05-26 7:20 ` Luca Ceresoli
2025-05-27 1:42 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
2025-04-29 2:35 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 32/34] drm/bridge: tc358767: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 11:39 ` Maxime Ripard
2025-04-28 15:25 ` Luca Ceresoli
2025-05-05 6:23 ` Maxime Ripard
2025-05-05 15:20 ` Luca Ceresoli
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-28 15:42 ` Maxime Ripard
2025-04-28 16:33 ` Luca Ceresoli
2025-04-29 9:27 ` (subset) " Louis Chauvet
2025-04-29 12:41 ` Louis Chauvet
2025-04-30 8:08 ` Maxime Ripard
2025-05-05 11:06 ` Luca Ceresoli
2025-05-05 11:58 ` Dmitry Baryshkov
2025-05-05 12:31 ` Luca Ceresoli
2025-04-29 14:42 ` Dmitry Baryshkov
2025-04-30 8:21 ` Louis Chauvet
2025-04-30 10:39 ` Maxime Ripard
2025-04-30 15:30 ` Louis Chauvet
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).