From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 764CA2BDC3F for ; Fri, 28 Nov 2025 16:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764348723; cv=none; b=NPuyvkTrX/EQmHbRNdJERgPDG3GB46T6uXWtPot1SHAxaKhaeLOxsIm5SGGPg4NQhmsgYaaz3PtUM4uPc3+srT54/yXY+7TDXS1RNQ+NcGSsYXl4gH+XbK+BsPZgHuIDK8PYXo5yZNMdR9kE49Z4OR9REXigP/M9ad37bMqjheE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764348723; c=relaxed/simple; bh=lbq7/9hM4h0tP9G0otpE2sQlBcOtnUST2OFtBTbJm3o=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=R4QbQjwTVPJkllF32mYTDw6Cb5u8ree5ML4AVDLHqIQu6zWGtQnxoMnwpRV9nQfhsE2fSqtrTt+/07d1GqJha6Xui7qg0u1znW9v5pL8AtqIyx2jUkt8QehxaNG9xxZH8j3YBqtu3JuoteveKRQrlOv3s65xLseuFa7DjqxzLvw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=VUX78Sy4; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VUX78Sy4" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id BEC4B1A1E09; Fri, 28 Nov 2025 16:51:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 83CD460706; Fri, 28 Nov 2025 16:51:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3B46510B02155; Fri, 28 Nov 2025 17:51:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764348710; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding; bh=4LXnxBJlqd2UazTmBhwXwFStb/3+5cf3TPNAlsU5TvA=; b=VUX78Sy4XiyC9MPlVpttqJ9SQIQnLJGEto9dm/Wz9ym7T7bN/CgnVlY9YH1bFcC0CgzUQe cZofZ4OEZUrrcGm7JEzsnL/etiRVBFwZzGGetbM0bgfGQ8fhKl1CmChVPekpLxS7jOlSK/ B1kea5ki5mVy1By5DwWomHJRAzf/5aB3po6F7XpWKHUzRNA/KlBEfcw2dr1S/BoUKwTmTY jTevGUZnNFJkK/0JxyFshBgnAEB0h6+hbX3C2stg8aS1MNDCf/acKsU6YDTC4b6Xv/aXH9 y6s8LhEMqH9Ez7UYbhzo3zb3DijYvmvDN8X+0amDd5uaA6wuXX7uEGzIbnqiwg== From: Luca Ceresoli Subject: [PATCH v2 00/26] drm/bridge: add drm_of_find_bridge(), deprecate of_drm_find_bridge() Date: Fri, 28 Nov 2025 17:50:10 +0100 Message-Id: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@bootlin.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAMLSKWkC/5WNQQ6DIBQFr2JYlwaQFu2q92iMUQH9ifINUNPGe PeiaQ/Q5cxL3qwkGA8mkFu2Em8WCIAugThlpBsa1xsKOjERTFw454pqP9HWg05LM47Y0d7E+Rl 3X6OtLThdf3clS5bnVyVloUk6nL2x8DpijyrxACGifx/the/2lyn/ySycMsp0WxaNskYqeW8R4 wju3OFEqm3bPvDOx3LmAAAA X-Change-ID: 20251117-drm-bridge-alloc-getput-drm_of_find_bridge-74903367448d To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jonathan Corbet , Alexey Brodkin , Phong LE , Liu Ying , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Adrien Grassein , Laurent Pinchart , Tomi Valkeinen , Kieran Bingham , Geert Uytterhoeven , Magnus Damm , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Anitha Chrisanthus , Inki Dae , Seung-Woo Kim , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar Cc: Hui Pu , Thomas Petazzoni , Louis Chauvet , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 This series deprecated of_drm_find_bridge(), adds a replacement which handles bridge refcounting, and converts most of the direct users. This is part of the work to support hotplug of DRM bridges. The grand plan was discussed in [0]. Here's the work breakdown (➜ marks the current series): 1. ➜ add refcounting to DRM bridges struct drm_bridge, based on devm_drm_bridge_alloc() A. ✔ add new alloc API and refcounting (v6.16) B. ✔ convert all bridge drivers to new API (v6.17) C. ✔ kunit tests (v6.17) D. ✔ add get/put to drm_bridge_add/remove() + attach/detach() and warn on old allocation pattern (v6.17) E. ➜ add get/put on drm_bridge accessors 1. ✔ drm_bridge_chain_get_first_bridge(), add cleanup action (v6.18) 2. ✔ drm_bridge_get_prev_bridge() (v6.18) 3. ✔ drm_bridge_get_next_bridge() (v6.19) 4. ✔ drm_for_each_bridge_in_chain() (v6.19) 5. ✔ drm_bridge_connector_init (v6.19) 6. … protect encoder bridge chain with a mutex 7. ➜ of_drm_find_bridge() a. ➜ add of_drm_get_bridge(), convert most direct users b. convert other direct users c. convert bridge-only drm_of_find_panel_or_bridge() users 8. drm_of_find_panel_or_bridge, *_of_get_bridge 9. ✔ enforce drm_bridge_add before drm_bridge_attach (v6.19) F. ✔ debugfs improvements 1. ✔ add top-level 'bridges' file (v6.16) 2. ✔ show refcount and list lingering bridges (v6.19) 2. … handle gracefully atomic updates during bridge removal A. … Add drm_dev_enter/exit() to protect device resources B. … protect private_obj removal from list 3. … DSI host-device driver interaction 4. ✔ removing the need for the "always-disconnected" connector 5. finish the hotplug bridge work, moving code to the core and potentially removing the hotplug-bridge itself (this needs to be clarified as points 1-3 are developed) [0] https://lore.kernel.org/lkml/20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com/#t Almost all the functions returning a struct drm_bridge pointer have been modified to drm_bridge_get() the returned bridge, and their users updated to drm_bridge_put() it. See items 1.E.{1-6} above. of_drm_find_bridge() could be modified easily in the same way, but it has a lot of (direct + indirect) callers, and most notably drm_of_find_panel_or_bridge() which is very hard to adapt without reowrking the panel_bridge lifetime. This has been discussed in [1] and Maxime proposed an incremental approach: > So maybe we can just create drm_of_find_bridge() that takes a reference, > make of_drm_find_bridge() deprecated in favour of drm_of_find_bridge(), > add a TODO, and call it a day. People will gradually switch to the new > API over time. That proposal is implemented by this series. Most of the direct callers are also converted: they are all trivial conversions except for one, which is handled by the last 3 patches. Follow-up series will: - convert remaining direct callers of of_drm_find_bridge() - convert simple cases of drm_of_find_panel_or_bridge() [1] https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/ Signed-off-by: Luca Ceresoli --- Changes in v2: - All patches: renamed drm_of_find_bridge() -> of_drm_get_bridge() - Various fixes and improvements to patches 1-6, see individual patches changelog - Removed bouncing recipient: Edmund Dea - Link to v1: https://lore.kernel.org/r/20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-0-0db98a7fe474@bootlin.com --- Luca Ceresoli (26): drm/bridge: add of_drm_get_bridge() drm/bridge: deprecate of_drm_find_bridge() drm/todo: add entry about converting to of_drm_get_bridge() drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_get_bridge() drm/arcpgu: convert to of_drm_get_bridge() drm/bridge: add devm_of_drm_get_bridge drm/bridge: ite-it66121: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: imx8qxp-pixel-combiner: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: simple-bridge: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: tpd12s015: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: thc63lvd1024: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: imx8qxp-pxl2dpi: use devm_of_drm_get_bridge() to put the next and companion bridges drm/bridge: lt8912b: use devm_of_drm_get_bridge() to put the hdmi bridge drm/bridge: tfp410: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: imx8qxp-ldb: use devm_of_drm_get_bridge() to put the companion bridge drm/rcar-du: lvds: use devm_of_drm_get_bridge() to put the next bridge drm/meson: encoder_*: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: sii902x: use devm_of_drm_get_bridge() to put the next bridge drm/mediatek: use devm_of_drm_get_bridge() to put the next bridge drm/kmb: dsi: use devm_of_drm_get_bridge() to put the next bridge drm/imx/ipuv3: use devm_of_drm_get_bridge() to put the next bridge drm/exynos: hdmi: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: dw-hdmi: use devm_of_drm_get_bridge() to put the next bridge drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node drm/bridge: imx8qxp-pixel-link: convert to of_drm_get_bridge() Documentation/gpu/todo.rst | 16 ++++ drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 2 +- .../gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 2 +- drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 37 +++++---- drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c | 4 +- drivers/gpu/drm/bridge/ite-it66121.c | 2 +- drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +- drivers/gpu/drm/bridge/sii902x.c | 2 +- drivers/gpu/drm/bridge/simple-bridge.c | 2 +- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +- drivers/gpu/drm/bridge/thc63lvd1024.c | 2 +- drivers/gpu/drm/bridge/ti-tfp410.c | 2 +- drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +- drivers/gpu/drm/drm_bridge.c | 91 ++++++++++++++++++---- drivers/gpu/drm/exynos/exynos_hdmi.c | 2 +- drivers/gpu/drm/imx/ipuv3/dw_hdmi-imx.c | 2 +- drivers/gpu/drm/kmb/kmb_dsi.c | 2 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 2 +- drivers/gpu/drm/meson/meson_encoder_dsi.c | 2 +- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 +- drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c | 2 +- drivers/gpu/drm/tiny/arcpgu.c | 4 +- include/drm/drm_bridge.h | 10 +++ 24 files changed, 143 insertions(+), 55 deletions(-) --- base-commit: e85e9ccf3f8404007f62dff9a02273fcdeb44206 change-id: 20251117-drm-bridge-alloc-getput-drm_of_find_bridge-74903367448d Best regards, -- Luca Ceresoli