From nobody Thu Oct 2 16:48:58 2025 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 4904D2FB632 for ; Mon, 15 Sep 2025 10:14:08 +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=1757931250; cv=none; b=l+KnlYIWgRSX9dWOx8K+XAUH3BnA1CE1yrQwZvUSEAUP7ATXuuo18ZKNnEtPKke/AQf16ljq+6KTUjG77HbL+G+p9jOGBAxvvLGPfAOBcA8SDCOpNypsGj0dXVogz3hglkFwXm9KqOHAzo4QRqc5hParFSMkxM8kQEQjTNoAQKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757931250; c=relaxed/simple; bh=ecPadECTbqy38SJJqaQ6PdYuKoRS8Wmn5VIsEo8/w/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X0i971300n40KPmlzeF+H3iIZq2S8rl6QBIqgDBFo5DCHl3GZ9PfrEUZ7hEKt5dTKaMUwSi4PcBbsmYAb62E4IdqsYFXJgD1FkJ/tKiUehqc+IYVilUtT9QC05iH9YsJzeDB7xMJULUGXcd7F8GR6sy/j7o4giKouy9eSXmrIjM= 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=CtZTMnMU; 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="CtZTMnMU" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 37A2C4E40C32; Mon, 15 Sep 2025 10:14:06 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0CD9B6063F; Mon, 15 Sep 2025 10:14:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 32F1E102F2ABB; Mon, 15 Sep 2025 12:14:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757931245; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=MxaPaKKWKs3ulFwyzozXHLb7YuQsngXreF1xvu2bmpo=; b=CtZTMnMU03MxTsrWXJ9NXMRSnC0dMIdN9ALKSTRBqUHAc7zlUv+xA2w7kfdoJKHwa/y5J/ 63Nq+cjEoHfO5MKZd0vlB6xyPwf2YDm0Y6UPJaI8JUqtVFpkcFfCGCtC0L+So0A2FDwZL0 W6+orSJQh/TbX17Trd9bW3xtJG3P/e3ymWii4/1pEQnuWsEEZiLrhauMYqDAkF6LrWk2bN WWBb7AqKUKtkOBN983pbMZebyzDH9mWONo2pFFbfZNbZ/KtKXTSTpUdQyzJRJHKuwyWkAw pzjxZnALiNY7i2jeKZbWzcZ9AnMXaAfbGg+mCsJwRZX8STxTrPqihKUtY/4Dsw== From: Luca Ceresoli Date: Mon, 15 Sep 2025 12:12:47 +0200 Subject: [PATCH v9 2/3] drm/debugfs: show lingering 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: <20250915-drm-bridge-debugfs-removed-v9-2-6e5c0aff5de9@bootlin.com> References: <20250915-drm-bridge-debugfs-removed-v9-0-6e5c0aff5de9@bootlin.com> In-Reply-To: <20250915-drm-bridge-debugfs-removed-v9-0-6e5c0aff5de9@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 Cc: Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 The usefulness of /sys/kernel/debug/dri/bridges is limited as it only shows bridges between drm_bridge_add() and drm_bridge_remove(). However refcounted bridges can stay allocated and lingering for a long time after drm_bridge_remove(), and a memory leak due to a missing drm_bridge_put() would not be visible in this debugfs file. Add lingering bridges to the /sys/kernel/debug/dri/bridges output. Reviewed-by: Maxime Ripard Signed-off-by: Luca Ceresoli --- Changes in v9: - rename leftover instances of "removed" to "lingering" Changes in v8: - updated to rename bridge_removed_list -> bridge_lingering_list Changes in v7: - rebased on current code which is in drm_bridge.c now - removed if (drm_bridge_is_refcounted(bridge)), refcounting is not optional - don't show bridge address - improve commit message This patch was added in v6. --- drivers/gpu/drm/drm_bridge.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 9491ae7c884d355be4a82fb02a43a42d17fa8e0c..dda4e641a38fa38cef16296366e= ea08fe8702618 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1491,17 +1491,20 @@ EXPORT_SYMBOL(devm_drm_put_bridge); =20 static void drm_bridge_debugfs_show_bridge(struct drm_printer *p, struct drm_bridge *bridge, - unsigned int idx) + unsigned int idx, + bool lingering) { drm_printf(p, "bridge[%u]: %ps\n", idx, bridge->funcs); =20 - drm_printf(p, "\trefcount: %u\n", kref_read(&bridge->refcount)); + drm_printf(p, "\trefcount: %u%s\n", kref_read(&bridge->refcount), + lingering ? " [lingering]" : ""); =20 drm_printf(p, "\ttype: [%d] %s\n", 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 && !lingering) drm_printf(p, "\tOF: %pOFfc\n", bridge->of_node); =20 drm_printf(p, "\tops: [0x%x]", bridge->ops); @@ -1527,7 +1530,10 @@ static int allbridges_show(struct seq_file *m, void = *data) mutex_lock(&bridge_lock); =20 list_for_each_entry(bridge, &bridge_list, list) - drm_bridge_debugfs_show_bridge(&p, bridge, idx++); + drm_bridge_debugfs_show_bridge(&p, bridge, idx++, false); + + list_for_each_entry(bridge, &bridge_lingering_list, list) + drm_bridge_debugfs_show_bridge(&p, bridge, idx++, true); =20 mutex_unlock(&bridge_lock); =20 @@ -1542,7 +1548,7 @@ static int encoder_bridges_show(struct seq_file *m, v= oid *data) unsigned int idx =3D 0; =20 drm_for_each_bridge_in_chain_scoped(encoder, bridge) - drm_bridge_debugfs_show_bridge(&p, bridge, idx++); + drm_bridge_debugfs_show_bridge(&p, bridge, idx++, false); =20 return 0; } --=20 2.51.0