From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: sudeep.holla@kernel.org, james.quinlan@broadcom.com,
f.fainelli@gmail.com, vincent.guittot@linaro.org,
etienne.carriere@st.com, peng.fan@oss.nxp.com,
michal.simek@amd.com, d-gole@ti.com, jic23@kernel.org,
elif.topuz@arm.com, lukasz.luba@arm.com, philip.radford@arm.com,
david@kernel.org, souvik.chakravarty@arm.com, leitao@kernel.org,
kas@kernel.org, puranjay@kernel.org, usama.arif@linux.dev,
kernel-team@meta.com, Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v11 15/25] firmware: arm_scmi: Add common per-protocol debugfs support
Date: Sun, 6 Sep 2026 11:06:13 +0100 [thread overview]
Message-ID: <20260906100623.3488327-16-cristian.marussi@arm.com> (raw)
In-Reply-To: <20260906100623.3488327-1-cristian.marussi@arm.com>
Allow interested SCMI protocols to register their own specific debugfs
entries under a common per-instance and per-protocol subtree rooted
at /sys/kernel/debug/scmi/<N>/protocols/<PROTO_ID>/
Expose a helper to enable protocol initialization code to get access to
such per-protocol/per-instance dentries in order to be able to install
their own dedicated debugfs entries.
Per-protocol debugfs support is configurable and default off.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v8 --> v9
- avoid NULL deref on DBG cleanup path
v5 --> v6
- bail out of dentry_get helper when SCMI debug susbsytem failed to init
- remove stale SCMI protocol operations
- add a preoper clean up of debugfs when protocol init fails
---
drivers/firmware/arm_scmi/Kconfig | 14 +++++++++++
drivers/firmware/arm_scmi/common.h | 2 ++
drivers/firmware/arm_scmi/driver.c | 35 +++++++++++++++++++++++++--
drivers/firmware/arm_scmi/protocols.h | 6 +++++
include/linux/scmi_protocol.h | 1 -
5 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index 783c24a20e29..f506c4d1d96a 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -69,6 +69,20 @@ config ARM_SCMI_DEBUG_COUNTERS
such useful debug counters. This can be helpful for debugging and
SCMI monitoring.
+config ARM_SCMI_DEBUG_PROTOCOLS
+ bool "Enable SCMI protocols debug"
+ select ARM_SCMI_NEED_DEBUGFS
+ depends on DEBUG_FS
+ default n
+ help
+ Enables per-protocol specific debug features, where available.
+ When provided, such per-protocol debugfs entries are grouped
+ inside a common a subtree named by the protocol number and rooted
+ under a per-instance 'protocols' directory.
+
+ Such per-protocol entries subtree structure is freely defined
+ within the related protocol code.
+
config ARM_SCMI_QUIRKS
bool "Enable SCMI Quirks framework"
depends on JUMP_LABEL || COMPILE_TEST
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index 1d9e6af09672..8c0e49748c32 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -324,6 +324,7 @@ enum debug_counters {
/**
* struct scmi_debug_info - Debug common info
* @top_dentry: A reference to the top debugfs dentry
+ * @protos: A reference to the top debugfs protocols subdirectory
* @name: Name of this SCMI instance
* @type: Type of this SCMI instance
* @is_atomic: Flag to state if the transport of this instance is atomic
@@ -331,6 +332,7 @@ enum debug_counters {
*/
struct scmi_debug_info {
struct dentry *top_dentry;
+ struct dentry *protos;
const char *name;
const char *type;
bool is_atomic;
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 408fa4cb83a6..e8d93690ecc2 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -18,6 +18,7 @@
#include <linux/bitmap.h>
#include <linux/cleanup.h>
+#include <linux/dcache.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/export.h>
@@ -102,6 +103,8 @@ struct scmi_xfers_info {
* has completed.
* @ph: An embedded protocol handle that will be passed down to protocol
* initialization code to identify this instance.
+ * @dbg: An optional reference to this protocol top debugfs directory; it will
+ * be automatically recursively removed on protocol de-initialization.
*
* Each protocol is initialized independently once for each SCMI platform in
* which is defined by DT and implemented by the SCMI server fw.
@@ -116,6 +119,7 @@ struct scmi_protocol_instance {
unsigned int version;
unsigned int negotiated_version;
struct scmi_protocol_handle ph;
+ struct dentry *dbg;
};
#define ph_to_pi(h) container_of(h, struct scmi_protocol_instance, ph)
@@ -2094,6 +2098,25 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db)
SCMI_PROTO_FC_RING_DB(64);
}
+static struct dentry *
+scmi_debugfs_proto_dentry_get(const struct scmi_protocol_handle *ph)
+{
+ struct scmi_protocol_instance *pi = ph_to_pi(ph);
+ struct scmi_info *info = handle_to_scmi_info(pi->handle);
+
+ if (!IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_PROTOCOLS) || !info->dbg)
+ return ERR_PTR(-ENODEV);
+
+ if (!pi->dbg) {
+ char proto_dir[8];
+
+ snprintf(proto_dir, 8, "0x%02X", pi->proto->id);
+ pi->dbg = debugfs_create_dir(proto_dir, info->dbg->protos);
+ }
+
+ return pi->dbg;
+}
+
static const struct scmi_proto_helpers_ops helpers_ops = {
.extended_name_get = scmi_common_extended_name_get,
.get_max_msg_size = scmi_common_get_max_msg_size,
@@ -2104,6 +2127,7 @@ static const struct scmi_proto_helpers_ops helpers_ops = {
.protocol_msg_check = scmi_protocol_msg_check,
.fastchannel_init = scmi_common_fastchannel_init,
.fastchannel_db_ring = scmi_common_fastchannel_db_ring,
+ .debugfs_proto_dentry_get = scmi_debugfs_proto_dentry_get,
};
/**
@@ -2289,12 +2313,12 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
/* proto->init is assured NON NULL by scmi_protocol_register */
ret = pi->proto->instance_init(&pi->ph);
if (ret)
- goto clean;
+ goto clean_dbg;
ret = idr_alloc(&info->protocols, pi, proto->id, proto->id + 1,
GFP_KERNEL);
if (ret != proto->id)
- goto clean;
+ goto clean_dbg;
/*
* Warn but ignore events registration errors since we do not want
@@ -2315,6 +2339,8 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
return pi;
+clean_dbg:
+ debugfs_remove_recursive(pi->dbg);
clean:
/* Take care to put the protocol module's owner before releasing all */
scmi_protocol_put(proto);
@@ -2430,6 +2456,8 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id)
if (refcount_dec_and_test(&pi->users)) {
void *gid = pi->gid;
+ debugfs_remove_recursive(pi->dbg);
+
if (pi->proto->events)
scmi_deregister_protocol_events(handle, protocol_id);
@@ -3169,6 +3197,9 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS))
scmi_debugfs_counters_setup(dbg, trans);
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_PROTOCOLS))
+ dbg->protos = debugfs_create_dir("protocols", top_dentry);
+
dbg->top_dentry = top_dentry;
if (devm_add_action_or_reset(info->dev,
diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h
index 1f9925b8f495..04e196a9fbf4 100644
--- a/drivers/firmware/arm_scmi/protocols.h
+++ b/drivers/firmware/arm_scmi/protocols.h
@@ -11,6 +11,7 @@
#include <linux/bitfield.h>
#include <linux/completion.h>
+#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -284,6 +285,9 @@ struct scmi_fc_info {
* gathering FC descriptions from the SCMI platform server.
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
* @get_max_msg_size: A common helper to get the maximum message size.
+ * @debugfs_proto_dentry_get: A common helper to get a per-protocol debugfs top
+ * directory to use as a root. It will be
+ * recursively removed on protocol de-initialization.
*/
struct scmi_proto_helpers_ops {
int (*extended_name_get)(const struct scmi_protocol_handle *ph,
@@ -307,6 +311,8 @@ struct scmi_proto_helpers_ops {
u32 *rate_limit);
void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
int (*get_max_msg_size)(const struct scmi_protocol_handle *ph);
+ struct dentry *(*debugfs_proto_dentry_get)
+ (const struct scmi_protocol_handle *ph);
};
/**
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 83ab8edc0b13..037b486dc873 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -1156,7 +1156,6 @@ struct scmi_handle {
void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
bool (*is_transport_atomic)(const struct scmi_handle *handle,
unsigned int *atomic_threshold);
-
const struct scmi_notify_ops *notify_ops;
};
--
2.54.0
next prev parent reply other threads:[~2026-09-06 10:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 10:05 [PATCH v11 00/25] Introduce SCMI Telemetry support Cristian Marussi
2026-09-06 10:05 ` [PATCH v11 01/25] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 02/25] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 03/25] firmware: arm_scmi: Introduce protocol instance notifiers Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 04/25] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 05/25] include: trace: Add Telemetry trace events Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 06/25] firmware: arm_scmi: Add basic Telemetry support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 07/25] firmware: arm_scmi: Add support to parse SHMTIs areas Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 08/25] firmware: arm_scmi: Add Telemetry configuration operations Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 09/25] firmware: arm_scmi: Add Telemetry DataEvent read capabilities Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 10/25] firmware: arm_scmi: Add support for Telemetry reset Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 11/25] firmware: arm_scmi: Add Telemetry notification support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 12/25] firmware: arm_scmi: Add support for boot-on Telemetry Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 13/25] firmware: arm-scmi: Add telemetry generic event support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 14/25] firmware: arm_scmi: Add Telemetry generation counter event Cristian Marussi
2026-09-06 10:06 ` Cristian Marussi [this message]
2026-09-06 10:06 ` [PATCH v11 16/25] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 17/25] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 18/25] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 19/25] firmware: arm_scmi: Add un-managed methods to get/put protocols operations Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 20/25] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 21/25] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 22/25] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 23/25] [RFC] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 24/25] [RFC] tools/scmi: Add SCMI Telemetry testing tool Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 25/25] [RFC] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260906100623.3488327-16-cristian.marussi@arm.com \
--to=cristian.marussi@arm.com \
--cc=arm-scmi@vger.kernel.org \
--cc=d-gole@ti.com \
--cc=david@kernel.org \
--cc=elif.topuz@arm.com \
--cc=etienne.carriere@st.com \
--cc=f.fainelli@gmail.com \
--cc=james.quinlan@broadcom.com \
--cc=jic23@kernel.org \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=leitao@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=philip.radford@arm.com \
--cc=puranjay@kernel.org \
--cc=souvik.chakravarty@arm.com \
--cc=sudeep.holla@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).