From nobody Mon Jun 15 19:06:01 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (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 4304A37E2E3 for ; Mon, 13 Apr 2026 11:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776081269; cv=none; b=p0ymD93ybEq4aIOSdkRh9Cvt2bW3h+bw5hCCztzsls/SGfSb9MVEWybpI/296CP7Dju/NqlGCOh2TBy/0z9XDEZm4Z6WDtJ5LCVYudaAkVlyg2sPdBULoQxH81k5JTRdtnrupgQNe7p+QPxqn92yZsiZehVngqMpjVrYFeRCBrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776081269; c=relaxed/simple; bh=zYaci4GuiPu2E3v9VmY/HnlHgsL4C/+uJGqa97dHp+g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fDRgLOaSRiF+yeMacmQrSvATIF4bWdrXAYh9WTinH/HKSCWApljYi4ER24RRxFYW83+H8zGPQ08knMfeaHuJU4YetSNivAXbkDLzNO3rOh5R5jkZnFjUIBYmTqrRjsle6w14j/7/x3G4n4OHheQpjrKzYq/7gkaoZU/WdoaQpt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=AE8nVCyb; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="AE8nVCyb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=k1; bh=si7E5p+8MOHPZ+ YciQrqhDWQnN9iXIS4hi6TxzCpUQg=; b=AE8nVCyb/KkEvDNK335/UvRsGncg+f QGjsfnT7kuWY/yDwJ/4td13MSIJA3VI10RGj1WPVqZwOqgvkJXiQqZ7Wsgouad2g 19N0E1XzQq4E2W+OoKwcT1Q1J8HObwkFVv7ewJwej0nHhcEOllHh0e8oXXGPHfU+ 1xiL7/Hs7vfrOKCK8hrPsRL3JDpeY2QMfQlD9N4o0cMm6Hj1DvBo6Tzs+LsFxerF hV7UxFooSzrpW2vx191nnzoq/FNqrEgcnEedLPUmY7Pj7E/t+QqTRjVw4DM5XxlQ JbBLIjOmQGXzwob9TO+7Fz/pMTc5VcJZPYN8nP1owH8lCf4mkzXdBx4Q== Received: (qmail 2280368 invoked from network); 13 Apr 2026 13:54:21 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 13 Apr 2026 13:54:21 +0200 X-UD-Smtp-Session: l3s3148p1@OAmmJFZPINEujnvz From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sudeep Holla , Wolfram Sang , Jassi Brar Subject: [PATCH v2] mailbox: add list of used channels to debugfs Date: Mon, 13 Apr 2026 13:49:57 +0200 Message-ID: <20260413115416.35830-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 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" During development, it is useful to see which mailboxes are currently obtained. Use a seq-file in debugfs to list the currently registered controllers and their used channels. Example output from a Renesas R-Car X5H based system: 189e0000.system-controller: 0: c1000000.mailbox_test_send_to_recv 1: c1000100.mailbox_test_recv_to_send 128: c1000100.mailbox_test_recv_to_send 129: c1000000.mailbox_test_send_to_recv 189e1000.system-controller: 4: scmi_dev.1 5: scmi_dev.2 Note that mailbox controllers currently can be instantiated at any initcall stage. So, per-controller debugfs handling was discarded because it is not clear when to create the root "mailbox"-debugfs entry. A central file was chosen, similar to the GPIO subsystem, which is independent of the initcall stage because it will be accessed only when userspace is available anyhow. Signed-off-by: Wolfram Sang --- Changes since v1: * check NULL before using dev_name(). I wrongly thought it was handled by the function already (found by Sashiko [1]) * take the channel lock before accessing the client (Sashiko again [1]) [1] https://sashiko.dev/#/patchset/20260410131604.42267-2-wsa%2Brenesas%40s= ang-engineering.com drivers/mailbox/mailbox.c | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 24c611722a36..3a64d7870ca3 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -7,6 +7,7 @@ */ #define DEBUG #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include =20 static LIST_HEAD(mbox_cons); @@ -637,3 +639,58 @@ int devm_mbox_controller_register(struct device *dev, return 0; } EXPORT_SYMBOL_GPL(devm_mbox_controller_register); + +#ifdef CONFIG_DEBUG_FS +static void *mbox_seq_start(struct seq_file *s, loff_t *pos) +{ + mutex_lock(&con_mutex); + return seq_list_start(&mbox_cons, *pos); +} + +static void *mbox_seq_next(struct seq_file *s, void *v, loff_t *pos) +{ + return seq_list_next(v, &mbox_cons, pos); +} + +static void mbox_seq_stop(struct seq_file *s, void *v) +{ + mutex_unlock(&con_mutex); +} + +static int mbox_seq_show(struct seq_file *seq, void *v) +{ + const struct mbox_controller *mbox =3D list_entry(v, struct mbox_controll= er, node); + + seq_printf(seq, "%s:\n", dev_name(mbox->dev)); + + for (unsigned int i =3D 0; i < mbox->num_chans; i++) { + struct mbox_chan *chan =3D &mbox->chans[i]; + + scoped_guard(spinlock_irqsave, &chan->lock) { + if (chan->cl) { + struct device *cl_dev =3D chan->cl->dev; + + seq_printf(seq, " %3u: %s\n", i, + cl_dev ? dev_name(cl_dev) : "NULL device"); + } + } + } + + return 0; +} + +static const struct seq_operations mbox_sops =3D { + .start =3D mbox_seq_start, + .next =3D mbox_seq_next, + .stop =3D mbox_seq_stop, + .show =3D mbox_seq_show, +}; +DEFINE_SEQ_ATTRIBUTE(mbox); + +static int __init mbox_init(void) +{ + debugfs_create_file("mailbox_summary", 0444, NULL, NULL, &mbox_fops); + return 0; +} +subsys_initcall(mbox_init); +#endif /* DEBUG_FS */ --=20 2.51.0