From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 3B6CA30EF63; Mon, 15 Dec 2025 14:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765807907; cv=none; b=CNWaIlR57KOwmRBwaOIwAvKaFQQ+vRl0rFa9/g65Vo9zTAkbTSkd9fB6YRlrSQOWxhlc0/br4q/UxgmCHd9Kq/rH+370g291q7qEzLrqaxFWsk4LG4GBEN0I8s4cgwtyCw6WxDqY6ql7DRWciM5/wegYSWga3RZ53Vlk/+3yQh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765807907; c=relaxed/simple; bh=XfDxYmwnEjW3rgj/i9Csrk1WngYTaAh6I7dKqVAN3fw=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=kzm6u7j/yz40gnG1vFsGt6QjJk0dPjl/Pj47nPzDIlBgtNhVI8TrvQ5wtYSxDUXhxaHUimj4UcFkSimi95UF1Uv7WG4ItuztsQ0iK6DO8e1K64tcjPB2w8+/FA/5dYSV8+4pcEQD89STSPaoC0RbolwskgOQG6T5iEbPSmonjX4= 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=OECsWx7F; arc=none smtp.client-ip=185.246.85.4 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="OECsWx7F" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5750E4E41C0A; 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== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 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 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 exclusi= ve): >> > >> > 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 unplugg= ed, >> > 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_bridg= e is >> > not even needed in that case, the pointer would be computed from OF wh= en >> > 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 nee= d >> 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