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,
jonathan.cameron@oss.qualcomm.com, 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 v17 25/34] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support
Date: Tue, 24 Nov 2026 19:48:31 +0000 [thread overview]
Message-ID: <20261124194841.1147072-26-cristian.marussi@arm.com> (raw)
In-Reply-To: <20261124194841.1147072-1-cristian.marussi@arm.com>
Expose one debugfs entry for each discovered SHMTI that can be used to
dump the related SHMTI in binary form from TBGN up to TEND markers.
No processing is done kernel side, beside using proper accessors for
device memory.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v15 --> v16
- initialize/destroy debugFS around SHMTIs init
v14 --> v15
- cleanup local debugfs subtree with debugfs_remove_recursive on remove
v12 --> v13
- get inode lock on time update
v11 --> v12
- fix debugfs shmti dump file to use the SID as name
v8 --> v9
- use kvzalloc/kfree
- use file_update_time to update debugfs file ts
v5 --> v6
- added mutex to protect binary dump buffer during reads (Sashiko)
- using debugfs_create_file_size() (Sashiko)
---
drivers/firmware/arm_scmi/telemetry.c | 103 ++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
index a3f446b98cb4..ddfa27b71ee4 100644
--- a/drivers/firmware/arm_scmi/telemetry.c
+++ b/drivers/firmware/arm_scmi/telemetry.c
@@ -9,9 +9,11 @@
#include <linux/bitfield.h>
#include <linux/compiler_types.h>
#include <linux/completion.h>
+#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
+#include <linux/fs.h>
#include <linux/hash.h>
#include <linux/hashtable.h>
#include <linux/jhash.h>
@@ -445,6 +447,14 @@ struct telemetry_shmti {
#define TDCF_OFFS(_b, _p) \
((unsigned long)((__force void *)(_p) - (__force void *)(_b)))
+struct scmi_telemetry_dbg_shmti {
+ struct telemetry_shmti *shmti;
+ size_t buf_sz;
+ void *buf;
+ /* Protect this descriptor from concurrent readers using it */
+ struct mutex mtx;
+};
+
#define SHMTI_EPLG(s) \
({ \
struct telemetry_shmti *_s = (s); \
@@ -554,6 +564,7 @@ struct telemetry_info {
unsigned int default_blk_ts_rate;
const struct scmi_protocol_handle *ph;
struct telemetry_shmti *shmti;
+ struct dentry *shmti_top;
struct telemetry_de *tdes;
struct xarray xa_des;
struct telemetry_uuid *primary_uuid;
@@ -1358,6 +1369,10 @@ static void scmi_telemetry_tdes_cleanup(void *arg)
scmi_telemetry_de_unlink(&tde->de);
scmi_telemetry_free_tde_put(ti, tde);
}
+
+ /* Safe removal of SHMTI debugfs tree before freeing underlying data */
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_PROTOCOLS))
+ debugfs_remove_recursive(ti->shmti_top);
}
static int scmi_telemetry_de_descriptors_get(struct telemetry_info *ti)
@@ -1535,6 +1550,91 @@ scmi_telemetry_enumerate_common_intervals(struct telemetry_info *ti)
ti->info.intervals);
}
+static int scmi_telemetry_dbg_shmti_open(struct inode *inode, struct file *filp)
+{
+ struct scmi_telemetry_dbg_shmti *sblob;
+ struct telemetry_shmti *shmti;
+
+ if (!inode->i_private)
+ return -ENODEV;
+
+ shmti = inode->i_private;
+ sblob = kzalloc_obj(*sblob);
+ if (!sblob)
+ return -ENOMEM;
+
+ sblob->shmti = shmti;
+ sblob->buf = kvzalloc(shmti->info.len, GFP_KERNEL);
+ if (!sblob->buf) {
+ kfree(sblob);
+ return -ENOMEM;
+ }
+
+ mutex_init(&sblob->mtx);
+
+ filp->private_data = sblob;
+
+ return 0;
+}
+
+static ssize_t scmi_telemetry_dbg_shmti_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct scmi_telemetry_dbg_shmti *sblob = filp->private_data;
+
+ /* Dump on first read and again after each rewind to start pos */
+ guard(mutex)(&sblob->mtx);
+ if (!sblob->buf_sz || *ppos == 0) {
+ struct inode *ino = file_inode(filp);
+
+ memcpy_fromio(sblob->buf, sblob->shmti->base,
+ sblob->shmti->info.len);
+ sblob->buf_sz = sblob->shmti->info.len;
+ /* update inode timestamps */
+ inode_lock(ino);
+ file_update_time(filp);
+ inode_unlock(ino);
+ }
+
+ return simple_read_from_buffer(buf, count, ppos, sblob->buf, sblob->buf_sz);
+}
+
+static int scmi_telemetry_dbg_shmti_release(struct inode *inode, struct file *filp)
+{
+ struct scmi_telemetry_dbg_shmti *sblob = filp->private_data;
+
+ kvfree(sblob->buf);
+ kfree(sblob);
+
+ return 0;
+}
+
+static const struct file_operations scmi_telemetry_dbg_shmti_fops = {
+ .open = scmi_telemetry_dbg_shmti_open,
+ .release = scmi_telemetry_dbg_shmti_release,
+ .read = scmi_telemetry_dbg_shmti_read,
+ .llseek = generic_file_llseek,
+ .owner = THIS_MODULE,
+};
+
+static void scmi_telemetry_debugfs_initialize(struct telemetry_info *ti)
+{
+ const struct scmi_protocol_handle *ph = ti->ph;
+ struct dentry *top;
+
+ top = ph->hops->debugfs_proto_dentry_get(ph);
+ ti->shmti_top = debugfs_create_dir("shmtis", top);
+
+ for (unsigned int i = 0; i < ti->num_shmti; i++) {
+ char id[16];
+
+ snprintf(id, 16, "%u", ti->shmti[i].info.sid);
+ debugfs_create_file_size(id, 0444, ti->shmti_top, &ti->shmti[i],
+ &scmi_telemetry_dbg_shmti_fops,
+ ti->shmti[i].info.len);
+ }
+}
+
static int iter_shmti_update_state(struct scmi_iterator_state *st,
const void *response, void *priv)
{
@@ -1750,6 +1850,9 @@ static int scmi_telemetry_enumerate_shmti(struct telemetry_info *ti)
/* Expose the fully initialized SHMTI infos */
smp_store_release(&ti->info.base.num_shmtis, ti->num_shmti);
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_PROTOCOLS))
+ scmi_telemetry_debugfs_initialize(ti);
+
return devm_add_action_or_reset(ph->dev, scmi_telemetry_tdes_cleanup, ti);
}
--
2.54.0
next prev parent reply other threads:[~2026-11-24 19:51 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 19:48 [PATCH v17 00/34] Introduce SCMI Telemetry support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 01/34] firmware: arm_scmi: Harden iterators state parsing Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 02/34] [RFC] firmware: arm_scmi: Additional iterators consistency checks Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 03/34] firmware: arm_scmi: Make Clock attributes size deterministic Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 04/34] firmware: arm_scmi: Add centralized detection of truncated replies Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 05/34] firmware: arm_scmi: Introduce a dedicated SCMI Errors header Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 06/34] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 07/34] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 08/34] firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 09/34] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 10/34] include: trace: Add Telemetry trace events Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 11/34] firmware: arm_scmi: Add Telemetry basic attributes enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 12/34] firmware: arm_scmi: Add Telemetry resources enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 13/34] firmware: arm_scmi: Add Telemetry global update intervals enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 14/34] firmware: arm_scmi: Add Telemetry SHMTI areas enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 15/34] firmware: arm_scmi: Add Telemetry TDCF areas parsing support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 16/34] firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 17/34] firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 18/34] firmware: arm_scmi: Add Telemetry DEs configuration support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 19/34] firmware: arm_scmi: Add Telemetry global " Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 20/34] firmware: arm_scmi: Add Telemetry Single/Bulk DEs reads Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 21/34] firmware: arm_scmi: Add Telemetry boot-on support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 22/34] firmware: arm_scmi: Invoke proper protocol cleanup on failure Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 23/34] firmware: arm_scmi: Refactor protocol allocation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 24/34] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-11-24 19:48 ` Cristian Marussi [this message]
2026-11-24 19:48 ` [PATCH v17 26/34] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 27/34] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 28/34] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 29/34] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 30/34] firmware: arm_scmi: Enable autoloading for " Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 31/34] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 32/34] [RFC] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 33/34] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 34/34] [RFC] tools/testing/scmi: Add SCMI Telemetry testing tool 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=20261124194841.1147072-26-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=jonathan.cameron@oss.qualcomm.com \
--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
all inboxes | Powered by JetHome®