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 E3A9A314B69; Mon, 24 Nov 2025 16:23:51 +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=1764001435; cv=none; b=g0tJXcCZnNVOb08RBE+f1q809dT0qxWJEa3k9Auxj+mzxbfmL+sDbIb7OiG09rcsPUduohW7WeGa6Yrg8nvb4TPgo3+sRMx0GA98Okb6waja9i4bdR2W2+xXrONFrJzOpBiuL4RTpgEmvsIjTOj4P8DVjUv62gOCqnb7vQtbBro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764001435; c=relaxed/simple; bh=5iAbDOgOR8ZMbTQTdCUF7iLVrRq1qzVBnjvSfBkCQjY=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=plrvtXspv7r5E4dBOV42qoeJ5fLo0NfDisTrxhtuNTFNdXIJZ7IZXG46RHKnTMYFbC/RnGeqcuQj/Q3+FNC7Lkv+GmwlJ6nBRmc0l5QWcrmJr3KVjs3TMqmEAsJrJuzoWoQmGhyyFsYyvqqUIwThLpJd3tKTpC93ilRKVPnTBXc= 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=BmmKrDVR; 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="BmmKrDVR" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 35C964E418A0; Mon, 24 Nov 2025 16:23:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 02ACB606FC; Mon, 24 Nov 2025 16:23:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2AF0A10371D9A; Mon, 24 Nov 2025 17:23:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764001428; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=4dwXgW7awt8oQD3TrOxHo6im6bS23ABW/5Js6C/RUYk=; b=BmmKrDVRXr5Ui32ulufganjLHxAsQu1h7GaA9GD/T26zZxsOmgBvpSlEsWb4eI9jBIrq8K HJRZgRJik54F0xx2TU/v0tHCfxRpZNOWhhVFU0fh/tctuiBkGe6xW5AKIFV56AzOFeR0D+ KkRUZ/Hf/eBL0NxbHwdjqgI5BzLofOXiNiZX41H7n5Pc/c2ktwFubkq0zA6WKyHxr/g7w0 Fj3SFW1KfFRHkOtqPrRz8zKkw4Y3NTKrSm8YCJtPSGvkDc4QPbzddQG3GvEd0nqVdi7Tba eeHfeMNGKEukwL0NNBiTyeDeUH5H5ptJ2JmJJI7XgEcDg4bqaXb0zUbE3FpsZg== Precedence: bulk X-Mailing-List: linux-doc@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, 24 Nov 2025 17:23:34 +0100 Message-Id: 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" , "Louis Chauvet" From: "Luca Ceresoli" Subject: Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge() 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-2-0db98a7fe474@bootlin.com> <66cdbe39-d065-4aa4-86e4-84a38b49c09c@bootlin.com> In-Reply-To: X-Last-TLS-Session-Version: TLSv1.3 Hi Maxime, On Mon Nov 24, 2025 at 11:18 AM CET, Maxime Ripard wrote: > On Wed, Nov 19, 2025 at 02:28:41PM +0000, Louis Chauvet wrote: >> On 11/19/25 13:05, Luca Ceresoli wrote: >> > of_drm_find_bridge() does not increment the returned bridge >> > refcount. drm_of_find_bridge() is to be used as a replacement. >> > >> > Suggested-by: Maxime Ripard >> > Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose= -0a18ad@houat/ >> > Signed-off-by: Luca Ceresoli >> > --- >> > drivers/gpu/drm/drm_bridge.c | 7 +++++-- >> > 1 file changed, 5 insertions(+), 2 deletions(-) >> > >> > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge= .c >> > index d98a7b4a83c0..6debbf20aaa8 100644 >> > --- a/drivers/gpu/drm/drm_bridge.c >> > +++ b/drivers/gpu/drm/drm_bridge.c >> > @@ -299,7 +299,7 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc); >> > * @bridge: bridge control structure >> > * >> > * Add the given bridge to the global list of bridges, where they ca= n be >> > - * found by users via of_drm_find_bridge(). >> > + * found by users via drm_of_find_bridge(). >> > * >> > * The bridge to be added must have been allocated by >> > * devm_drm_bridge_alloc(). >> > @@ -360,7 +360,7 @@ EXPORT_SYMBOL(devm_drm_bridge_add); >> > * @bridge: bridge control structure >> > * >> > * Remove the given bridge from the global list of registered bridge= s, so >> > - * it won't be found by users via of_drm_find_bridge(), and add it to= the >> > + * it won't be found by users via drm_of_find_bridge(), and add it to= the >> > * lingering bridge list, to keep track of it until its allocated me= mory is >> > * eventually freed. >> > */ >> > @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge); >> > * >> > * @np: device node >> > * >> > + * This function is deprecated. Use drm_of_find_bridge() instead for = proper >> > + * refcounting. >> > + * >> >> I think it should be more explicit that the refcounting is not done by t= his >> function, like: >> >> This function is deprecated. The returned bridge is not refcounted, you >> should not use drm_bridge_put(). Use drm_of_find_bridge() instead for pr= oper >> refcounting. > > I'd rather say that the callers must take care of the refcounting by > themselves but that it's racy, or at least that it *must* not use > drm_bridge_put(). I was rather leaning towards "Deprecated. Convert to drm_of_get_bridge().". But if we want to still support existing (lazy) users, with yours and Louis' comments taken into account, what about: * This function is deprecated. Convert to of_drm_get_bridge() instead for * proper refcounting. * * The bridge returned by this function is not refcounted. This is * dangerous because the bridge might be deallocated even before the caller * has a chance to use it. To use this function you have to do one of: * - get a reference with drm_bridge_get() as soon as possible to * minimize the race window, and then drm_bridge_put() when no longer * using the pointer * - not call drm_bridge_get() or drm_bridge_put() at all, which used to * be the correct practice before dynamic bridge lifetime was introduced * - again, convert to of_drm_get_bridge(), which is the only safe thing * to do Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com