From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11EDCD5B16E for ; Mon, 15 Dec 2025 14:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:From:To:Cc: Subject:Message-Id:Date:Mime-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=85f/Ol0eP8Cbl7ttEus6LElW9E9HPYimdXgFLAAwuL4=; b=maDbNe217EvbAz KkfqhjZTvf8l+tciUJU88/Ld1E/G0KsAR4PoYapEo3xi4L2CXHKHnHO/9U35aqXPwptw4tmogr0Q5 ksiPuLQlxS4ABOV96oA7GXvD6mo4FlZ/pJ580yIx5CQVgFzoBB+BmkkP6l2hZRZyPa4bli1k7QRwE ms0zwzU35HwZzEuEhcTIeTAgNI7eQtfSOGIlJWg2h6guDZRVYftOjCnQsU/DDweo5vofb5eNB4Zei DaS0SYCgZRRocTPbsYlTkVxJ8saxhj6P8AFcKUd4s+4ynjn3oXadafgPSkht+QZP4lSuboifu3dUw hIqvn0eA3Wr8E2Vow2/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vV9Ig-00000003ktO-3roO; Mon, 15 Dec 2025 14:11:46 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vV9Id-00000003kqI-2fsW; Mon, 15 Dec 2025 14:11:45 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 5646E1A21DB; Mon, 15 Dec 2025 14:11:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 239FE60664; Mon, 15 Dec 2025 14:11:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 29A8E119422E6; Mon, 15 Dec 2025 15:11:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1765807895; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=GaZqoyrRFDKWBlOXglMrXMF3qjcnoMmJDluDUgIWSsM=; b=OECsWx7FHMnHsTiEWe95R0X/rhnlkHzsoat62TNpnal1UtUfmgJoK+UlcEImBZgrSUQtgX Bi9L17rvGG0VuUJzYZe3q3F4eFbnSJmWkhqJI367VXOnYnd0WY8N3Ax4UR1sXRBMm9Qkps dmoQYyFlkhiuBEQ/S81gcoBkIcia9w+KtvGl3ip4onRDdQzp5jTshjZfm+I+AmpNCYWSTa JPygNzOrYXSqmHWUHMdEJdUk+ny/dxFJWUJkRFOEt8n48AdXIeerW9K8zEwP8oFZn/s1nU aM+k80qaA7tqbrbCCFJmzHEp2J1aHWwdvkr7gPEk7XG54Ovqe2ESMRR92HxtdA== Mime-Version: 1.0 Date: Mon, 15 Dec 2025 15:11:21 +0100 Message-Id: Subject: Re: [PATCH 06/26] drm/bridge: add devm_drm_of_find_bridge Cc: "Andrzej Hajda" , "Neil Armstrong" , "Robert Foss" , "Laurent Pinchart" , "Jonas Karlman" , "Jernej Skrabec" , "Maarten Lankhorst" , "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" , "Edmund Dea" , "Inki Dae" , "Seung-Woo Kim" , "Kyungmin Park" , "Krzysztof Kozlowski" , "Alim Akhtar" , "Hui Pu" , "Thomas Petazzoni" , , , , , , , , , To: "Maxime Ripard" From: "Luca Ceresoli" X-Mailer: aerc 0.20.1 References: <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-0-0db98a7fe474@bootlin.com> <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-6-0db98a7fe474@bootlin.com> <20251201-thick-jasmine-oarfish-1eceb0@houat> <20251215-mottled-dexterous-marmot-c69ad3@penduick> In-Reply-To: <20251215-mottled-dexterous-marmot-c69ad3@penduick> X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251215_061143_936220_32336D4E X-CRM114-Status: GOOD ( 22.37 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Hi Maxime, On Mon Dec 15, 2025 at 11:35 AM CET, Maxime Ripard wrote: [...] >> > Additionally, as a matter of fact there are currently drivers storing >> > bridge pointers. The next_bridge is the most common case. Code using >> > drm_bridge_connector_init() for example can store up to eight of them, but >> > individual drivers are the hardest to hunt for. >> > >> > I can see these (potential) tools to handle this (not mutually exclusive): >> > >> > 1. remove drm_bridge pointers pointing to other bridges >> > 2. check whether a bridge (say B) still exists before any dereference >> > to B->another_bridge: that's drm_bridge_enter/exit() >> > 3. let owners of bridge pointers be notified when a bridge is unplugged, >> > so they can actively put their reference and clear their pointer >> > >> > For item 1, I think the drm_of_bridge_attach() idea quoted above would >> > work, at least for the simple cases where bridge drivers use the >> > next_bridge only for attach. A next_bridge pointer in struct drm_bridge is >> > not even needed in that case, the pointer would be computed from OF when >> > needed and not stored. I can do an experiment and send a first series, do >> > you think it would be useful? >> >> I had a look and, while the implementation should be simple, only a few >> drivers could benefit right now. The majority fall into one of these >> categories: >> >> * drivers using drm_of_find_panel_or_bridge() or *_of_get_bridge() >> (maybe 60-80% of all drivers, those will have to wait for the panel >> improvements) >> * drivers using the next_bridge pointer for more than just attach >> * drivers doing more complicated stuff >> >> I think your "put next_bridge in __drm_bridge_free" idea would fit well the >> 2nd category and perhaps also the 1st one. For the 3rd category we'd need >> something different, e.g. a per-driver .destroy callback. > > Yep, that's fine. We should optimize for the common case, with an escape > hatch. That's exactly what we are talking about here. Not sure why, but it's taking a while before I grasp your ideas about this series and meld them with mine. I hopefully got a clear POV now, so based on it my plan is to rework this series to: * keep drm_of_find_bridge() but renamed to of_drm_get_bridge(), and keep patches 1-5 (with the changes suggested by you and Louis, nothing big and all already sent in v2) * not add devm_drm_of_find_bridge() * add next_bridge pointer to struct drm_bridge and call drm_bridge_put(bridge->next_bridge) in __drm_bridge_free, document it * convert patches 7-26 to use bridge->next_bridge where applicable, or to do something different when needed * maybe remove part of patches 7-26 just to reduce spam and rework effort in case of further iterations, to send them separately once the approach is accepted Does it look OK? Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic