From nobody Tue Dec 16 14:22:04 2025 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 A567B19F41B; Thu, 6 Feb 2025 18:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738865740; cv=none; b=LxFAeCWGMs4AQ3WHkG1W/ipIOlrsPVJpWhY5i5vWnM9ytmRxP40gnOF4tFbnQr6eC0uqZaopYRHOz3zssWI65uKQ1JMCv34W+G8GXucJf7ksoH93frwP+tVUc8hi6/CF+Vgo2rpq7owjkECIzMciQcVhLBzzA0KqtF6ED+xQzcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738865740; c=relaxed/simple; bh=HwwOEVp5qD1QzrVBTpEMxbqsEsINfHX8REk53ulGwAk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PXC8vfNl1CBrBxvB8UsA1Y0CUJLcEtJU8gTFyy6y5uC3IEzAptfnS4vmwHpVg2AZPvHQ9Lga/De6lobJLyvcjwB+A7OuXgrJIO6MIrvNA33hvkuMRM34PE318kZRrpTsE23mxi9DRo96vPUqrOgtuJv9/Qm22nggOgG/svfq43M= 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=JznA0qyI; arc=none smtp.client-ip=217.70.183.198 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="JznA0qyI" Received: by mail.gandi.net (Postfix) with ESMTPSA id 648AC44264; Thu, 6 Feb 2025 18:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738865736; 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=jyt92zCCqkFkC7In83mYaBu4PIN5nSKfNfG/5T0DTUw=; b=JznA0qyIaTSfICk4caWACJbFbfNzXB1pg7S6uD3cgTrCOwAGOR2jl4hYbaD6qwNFYLQjN/ GGCvKL2OKdNYgXo8ypms6t1EC1NNA6QPCklEjsnL19iJYH0AXm0WWTl8xNNiC85x2JJVcp 1x59+fg5iQbMzBtYLad904nKO9R1wxem87yt4xMpaVM/y8jD8ki2oCT4FzIBeRepdHWSZ2 +hh+gRudoYHKq0zrujEIp6PXOlNDXDErASHdc8bbvJ47Tvnap9VPBO1UcRfqZj479G8BER uXcFAiFImmpFZ3ycDUn47hzc6H5utTKcEUj9jZUBZUnGq7PK/kz0Z9E/71WSHg== From: Luca Ceresoli Date: Thu, 06 Feb 2025 19:14:37 +0100 Subject: [PATCH v6 22/26] drm/debugfs: show removed bridges 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: <20250206-hotplug-drm-bridge-v6-22-9d6f2c9c3058@bootlin.com> References: <20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com> In-Reply-To: <20250206-hotplug-drm-bridge-v6-0-9d6f2c9c3058@bootlin.com> To: Simona Vetter , Inki Dae , Jagan Teki , Marek Szyprowski , Catalin Marinas , Will Deacon , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Daniel Thompson , Andrzej Hajda , Jonathan Corbet , Sam Ravnborg , Boris Brezillon , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Jessica Zhang Cc: Paul Kocialkowski , Maxime Ripard , Dmitry Baryshkov , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Thomas Zimmermann , David Airlie , =?utf-8?q?Herv=C3=A9_Codina?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paul Kocialkowski , Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvjedtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefnuhgtrgcuvegvrhgvshholhhiuceolhhutggrrdgtvghrvghsohhlihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepieeiuedvffetgfeuudelheeutefggfejieettdetteekueeuueeukeevvedvueevnecukfhppedvrgdtvdemieejtdemvddtvddtmegvrgdtudemhegrgedtmedvughfieemrgdulegvmedutgejgeenucevlhhushhtvghrufhiiigvpedvtdenucfrrghrrghmpehinhgvthepvdgrtddvmeeijedtmedvtddvtdemvggrtddumeehrgegtdemvdgufheimegrudelvgemudgtjeegpdhhvghloheplgduvdejrddtrddurddungdpmhgrihhlfhhrohhmpehluhgtrgdrtggvrhgvshholhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeefkedprhgtphhtthhopegtrghtrghlihhnrdhmrghrihhnrghssegrrhhmrdgtohhmpdhrtghpthhtohepshdrhhgruhgvrhesphgvnhhguhhtrhhonhhigidruggvpdhrtghpthhtoheprghlvgigrghnughrvgdrsggvlhhlohhnihessghoohhtlhhinhdrtghom hdprhgtphhtthhopegtlhgruhguihhurdgsvgiinhgvrgesthhugihonhdruggvvhdprhgtphhtthhopehmrdhsiiihphhrohifshhkihesshgrmhhsuhhnghdrtghomhdprhgtphhtthhopegtohhrsggvtheslhifnhdrnhgvthdprhgtphhtthhopehsihhmohhnrgesfhhffihllhdrtghhpdhrtghpthhtohepughrihdquggvvhgvlheslhhishhtshdrfhhrvggvuggvshhkthhophdrohhrgh X-GND-Sasl: luca.ceresoli@bootlin.com The usefulness of /sys/kernel/debug/dri/bridges is limited as it only shows bridges betweeb drm_bridge_add() and drm_bridge_remove(). However refcounted bridges can stay allocated for way longer, and a memory leak due to a missing drm_bridge_put() would not be visible in this debugfs file. Add removed bridges to the /sys/kernel/debug/dri/bridges output. Now however if a bridge is added and removed multiple times (as in hot-pluggable hardware) and not freed immediately, there would be multiple identical entries for the same bridge model/driver. To distinguish between each instance add the bridge pointer to the output. Signed-off-by: Luca Ceresoli --- This patch was added in v6. --- drivers/gpu/drm/drm_debugfs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 629074247ffec4fa18df7af2d9023255abed501c..b04e1fba8faf7320794277c2017= c97216320f017 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -740,12 +740,16 @@ void drm_debugfs_crtc_remove(struct drm_crtc *crtc) crtc->debugfs_entry =3D NULL; } =20 -static void bridge_print(struct drm_printer *p, struct drm_bridge *bridge,= unsigned int idx) +static void bridge_print(struct drm_printer *p, struct drm_bridge *bridge,= unsigned int idx, + bool removed) { drm_printf(p, "bridge[%u]: %ps\n", idx, bridge->funcs); =20 + drm_printf(p, "\taddr: %p\n", bridge); + if (drm_bridge_is_refcounted(bridge)) - drm_printf(p, "\trefcount: %u\n", kref_read(&bridge->refcount)); + drm_printf(p, "\trefcount: %u%s\n", kref_read(&bridge->refcount), + removed ? " [removed]" : ""); else drm_printf(p, "\trefcount: N/A\n"); =20 @@ -753,7 +757,8 @@ static void bridge_print(struct drm_printer *p, struct = drm_bridge *bridge, unsig bridge->type, drm_get_connector_type_name(bridge->type)); =20 - if (bridge->of_node) + /* The OF node could be freed after drm_bridge_remove() */ + if (bridge->of_node && !removed) drm_printf(p, "\tOF: %pOFfc\n", bridge->of_node); =20 drm_printf(p, "\tops: [0x%x]", bridge->ops); @@ -778,7 +783,7 @@ static int bridges_show(struct seq_file *m, void *data) unsigned int idx =3D 0; =20 drm_for_each_bridge_in_chain(encoder, bridge) - bridge_print(&p, bridge, idx++); + bridge_print(&p, bridge, idx++, false); =20 return 0; } @@ -822,7 +827,10 @@ static int allbridges_show(struct seq_file *m, void *d= ata) mutex_lock(&bridge_lock); =20 list_for_each_entry(bridge, &bridge_list, list) - bridge_print(&p, bridge, idx++); + bridge_print(&p, bridge, idx++, false); + + list_for_each_entry(bridge, &bridge_removed_list, list) + bridge_print(&p, bridge, idx++, true); =20 mutex_unlock(&bridge_lock); =20 --=20 2.34.1