From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 5D18D288C24 for ; Wed, 23 Jul 2025 09:54:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264479; cv=none; b=m+kpFOeSZUIGuotwLce2bZeH5G3MZBr9X5V52GkDRwNsSZPHjB49MZpG85+kx9hoGZukALb+psyaTsfN51aqPDxbqiTM+I90/GCzYJH89Gc9UJa69MkmWs1/fN2gkzfnXj19nLS+OOVVDDa25BC+9jHqjBSglJygLept58zF0dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264479; c=relaxed/simple; bh=TR6H9vhB/qFJMc8S7OFtQFjgbVhU9R6LQz2RKnpHAa4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A9I9JP3kc9HHVmCNB6V7Q7NFPMB3OPrxREuuWJJ0Snh1+u+zUnNKDVsHx4SkKuAdVYU8Lp1I/TpTTkkMlB0C72i3COAVGM2n8guppyUrfpUpgsin7rmJo5mpJm1p9+IWfMl0NuQL45DnA7CJZg1fHXWMIiz/Iz/kbusgF6ov5zU= 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=IGF0ZUkh; arc=none smtp.client-ip=217.70.183.201 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="IGF0ZUkh" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7A6C14336F; Wed, 23 Jul 2025 09:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+FAywltmFU9dB2pOTz2lEsEdD9YeBwzzMU9uV0qEppY=; b=IGF0ZUkhuWgd7hbMZFwfFNWAOiPI3e6zy/JvOhDXuT8YAWkCPdH2Zo23I/Akeuz40kfFW2 fmsaJ27ZwmTlrgw0gRUENOJA03VO57mDoFa4WjuvFt1rYssc9wzXuRGwlJJcdlGI8PqMQ0 i5UCaWdilSXugNAgkP+Qu8EWQG9qJx+aexCOPfcH+I4p+iRkaO+cOR1UTk2pktTzY1Heu5 QCvG8o7wSNltRk1mIgPQrwRgytu19hx7jElxfiRus73vI09D1xT7dFKmGVmi2rzXNTpIYG SOWs7NKxaRuDc3acS4lfXJ+uqD7cCDBE/OKtHa6N3JVIRDVYiFpu1hxOnKSCIg== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:08 +0200 Subject: [PATCH 1/9] drm/display: bridge-connector: use scope-specific variable for the bridge pointer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-1-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Currently drm_bridge_connector_init() reuses the 'bridge' variable, first as a loop variable in the long drm_for_each_bridge_in_chain() and then in the HDMI-specific code as a shortcut to bridge_connector->bridge_cec. We are about to remove the 'bridge' loop variable for drm_for_each_bridge_in_chain() by moving to a scoped version of the same macro, which implies removing the 'bridge' variable from the main function scope. Additionally reusing the variable can make such long function less readable. Similarly to what commit 6f727c838ea8 ("drm/bridge-connector: Fix bridge in drm_connector_hdmi_audio_init()") already did for the audio HDMI bridge, use n local variable inside the scopes where it is needed as a bridge_connector->bridge_hdmi_cec shortcut to make its scope clearer as well as to allow removing the 'bridge' variable in an upcoming commit. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/display/drm_bridge_connector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/d= rm/display/drm_bridge_connector.c index 8c915427d0538435661d771940efe38b462027a1..3ddde53b28131c3ce026413eb55= 18e9c8ed08b4d 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -816,7 +816,7 @@ struct drm_connector *drm_bridge_connector_init(struct = drm_device *drm, =20 if (bridge_connector->bridge_hdmi_cec && bridge_connector->bridge_hdmi_cec->ops & DRM_BRIDGE_OP_HDMI_CEC_NOTIF= IER) { - bridge =3D bridge_connector->bridge_hdmi_cec; + struct drm_bridge *bridge =3D bridge_connector->bridge_hdmi_cec; =20 ret =3D drmm_connector_hdmi_cec_notifier_register(connector, NULL, @@ -827,7 +827,7 @@ struct drm_connector *drm_bridge_connector_init(struct = drm_device *drm, =20 if (bridge_connector->bridge_hdmi_cec && bridge_connector->bridge_hdmi_cec->ops & DRM_BRIDGE_OP_HDMI_CEC_ADAPT= ER) { - bridge =3D bridge_connector->bridge_hdmi_cec; + struct drm_bridge *bridge =3D bridge_connector->bridge_hdmi_cec; =20 ret =3D drmm_connector_hdmi_cec_register(connector, &drm_bridge_connector_hdmi_cec_funcs, --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 3898B289E20 for ; Wed, 23 Jul 2025 09:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264480; cv=none; b=c+JEmllwwFMvNi1Xe/HTlrJWkDxP7tjtCOPrUKVN6b0/mqhamrTawQogqJaMOL45PtqContNeV05ntbnoeupynO/dUUGOcZSBhZi00r4dmyDalY06y5aeVr0oJuX6oWdGh3P5B6uNySE4LKRzb14IzrO5ABr4TPzSjITosTR9ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264480; c=relaxed/simple; bh=QrKmFwnxZUfgVW3kf0DiW1oEWtF8/1WgSf5c7JcutRU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S/F9neJqM0ZoNDop5b1L4mWDKIfJXguxsQ63M+TmPivcHQhPI8akJx93+zEYjSE+i0zNMrM0ZdY6iDynv6vfI+tWedXg/5VOqM76XMp8VM+O9U+qt1mDWir7JVE2bHHGhg9E9fFEFKGvxiTWTJG7HRweJV1GWfop6K1yjmCJ9is= 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=KOVZsnJp; arc=none smtp.client-ip=217.70.183.201 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="KOVZsnJp" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5A4F543380; Wed, 23 Jul 2025 09:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FkqNLf+MZPnU+iEy6rEgnrZLpt29tm167Wloxfy3lcw=; b=KOVZsnJpxKXTg6U3tWkvloTo06IfqokSELtGVbtrbEzNPuJ99stjn0fNirPCO70bsjLnuV mhtcWzDdKkEvvbA5oC0aC1lMwHH4smxyorfZ7qRfWT6IpDghzHErYTjh83QZHnalCh1Ine 51IPl9r5d4HRtU8V7Dl+hIT4RrEIdIllD0WQYpbLL2MmaQtaCsVJ1vbhtta/wM3A+EoEiN 1Cvh4UFlYU3csZFhYhCgb//Cgoc7fxYRF8dIJZBeTjn5po2d1DG2X5SzEm/3gglhK8Y2Mu o5dt4MXlkwtYUevsxZhhNEnXyyGoWvNMfD7iVOEoUnETBUkKH3E8nD5kL32FlQ== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:09 +0200 Subject: [PATCH 2/9] drm/display: bridge-connector: remove unused variable assignment Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-2-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com The 'bridge' pointer started being assigned and used within this 'if' scope in commit 0beba3f9d366 ("drm/bridge: connector: add support for HDMI codec framework"). After that, commit 5d04b4188959 ("drm/bridge: split HDMI Audio from DRM_BRIDGE_OP_HDMI") removed the code dereferencing it from the same 'if' scope, but did not remove the assignment. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/display/drm_bridge_connector.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/d= rm/display/drm_bridge_connector.c index 3ddde53b28131c3ce026413eb5518e9c8ed08b4d..65d54019e5eab323ecd3dc56854= 1ed1e1793a683 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -772,8 +772,6 @@ struct drm_connector *drm_bridge_connector_init(struct = drm_device *drm, if (!connector->ycbcr_420_allowed) supported_formats &=3D ~BIT(HDMI_COLORSPACE_YUV420); =20 - bridge =3D bridge_connector->bridge_hdmi; - ret =3D drmm_connector_hdmi_init(drm, connector, bridge_connector->bridge_hdmi->vendor, bridge_connector->bridge_hdmi->product, --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 6F37328A73C for ; Wed, 23 Jul 2025 09:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264482; cv=none; b=nZjIkxnHesTp55vo3PQYwCSUuK2aYRy0/eMBfIABAucYpYz43VrMM8YKOic7kRivUYmch6UJkVQx81TTe0VilPyjKGyGddN9bar6jEvm2QdnBWf7FUPFusyb9+wZPVwtuFuhOWLazpDRDlTfCTbksw/Ywq9f9AwSW2DgjA6vsj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264482; c=relaxed/simple; bh=TCwCIwOwbWhbbDPYROKZRf33jwFfhp0mOqznmCqm3Og=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DIUTDfSM6SeWHVs872V2VJtI071FzE15IrsPxGATAysSY9CamSx6wq2w6VvnwbdTZLhHwI3uXVNCvYRy9yei+qf6H0muuqCBrNOWkmNja7wHc4oiGQG2vm3d9m2x1p8J2PDSB8SxUVv6Ank9MEuDOtXKOBPaumdehty0/YXG74w= 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=m7XMOkwo; arc=none smtp.client-ip=217.70.183.201 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="m7XMOkwo" Received: by mail.gandi.net (Postfix) with ESMTPSA id 2995043383; Wed, 23 Jul 2025 09:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jgckLiMksu9NnI+G7de0Tf4Zyv3AuB7uM1WmnD7AIR8=; b=m7XMOkwoMvAIY87rt0wpG2TyTg46a2ZpVK/x0b2uwlezL35OUxXUNxLlpqmKLno/GRNh2A b+JpzKD8q/8VDvjJtQQoWwrTbSdyK40Je4ysoiwtC7qg3iYVMZs2F2j1FPVsWPhOC39+Ka jpDp++b19o9990TSytJaEGFP8nuZQndY1WGkoA5g481YAX/wvffBqDqeBdC8zkEu9zzfml PD/A4B1ymz7lfB1muexdWiPABVtPefnaukY0k1QBB0D/42+EViQ0AQMrqg4b19e9ci3PgE 2c9hcJ07kl9yAi9WFLu50jVuawgwOUkX1QTmOvriCbJ3RZtlqiq4SaM06883Zg== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:10 +0200 Subject: [PATCH 3/9] drm/bridge: add drm_for_each_bridge_in_chain_scoped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-3-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Add variant of drm_for_each_bridge_in_chain() that gets/puts the bridge reference at the beginning/end of each iteration, and puts it if breaking ot of the loop. Note that this requires adding a new drm_bridge_get_next_bridge_and_put() function because, unlike similar functions as __of_get_next_child(), drm_bridge_get_next_bridge() gets the "next" pointer but does not put the "prev" pointer, and some of its users rely on this. Also deprecate drm_for_each_bridge_in_chain(), in preparation for removing it after converting all users to the scoped version. Signed-off-by: Luca Ceresoli --- Note 1: drm_for_each_bridge_in_chain_scoped() could be renamed removing the _scoped suffix after removing all the users of the current macro and eventually the current macro itself. Even though this series is converting all users, I'd at least wait one kernel release before renaming, to minimize issues with existing patches which would fail building. Note 2: Yes, the drm_bridge_get_next_bridge_and_put() name is ugly, but we do need a "next_bridge" function that does not put the "prev" bridge and one that does. Any proposal for a better name or a different implementation is welcome. --- .clang-format | 1 + include/drm/drm_bridge.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/.clang-format b/.clang-format index 48405c54ef271e9546da08893d200a4cf48f3a55..1cac7d4976644c8f083f801e98f= 619782c2e23cc 100644 --- a/.clang-format +++ b/.clang-format @@ -168,6 +168,7 @@ ForEachMacros: - 'drm_exec_for_each_locked_object' - 'drm_exec_for_each_locked_object_reverse' - 'drm_for_each_bridge_in_chain' + - 'drm_for_each_bridge_in_chain_scoped' - 'drm_for_each_connector_iter' - 'drm_for_each_crtc' - 'drm_for_each_crtc_reverse' diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 717171d0e58725ed854209c3355260e415b4c5d7..990ef98011c96619b269787ebe0= 1a2ad3b225c42 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1358,10 +1358,51 @@ drm_bridge_chain_get_first_bridge(struct drm_encode= r *encoder) * iteration * * Iterate over all bridges present in the bridge chain attached to @encod= er. + * + * This is deprecated, do not use! + * New drivers shall use drm_for_each_bridge_in_chain_scoped(). */ #define drm_for_each_bridge_in_chain(encoder, bridge) \ list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node) =20 +/** + * drm_bridge_get_next_bridge_and_put - Get the next bridge in the chain + * and put the previous + * @bridge: bridge object + * + * Same as drm_bridge_get_next_bridge() but additionally puts the @bridge. + * + * RETURNS: + * the next bridge in the chain after @bridge, or NULL if @bridge is the l= ast. + */ +static inline struct drm_bridge * +drm_bridge_get_next_bridge_and_put(struct drm_bridge *bridge) +{ + struct drm_bridge *next =3D drm_bridge_get_next_bridge(bridge); + + drm_bridge_put(bridge); + + return next; +} + +/** + * drm_for_each_bridge_in_chain_scoped - iterate over all bridges attached + * to an encoder + * @encoder: the encoder to iterate bridges on + * @bridge: a bridge pointer updated to point to the current bridge at each + * iteration + * + * Iterate over all bridges present in the bridge chain attached to @encod= er. + * + * Automatically gets/puts the bridge reference while iterating, and puts + * the reference even if returning or breaking in the middle of the loop. + */ +#define drm_for_each_bridge_in_chain_scoped(encoder, bridge) \ + for (struct drm_bridge *bridge __free(drm_bridge_put) =3D \ + drm_bridge_chain_get_first_bridge(encoder); \ + bridge; \ + bridge =3D drm_bridge_get_next_bridge_and_put(bridge)) + enum drm_mode_status drm_bridge_chain_mode_valid(struct drm_bridge *bridge, const struct drm_display_info *info, --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 6937428C032 for ; Wed, 23 Jul 2025 09:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264483; cv=none; b=Df/SpzogK2415SNfR8ccxh7ZJg5Bkto5vdOqI68bxTj8VMPLm3g2W74784SslIV0CiFYMU7gYbjEZjqMYyQ13oziQMqbNQ9dsIzZJSg9EGwRvtYPq9uPTbcIImEJPRjCTbtU3FZ18JrlA/wNBcIaobtyecUJPPpG1Zu2QMOgZ1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264483; c=relaxed/simple; bh=WEZ1ziloDnil/PqVBzMdnscQ31QVasKHXHwFrfZCqrQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T8hOSV1vs6aavg5uSIPOrUn4EJrLLVj1wrtDPdwlN4Udd6hM0KPbMK2dhvoNc6JENL8WMxs6XzcbDzbmxS7Mg/iOTFDbBwcx/vqY8IUvUYCUx+pk5IS/2GjD7thXk5GTwXsyV6+LgSwtf6LJ+niGd4K2XKi/V/mqg8p8OWkDcEo= 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=STVKOQhV; arc=none smtp.client-ip=217.70.183.201 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="STVKOQhV" Received: by mail.gandi.net (Postfix) with ESMTPSA id 063DB4338F; Wed, 23 Jul 2025 09:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MxTILuKlEXX8gx2CBbWGOC/3dK9iaEP97mQFbZ3GY8E=; b=STVKOQhVOMG6rzeA6Qgy2yPJmjDt1Gi4j6K9c8+BK5GOGxtezb9RTY5iOhH7m+PGF7Cl0s rLMLGYJ8jS9Aouje09ci20AY4UjKj3M/O69ZsSa/qpNtwJmUxC5+G+CIbGx29/7INh533J Oiai9nhnFHDP2OSksKu+0TrS0fxbdLVLXzFV+pnndNnYFZoURdMkFpXa2hEh8On1mU01mn mgysB1qhn+FZur5Ys3eOJfgV8+u8CKYg1JN/yIrQJDkY5E3Yc2cLi2X1VVrqkKOzVcNoXV nybAIHj0zK/n6RVpNP+VLMEKhHqaIT1LzPr8YZL/3lrwifkiIjaGnC2ULud9gA== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:11 +0200 Subject: [PATCH 4/9] drm/display: bridge-connector: use drm_for_each_bridge_in_chain_scoped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-4-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Use drm_for_each_bridge_in_chain_scoped() instead of drm_for_each_bridge_in_chain() to ensure the bridge being looped on is refcounted. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/display/drm_bridge_connector.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/d= rm/display/drm_bridge_connector.c index 65d54019e5eab323ecd3dc568541ed1e1793a683..760ee00b6b02192dc1e59c213ef= 043a6bb9e3b60 100644 --- a/drivers/gpu/drm/display/drm_bridge_connector.c +++ b/drivers/gpu/drm/display/drm_bridge_connector.c @@ -136,10 +136,9 @@ static void drm_bridge_connector_hpd_notify(struct drm= _connector *connector, { struct drm_bridge_connector *bridge_connector =3D to_drm_bridge_connector(connector); - struct drm_bridge *bridge; =20 /* Notify all bridges in the pipeline of hotplug events. */ - drm_for_each_bridge_in_chain(bridge_connector->encoder, bridge) { + drm_for_each_bridge_in_chain_scoped(bridge_connector->encoder, bridge) { if (bridge->funcs->hpd_notify) bridge->funcs->hpd_notify(bridge, status); } @@ -638,7 +637,7 @@ struct drm_connector *drm_bridge_connector_init(struct = drm_device *drm, struct drm_bridge_connector *bridge_connector; struct drm_connector *connector; struct i2c_adapter *ddc =3D NULL; - struct drm_bridge *bridge, *panel_bridge =3D NULL; + struct drm_bridge *panel_bridge =3D NULL; unsigned int supported_formats =3D BIT(HDMI_COLORSPACE_RGB); unsigned int max_bpc =3D 8; int connector_type; @@ -665,7 +664,7 @@ struct drm_connector *drm_bridge_connector_init(struct = drm_device *drm, * detection are available, we don't support hotplug detection at all. */ connector_type =3D DRM_MODE_CONNECTOR_Unknown; - drm_for_each_bridge_in_chain(encoder, bridge) { + drm_for_each_bridge_in_chain_scoped(encoder, bridge) { if (!bridge->interlace_allowed) connector->interlace_allowed =3D false; if (!bridge->ycbcr_420_allowed) --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 1B2F328C5B0 for ; Wed, 23 Jul 2025 09:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264484; cv=none; b=JQGFKYGJ7xD8SQUCwh+2ws1M1lDo0eKzyMb20ZgMSwRCfqiTuv08sQCXnU3gLGXK71ihD5ZNXqgmRSZQlh0nyqM6yvBCcrnPxO5Kp6wmcSXbu84savvqh7mHq7nu+ZvXKfVnMoOl8g91RO5Hugjv9w/xbRciqmRln93wr1vLy44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264484; c=relaxed/simple; bh=H5Xb1Om8mdF5RIZgOAHxxetoF+yntH0NeJzyLF1TBI0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q2EEW4d9DWJgQgV0J4rtkuSC9KzGg4gCv3sCZb5bcuoDWKyJkRPNuSJMHUTnE+5rbaKnW8Xabnry7xvr4A60w8aWt2Iu5FxYFD3wgyU3xtuDP9MHqYIFXJ9F1ecLP1WvmDnynEqJlAufwk5CUn0HSylN9g7IJTR9ivuxPH2mY3A= 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=GUvROV94; arc=none smtp.client-ip=217.70.183.201 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="GUvROV94" Received: by mail.gandi.net (Postfix) with ESMTPSA id D485F43384; Wed, 23 Jul 2025 09:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x5FboEgCdGJLmxZMiB0i2htDNO12smggut39uay0DPM=; b=GUvROV94pozBFc65v/DzF4t3HhV21w50rtBPVJanFBjKKN1dIoPWuvLLhmJoR8800y6elU ikjU93kkSRYfrcjpmKjk5xcH1sPuUrAu6+I1x+sTLAHMyyugKOdC43yN5dDe4MxW04e3Ze BCuPuKevq2Gmx/XukEu4CL8jZKWcXpQ8k88lcX0/omtnD6Q8zt4zR1Cyo1qZX+luY6BN5e gEmBg7DyH2aC/Wr1PwnCzWUbMU2JI8yD+PSPnsHVDz5EwUHZ5FeWDebKAfu8XVqtMFr0X1 rm33tO/jHnIHF6Ran0l7PQXVyRXsA8pwpz60MnAwPELPoBXUawp6JUOZuYVt1g== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:12 +0200 Subject: [PATCH 5/9] drm/atomic: use drm_for_each_bridge_in_chain_scoped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-5-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Use drm_for_each_bridge_in_chain_scoped() instead of drm_for_each_bridge_in_chain() to ensure the bridge being looped on is refcounted. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index cd15cf52f0c9144711da5879da57884674aea9e4..ed5359a71f7e2cd8fa52b993e62= ee65f8fed4537 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1308,7 +1308,6 @@ drm_atomic_add_encoder_bridges(struct drm_atomic_stat= e *state, struct drm_encoder *encoder) { struct drm_bridge_state *bridge_state; - struct drm_bridge *bridge; =20 if (!encoder) return 0; @@ -1317,7 +1316,7 @@ drm_atomic_add_encoder_bridges(struct drm_atomic_stat= e *state, "Adding all bridges for [encoder:%d:%s] to %p\n", encoder->base.id, encoder->name, state); =20 - drm_for_each_bridge_in_chain(encoder, bridge) { + drm_for_each_bridge_in_chain_scoped(encoder, bridge) { /* Skip bridges that don't implement the atomic state hooks. */ if (!bridge->funcs->atomic_duplicate_state) continue; --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 254C928CF5F for ; Wed, 23 Jul 2025 09:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264486; cv=none; b=aQoxx2ciPfO8w7ntShF1t1kxCiV6oYFl7HiFn6mCROvp9Y9WSTBj2so62y9TNHLP+z5mJmQp/xLbAY7zw8HN9T8ul6kMUSZxh4dufSa0XxKr2QjGf2IhCH8LA20oRGk4QgFRihrhw2FHjeXbM7TLYN/W2aN/EMHSSOEcv/sGxTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264486; c=relaxed/simple; bh=KdL5F45RTYdR4aFMOKBN1ImXHkFgg5qgGsxKYa0B2RE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZYf/jo4SZgr7oXBBlyw0zbK76QzwFBkM0ZzcKbx+nY65bQKC2EfNWqlKrNEZQbLthitLxHpRsL+uTLJw1aJqERjqE0RHTCKbbm/yFKPatGzN7S7cIDi4skdMvTZq7htV4AxESHsYmVZ9fwOlvFQNEXMCDzIwgB4j4aum07HfYMI= 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=a5ysdtpe; arc=none smtp.client-ip=217.70.183.201 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="a5ysdtpe" Received: by mail.gandi.net (Postfix) with ESMTPSA id B33CF43369; Wed, 23 Jul 2025 09:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dJo7ghMiIZotvVeKxTetMQIxPpCfLLJg57qJECz1Vds=; b=a5ysdtpeS+HG2AVt6jZqBt309XUOj8ZAa6QCYmAtns/8X4z/7dpngFg6Qou4ApGmP4RDHq dKN7MK5wnKiss9QXGrMg0kIVnK8TsG/JnGeS/NOITXldLxv4T9b4NlaX9w3l9PlR13W/kA +27HoCHPz0osuJHnzO0oMmGZojrHtMMD70oF7SdRX3MGJfrX7m8lrfANi1vyxijc788403 HSpETqx08cwOq3lj28R7QS4ksrnwm9az7pYQTvIdoyh1iPoEU6V4ol1bw8/gCNwYmx+Ror YlsnHa7L6fTQiIOuMjFGJxs5Ri9JvIQJzj0N03xe6oOYhXw7InzM2GTCs6DFSg== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:13 +0200 Subject: [PATCH 6/9] drm/bridge: use drm_for_each_bridge_in_chain_scoped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-6-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Use drm_for_each_bridge_in_chain_scoped() instead of drm_for_each_bridge_in_chain() to ensure the bridge being looped on is refcounted. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_bridge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index dd45d9b504d8f2802f4ee93e4b4d893d8535abea..297e8cde585c685e5105f8e6060= ae7c2371dea00 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1476,10 +1476,9 @@ static int encoder_bridges_show(struct seq_file *m, = void *data) { struct drm_encoder *encoder =3D m->private; struct drm_printer p =3D drm_seq_file_printer(m); - struct drm_bridge *bridge; unsigned int idx =3D 0; =20 - drm_for_each_bridge_in_chain(encoder, bridge) + drm_for_each_bridge_in_chain_scoped(encoder, bridge) drm_bridge_debugfs_show_bridge(&p, bridge, idx++); =20 return 0; --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 D36CC28CF47 for ; Wed, 23 Jul 2025 09:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264488; cv=none; b=PYlqs+BZQasQI7QNVnN8/9TSkU9fMRhAZKx4NiLSFzR5/1cL4m+7LeEkqRfnJTi1IJq1wruH+Mf/PeibqyNnKzLgvu22bZPHVHow1TbdjgBwUt8R6+R9jQLxDM4H13OSYTeZd7s/NybJWfE9IMxIY6+cuQLQM70OqcQbr9XHf10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264488; c=relaxed/simple; bh=mRYS39zNc769MPF6cqrwELZCDV9+yoOTGAq/3MYHuTs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MYW6P1+prjtfncJys72xLP2ym55yjZ4cf6MtYbbSFZFv6NhqbkCkARW6Ih2vLFDc9ZmOEMZUwKyUxz2D9A3wvT0Mdoca3NJAUP4c1XtJ7Jf1AOb3Oc8VhF/ryydGEGjxD0OZQAfyZh8qoS4m7lniZbxufTm5m/SBdmw+ypFMojc= 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=NyO0e86L; arc=none smtp.client-ip=217.70.183.201 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="NyO0e86L" Received: by mail.gandi.net (Postfix) with ESMTPSA id A75CB43383; Wed, 23 Jul 2025 09:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A1aT9UvQsypJ5FnvT7oFv2tdykMxUGRvv4TCDw3cO58=; b=NyO0e86L5Ew9FQ+ZDvPWICbl2ZELRq6JoavXwU3d8ghvpUnCGDP6t7o9f+z5p7Rg0dcnjA SV9eRA6ghquPknMnGniCLiapzOYVHG/kC4LJ6DI056nK+S2LkbgMETG5TFsVrP1uDG+QJw Qj4uXKK83ubRf//72U5nlbCCXJkjnwKn96sdm5T83gkqYI1+vuPKLrL1z+2TBpvGKal094 4gU7D+wyWGqemkxLCAGul9JwPxq2J8cOeqIEQb6clUta60vWYIQWMeDDYFeEKwmpW4b/nU V0boCTBoor2r1tANrcwg+3QavKSzCdDZa0uCISkxoaQIzNDJ7xZhSo/HsWmS+Q== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:14 +0200 Subject: [PATCH 7/9] drm/bridge: remove drm_for_each_bridge_in_chain() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-7-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com All users have been replaced by drm_for_each_bridge_in_chain_scoped(). Signed-off-by: Luca Ceresoli --- .clang-format | 1 - include/drm/drm_bridge.h | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/.clang-format b/.clang-format index 1cac7d4976644c8f083f801e98f619782c2e23cc..d5c05db1a0d96476b711b95912d= 2b82b2e780397 100644 --- a/.clang-format +++ b/.clang-format @@ -167,7 +167,6 @@ ForEachMacros: - 'drm_connector_for_each_possible_encoder' - 'drm_exec_for_each_locked_object' - 'drm_exec_for_each_locked_object_reverse' - - 'drm_for_each_bridge_in_chain' - 'drm_for_each_bridge_in_chain_scoped' - 'drm_for_each_connector_iter' - 'drm_for_each_crtc' diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 990ef98011c96619b269787ebe01a2ad3b225c42..0a45ed862ca3293bd0b12dacf3b= a2c5429800d00 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1351,20 +1351,6 @@ drm_bridge_chain_get_first_bridge(struct drm_encoder= *encoder) struct drm_bridge, chain_node)); } =20 -/** - * drm_for_each_bridge_in_chain() - Iterate over all bridges present in a = chain - * @encoder: the encoder to iterate bridges on - * @bridge: a bridge pointer updated to point to the current bridge at each - * iteration - * - * Iterate over all bridges present in the bridge chain attached to @encod= er. - * - * This is deprecated, do not use! - * New drivers shall use drm_for_each_bridge_in_chain_scoped(). - */ -#define drm_for_each_bridge_in_chain(encoder, bridge) \ - list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node) - /** * drm_bridge_get_next_bridge_and_put - Get the next bridge in the chain * and put the previous --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 F1CFA28EA63 for ; Wed, 23 Jul 2025 09:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264490; cv=none; b=YKu9NVatR6Imf/B18zoyXmbUXP+9TrsRZgZ1PWKGIoRL1Piqe7DsBG4o3k4ZgN9PX8jK7+apxt//yGqGdQmtdTA2+R1o47S5+Z2vovJIO3+doE76jUok2pq5fejw4Or8DUOqCjqyUK8QwxDk4DyWMvnGuIHRv87+g3s1FE4fvJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264490; c=relaxed/simple; bh=2u0Xa/5z3nT/cVfrjAAYmiRuGWKJH1Clu1iCocmDh/Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ksRh7HDZ2fQURO3za0dmNdmp0kb7lOUqjXDTJGRPNGmzU8mjMMtiTj2yit/faCxhXXb2heH3o51CqYqJp4a1XVwup27jdrngVpDsuckV4EDI5ZYwKzWfD1/GgXDkO+B515TyDV0volZejQu1mw+oi/N+YpCbwldsZkGrcQPwb9w= 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=OLhpIzVJ; arc=none smtp.client-ip=217.70.183.201 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="OLhpIzVJ" Received: by mail.gandi.net (Postfix) with ESMTPSA id 907CE43380; Wed, 23 Jul 2025 09:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LClR2cqFUi4SSBqHoy3glnoRo4IOBUbQ/Lmg6Lq1GSw=; b=OLhpIzVJ/xQEkvq8Y4qqJMyGWRRs2eUI6C6y1oYJWUCvTdglTzTXWDMwrmvcYjwav1oez4 t6gWn3sa6oxHlQ+hXVAFrxkOvFTSe2e9rioOJ8NTEFI3f9bLHrgV6Ddg+cT3GxTipIuMKw w+5xwiFtYjEsO38uW7Jlqy2LejJYubvOnD9dEwWJ6Bs7vSJf3bbPbaLQu6d9vmc3EZgH6E vtkmMGTJU1duRrepRXtSXE8ZbARBOvJu8aGxMnepUBOO5DcHh3pvQV622zM9cXRccmt6h0 36th97sI3g4qr7zdGv0f9ix5wgdHenuhwD3ozEXZJFe+ETnTjqN2DKbQClrliw== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:15 +0200 Subject: [PATCH 8/9] drm/bridge: add drm_for_each_bridge_in_chain_from() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-8-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepjeenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Add variant of drm_for_each_bridge_in_chain_scoped() that iterates on the encoder bridge from a given bridge until the end of the chain. Signed-off-by: Luca Ceresoli --- include/drm/drm_bridge.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 0a45ed862ca3293bd0b12dacf3ba2c5429800d00..b271e1204c002f8dba080448583= d75612f22a366 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1389,6 +1389,25 @@ drm_bridge_get_next_bridge_and_put(struct drm_bridge= *bridge) bridge; \ bridge =3D drm_bridge_get_next_bridge_and_put(bridge)) =20 +/** + * drm_for_each_bridge_in_chain_from - iterate over all bridges starting + * from the given bridge + * @first_bridge: the bridge to start from + * @bridge: a bridge pointer updated to point to the current bridge at each + * iteration + * + * Iterate over all bridges in the encoder chain starting from + * @first_bridge, included. + * + * Automatically gets/puts the bridge reference while iterating, and puts + * the reference even if returning or breaking in the middle of the loop. + */ +#define drm_for_each_bridge_in_chain_from(first_bridge, bridge) \ + for (struct drm_bridge *bridge __free(drm_bridge_put) =3D \ + drm_bridge_get(first_bridge); \ + bridge; \ + bridge =3D drm_bridge_get_next_bridge_and_put(bridge)) + enum drm_mode_status drm_bridge_chain_mode_valid(struct drm_bridge *bridge, const struct drm_display_info *info, --=20 2.50.1 From nobody Mon Oct 6 08:23:12 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 DAA8428FA9F for ; Wed, 23 Jul 2025 09:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264492; cv=none; b=HrKwwi725PAEuLYMC0+KodQy931KIxuDdD7I0MOnuehFlp6n1sHfSCmo2YyIufP7+gOSj8PyoYw4iM7MF5+cGRX7q6pMq2r043Rcazhonsl/6U890jMuLn799G2hAXkSPksHojxpJ4Yl7n8VD3JpnnuQQMloG9DuzJu9mmDH9e8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753264492; c=relaxed/simple; bh=vzTXPFiaCfHK9nSqz15wssha4YOhs9UOcmrHp2JSAW4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gzvHIjhqyYWvi4AQf1DzYzHM5d2cjWANgzbdtFzzOSz6foqVEMswyfMLz6VsLupsX5c20gVFszYsqLuYG719oJdctW5mdca5QHvsfDFh1RMu/DDd9sTs4i6y5+tIa5x1OXNfgslyboe9JIYFcRuDNSWR+JRTllo2N+/TxME/ZDY= 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=JQbyvmB1; arc=none smtp.client-ip=217.70.183.201 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="JQbyvmB1" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8DCD043369; Wed, 23 Jul 2025 09:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1753264489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gYn1Rc8HkKQf4J/p8AgwWmzwMMTkHWwwAtY/ky/WmUs=; b=JQbyvmB1aLyN9i2RF7H+oQSaywgNLxA3xNYGN+/W5qpP+0pVporzDEyOHZwI7Tt5r5tMeD cBp0e40cBIoxXOUUTe1qG+JlHyPfAQDKoWnMW7FJt1V/Ax5z64vDk9/EckK0is4Zeu6JUG 5Ac52EwwlpYTvfYawwKDD26vnE76yzK7VSIy5F0bvcgIDrG3awkD4oPsDq8ti19pNQWCqe w0HOZCQKlazbsm4EiL5I7kPHlgOudaRyWgQQjSTxphJFQstK9B3GDNC+7m7t6LC1jTAXVB F48xgJBCIjMcZk8bjT5QIfvHpiFmEl7W4kj6fR+ufiqpDoycJP23PWUPD+lkZg== From: Luca Ceresoli Date: Wed, 23 Jul 2025 11:54:16 +0200 Subject: [PATCH 9/9] drm/omap: use drm_for_each_bridge_in_chain_from() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-9-be8f4ae006e9@bootlin.com> References: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> In-Reply-To: <20250723-drm-bridge-alloc-getput-for_each_bridge-v1-0-be8f4ae006e9@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Tomi Valkeinen Cc: Dmitry Baryshkov , Chaoyi Chen , Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemsggvgedumeelhegvjeemfeegfeemledufegvnecuvehluhhsthgvrhfuihiivgepjeenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumegsvgegudemleehvgejmeefgeefmeeludefvgdphhgvlhhopegludelvddrudeikedrudejkedrjeehngdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvhedprhgtphhtthhopehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepmhhrihhprghrugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthiiihhmmhgvrhhmrghnnhesshhushgvrdguvgdprhgtphhtthhopehth hhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepnhhitghkrdguvghsrghulhhnihgvrhhsodhlkhhmlhesghhmrghilhdrtghomhdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrfhhoshhssehkvghrnhgvlhdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com Use drm_for_each_bridge_in_chain_from _scoped() instead of an open-coded loop based on drm_bridge_get_next_bridge() to ensure the bridge being looped on is refcounted and simplify the driver code. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/omapdrm/omap_encoder.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapd= rm/omap_encoder.c index 4dd05bc732daebcedbfcbbc9ba7dffee7415bdfc..195715b162e38ea0cd0870f3dd7= 9342a8cbf218b 100644 --- a/drivers/gpu/drm/omapdrm/omap_encoder.c +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c @@ -77,7 +77,6 @@ static void omap_encoder_mode_set(struct drm_encoder *enc= oder, struct omap_dss_device *output =3D omap_encoder->output; struct drm_device *dev =3D encoder->dev; struct drm_connector *connector; - struct drm_bridge *bridge; struct videomode vm =3D { 0 }; u32 bus_flags; =20 @@ -97,8 +96,7 @@ static void omap_encoder_mode_set(struct drm_encoder *enc= oder, * * A better solution is to use DRM's bus-flags through the whole driver. */ - for (bridge =3D output->bridge; bridge; - bridge =3D drm_bridge_get_next_bridge(bridge)) { + drm_for_each_bridge_in_chain_from(output->bridge, bridge) { if (!bridge->timings) continue; =20 --=20 2.50.1