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 0E5651DDC2B for ; Wed, 18 Mar 2026 16:53:20 +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=1773852803; cv=none; b=hCtIwqtuydTfrrz2BroGHXWFzS8W32GNwu1fHzMbPVFxhlvXwbyqgEh1byP/BupeQ9Gu+IypoXX/PW9r80MrxMu74d8GGX+cRKHGvaEkbf6aGJyAtjnk/wGNjS7t8rM/63tTcSlmh6xD+WMJQL002hmdI3iACEpwkFxVd1xkuyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852803; c=relaxed/simple; bh=QB7asd5yne/ZDHleXh7tw2aGOGvdw7upoCqJaRQfnOI=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=T44K122B4HoRN2LlgmPqKAdI9Y/ixnjSUwkQicc4cd6HsFn9gaKXPl558g19/bMf4doV5MGb7aXEORcPOo+Pt05U/SaGqdAbGhVD0WGlWqfd30Mkn+K+DMnZB5cNYMb8ZS5d6LOy+tX8F/xcB+7QieWpDAouAyzps2eyRmF8CpA= 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=LbzlFJ8X; 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="LbzlFJ8X" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 4C6471A2EAF; Wed, 18 Mar 2026 16:43:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0E5DF60050; Wed, 18 Mar 2026 16:43:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7B44910450554; Wed, 18 Mar 2026 17:43:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1773852237; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=kFyWujQcWcLidxUL7ayZ4mliS2DvOdnHo4P290V1PlY=; b=LbzlFJ8Xhnh2KuQsoQmi3aaoY9HXy6iACQFSPY0M7LdYUGJdmCQCLv10Eoi200HO7NDuEY xzvatxldLpDNQqXbNB9BlLecEr07ff3KgqTauporTxAamodTt3BOqIliu6vjlhjIVrn7Mc bhUcQkUPHW+6e/DjVuzEMZo6NvOpF7d1C9AsSEHOzQPH0GhQuf6S89s4cGqlup+xawyfyP bE4EmbOUnKq94MeWYtcRYCSEADmF+SVbCqGw4kJkacRo+C2a2gP/Xv/Vum3su4qr0haFVU wBdp8yIzVMTfDs46XCAmFLqirw7dSyn+tdvYX9z+wpcSwYZKvN6yrOf/s3IkQg== 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: Wed, 18 Mar 2026 17:43:50 +0100 Message-Id: Cc: "Biju Das" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Anitha Chrisanthus" , "Linus Walleij" , "Tomi Valkeinen" , "Kieran Bingham" , "Geert Uytterhoeven" , "Magnus Damm" , "Tomi Valkeinen" , "Hui Pu" , "Ian Ray" , "Thomas Petazzoni" , , , To: "Laurent Pinchart" From: "Luca Ceresoli" Subject: Re: [PATCH v3 3/4] drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge() X-Mailer: aerc 0.20.1 References: <20260318-drm-bridge-alloc-getput-drm_of_find_bridge-4-v3-0-10f502520357@bootlin.com> <20260318-drm-bridge-alloc-getput-drm_of_find_bridge-4-v3-3-10f502520357@bootlin.com> <20260318152533.GA633439@killaraus.ideasonboard.com> In-Reply-To: <20260318152533.GA633439@killaraus.ideasonboard.com> X-Last-TLS-Session-Version: TLSv1.3 Hi Laurent, On Wed Mar 18, 2026 at 4:25 PM CET, Laurent Pinchart wrote: > Hi Luca, > > Thank you for the patch. > > On Wed, Mar 18, 2026 at 10:39:37AM +0100, Luca Ceresoli wrote: >> of_drm_find_bridge() is deprecated. Move to its replacement >> of_drm_find_and_get_bridge() which gets a bridge reference, and ensure i= t >> is put when done. >> >> We need to handle the two cases: when a panel_bridge is added and when i= t >> isn't. So: >> >> * in the 'else' case a panel_bridge is not added and bridge is found: u= se >> of_drm_find_and_get_bridge() to get a reference to the found bridge >> * in the 'then' case a panel_bridge is found using a devm function whic= h >> already takes a refcount and will put it on removal, but we need to t= ake >> another so the following code in this function always get exactly one >> reference that it needs to put >> >> In order to put the reference, add the needed drm_bridge_put() calls in = the >> existing cleanup function. >> >> Signed-off-by: Luca Ceresoli >> --- >> drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 28 ++++++++++++++++= ++----- >> drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 + >> drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++ >> 3 files changed, 25 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c b/drivers= /gpu/drm/renesas/rcar-du/rcar_du_encoder.c >> index 7ecec7b04a8d..5789fc75092f 100644 >> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c >> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c >> @@ -51,7 +51,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, >> { >> struct rcar_du_encoder *renc; >> struct drm_connector *connector; >> - struct drm_bridge *bridge; >> + struct drm_bridge *bridge __free(drm_bridge_put) =3D NULL; >> int ret; >> >> /* >> @@ -69,20 +69,26 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu= , >> >> bridge =3D devm_drm_panel_bridge_add_typed(rcdu->dev, panel, >> DRM_MODE_CONNECTOR_DPI); >> - if (IS_ERR(bridge)) >> - return PTR_ERR(bridge); >> + if (IS_ERR(bridge)) { >> + // Inhibit the cleanup action on an ERR_PTR > > C-style comments. OK > Shouldn't drm_bridge_put() be extended to be a no-op when called on an > ERR_PTR ? Uhm, maybe, even though I think I haven't encountered many cases like this where this was troublesome, and all those I can remember are related to panel_bridge functions that are meant to be reworked. Also, drm_bridge_put() deliberately mimicks of_node_put() which also checks for NULL but not for IS_ERR. Maxime, your opinion about Laurent's suggestion? >> + ret =3D PTR_ERR(bridge); >> + bridge =3D NULL; >> + return ret; >> + } >> + > > A comment here would be good. > > /* > * The reference taken by devm_drm_panel_bridge_add_typed() is > * released automatically. Take a second one for the __free() > * when this function will return. > */ Sure, makes sense. I'll add one to other patches of this series where relevant. > >> + drm_bridge_get(bridge); >> } else { >> - bridge =3D of_drm_find_bridge(enc_node); >> + bridge =3D of_drm_find_and_get_bridge(enc_node); >> if (!bridge) >> return -EPROBE_DEFER; >> >> if (output =3D=3D RCAR_DU_OUTPUT_LVDS0 || >> output =3D=3D RCAR_DU_OUTPUT_LVDS1) >> - rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =3D bridge; >> + rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =3D drm_bridge_get(bridge)= ; > > Line wrap. I wish the 80-VS-100 policy were clear and valid for all the kernel. But no big deal here, and you maintain this driver, so I'll split. > I have tested the patch and it seems to behave fine. thanks for reviewing and testing! Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com