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 38C08386564 for ; Wed, 15 Apr 2026 06:28:41 +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=1776234526; cv=none; b=kH6CTG8fePQY80nckzom3XajDuDqxE7ieMjMvlK6PkJIRZ43TtupI7k4Bbyxzls3r6Acj4KxYdU4U0VUMuEUYwBFaRRxIO6zgiz7phrQ2Xtofgoqk7Oemty1B02LK9FObg5ugwOXy7EHzGYPP2LemyA7C5uYtOBaswPvxC1XkbI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776234526; c=relaxed/simple; bh=X5i7BaUafFWp3oWuErpGWh72ROtDWH4HdtP9LJnemAQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=A7H5j+k5CaVX+/yQClUFMOtnqtG43DDa5m42z6qsriP2ZAbCtpODe6gNRhO79tgE8jZfNj2bwgDp/8h1USw6kDFc9BnWbM5d3wEX+ycCjO2jMLZdp4Ik3mxpMTpurLdal5dXvKUL4oghEtCBN+mjakqxqXt4H/qmVbeHj0jox9g= 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=RTieCdr3; 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="RTieCdr3" 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=lUuedl4xNkH3ux X5lEecPFpisz9aULFi2gxjtiH3i8M=; b=RTieCdr3IHobvR4d0maRRJLfSbmayO vU+GdStj19fsjowOWW0EOblz8BwPyoBsnsZ6LmeLG6zfJwsGU+umZLIaV7eG6nD7 1vdDXfiiOeu0HBdszd/wkrCFb8IxdMwYY5HVw9IzlNs7Wh9XnaHhFet/vQUDT2jd C/zZT18XuJvdTR+j9Qvk4oAC5+uAILUp099IW5/CpUbd4psXcg7pRO+oFZTcuMLs Yexwgo8Ok5qWQyci/qvS+cTvKLYDLxqQpn/EP0wjLYNJ0siCJeGRwwaTvqkQVRDs k9Xj7c+8k4pXKWnGv1sV/WEATxs/TM8GMSeY6waPCtPTVrVF4eMpWuUg== Received: (qmail 3006962 invoked from network); 15 Apr 2026 08:28:39 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 15 Apr 2026 08:28:39 +0200 X-UD-Smtp-Session: l3s3148p1@9X6J03lP6rwujnt6 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Jassi Brar Subject: [PATCH v4] mailbox: add list of used channels to debugfs Date: Wed, 15 Apr 2026 08:27:04 +0200 Message-ID: <20260415062832.18503-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: # cat /sys/kernel/debug/mailbox/mailbox_summary 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 Signed-off-by: Wolfram Sang --- Changes since v3: * create 'mailbox' subdir and put file there (Geert) * add comment explaining the initcall situation drivers/mailbox/mailbox.c | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index bbc9fd75a95f..bd758ffefd5f 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include static LIST_HEAD(mbox_cons); @@ -632,3 +634,66 @@ 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 = list_entry(v, struct mbox_controller, node); + + seq_printf(seq, "%s:\n", dev_name(mbox->dev)); + + for (unsigned int i = 0; i < mbox->num_chans; i++) { + struct mbox_chan *chan = &mbox->chans[i]; + + scoped_guard(spinlock_irqsave, &chan->lock) { + if (chan->cl) { + struct device *cl_dev = 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 = { + .start = mbox_seq_start, + .next = mbox_seq_next, + .stop = mbox_seq_stop, + .show = mbox_seq_show, +}; +DEFINE_SEQ_ATTRIBUTE(mbox); + +/* + * subsys_initcall() is used here but controllers may already have been + * registered earlier. The rationale is that debugfs is accessed only late, + * i.e. from userspace. So, files created here must work independently of the + * initcall ordering. + */ +static int __init mbox_init(void) +{ + struct dentry *mbox_debugfs = debugfs_create_dir("mailbox", NULL); + + debugfs_create_file("mailbox_summary", 0444, mbox_debugfs, NULL, &mbox_fops); + return 0; +} +subsys_initcall(mbox_init); +#endif /* DEBUG_FS */ -- 2.51.0