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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 C6CBFC8303C for ; Tue, 8 Jul 2025 14:19:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 387E010E19D; Tue, 8 Jul 2025 14:19:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="J9fSSb3Q"; dkim-atps=neutral Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F81910E19D for ; Tue, 8 Jul 2025 14:19:42 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id EC76644453; Tue, 8 Jul 2025 14:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1751984380; 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=VQx2MpPN2IuQhmgbUCoyo6ebaQZj/+m92+qxRxm2694=; b=J9fSSb3QQDqpDLGXw7eGlcku0grzq366UVw4DlS7xQUhmdOsnk5WaNm/bowiSSjj0l9AS8 dni9cDCWTTdpUV4YUQ4GIsh+qzQOedBdzV5lE9z9uTL8rkcvn9qIZcusze9fzW03pXZjlO ipMestSLs/MYANhxNSHRYkF6Iv9bXp+hBp9Du3rSVz/vamOTWf+41GIxriBXa3JPDZ0QuN HeG8NGu/PeAfXNKckfhTi0NRyM2AUaqbOWzm/HbmWSs/IJlcbZqGD6ExMpLcp+AtBHGBzZ /s+UNfbIhcv9q2wOvBx5eRirnIJpaupMTbwTD1muknzJa8NyYF2exPbh/DGt9w== Date: Tue, 8 Jul 2025 16:19:15 +0200 From: Luca Ceresoli To: Maxime Ripard Cc: Marek Szyprowski , dri-devel@lists.freedesktop.org, Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Dmitry Baryshkov , Douglas Anderson , Damon Ding Subject: Re: [PATCH] drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API Message-ID: <20250708161915.421d241c@booty> In-Reply-To: <20250707125954.5e0bbaa8@booty> References: <20250627165652.580798-1-m.szyprowski@samsung.com> <20250630-famous-dark-boar-89bed7@houat> <20250701160219.20dc7466@booty> <20250701-petite-mutant-starling-24bbe5@houat> <20250703175032.6f49f862@booty> <20250707125954.5e0bbaa8@booty> Organization: Bootlin X-Mailer: Claws Mail 4.3.1 (GTK 3.24.49; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefgeeltdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkjghfohfogggtgfesthhqredtredtjeenucfhrhhomhepnfhutggrucevvghrvghsohhlihcuoehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpefhteduuefgheehleeihfejjeduvdeltddutddtveeltdfhheeguefgteehkefgffenucffohhmrghinhepsghoohhtlhhinhdrtghomhenucfkphepkeejrdduvddtrddvudekrddvtdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeejrdduvddtrddvudekrddvtdejpdhhvghlohepsghoohhthidpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopehmrdhsiiihphhrohifshhkihesshgrmhhsuhhnghdrtghomhdprhgtphhtthhopehmrhhiphgrrhgusehkvghrnhgvlhdrohhrghdprhgtphhtthhopegurhhiqdguvghvvghlsehlihhsthhsrdhfrhgvvgguvghskhhtohhprdhorhhgpdhrtghpthhtoheprghnughriigvjhdrhhgrjhgurgesihhnthgvlhdrtghomhdprhgtp hhtthhopehnvghilhdrrghrmhhsthhrohhngheslhhinhgrrhhordhorhhgpdhrtghpthhtoheprhhfohhssheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepnfgruhhrvghnthdrphhinhgthhgrrhhtsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhopehjohhnrghssehkfihisghoohdrshgv X-GND-Sasl: luca.ceresoli@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hello Maxime, all, On Mon, 7 Jul 2025 12:59:54 +0200 Luca Ceresoli wrote: > On Mon, 7 Jul 2025 11:07:26 +0200 > Marek Szyprowski wrote: >=20 > > On 03.07.2025 17:50, Luca Ceresoli wrote: =20 > > > On Tue, 1 Jul 2025 16:27:54 +0200 > > > Maxime Ripard wrote: > > > =20 > > >> On Tue, Jul 01, 2025 at 04:02:19PM +0200, Luca Ceresoli wrote: =20 > > >>> Hello Marek, Maxime, > > >>> > > >>> thanks Marek for spotting the issue and sending a patch! > > >>> > > >>> On Mon, 30 Jun 2025 18:44:24 +0200 > > >>> Maxime Ripard wrote: > > >>> =20 > > >>>>> @@ -1643,7 +1625,7 @@ int analogix_dp_bind(struct analogix_dp_dev= ice *dp, struct drm_device *drm_dev) > > >>>>> return ret; > > >>>>> } > > >>>>> =20 > > >>>>> - ret =3D analogix_dp_create_bridge(drm_dev, dp); > > >>>>> + ret =3D drm_bridge_attach(dp->encoder, &dp->bridge, NULL, 0); > > >>>>> if (ret) { > > >>>>> DRM_ERROR("failed to create bridge (%d)\n", ret); > > >>>>> goto err_unregister_aux; =20 > > >>>> It looks like you don't set bridge->driver_private anymore. Is it = on purpose? =20 > > >>> This looks correct to me. In current code, driver_private is used to > > >>> hold a pointer to the driver private struct (struct > > >>> analogix_dp_device). With devm_drm_bridge_alloc() container_of() is= now > > >>> enough, no pointer is needed. With the patch applied, driver_private > > >>> becomes unused. =20 > > >> Then we should remove it from the structure if it's unused. =20 > > > Makes sense now that struct drm_bridge is meant to be always embedded > > > in a driver-private struct. But several drivers are still using it, so > > > those would need to be updated beforehand: > > > > > > $ git grep -l driver_private -- drivers/gpu/drm/ | wc -l > > > 23 > > > $ > > > > > > So I think this patch should be taken as it fixes a regression. Do you > > > agree on this? =20 > >=20 > > Yes, please apply it as a fix :) > >=20 > >=20 > > BTW, there are 2 more bridge drivers that need a fix similar to the=20 > > $subject patch: > >=20 > > $ git grep "bridge =3D devm_kzalloc" drivers/gpu > > drivers/gpu/drm/sti/sti_hda.c:=C2=A0 bridge =3D devm_kzalloc(dev,=20 > > sizeof(*bridge), GFP_KERNEL); > > drivers/gpu/drm/sti/sti_hdmi.c: bridge =3D devm_kzalloc(dev,=20 > > sizeof(*bridge), GFP_KERNEL); =20 >=20 > Ouch. My grep logic was probably too clever and missed these obvious > ones. I'm taking care of converting these ones later this week as time > permits, unless patches are sent before. I think I missed those two because I searched for all calls to drm_bridge_add(), and converted matching drivers, but these two do now call drm_bridge_add() at all. I understand this probably works just fine, for non-DT hardware at least. However, doesn't this look like wrong, from a DRM bridge API point of view? Right now I'm preparing patches to convert to devm_drm_bridge_alloc(), but what about the following two additions: * add calls to drm_bridge_add/remove() in those drivers * add a WARN in drm_bridge_attach() if the bridge was not added ? Luca --=20 Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com