Skip to contentSkip to conversation

Introduce SCMI Telemetry support

PATCH Superseded Cristian Marussi 4 participants 94 messages Nov 9 – Nov 19 Page 2 of 2

Subsystems (6)

v15 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
author reviewer
#68 lore raw

PATCH v15 29/35 uapi: Add ARM SCMI Telemetry definitions

In reply to Cristian Marussi

Add a number of structures and ioctls definitions used by the ARM SCMI Telemetry protocol.

---
v14 --> v15
- a couple of clarification in doxygen
v11 --> v12
- fixed documentation around event lifetime cycle to align with the new implemented logic
v10 --> v11
- typos fixing and comments fixup
- more docs on BATCH IOCTLs and structures
- more docs on SHMTI_LIST
- more docs on EVENT_REGISTER
- more docs on GET_INTRVS upper bounds and zero-query
- more docs on BULK/SINGLE upper bounds and zero-query
v8 --> v9
- Simplified ABI related to _LIST IOCTL, substituting all custom container structures in favour of the usage of scmi_tlm_batch, i.e. dropping:
- scmi_tlm_des_list
- scmi_tlm_uuid_list
- scmi_tlm_grps_list
- scmi_tlm_shmtis_list
- Updated related _LIST documentation
v7 --> v8
- Fixes for some Sashiko issues on v7
- fix typos and wrong struct reference in SCMI_TLM_BATCH_READ
- move a couple of IOCTL to be _IOW
- add a few more comments on usage and behaviour of BATCH ops
v6 --> v7
- added per-DE UUID/SID/OFFS
- IOCTL EVENTS: generation counter
- generic BATCH support (scmi_tlm_batch)
- BATCH READ with perf-DE status
- BATCH DE GET/SET CONFIG
- added reserved fields for grow
- added more ABI features flags
- better Doxygen desciption for IN/OUT params
v5 --> v6
- Fixed interval exp to be __s32 as documented
- Using a more unique name for IOCTL MAGIC define
- Renamed a few IOCTLs to be consistent
- redefine primary UUID as an array of u8
- add GET_ABI_INFO to gather ABI version and instance info
- add RESET support
- fixed typos in kdoc
v4 --> v5
- Added more structure padding
- Removed frowned upon flexible array in favour of u64 pointers to external userspace provided buffer
- Added UAPI support to access SHMTIs from userspace
- Cleaned up Doxygen
v2 --> v3
- Change tstamp_exp tp ts_rate
- renamed num -> num_intervals in scmi_tlm_interval
- added padding in scmi_tlm_de_sample to avoid packing issues on 32bit
v1 --> v2
- Added proper __counted_by marks
- Fixed a few dox comments
- Renamed reserved[] fields to pad[]

---
 MAINTAINERS               |   1 +
 include/uapi/linux/scmi.h | 531 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 532 insertions(+)
 create mode 100644 include/uapi/linux/scmi.h
MAINTAINERS +1 -0
index 222b7fc2c3aa..bf34585711e8 100644
@@ -27341,6 +27341,7 @@ F:	drivers/reset/reset-scmi.c
 F:	include/linux/device-id/scmi.h
 F:	include/linux/sc[mp]i_protocol.h
 F:	include/trace/events/scmi.h
+F:	include/uapi/linux/scmi.h
 F:	include/uapi/linux/virtio_scmi.h
 
 SYSTEM CONTROL MANAGEMENT INTERFACE (SCMI) i.MX Extension Message Protocol drivers
include/uapi/linux/scmi.h new file +531 -0

531 lines not on this page · raw message

Signature · 1 line
2.54.0
#69 lore raw

Re: [PATCH v15 29/35] uapi: Add ARM SCMI Telemetry definitions

Quoted 36 lines · On Mon, 9 Nov 2026 09:12:15 +0000 Cristian Marussi <[email protected]>…

Add a number of structures and ioctls definitions used by the ARM SCMI Telemetry protocol.

---

---

include/uapi/linux/scmi.h new file +21 -0
new file mode 100644
index 000000000000..dd78220554a2
@@ -0,0 +1,531 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2026 ARM Ltd.
+ */
+#ifndef _UAPI_LINUX_SCMI_H
+#define _UAPI_LINUX_SCMI_H
+
+/*
+ * Userspace interface SCMI Telemetry
+ */
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+#define SCMI_TLM_ABI_VERSION_V1			1
+#define SCMI_TLM_CURRENT_ABI_VERSION		SCMI_TLM_ABI_VERSION_V1
+#define SCMI_TLM_DE_IMPL_UUID_SZ		16
+
+#define SCMI_TLM_SHMTI_ID_INVALID		0xFFFFFFFF
+
+/**

include/uapi/linux/scmi.h line 31

Quoted 10 lines
include/uapi/linux/scmi.h new file +10 -0
+ * struct scmi_tlm_abi_info - Basic information on the ABI/instance
+ *
+ * SCMI Telemetry characteristics like number of DEs, Groups, Intervals and
+ * SHMTIs are statically determined by the platform and do not change within
+ * one boot/session; they are reported here so that they can be used to properly
+ * size the requests on other IOCTLs, without having to discover dynamically
+ * those sizes by issuing a zero-sized IOCTL request at first.
+ *
+ * @size: sizeof this structure - IN
+ * @abi_version: ABI Version - OUT

I'm curious what the plan is for ABI versioning. Normally to have any hope of backwards compatibility it needs to be a negotiation between userspace and kernel (and then hardware if appropriate). Is there any route to do that?

include/uapi/linux/scmi.h line 40

Quoted 9 lines
include/uapi/linux/scmi.h new file +9 -0
+ * @abi_features: ABI capabilities bitmap - OUT
+ * @primary_de_impl_version: SCMI Telemetry DE implementation revision - OUT
+ * @num_des: Number of defined DEs - OUT
+ * @num_groups: Number of defined DEs groups - OUT
+ * @num_intervals: Number of available update intervals (instance-level) - OUT
+ * @num_shmtis: Number of discovered SHMTI areas - OUT
+ * @features: Instance specific SCMI feature-support bitmap - OUT
+ * @reserved: Some room for future expansion without the need to resize.
+ *	      Must be zero.

Why? I'd expect the input size to indicate what userspace supports. As such what use is this reserved padding?

Quoted 32 lines
include/uapi/linux/scmi.h new file +30 -0
+ *
+ * Used by:
+ *	RW - SCMI_TLM_GET_ABI_INFO
+ */
+struct scmi_tlm_abi_info {
+	__u32 size;
+	__u32 abi_version;
+	__u32 abi_features;
+#define SCMI_TLM_ABI_FEAT_RESET				(1 << 0)
+#define SCMI_TLM_ABI_FEAT_EVENT				(1 << 1)
+#define SCMI_TLM_ABI_FEAT_UUID_LIST			(1 << 2)
+#define SCMI_TLM_ABI_FEAT_BATCH_STATE			(1 << 3)
+#define SCMI_TLM_ABI_FEAT_BATCHED_CFG			(1 << 4)
+#define SCMI_TLM_ABI_FEAT_DE_TRACKING			(1 << 5)
+	__u8 primary_de_impl_version[SCMI_TLM_DE_IMPL_UUID_SZ];
+	__u32 num_des;
+	__u32 num_groups;
+	__u32 num_intervals;
+	__u32 num_shmtis;
+	__u32 features;
+#define SCMI_TLM_SCMI_SUPPORT_RESET			(1 << 0)
+#define SCMI_TLM_SCMI_SUPPORT_SINGLE_SAMPLE		(1 << 1)
+#define SCMI_TLM_SCMI_SUPPORT_GROUP_CONFIG		(1 << 2)
+#define SCMI_TLM_SCMI_SUPPORT_UPDATE_NOTIFICATION	(1 << 3)
+	__u64 reserved;
+};
+
 
 
+/**
+ * struct scmi_tlm_config  - Whole instance or group configuration
+ *

include/uapi/linux/scmi.h line 94

Quoted 10 lines
include/uapi/linux/scmi.h new file +10 -0
+ * @enable: Get/Set Telemetry enabled state for the whole instance or the
+ *	    group specified in @grp_id - IN/OUT
+ * @t_enable: Get/Set timestamp state for the group specified in @grp_id - IN/OUT
+ * @flags: Bitmask to represent special characteristics - IN
+ * @pad: Padding fields to enforce alignment
+ * @grp_id: Identifier of the target group upon which this configuration will
+ *	    be applied: ignored if not marked as a group in @flags - IN/OUT
+ * @active: Get/Set currently active update interval for the whole instance
+ *	    or the group specified in @grp_id - IN/OUT
+ * @reserved: Some room for future expansion. Must be zero.

I'd add a size field for this one too to make it easier to expand. Probably the same applies to all others.

Quoted 16 lines

+ *
+ * Used by:
+ * RW - SCMI_TLM_GET_CFG
+ * WO - SCMI_TLM_SET_CFG
+ */

include/uapi/linux/scmi.h new file +11 -0
+struct scmi_tlm_config {
+	__u8 enable;
+	__u8 t_enable;
+	__u8 flags;
+#define SCMI_TLM_CONFIG_GROUP		(1 << 0)
+#define SCMI_TLM_CONFIG_FLAGS		(SCMI_TLM_CONFIG_GROUP)
+#define SCMI_TLM_CONFIG_IS_GROUP(f)	((f) & SCMI_TLM_CONFIG_GROUP)
+	__u8 pad;
+	__u32 grp_id;
+	struct scmi_tlm_update_interval active;
+	__u64 reserved;

include/uapi/linux/scmi.h line 120

Quoted 10 lines
include/uapi/linux/scmi.h new file +10 -0
+};
+
+/**
+ * struct scmi_tlm_intervals  - Update intervals descriptor
+ *
+ * @grp_id: Identifier of the target group upon which this configuration
+ *	    will be applied: ignored if not marked as a group in @flags - IN
+ * @flags: Bitmask to represent special characteristics. When the interval
+ *	   is NOT marked as SCMI_TLM_INTERV_DISCRETE, @intervals will
+ *	   contain a triplet: min/max/step - OUT

I'd have a reference to this in the num_intervals text. What happens if the input only allows for two intervals?

Quoted 5 lines

+ * @pad: Padding fields to enforce alignment
+ * @num_intervals: Number of entries of @intervals. On input this represents the

+ *		   size of @intervals, while on output carries the effective
+ *		   number of entries filled-in.
+ *		   On input this has an upper-bound determined as:
author reviewer
#70 lore raw

PATCH v15 30/35 firmware: arm_scmi: Add System Telemetry driver

In reply to Cristian Marussi

Add an SCMI driver to allow enumeration, configuration and data collection of SCMI Telemetry data.

The driver exposes one character device for each found SCMI instance and a set of related IOCTLs can be used to enumerate, configure and collect Telemetry resources.

---
v14 --> v15
- reject config attempts and intervals query for groups that do not support per-group config
- harden/simplify batch helpers
- fix shmti mmap size check to include offset
- drop usage of sdev->dev in device_release
- simplify session_unsubscribe cleanup on exit/unbind
- added missing kref.h include
- expose TLM EVENTS capabilities ONLY IF CONFIG_EVENTFD
- mmap: check/clear also VM_EXEC VM_MAYWRITE VM_MAYEXEC
- reject non zero vm_pgoff
- drop usage of guard(srcu) to avoid races with put_device
v13 --> v14
- avoid double free on probe err path
- grab ctx and check if dead when mmapping an anon_fd
- move away from dead_mtx in favour of dead_srcu and extend srcu'ed section in ioctl handler
v12 --> v13
- pass back E2BIG from copy_struct_from_user to userspace
- remove a few redundant copy_from_user
- fix filedescriptor lifecycle: drop kref in favour of embedded cdev and use cdev_device_add. Rely on devm_protocol_get for proto_ops
- refactor EVENT session unsubscribe and check for aliveness
- use *alloc_objs
v11 --> v12
- added RCU deref access on UUIDs
- dropped needless copy_from_user on states_batch
- fixed double free on anon ids error path
- reworked eventfd handling using per-session tracking and cleanup on chardev last release
- properly free also ti->tsp on error path
- properly acquire/release sdev->dev via get/put_device
v10 --> v11
- make SCMI tlm_<N> devices 664 by default
- add 0-sized query support for all the NON _LIST remaining BATCH ops
- add 0-sized query support on GET_INTRVS
- add 0-sized query support on BULOK/SINGLE reads
v8 --> v9
- Fix some Sashiko reports on v8
- use kvmalloc/kvcalloc for all buffers with user/FW generated size
- add a proper upper bounds checks on IOCTL requests
- make SET_ALL_CFG carry on after a failure (reporting last error anyway)
- properly initialize some possibly unused stack vars
- refactor SHMTIs list processing and ANON fds allocation to avoid leaking fds by premature installing them into process.
- completely rework cdev and scmi_tlm_instance interactions and lifecycle and drop all devres allocation: reject fops on cdev after driver unbind and delay data structures freeing till the last reference has been dropped.
- reworked BATCH helpers to handle ZERO items requests (for IOCTL query)
- reworked all the _LIST IOCTLs to use scmi_tlm_batch as a container structure instead of custom structs
- add support for 0-items query pattern to all _LIST IOCTLs
v7 --> v8
- Fixes for some Sashiko issues on v7
- refactor batch handling into common batch init/fini routines
- use array_size to check for overflows
- explain cleanup logic of eventfd_ctx (xa_for_each)
- add a mutex to protect events_xa
- introduce per-IOCTL check on batch upper bounds
v6 --> v7
- fixed module_init errors paths
- introduced a check on FMODE to filter-out unprivleged writers
- added UUID list IOCTL
- added UUID/SID/OFFS tp GET/SET config IOCTLs
- added EVENT subscribe IOCTL
- modified BATCH READ with per-DE status
- added BATCHed mode for DE_CFG_SET/GET
- fix setting properly discrete interval flag
- new ABI feats flags\
- new SCMI feats flags
- new reserved checks
v5 --> v6
- drop hunam readable .read capabilities on chardev
- fill-up the new UAPI de_implementation version u8 array
- added compat_ioctl support
- fixed initialization of flags in scmi_tlm_to_uapi_base_info
- fix grp_id bounds check in scmi_tlm_grp_info_get_ioctl
- fix booleans
- fix SHMTI get list to loop on input params
- reworked bounds checks into:
- scmi_tlm_intervals_get_ioctl
- scmi_tlm_des_list_get_ioctl
- scmi_tlm_grp_list_get_ioctl
- scmi_tlm_grp_desc_get_ioctl
- renamed some READ ioctl to be consistent
- reject oversized mmap requests
- support new GET_ABI_INFO IOCTL
- support RESET IOCTL
- add a missing READ_ONCE() to rinfo get
- avoid gaps in the anon fds returned array needed by shmti mmap
- adding missing cdev_del on remove

---
 drivers/firmware/arm_scmi/Kconfig             |   10 +
 drivers/firmware/arm_scmi/Makefile            |    1 +
 .../firmware/arm_scmi/scmi_system_telemetry.c | 1788 +++++++++++++++++
 3 files changed, 1799 insertions(+)
 create mode 100644 drivers/firmware/arm_scmi/scmi_system_telemetry.c
drivers/firmware/arm_scmi/Kconfig +10 -0
index f506c4d1d96a..e7d8dd9fa907 100644
@@ -113,4 +113,14 @@ config ARM_SCMI_POWER_CONTROL
 	  called scmi_power_control. Note this may be needed early in boot to
 	  catch early shutdown/reboot SCMI requests.
 
+config ARM_SCMI_SYSTEM_TELEMETRY
+	tristate "SCMI System Telemetry driver"
+	depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF)
+	help
+	  This enables SCMI Systemn Telemetry support that allows userspace to
+	  retrieve ARM Telemetry data made available via SCMI.
+
+	  This driver can also be built as a module.  If so, the module will be
+	  called scmi_system_telemetry.
+
 endmenu
drivers/firmware/arm_scmi/Makefile +1 -0
index fe55b7aa0707..20f8d55840a5 100644
@@ -18,3 +18,4 @@ obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o
 obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o
 
 obj-$(CONFIG_ARM_SCMI_POWER_CONTROL) += scmi_power_control.o
+obj-$(CONFIG_ARM_SCMI_SYSTEM_TELEMETRY) += scmi_system_telemetry.o
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +1788 -0

1,788 lines not on this page · raw message

Signature · 1 line
2.54.0
#71 lore raw

Re: [PATCH v15 30/35] firmware: arm_scmi: Add System Telemetry driver

Quoted 8 lines · On Mon, 9 Nov 2026 09:12:16 +0000 Cristian Marussi <[email protected]>…

Add an SCMI driver to allow enumeration, configuration and data collection of SCMI Telemetry data.

The driver exposes one character device for each found SCMI instance and a set of related IOCTLs can be used to enumerate, configure and collect Telemetry resources.

Some comments inline. I'm not even going to pretend to be alert enough to claim this is a thorough review though.

Jonathan

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 945

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +4 -0
new file mode 100644
index 000000000000..185c8e646628
 
+static long scmi_tlm_des_batch_read_ioctl(const struct scmi_tlm_instance *ti,
+					  unsigned long arg)
+{
+	struct scmi_telemetry_de_sample *samples __free(kvfree) = NULL;

As near as possible to the constructor for an __free declarations.

drivers/firmware/arm_scmi/scmi_system_telemetry.c

Quoted 1 line
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +1 -0
+	int ret, *states __free(kvfree) = NULL;

Definitely don't mix __free and non __free declarations. Separate lines!

Quoted 37 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +37 -0
+	const struct scmi_telemetry_res_info *rinfo;
+	void __user *uptr = (void __user *)arg;
+	struct scmi_tlm_batch batch = {};
+	size_t batch_sz, states_sz;
+
+	rinfo = scmi_telemetry_res_info_get(ti->tsp);
+	ret = scmi_tlm_batch_initialize(uptr, &batch, sizeof(*samples),
+					rinfo->num_des, (void **)&samples,
+					&batch_sz, &states, &states_sz);
+	if (ret)
+		return ret;
+
+	for (int i = 0; i < batch.num_items; i++) {
+		int ret;
+
+		ret = ti->tsp->ops->de_data_read(ti->tsp->ph, &samples[i]);
+		if (ret) {
+			if (!states)
+				return ret;
+
+			states[i] = ret;
+			continue;
+		}
+	}
+
+	/* Return max batch size on zero query */
+	if (!batch.num_items)
+		batch.num_items = rinfo->num_des;
+
+	return scmi_tlm_batch_finalize(uptr, &batch, samples, states, batch_sz,
+				       states_sz);
+}
+
+static struct scmi_tlm_shmti_ctx *
+scmi_tlm_shmti_ctx_alloc(struct scmi_tlm_instance *ti,
+			 struct scmi_telemetry_shmti_info *shmti)
+{

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 993

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+	struct scmi_tlm_shmti_ctx *ctx;
+
+	ctx = kzalloc_obj(*ctx);
+	if (!ctx)
+		return ERR_PTR(-ENOMEM);
+
+	ctx->shmti = shmti;
+	kref_init(&ctx->ref);
+
+	/* Get hold of the Telemetry instance when returning anon_fds */

This bit of the code isn't returning anon_fds???

Quoted 18 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +17 -0
+	get_device(&ti->dev);
+	ctx->ti = ti;
+
+	return ctx;
+}
 
+
+static int scmi_tlm_shmti_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+	unsigned long npages, expect, needed, req;
+	struct scmi_tlm_shmti_ctx *ctx;
+	phys_addr_t base;
+	size_t map_sz;
+	int ret, idx;
+
+	if (vma->vm_pgoff)
+		return -EINVAL;
+

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1057

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+	if (vma->vm_flags & (VM_WRITE | VM_EXEC))
+		return -EPERM;
+
+	vm_flags_clear(vma, VM_MAYWRITE | VM_MAYEXEC);
+
+	/* Grab a ctx reference early on */
+	ctx = scmi_tlm_shmti_ctx_get(filp->private_data);
+	/*
+	 * Note that any ctx_put potentially release the device and
+	 * cleans the SRCU structure...no guards.

No guards is fine but maybe goto and a common cleanup block?

Quoted 51 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +50 -0
+	 */
+	idx = srcu_read_lock(&ctx->ti->dead_srcu);
+	if (READ_ONCE(ctx->ti->dead)) {
+		srcu_read_unlock(&ctx->ti->dead_srcu, idx);
+		scmi_tlm_shmti_ctx_put(ctx);
+		return -ENODEV;
+	}
+
+	needed = ctx->shmti->len + ctx->shmti->offset;
+	req = vma->vm_end - vma->vm_start;
+	if (req < needed) {
+		srcu_read_unlock(&ctx->ti->dead_srcu, idx);
+		scmi_tlm_shmti_ctx_put(ctx);
+		return -EINVAL;
+	}
+
+	/* Align & reject oversized requests */
+	base = ctx->shmti->phys & PAGE_MASK;
+	expect = DIV_ROUND_UP(needed, PAGE_SIZE);
+	npages = req >> PAGE_SHIFT;
+	if (npages > expect) {
+		srcu_read_unlock(&ctx->ti->dead_srcu, idx);
+		scmi_tlm_shmti_ctx_put(ctx);
+		return -EINVAL;
+	}
+
+	map_sz = PAGE_ALIGN(needed);
+	vma->vm_private_data = ctx;
+	vma->vm_ops = &scmi_tlm_shmti_vm_ops;
+	/* Set appropriate caching attributes */
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+	/* Map physical address range into user space */
+	ret = vm_iomap_memory(vma, base, map_sz);
+	if (ret) {
+		srcu_read_unlock(&ctx->ti->dead_srcu, idx);
+		scmi_tlm_shmti_ctx_put(ctx);
+		return ret;
+	}
+
+	srcu_read_unlock(&ctx->ti->dead_srcu, idx);
+
+	return 0;
+}
 
+static void
+scmi_tlm_allocate_anon_fds(struct scmi_tlm_instance *ti, unsigned int *num_shmtis,
+			   struct scmi_tlm_shmti_info *shinfo,
+			   struct file **filps)
+{
+	const struct scmi_telemetry_info *info = ti->info;

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1131

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+	struct device *dev = &ti->tsp->sdev->dev;
+	int idx = 0;
+
+	for (int i = 0; i < *num_shmtis; i++) {
+		struct scmi_telemetry_shmti_info *shmti = info->shmtis[i];
+		struct scmi_tlm_shmti_ctx *ctx;
+		struct file *filp;
+		int fd;
+
+		fd = get_unused_fd_flags(O_CLOEXEC);

Bit marginal, but perhaps some __free magic for this.

Quoted 7 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +7 -0
+		if (fd < 0) {
+			dev_err(dev, "Failed GET_UNUSED_FD for SID: %u\n",
+				shmti->sid);
+			continue;
+		}
+
+		ctx = scmi_tlm_shmti_ctx_alloc(ti, shmti);

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1148

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+		if (IS_ERR(ctx)) {
+			dev_err(dev, "Failed CTX_ALLOC for SID: %u\n", shmti->sid);
+			put_unused_fd(fd);
+			continue;
+		}
+
+		filp = anon_inode_getfile(SCMI_TLM_DRIVER, &scmi_tlm_shmti_fops,
+					  ctx, O_RDONLY | O_CLOEXEC);
+		if (IS_ERR(filp)) {
+			scmi_tlm_shmti_ctx_put(ctx);

Bit fiddlier but maybe some __free magic for ctx as well.

Quoted 13 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +13 -0
+			put_unused_fd(fd);
+			dev_err(dev, "Failed ANON GET_FILE for SID: %u\n",
+				shmti->sid);
+			continue;
+		}
+
+		shinfo[idx].sid = shmti->sid;
+		shinfo[idx].fd = fd;
+		shinfo[idx].len = shmti->len;
+		shinfo[idx].offset = shmti->offset;
+
+		filps[idx++] = filp;
+	}

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1189

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +9 -0
+
+	/* Return effective initialized items */
+	*num_shmtis = idx;
+}
 
+
+static long
+scmi_tlm_shmtis_list_get_ioctl(struct scmi_tlm_instance *ti, unsigned long arg)
+{
+	struct scmi_tlm_shmti_info *shinfo __free(kvfree) = NULL;

Move down to where it's constructed. cleanup.h talks about this.

Quoted 31 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +31 -0
+	unsigned int max_shmtis = ti->info->base.num_shmtis;
+	void __user *uptr = (void __user *)arg;
+	struct scmi_tlm_batch batch = {};
+	size_t batch_sz;
+	int ret;
+
+	ret = scmi_tlm_batch_initialize(uptr, &batch, sizeof(*shinfo), max_shmtis,
+					(void **)&shinfo, &batch_sz, NULL, NULL);
+	if (ret)
+		return ret;
+
+	if (batch.num_items == 0) {
+		batch.num_items = max_shmtis;
+
+		return scmi_tlm_batch_finalize(uptr, &batch, shinfo, NULL,
+					       batch_sz, 0);
+	}
+
+	struct file **filps __free(kfree) = kzalloc_objs(*filps, batch.num_items);
+	if (!filps)
+		return -ENOMEM;
+
+	/* Passing the array as a param avoids dancing with uptr->items */
+	scmi_tlm_allocate_anon_fds(ti, &batch.num_items, shinfo, filps);
+	ret = scmi_tlm_batch_finalize(uptr, &batch, shinfo, NULL, batch_sz, 0);
+	if (ret) {
+		scmi_tlm_anon_fds_free(batch.num_items, shinfo, filps);
+		return ret;
+	}
+
+	scmi_tlm_anon_fds_install(batch.num_items, shinfo, filps);

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1235

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +9 -0
+
+	return 0;
+}
 
+
+static long
+scmi_tlm_uuid_list_get_ioctl(const struct scmi_tlm_instance *ti,
+			     unsigned long arg)
+{
+	struct scmi_tlm_uuid *uuids __free(kvfree) = NULL;

Move this down next to where the constructor is. See cleanup.h guidance on why they should be together.

Quoted 85 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +85 -0
+	void __user *uptr = (void __user *)arg;
+	struct scmi_tlm_batch batch = {};
+	unsigned int num_uuids;
+	uuid_t **cur_uuids;
+	size_t batch_sz;
+	int ret;
+
+	/*
+	 * Note that UUID array can ONLY grow and it has NOT a known upper
+	 * bound, so it does not matter if by the time we grab the cur_uuids
+	 * via rcu_dereference() the array has grown in size and we end up
+	 * here reading a stale/incomplete set of UUIDs, we will simply
+	 * read the new UUIDs next-time: this simplifies allocation.
+	 */
+	num_uuids = smp_load_acquire(&ti->info->num_uuids);
+	ret = scmi_tlm_batch_initialize(uptr, &batch, sizeof(*uuids),
+					num_uuids, (void **)&uuids, &batch_sz,
+					NULL, NULL);
+	if (ret)
+		return ret;
+
+	rcu_read_lock();
+	cur_uuids = rcu_dereference(ti->info->uuids);
+	for (int j = 0; j < batch.num_items; j++)
+		export_uuid(uuids[j].bytes, cur_uuids[j]);
+	rcu_read_unlock();
+
+	/* Return max batch size on zero query */
+	if (!batch.num_items)
+		batch.num_items = num_uuids;
+
+	return scmi_tlm_batch_finalize(uptr, &batch, uuids, NULL, batch_sz, 0);
+}
+
+static int scmi_tlm_event_subscribe(struct scmi_tlm_instance *ti,
+				    struct scmi_tlm_event *evt, void *key)
+{
+	struct scmi_tlm_events_session *session;
+	struct scmi_tlm_registered_event *revt;
+	struct eventfd_ctx *ctx;
+	u32 cookie;
+	int ret;
+
+	scoped_guard(mutex, &ti->sessions_mtx) {
+		session = xa_load(&ti->sessions_xa, (unsigned long)key);
+		if (!session) {
+			/*
+			 * Initialize a new session on first call.
+			 * Once created successfully initialized sessions are
+			 * freed only on final release.
+			 */
+			session = kzalloc_obj(*session);
+			if (!session)
+				return -ENOMEM;
+
+			/* Initialize inner with proper flags to support xa_alloc */
+			xa_init_flags(&session->events_xa, XA_FLAGS_ALLOC);
+			mutex_init(&session->events_mtx);
+			ret = xa_insert(&ti->sessions_xa, (unsigned long)key,
+					session, GFP_KERNEL);
+			if (ret) {
+				xa_destroy(&session->events_xa);
+				kfree(session);
+				return ret;
+			}
+		}
+	}
+
+	ctx = eventfd_ctx_fdget(evt->efd);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	revt = kzalloc_obj(*revt);
+	if (!revt) {
+		eventfd_ctx_put(ctx);
+		return -ENOMEM;
+	}
+
+	guard(mutex)(&session->events_mtx);
+	revt->ctx = ctx;
+	revt->type = evt->type;
+	ret = xa_alloc(&session->events_xa, &cookie, revt,
+		       scmi_evt_xa_limit, GFP_KERNEL);
+	if (ret) {
+		eventfd_ctx_put(revt->ctx);

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1330

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+		kfree(revt);
+		return ret;
+	}
+
+	ret = ti->tsp->ops->event_subscribe(ti->tsp->ph, revt->type, revt->ctx);
+	if (ret) {
+		xa_erase(&session->events_xa, cookie);
+		eventfd_ctx_put(revt->ctx);
+		kfree(revt);
+		return ret;

Quite a bit of repetition in the error paths. Use a common goto block to clean up. For the guard stuff above, a helper is probably the easiest way to avoid mixing that with cleanup via gotos down here.

Quoted 68 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +67 -0
+	}
+
+	/* Return the allocated cookie */
+	evt->cookie = cookie;
+
+	/* Get hold of the instance */
+	get_device(&ti->dev);
+
+	return 0;
+}
 
+
+static long scmi_tlm_unlocked_ioctl(struct file *filp, unsigned int cmd,
+				    unsigned long arg)
+{
+	struct scmi_tlm_instance *ti = filp->private_data;
+	bool writable = filp->f_mode & FMODE_WRITE;
+
+	guard(srcu)(&ti->dead_srcu);
+	if (READ_ONCE(ti->dead))
+		return -ENODEV;
+
+	switch (cmd) {
+	case SCMI_TLM_GET_ABI_INFO:
+		return scmi_tlm_abi_info_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_CFG:
+		return scmi_tlm_config_get_ioctl(ti, arg);
+	case SCMI_TLM_SET_CFG:
+		if (writable)
+			return scmi_tlm_config_set_ioctl(ti, arg);
+		break;
+	case SCMI_TLM_GET_INTRVS:
+		return scmi_tlm_intervals_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_DE_CFG:
+		return scmi_tlm_de_config_get_ioctl(ti, arg);
+	case SCMI_TLM_SET_DE_CFG:
+		if (writable)
+			return scmi_tlm_de_config_set_ioctl(ti, arg);
+		break;
+	case SCMI_TLM_GET_DE_INFO:
+		return scmi_tlm_de_info_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_DE_LIST:
+		return scmi_tlm_des_list_get_ioctl(ti, arg);
+	case SCMI_TLM_DE_READ:
+		return scmi_tlm_de_value_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_ALL_CFG:
+		return scmi_tlm_all_de_config_get_ioctl(ti, arg);
+	case SCMI_TLM_SET_ALL_CFG:
+		if (writable)
+			return scmi_tlm_all_de_config_set_ioctl(ti, arg);
+		break;
+	case SCMI_TLM_GET_GRP_LIST:
+		return scmi_tlm_grps_list_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_GRP_INFO:
+		return scmi_tlm_grp_info_get_ioctl(ti, arg);
+	case SCMI_TLM_GET_GRP_DESC:
+		return scmi_tlm_grp_desc_get_ioctl(ti, arg);
+	case SCMI_TLM_SINGLE_READ:
+		return scmi_tlm_des_read_ioctl(ti, arg, true);
+	case SCMI_TLM_BULK_READ:
+		return scmi_tlm_des_read_ioctl(ti, arg, false);
+	case SCMI_TLM_BATCH_READ:
+		return scmi_tlm_des_batch_read_ioctl(ti, arg);
+	case SCMI_TLM_GET_SHMTI_LIST:
+		return scmi_tlm_shmtis_list_get_ioctl(ti, arg);
+	case SCMI_TLM_RESET:
+		if (writable)
+			return scmi_tlm_reset_ioctl(ti, arg);

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1482

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+		break;
+	case SCMI_TLM_GET_UUID_LIST:
+		return scmi_tlm_uuid_list_get_ioctl(ti, arg);
+	case SCMI_TLM_EVENT_SUBSCRIBE:
+		return scmi_tlm_event_subscribe_ioctl(ti, arg, filp);
+	default:
+		return -ENOTTY;
+	}
+
+	return -EPERM;

I'd just return this where you break above.
Seems little benefit in coming down here to do so given they are all error paths.

Quoted 68 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +67 -0
+}
 
+
+static int scmi_telemetry_probe(struct scmi_device *sdev)
+{
+	const struct scmi_handle *handle = sdev->handle;
+	struct scmi_protocol_handle *ph;
+	struct scmi_tlm_instance *ti;
+	unsigned int instance;
+	const void *ops;
+	int ret;
+
+	if (!handle)
+		return -ENODEV;
+
+	instance = handle->id;
+	if (instance >= SCMI_TLM_NUM_DEVS)
+		return -ENOSPC;
+
+	ops = handle->devm_protocol_get(sdev, sdev->protocol_id, &ph);
+	if (IS_ERR(ops))
+		return dev_err_probe(&sdev->dev, PTR_ERR(ops),
+				     "Cannot access protocol:0x%X\n",
+				     sdev->protocol_id);
+
+	ti = scmi_tlm_instance_init(sdev, ops, ph, instance);
+	if (IS_ERR(ti))
+		return PTR_ERR(ti);
+
+	/*
+	 * Setting the platform device as parent to enforce proper ordering
+	 * at shutdown and to avoid the need for explicit get/put_device
+	 */
+	ti->dev.parent = &sdev->dev;
+	ti->dev.devt = MKDEV(MAJOR(stlm_devt), MINOR(stlm_devt) + instance);
+	ti->dev.class = &stlm_class;
+	ti->dev.release = scmi_tlm_device_release;
+	device_initialize(&ti->dev);
+
+	ret = dev_set_name(&ti->dev, "tlm_%d", ti->id);
+	if (ret)
+		goto err_dev;
+
+	cdev_init(&ti->cdev, &stlm_fops);
+	ti->cdev.owner = THIS_MODULE;
+
+	ret = cdev_device_add(&ti->cdev, &ti->dev);
+	if (ret)
+		goto err_dev;
+
+	dev_set_drvdata(&sdev->dev, ti);
+
+	return 0;
+
+err_dev:
+	put_device(&ti->dev);
+
+	return ret;
+}
+
+static void scmi_telemetry_remove(struct scmi_device *sdev)
+{
+	struct scmi_tlm_events_session *session;
+	struct scmi_tlm_instance *ti;
+	unsigned long index;
+
+	ti = dev_get_drvdata(&sdev->dev);
+	if (!ti)

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1722

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+		return;
+
+	/* Stop ongoing opens and wait on in-flight operation to drain */
+	WRITE_ONCE(ti->dead, true);
+	synchronize_srcu(&ti->dead_srcu);
+
+	/* Inhibit future opens */
+	cdev_device_del(&ti->cdev, &ti->dev);
+	/*
+	 * Drop any residual session and related events if unbind happened whiel

while

Quoted 37 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +36 -0
+	 * some event fds were still open.
+	 */
+	mutex_lock(&ti->sessions_mtx);
+	xa_for_each(&ti->sessions_xa, index, session) {
+		xa_erase(&ti->sessions_xa, index);
+		/* Force any event unsubscribe...protocol is still alive */
+		scmi_tlm_events_session_unsubscribe(ti, session);
+	}
+	mutex_unlock(&ti->sessions_mtx);
+
+	put_device(&ti->dev);
+}
 
+
+static int __init scmi_telemetry_init(void)
+{
+	int ret;
+
+	ret = alloc_chrdev_region(&stlm_devt, 0, SCMI_TLM_NUM_DEVS,
+				  SCMI_TLM_DRIVER);
+	if (ret)
+		return ret;
+
+	ret = class_register(&stlm_class);
+	if (ret)
+		goto err_class;
+
+	ret = scmi_register(&scmi_telemetry_driver);
+	if (ret)
+		goto err_scmi;
+
+	return 0;
+
+err_scmi:
+	class_unregister(&stlm_class);
+
+err_class:

drivers/firmware/arm_scmi/scmi_system_telemetry.c line 1781

Quoted 10 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +10 -0
+	unregister_chrdev_region(stlm_devt, SCMI_TLM_NUM_DEVS);
+
+	return ret;
+}
+module_init(scmi_telemetry_init);
+
+static void __exit scmi_telemetry_exit(void)
+{
+	scmi_unregister(&scmi_telemetry_driver);
+	unregister_chrdev_region(stlm_devt, SCMI_TLM_NUM_DEVS);

This should be reverse order of init == same as error paths at the end of init. Anything else needs some comments on why.

Quoted 3 lines
drivers/firmware/arm_scmi/scmi_system_telemetry.c new file +3 -0
+	class_unregister(&stlm_class);
+}
+module_exit(scmi_telemetry_exit);
author reviewer
#72 lore raw

PATCH v15 31/35 firmware: arm_scmi: Enable autoloading for System Telemetry driver

In reply to Cristian Marussi

Add the SCMI System Telemetry driver and related protocols to the list of standard protocols whosw devices are created automatically, so enabling module autoloading.

---
 drivers/firmware/arm_scmi/bus.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/arm_scmi/bus.c +1 -0
index 25197197db8e..32002fd9d843 100644
@@ -546,6 +546,7 @@ static const struct scmi_device_id scmi_std_id_table[] = {
 	{ SCMI_PROTOCOL_POWERCAP, "powercap" },
 	{ SCMI_PROTOCOL_PINCTRL, "pinctrl" },
 	{ SCMI_PROTOCOL_PINCTRL, "pinctrl-imx" },
+	{ SCMI_PROTOCOL_TELEMETRY, "telemetry" },
 	{ },
 };
 
Signature · 1 line
2.54.0
author reviewer
#73 lore raw

PATCH v15 32/35 docs: ioctl-number: Add SCMI Ioctls

In reply to Cristian Marussi

Add SCMI Subsystem IOCTLs numbers

---
 Documentation/userspace-api/ioctl/ioctl-number.rst | 1 +
 1 file changed, 1 insertion(+)
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -0
index dbe462040999..53e970fc750e 100644
@@ -403,6 +403,7 @@ Code  Seq#    Include File                                             Comments
 0xEC  00-01  linux/platform_data/cros_ec_chardev.h                     ChromeOS EC driver
 0xEE  00-09  uapi/linux/pfrut.h                                        Platform Firmware Runtime Update and Telemetry
 0xEF  00-0F  uapi/linux/ntfs.h                                         NTFS
+0xF1  00-FF  uapi/linux/scmi.h					       ARM SCMI Subsystem
 0xF3  00-3F  drivers/usb/misc/sisusbvga/sisusb.h                       sisfb (in development)
                                                                        <mailto:[email protected]>
 0xF6  all                                                              LTTng Linux Trace Toolkit Next Generation
Signature · 1 line
2.54.0
author reviewer
#74 lore raw

PATCH v15 33/35 Documentation: Add SCMI System Telemetry documentation

In reply to Cristian Marussi

Document ARM SCMI Telemetry IOCTLs interface.

---
 Documentation/userspace-api/index.rst |   1 +
 Documentation/userspace-api/stlm.rst  | 590 ++++++++++++++++++++++++++
 2 files changed, 591 insertions(+)
 create mode 100644 Documentation/userspace-api/stlm.rst
Documentation/userspace-api/index.rst +1 -0
index a68b1bea57a8..22daa7ebf78e 100644
@@ -54,6 +54,7 @@ Devices and I/O
    dcdbas
    vduse
    isapnp
+   stlm
 
 Everything else
 ===============
Documentation/userspace-api/stlm.rst new file +590 -0

590 lines not on this page · raw message

Signature · 1 line
2.54.0
#75 lore raw

Re: [PATCH v15 33/35] Documentation: Add SCMI System Telemetry documentation

Quoted 4 lines · On Mon, 9 Nov 2026 09:12:19 +0000 Cristian Marussi <[email protected]>…

Document ARM SCMI Telemetry IOCTLs interface.

Various trivial things inline. For example code it is always a balance between writing production quality stuff that has lots of info that doesn't matter for docs, and over simplifying to the point of ending with random broken code.

Here there is enough error handling to expect it to work but there are cases where it doesn't. So tidy those up for consistency.

Jonathan

Quoted 26 lines
---
 Documentation/userspace-api/index.rst |   1 +
 Documentation/userspace-api/stlm.rst  | 590 ++++++++++++++++++++++++++
 2 files changed, 591 insertions(+)
 create mode 100644 Documentation/userspace-api/stlm.rst
Documentation/userspace-api/index.rst +1 -0
index a68b1bea57a8..22daa7ebf78e 100644
@@ -54,6 +54,7 @@ Devices and I/O
    dcdbas
    vduse
    isapnp
+   stlm
 
 Everything else
 ===============
Documentation/userspace-api/stlm.rst new file +2 -0
new file mode 100644
index 000000000000..ea05a10d314f
@@ -0,0 +1,590 @@
+.. SPDX-License-Identifier: GPL-2.0
+

Documentation/userspace-api/stlm.rst line 12

Quoted 10 lines
Documentation/userspace-api/stlm.rst new file +10 -0
+=======================================
+STLM - ARM SCMI Telemetry Userspace API
+=======================================
+
+.. contents::
+
+Overview
+========
+
+ARM SCMI is a System and Configuration Management protocol, based on a

Wrap docs to 80 chars.

Quoted 28 lines
Documentation/userspace-api/stlm.rst new file +27 -0
+client-server model, that defines a number of messages that allows a
+client/agent like Linux to discover, configure and make use of services
+provided by the server/platform firmware.
 
+
+Enumerating DataEvents
+======================
+
+SCMI_TLM_GET_DE_LIST returns the DataEvent descriptors exposed by the
+Telemetery instance. Users can size the request from
+SCMI_TLM_GET_ABI_INFO.num_des or by issuing a zero-sized batch query.
+
+Example
+-------
+
+.. code-block:: c
+
+	int main(int argc, char **argv)
+	{
+		struct scmi_tlm_abi_info abi = {};
+		struct scmi_tlm_batch batch = {};
+		struct scmi_tlm_de_info *des;
+		int fd, ret, i;
+
+		fd = open("/dev/scmi/tlm_0", O_RDONLY | O_CLOEXEC);
+		if (fd < 0)
+			return fd;
+

Documentation/userspace-api/stlm.rst line 85

Quoted 10 lines
Documentation/userspace-api/stlm.rst new file +10 -0
+		abi.size = sizeof(abi);
+		ret = ioctl(fd, SCMI_TLM_GET_ABI_INFO, &abi);
+		if (ret) {
+			close(fd);
+			return ret;
+		}
+
+		if (!abi.num_des) {
+			close(fd);
+			return ret;

returns success. Make that explicit with return 0;

Quoted 62 lines
Documentation/userspace-api/stlm.rst new file +62 -0
+		}
+
+		des = calloc(abi.num_des, sizeof(*des));
+		if (!des) {
+			close(fd);
+			return -ENOMEM;
+		}
+
+		batch.num_items = abi.num_des;
+		batch.item_sz = sizeof(*des);
+		batch.items = (unsigned long)des;
+
+		ret = ioctl(fd, SCMI_TLM_GET_DE_LIST, &batch);
+		if (ret) {
+			free(des);
+			close(fd);
+			return ret;
+		}
+
+		for (i = 0; i < batch.num_items; i++) {
+			printf("0x%08x: %.*s size:%u type:%u unit:%u", des[i].id, 16,
+				des[i].name, des[i].data_sz, des[i].type, des[i].unit);
+
+			if (des[i].flags & SCMI_TLM_DEINFO_GROUP)
+				printf("group:%u", des[i].grp_id);
+
+			printf("\n");
+		}
+
+		return 0;
+	}
+
+Enumerating Groups
+==================
+
+SCMI_TLM_GET_GRP_LIST returns the groups exposed by the Telemetry Instance.
+Group descriptors report; the group ID, the number of DEs in the group, and
+the number of update intervals supported by the group.
+
+SCMI_TLM_GET_GRP_DESC can then be used to retrieve the DE IDs of a specific
+group.
+
+Example
+-------
+
+.. code-block:: c
+
+	int main(int argc, char **argv)
+	{
+		struct scmi_tlm_abi_info abi = {};
+		struct scmi_tlm_batch batch = {};
+		struct scmi_tlm_grp_info *groups;
+		int fd, ret, i;
+
+		fd = open("/dev/scmi/tlm_0", O_RDONLY | O_CLOEXEC);
+		if (fd < 0)
+			return fd;
+
+		abi.size = sizeof(abi);
+		ret = ioctl(fd, SCMI_TLM_GET_ABI_INFO, &abi);
+
+		if (ret){

Documentation/userspace-api/stlm.rst line 157

Quoted 10 lines
Documentation/userspace-api/stlm.rst new file +10 -0
+			free(groups);
+			close(fd);
+			return ret;
+		}
+
+		if (!abi.num_groups) {
+			ret = 0;
+			free(groups);
+			close(fd);
+			return ret;
			return 0;

rather than setting ret.

Documentation/userspace-api/stlm.rst line 164

Quoted 7 lines
Documentation/userspace-api/stlm.rst new file +7 -0
+		}
+
+		groups = calloc(abi.num_groups, sizeof(*groups));
+		if (!groups) {
+			ret = -ENOMEM;
+			free(groups);
+			close(fd);

return an error rather than carrying on.

Quoted 20 lines
Documentation/userspace-api/stlm.rst new file +20 -0
+		}
+
+		batch.num_items = abi.num_groups;
+		batch.item_sz = sizeof(*groups);
+		batch.items = (unsigned long)groups;
+
+		ret = ioctl(fd, SCMI_TLM_GET_GRP_LIST, &batch);
+		if (ret) {
+			free(groups);
+			close(fd);
+			return ret;
+		}
+
+		for (i = 0; i < batch.num_items; i++) {
+			struct scmi_tlm_grp_desc desc = {};
+			__u32 *de_ids;
+			int j;
+
+			printf("group:%u des:%u intervals:%u\n", groups[i].grp_id,
+				groups[i].num_des, groups[i].num_intervals);

Documentation/userspace-api/stlm.rst line 194

Quoted 10 lines
Documentation/userspace-api/stlm.rst new file +10 -0
+
+			if (!groups[i].num_des)
+				continue;
+
+			de_ids = calloc(groups[i].num_des, sizeof(*de_ids));
+			if (!de_ids) {
+				ret = -ENOMEM;
+				free(groups);
+				close(fd);
+				return de_ids;
				return -ENOMEM;

I'm curious if sashiko noticed your docs and spotted this stuff? I guess it might be conservative as often such examples in docs skip error handling.

Quoted 26 lines
Documentation/userspace-api/stlm.rst new file +26 -0
+			}
+
+			desc.grp_id = groups[i].grp_id;
+			desc.num_des = groups[i].num_des;
+			desc.composing_des = (unsigned long)de_ids;
+
+			ret = ioctl(fd, SCMI_TLM_GET_GRP_DESC, &desc);
+			if (ret) {
+				free(de_ids);
+				free(groups);
+				close(fd);
+				return ret;
+			}
+
+			printf("DataEvents:");
+			for (j = 0; j < desc.num_des; j++)
+				printf(" 0x%08x", de_ids[j]);
+			printf("\n");
+
+			free(de_ids);
+		}
+
+		free(groups);
+		close(fd);
+		return 0;
+	}

...

author reviewer
#76 lore raw

RFC PATCH v15 34/35 kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases

In reply to Cristian Marussi

From: Philip Radford <[email protected]>

Add support to test SCMI Telemetry UAPI compliance testcases.

---
 tools/testing/selftests/arm64/Makefile        |    2 +-
 tools/testing/selftests/arm64/scmi/Makefile   |   12 +
 tools/testing/selftests/arm64/scmi/config     |    2 +
 .../arm64/scmi/test_scmi_telemetry_uapi.c     | 1810 +++++++++++++++++
 4 files changed, 1825 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/arm64/scmi/Makefile
 create mode 100644 tools/testing/selftests/arm64/scmi/config
 create mode 100644 tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c
tools/testing/selftests/arm64/Makefile +1 -1
index e456f3b62fa1..f3beae2ae164 100644
@@ -4,7 +4,7 @@
 ARCH ?= $(shell uname -m 2>/dev/null || echo not)
 
 ifneq (,$(filter $(ARCH),aarch64 arm64))
-ARM64_SUBTARGETS ?= tags signal pauth fp mte bti abi gcs
+ARM64_SUBTARGETS ?= tags signal pauth fp mte bti abi gcs scmi
 else
 ARM64_SUBTARGETS :=
 endif
tools/testing/selftests/arm64/scmi/Makefile new file +12 -0
new file mode 100644
index 000000000000..3d9576c7a3e8
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2026 ARM Limited
+
+# Additional include paths needed by kselftest.h and local headers
+CFLAGS += -std=gnu99 -I.
+LDFLAGS += -static
+
+# Generated binaries to be installed by top KSFT script
+TEST_GEN_PROGS := test_scmi_telemetry_uapi
+
+# Include KSFT lib.mk.
+include ../../lib.mk
tools/testing/selftests/arm64/scmi/config new file +2 -0
new file mode 100644
index 000000000000..63cd7e67ab55
@@ -0,0 +1,2 @@
+CONFIG_ARM_SCMI_SYSTEM_TELEMETRY=y
+
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +1810 -0

1,810 lines not on this page · raw message

Signature · 1 line
2.54.0
#77 lore raw

Re: [PATCH v15 34/35] [RFC] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases

Quoted 3 lines · On Mon, 9 Nov 2026 09:12:20 +0000 Cristian Marussi <[email protected]>…

From: Philip Radford <[email protected]>

Add support to test SCMI Telemetry UAPI compliance testcases.

I'm thoroughly in favor of self tests, but rather less 1825 line patches! I'd figure out an initial subset to propose of a few 100 lines then build the rest up. Possibly just have a minimal set as part of first series.

I took a look at the code style for a few as not going to dig into whether they are all functionally correct.
Given I'm assuming this LLM output, and those are pretty good at this sort of test authoring I'm assuming they are probably ok.

Jonathan

tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c

Quoted 18 lines
tools/testing/selftests/arm64/scmi/config new file +2 -0
new file mode 100644
index 000000000000..63cd7e67ab55
@@ -0,0 +1,2 @@
+CONFIG_ARM_SCMI_SYSTEM_TELEMETRY=y
+
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +0 -0
new file mode 100644
index 000000000000..24a8170a4380

...
I commented on style for a few near the end.

tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c line 1599

Quoted 7 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +7 -0
+
+TEST_F(stlm, tlm_get_uuid_list)
+{
+	struct scmi_tlm_batch batch = {};
+	struct scmi_tlm_uuid *uuids;
+	int i, j;
+	bool nonzero;

No other reason for order? Go with reverse xmas tree.

Quoted 14 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +14 -0
+
+	if ((ksft_session.info.abi_features & SCMI_TLM_ABI_FEAT_UUID_LIST) == 0)
+		SKIP(return, "UUID list not supported");
+
+	batch.num_items = 0;
+	batch.item_sz = sizeof(*uuids);
+
+	ASSERT_EQ(0, ioctl(self->fd, SCMI_TLM_GET_UUID_LIST, &batch));
+
+	if (!batch.num_items)
+		SKIP(return, "no UUIDs available");
+
+	uuids = malloc(sizeof(*uuids) * batch.num_items);
+	ASSERT_NE(NULL, uuids);

tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c line 1623

Quoted 10 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +10 -0
+	bzero(uuids, sizeof(*uuids) * batch.num_items);
+
+	batch.items = (__u64)uuids;
+
+	ASSERT_EQ(0, ioctl(self->fd, SCMI_TLM_GET_UUID_LIST, &batch));
+	ASSERT_GT(batch.num_items, 0);
+	ASSERT_EQ(sizeof(*uuids), batch.item_sz);
+	ASSERT_EQ(0, batch.reserved);
+
+	for (i = 0; i < batch.num_items; i++) {
	for (int i = 0; ... 

tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c line 1626

Quoted 3 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +3 -0
+		nonzero = false;
+
+		for (j = 0; j < SCMI_TLM_DE_IMPL_UUID_SZ; j++) {
		for (int j = 0; j < ...
Quoted 19 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +19 -0
+			if (uuids[i].bytes[j]) {
+				nonzero = true;
+				break;
+			}
+		}
+
+		EXPECT_TRUE(nonzero);
+
+		TH_LOG("SCMI_TLM_GET_UUID_LIST - [%d] %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+		       i, uuids[i].bytes[0], uuids[i].bytes[1],
+		       uuids[i].bytes[2], uuids[i].bytes[3],
+		       uuids[i].bytes[4], uuids[i].bytes[5],
+		       uuids[i].bytes[6], uuids[i].bytes[7],
+		       uuids[i].bytes[8], uuids[i].bytes[9],
+		       uuids[i].bytes[10], uuids[i].bytes[11],
+		       uuids[i].bytes[12], uuids[i].bytes[13],
+		       uuids[i].bytes[14], uuids[i].bytes[15]);
+	}
+

tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c line 1678

Quoted 10 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +9 -0
+	free(uuids);
+}
 
+TEST_F(stlm, tlm_get_uuid_list_bad_items_ptr)
+{
+	struct scmi_tlm_batch batch = {};
+
+	if ((ksft_session.info.abi_features & SCMI_TLM_ABI_FEAT_UUID_LIST) == 0)
+		SKIP(return, "UUID list not supported");
+

Where possible I'd assign structures with

	batch = (struct scmi_tlm_batch) {
		.num_items = 1,
		.items_sz = sizeof(struct scmi_tlm_uid),
		.items = 0, //Invalid pointer
	};

as that avoids having to zero explicitly and tends to end up more readable than a wall of separate values being set in the same structure.

Quoted 7 lines
tools/testing/selftests/arm64/scmi/test_scmi_telemetry_uapi.c new file +7 -0
+	batch.num_items = 1;
+	batch.item_sz = sizeof(struct scmi_tlm_uuid);
+	batch.items = 0;
+
+	ASSERT_EQ(-1, ioctl(self->fd, SCMI_TLM_GET_UUID_LIST, &batch));
+	EXPECT_EQ(EFAULT, errno);
+}
author reviewer
#78 lore raw

RFC PATCH v15 35/35 tools/testing/scmi: Add SCMI Telemetry testing tool

In reply to Cristian Marussi

Add a testing tool that exercises the SCMI ioctls UAPI interface: as of now the tool simply queries the initial state of the SCMI Telemetry subsystem, tries to enable all the existent Data Events and dumps all the Telemetry data.

---
v14 --> v15
- add lazy enumeration on info
- add des info/data cmdline options
- des info/data separation
- add SIGTERM handling
- use hex to dump OFFS
v13 -->v14
- fix mmap/munmap calls
- add proper NULL checks around failed enumerations
- harden cmd line parsing and report errors
v12 --> v13
- misc fixes on alloc/free
- add single DE dump capability to get info/cfg/data
- add SHMTIs decoder (by LLM)
- fix mmap len/offset call to account for bigger pages and offset
- fixed SPDX header
- added to MAINTAINERS file
v11 --> v12
- renamed command helpers
- reviewed all internal/external error codes handling
- fixed dump_shmti read loop
- fixed shmti_check end address calculation
- fixed batch read boundary checks
- fixed group indexing
v10 --> v11
- add query for ALL new 0-sized commands: GET_INTRVS/BULK/SINGLE
v8 --> v9
- move to new _LIST IOCTLs support based on scmi_tlm_batch container
- add a "query" command to issue 0-items IOCTLs requests
v7 -> v8
- add monitor detached option
v6 --> v7
- added monitor command for events
- using and exposing DE's UUID/SID/OFFSET
- use BATCH READ with status
- use BATCH DE CONFIG GET/SET
- use new ABI/SCMI feats flags
v5 --> v6
- carry-on on error if feats NOT supported
- build BATCH_READ with enumerated values
- new UAPI naming
- reworked UUID print
- added info/shmti interactive cmds
- added cfg/single/bulk/batch interactive cmds
- added reset
- added tlm enable
- using new GET_ABI_INFO
- moved DE_READ per-de sampling away from get_state
v4 --> v5
- changes to adapt to new chardev/IOCTLs ABI
- change IOCTLs param to avoid flexible arrays
- added SHMTIs mmap dump
v3 --> v4
- added generation file support

---
 MAINTAINERS                      |    1 +
 tools/testing/scmi/Makefile      |   25 +
 tools/testing/scmi/stlm.c        | 1692 ++++++++++++++++++++++++++++++
 tools/testing/scmi/stlm_decode.c |  252 +++++
 tools/testing/scmi/stlm_decode.h |    7 +
 5 files changed, 1977 insertions(+)
 create mode 100644 tools/testing/scmi/Makefile
 create mode 100644 tools/testing/scmi/stlm.c
 create mode 100644 tools/testing/scmi/stlm_decode.c
 create mode 100644 tools/testing/scmi/stlm_decode.h
MAINTAINERS +1 -0
index bf34585711e8..18209a66d755 100644
@@ -27343,6 +27343,7 @@ F:	include/linux/sc[mp]i_protocol.h
 F:	include/trace/events/scmi.h
 F:	include/uapi/linux/scmi.h
 F:	include/uapi/linux/virtio_scmi.h
+F:	tools/testing/scmi/
 
 SYSTEM CONTROL MANAGEMENT INTERFACE (SCMI) i.MX Extension Message Protocol drivers
 M:	Peng Fan <[email protected]>
tools/testing/scmi/Makefile new file +25 -0
new file mode 100644
index 000000000000..2d4f4e630a1b
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+CC?=$(CROSS_COMPILE)gcc
+OBJS = stlm.o stlm_decode.o
+
+CFLAGS=-Wall -static -std=gnu11 -I ../../../include/uapi/
+ifneq ($(DEBUG), )
+	CFLAGS+=-O0 -g -ggdb
+else
+	CFLAGS+=-static
+endif
+
+all: stlm
+
+stlm: $(OBJS)
+	$(CC) $(CFLAGS) $^ -o $@
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c $<
+
+clean:
+	rm -f *.o
+	rm -f stlm
+
+.PHONY: clean
tools/testing/scmi/stlm.c new file +1692 -0

1,692 lines not on this page · raw message

tools/testing/scmi/stlm_decode.c new file +252 -0

252 lines not on this page · raw message

tools/testing/scmi/stlm_decode.h new file +7 -0
new file mode 100644
index 000000000000..740d1528d1f4
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __STLM_DECODE_H
+#define __STLM_DECODE_H
+
+int tdcf_decode(const void *buf, size_t len);
+
+#endif
Signature · 1 line
2.54.0
#79 lore raw

Re: [PATCH v15 35/35] [RFC] tools/testing/scmi: Add SCMI Telemetry testing tool

Quoted 6 lines · On Mon, 9 Nov 2026 09:12:21 +0000 Cristian Marussi <[email protected]>…

Add a testing tool that exercises the SCMI ioctls UAPI interface: as of now the tool simply queries the initial state of the SCMI Telemetry subsystem, tries to enable all the existent Data Events and dumps all the Telemetry data.

Test tools need breaking up into bite sized patches too! Perhaps a little easier to read than kernel code, but you aren't generally going to get great review on a 2000 line ish single patch. I'd be tempted to do this a bit like we do PMUs vs perf. Separate series, often posted before the driver merges but not really considered for merge until afterwards.

Anyhow, enough telemetry for me for now so not going to review this yet.

Jonathan

#80 lore raw
In reply to Cristian Marussi
Quoted 3 lines

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

Hi Cristian,

So, the main issue here is pretty much summarized by:

 28 files changed, 12801 insertions(+), 99 deletions(-)

(obviously there are tests etc, but it's still > 10k lines)

There are relatively few reviewers who would even consider taking that on. I foolishly thought it wouldn't be too bad (and I review a lot of code). By about 3/4 of the way though, probably much earlier, I know the quality of review went down considerably. Honestly it was probably a waste of time continuing but I'm stubborn like that.

So, unless you have a path to bribing or sweet talking various folk to deal with reviewing this with each having to set aside multiple days to do it, likely repeating for a couple of versions yet, I think you've got to figure out out how to make the first patch set more manageable. Probably don't split it up as much as the mpam or CCA folk have had to, but you have a lot of colleagues who are experiencing the same problem at the moment. They may be able to advise.

So it would be nice if what was in that first patch set was 'functional' but I don't think it needs to function on every systems or support more than an absolutely minimal feature set. Just fail to probe when you see something that isn't supported by that minimal set if that means the thing won't be functional.

Once that's in place, over a couple of additional patch sets you can get to everything you have here.

So what if you choose one data path (shmti perhaps), no notifications, events, maybe even simplify to one of the readback paths. Maybe even drop event groups initially.
Possibly even drop timestamps. Definitely drop things like boot-on support and debugfs (unless you are using that as a cheeky 'functional' test ahead of the main userspace interface.

How much would that slim things down? It doesn't even have to be useful, just testable. Realistically I think the hope of getting enough review doubles if you can halve the size of what you are asking people to look at.

Anyhow, gut feeling only but the code felt like it was in a much better state than some of the versions I've looked at in the past, so I think the game is now how to get it over the line!

Thanks,

Jonathan

Quoted 78 lines

In a nutshell, the SCMI Telemetry protocol allows an agent to discover at runtime the set of Telemetry Data Events (DEs) available on a specific platform and provides the means to configure the set of DEs that a user is interested into, while reading them back using the collection method that is deeemed more suitable for the usecase at hand. (...amongst the various possible collection methods allowed by SCMI specification)

Without delving into the gory details of the whole SCMI Telemetry protocol let's just say that the SCMI platform/server firmware advertises a number of Telemetry Data Events, each one identified by a 32bit unique ID, and an SCMI agent/client, like Linux, can discover them and read back at will the associated data value in a number of ways.

Data collection is mainly intended to happen on demand via shared memory areas exposed by the platform firmware, discovered dynamically via SCMI Telemetry and accessed by Linux on-demand, but some DE can also be reported via SCMI Notifications asynchronous messages or via direct dedicated FastChannels (another kind of SCMI memory based access): all of this underlying mechanism is anyway hidden to the user since it is mediated by the kernel driver which will return the proper data value when queried.

Anyway, the set of well-known architected DE IDs defined by the spec is limited to a dozen IDs, which means that the vast majority of DE IDs are customizable per-platform: as a consequence, though, the same ID, say '0x1234', could represent completely different things on different systems.

Precise definitions and semantic of such custom Data Event IDs are out of the scope of the SCMI Telemetry specification and of this implementation:
they are supposed to be provided using some kind of JSON-like description file that will have to be consumed by a userspace tool which would be finally in charge of making sense of the set of available DEs.

IOW, in turn, this means that even though the DEs enumerated via SCMI come with some sort of topological and qualitative description provided by the protocol (like unit of measurements, name, topology info etc), kernel-wise we CANNOT be completely sure of "what is what" without being fed-back some sort of information about the DEs by the afore mentioned userspace tool.

For these reasons, currently this series does NOT attempt to register any of these DEs with any of the usual in-kernel subsystems (like HWMON, IIO, PERF etc), simply because we cannot be sure which DE is suitable, or even desirable, for a given subsystem. This also means there are NO in-kernel users of these Telemetry data events as of now.

So, while we do not exclude, for the future, to feed/register some of the discovered DEs to/with some of the above mentioned Kernel subsystems, as of now we have ONLY modeled a custom userspace API to make SCMI Telemetry available to userspace tools.

With V5 we adopted a pure chardev/IOCTL ABI approach, refining the IOCTL based interface already present with the previous FS-based ABI.

INTERFACES

For each discovered SCMI Instance a character device named tlm_<N> is created under /dev/scmi/ subtree.

The IOCTL interface described at 'include/uapi/linux/scmi.h' is made available to enumerate and configure Telemetry resources: Telemetry data can be collected using a few different IOCTls, depending on the required granularity.

Alternatively it is possible to obtain a list of the file descriptors referencing directly the underlying SCMI Telemetry SHMTI memory areas and implement in user space an SCMI Telemetry parser accessing directly the SHMTI, while staying in compliance with the SCMI TDCF format.

NOTE THAT from v3 onwards the firmware interface level NOW supports ONLY the latest SCMI v4.0 specification [0].

Based on V7.4-rc2, tested on an emulated setup and AGI HW.

This series is available also at [1].

If you still reading...any feedback welcome :P

Thanks,
Cristian

#81 lore raw

Hi Jonathan,

Quoted 11 lines · Jonathan Cameron
Quoted 3 lines

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

Hi Cristian,

So, the main issue here is pretty much summarized by:

 28 files changed, 12801 insertions(+), 99 deletions(-)

(obviously there are tests etc, but it's still > 10k lines)

Completely agreed and every time I want to review this, its just takes less than 10s to deprioritise this just based on the size.

Quoted 1 line

There are relatively few reviewers who would even consider taking that on.

And you are definitely one of them. Thanks for the patience and the review you have done so far.

Quoted 5 lines

I foolishly thought it wouldn't be too bad (and I review a lot of code). By about 3/4 of the way though, probably much earlier, I know the quality of review went down considerably. Honestly it was probably a waste of time continuing but I'm stubborn like that.

Much appreciated, please continue to be like that 😉.

Quoted 8 lines

So, unless you have a path to bribing or sweet talking various folk to deal with reviewing this with each having to set aside multiple days to do it, likely repeating for a couple of versions yet, I think you've got to figure out out how to make the first patch set more manageable. Probably don't split it up as much as the mpam or CCA folk have had to, but you have a lot of colleagues who are experiencing the same problem at the moment. They may be able to advise.

Quoted 6 lines

So it would be nice if what was in that first patch set was 'functional' but I don't think it needs to function on every systems or support more than an absolutely minimal feature set. Just fail to probe when you see something that isn't supported by that minimal set if that means the thing won't be functional.

Yes I am thinking I will complete review of basic support and all non-telemetry related patches here and see if we can queue them if not merge.

Quoted 3 lines

Once that's in place, over a couple of additional patch sets you can get to everything you have here.

Agreed and sounds like a strategy that would work in making progress here.

Signature · 2 lines
Regards,
Sudeep
author reviewer
#82 lore raw
In reply to Jonathan Cameron
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

Hi Cristian,

Hi Jonathan,

thanks for your time...I sincerely hope you're travelling abroad on some remote timezone given the time these reviews came in :D

Quoted 6 lines

So, the main issue here is pretty much summarized by:

 28 files changed, 12801 insertions(+), 99 deletions(-)

(obviously there are tests etc, but it's still > 10k lines)

Usually I try to implement the complete set of features of a new protocol but indeed this new Telemetry thing is huge by itself so it became quickly overwhelming to review...imagine to code and test it.

Quoted 20 lines

There are relatively few reviewers who would even consider taking that on. I foolishly thought it wouldn't be too bad (and I review a lot of code). By about 3/4 of the way though, probably much earlier, I know the quality of review went down considerably. Honestly it was probably a waste of time continuing but I'm stubborn like that.

So, unless you have a path to bribing or sweet talking various folk to deal with reviewing this with each having to set aside multiple days to do it, likely repeating for a couple of versions yet, I think you've got to figure out out how to make the first patch set more manageable. Probably don't split it up as much as the mpam or CCA folk have had to, but you have a lot of colleagues who are experiencing the same problem at the moment. They may be able to advise.

So it would be nice if what was in that first patch set was 'functional' but I don't think it needs to function on every systems or support more than an absolutely minimal feature set. Just fail to probe when you see something that isn't supported by that minimal set if that means the thing won't be functional.

Quoted 6 lines

Once that's in place, over a couple of additional patch sets you can get to everything you have here.

So what if you choose one data path (shmti perhaps), no notifications, events, maybe even simplify to one of the readback paths. Maybe even drop event groups initially.

Based on our real world initial customer of this I can certainly drop a few features that are not supported anyway by the real FW and move it to a later patchset, stuff like groups, notifications and single sample reads, but all of the rest is hardly removable while keeping the system functional and usable.

Quoted 3 lines

Possibly even drop timestamps. Definitely drop things like boot-on support and debugfs (unless you are using that as a cheeky 'functional' test ahead of the main userspace interface.

Not sure what you mean by drop timestamps, definitelly cannot drop boot-on (it is how systems are configured indeed) neither debugfs used for bring-up and FW debug.

Quoted 5 lines

How much would that slim things down? It doesn't even have to be useful, just testable. Realistically I think the hope of getting enough review doubles if you can halve the size of what you are asking people to look at.

I am not sure how many lines I can shed with the above features drops but I'll give it a go anyway at slimming down the series after I have gone through this round of Sashiko pains.

Quoted 5 lines

Anyhow, gut feeling only but the code felt like it was in a much better state than some of the versions I've looked at in the past, so I think the game is now how to get it over the line!

From the testing/functional/performance standpoints the series has definitely improved especially, but still some road to go.

Thanks,
Cristian

#83 lore raw
Quoted 11 lines · On Wed, 11 Nov 2026 10:15:16 +0000 Cristian Marussi <[email protected]>…
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

Hi Cristian,

Hi Jonathan,

thanks for your time...I sincerely hope you're travelling abroad on some remote timezone given the time these reviews came in :D

I'm based in Pacific time these days so was only 4pm ;)

Quoted 39 lines
Quoted 7 lines

So, the main issue here is pretty much summarized by:

 28 files changed, 12801 insertions(+), 99 deletions(-)

(obviously there are tests etc, but it's still > 10k lines)

Usually I try to implement the complete set of features of a new protocol but indeed this new Telemetry thing is huge by itself so it became quickly overwhelming to review...imagine to code and test it.

Quoted 20 lines

There are relatively few reviewers who would even consider taking that on. I foolishly thought it wouldn't be too bad (and I review a lot of code). By about 3/4 of the way though, probably much earlier, I know the quality of review went down considerably. Honestly it was probably a waste of time continuing but I'm stubborn like that.

So, unless you have a path to bribing or sweet talking various folk to deal with reviewing this with each having to set aside multiple days to do it, likely repeating for a couple of versions yet, I think you've got to figure out out how to make the first patch set more manageable. Probably don't split it up as much as the mpam or CCA folk have had to, but you have a lot of colleagues who are experiencing the same problem at the moment. They may be able to advise.

So it would be nice if what was in that first patch set was 'functional' but I don't think it needs to function on every systems or support more than an absolutely minimal feature set. Just fail to probe when you see something that isn't supported by that minimal set if that means the thing won't be functional.

Quoted 6 lines

Once that's in place, over a couple of additional patch sets you can get to everything you have here.

So what if you choose one data path (shmti perhaps), no notifications, events, maybe even simplify to one of the readback paths. Maybe even drop event groups initially.

Quoted 5 lines

Based on our real world initial customer of this I can certainly drop a few features that are not supported anyway by the real FW and move it to a later patchset, stuff like groups, notifications and single sample reads, but all of the rest is hardly removable while keeping the system functional and usable.

For purposes of upstream. I'm not sure we care if a particular implementation is useable with the feature set initially supported. We just care if there is a path to test the subset supported (hacks / emulation, whatever is fine).

Quoted 8 lines
Quoted 4 lines

Possibly even drop timestamps. Definitely drop things like boot-on support and debugfs (unless you are using that as a cheeky 'functional' test ahead of the main userspace interface.

Not sure what you mean by drop timestamps, definitelly cannot drop boot-on (it is how systems are configured indeed) neither debugfs used for bring-up and FW debug.

Timestamp variety is complex. Fairly sure you are allowed to report no timestamps at all as one option. If you pretend they all look like that initially it might bring some simplifications. Anyhow, you know this code better than I do, so maybe that is harder than I'm thinking.

I'd still push boot-on out for a follow on patch set. Sure can aim to land that one quickly! Sure customers will
get irritated by lack of support for what they have. Taking equivalent of MPAM. The initial support for that covered pretty much nothing on real platforms. Customers were (and still are) irritated. But that allowed progress in the right direction.

Quoted 10 lines
Quoted 6 lines

How much would that slim things down? It doesn't even have to be useful, just testable. Realistically I think the hope of getting enough review doubles if you can halve the size of what you are asking people to look at.

I am not sure how many lines I can shed with the above features drops but I'll give it a go anyway at slimming down the series after I have gone through this round of Sashiko pains.

If we have to fallback to breaking it into steps that don't do much more than print a message to say 'stuff found' then do that. It's ugly but MPAM did that, RME is doing that. No one likes dead code, but it does allow progress to be made. Ideal is end to end with subset of features then add features but not always achievable.

Normal rule of thumb for landing a feature is sub 2k lines of code because that is about what a reviewer can digest in one go.

Very rare anything above 5k makes progress. As Sudeep mentioned, a lot of folk will open the cover letter, see loc and close it again unread.

Jonathan

maintainer
#84 lore raw
In reply to Cristian Marussi
Quoted 149 lines · Cristian Marussi

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

In a nutshell, the SCMI Telemetry protocol allows an agent to discover at runtime the set of Telemetry Data Events (DEs) available on a specific platform and provides the means to configure the set of DEs that a user is interested into, while reading them back using the collection method that is deeemed more suitable for the usecase at hand. (...amongst the various possible collection methods allowed by SCMI specification)

Without delving into the gory details of the whole SCMI Telemetry protocol let's just say that the SCMI platform/server firmware advertises a number of Telemetry Data Events, each one identified by a 32bit unique ID, and an SCMI agent/client, like Linux, can discover them and read back at will the associated data value in a number of ways.

Data collection is mainly intended to happen on demand via shared memory areas exposed by the platform firmware, discovered dynamically via SCMI Telemetry and accessed by Linux on-demand, but some DE can also be reported via SCMI Notifications asynchronous messages or via direct dedicated FastChannels (another kind of SCMI memory based access): all of this underlying mechanism is anyway hidden to the user since it is mediated by the kernel driver which will return the proper data value when queried.

Anyway, the set of well-known architected DE IDs defined by the spec is limited to a dozen IDs, which means that the vast majority of DE IDs are customizable per-platform: as a consequence, though, the same ID, say '0x1234', could represent completely different things on different systems.

Precise definitions and semantic of such custom Data Event IDs are out of the scope of the SCMI Telemetry specification and of this implementation:
they are supposed to be provided using some kind of JSON-like description file that will have to be consumed by a userspace tool which would be finally in charge of making sense of the set of available DEs.

IOW, in turn, this means that even though the DEs enumerated via SCMI come with some sort of topological and qualitative description provided by the protocol (like unit of measurements, name, topology info etc), kernel-wise we CANNOT be completely sure of "what is what" without being fed-back some sort of information about the DEs by the afore mentioned userspace tool.

For these reasons, currently this series does NOT attempt to register any of these DEs with any of the usual in-kernel subsystems (like HWMON, IIO, PERF etc), simply because we cannot be sure which DE is suitable, or even desirable, for a given subsystem. This also means there are NO in-kernel users of these Telemetry data events as of now.

So, while we do not exclude, for the future, to feed/register some of the discovered DEs to/with some of the above mentioned Kernel subsystems, as of now we have ONLY modeled a custom userspace API to make SCMI Telemetry available to userspace tools.

With V5 we adopted a pure chardev/IOCTL ABI approach, refining the IOCTL based interface already present with the previous FS-based ABI.

INTERFACES

For each discovered SCMI Instance a character device named tlm_<N> is created under /dev/scmi/ subtree.

The IOCTL interface described at 'include/uapi/linux/scmi.h' is made available to enumerate and configure Telemetry resources: Telemetry data can be collected using a few different IOCTls, depending on the required granularity.

Alternatively it is possible to obtain a list of the file descriptors referencing directly the underlying SCMI Telemetry SHMTI memory areas and implement in user space an SCMI Telemetry parser accessing directly the SHMTI, while staying in compliance with the SCMI TDCF format.

NOTE THAT from v3 onwards the firmware interface level NOW supports ONLY the latest SCMI v4.0 specification [0].

Based on V7.4-rc2, tested on an emulated setup and AGI HW.

This series is available also at [1].

If you still reading...any feedback welcome :P

Thanks,
Cristian

---
v14 --> v15
- rebased on v7.4-rc2
- [STLM]
+ add lazy enumeration
+ add des/info cmdline options
+ add missing SIGTERM handling
- [SYS/TLM]
+ harden/simplify batch helpers
+ fix shmti mmap size check to include offset
+ simplify session_unsubscribe cleanup on exit/unbind
+ added missing kref.h include
+ expose TLM EVENTS capabilities ONLY IF CONFIG_EVENTFD
+ mmap: improved check to avoid WRITE/EXEC mapping
+ reject non zero vm_pgoff
+ drop usage of guard(srcu) to avoid races with put_device
- [TLM]
+ avoid genration counter reset on TLM RESET
+ add an overflow check on NOTIF payload lines parsing
+ convert to Linux errno before building notification report
+ use better startm/endm initial markers in tdcf_de_payld_get
+ trigger resource enumeration also on de_data_read
+ skip unitialized FCs on reads and return -EPROTO
+ check FC size on enumeration (big enough to hold TS ?)
+ introduce localized single DE snapshot on single DE data read
+ widen tde->mtx locking in msg_payld_process
+ refactor msg_payld_process
+ unlink BLK_TS on DE disable
+ update linked BLK_TS on enable
+ update TDE location ONLY after successfull linked lines processing
+ trigger resource enumeration on state_get
+ trigger resource enumeration on colletion configure only for groups
+ widen tde->mtx locking section on state_set
+ refactor UUID/BLK_TS lines processing in enable
+ introduce BLK_TS localized snapshot during enable
+ check line type at de_offs
+ sanitize requested mode on collection conf
+ use snapshots to collect UUIDs during full scans
+ stop tracking UUIDs lines singularly (useless overhead)
+ use UUIDs line hashing for lookup
+ use snapshots to track and collect BLK_TS during full scan bulk reads
+ account for tstamped TDE during discovery
+ correct SHMTI overflow off-by-one
+ rework TDE cache hit/miss logic
+ introduce snapshots on full scan reads
+ validate DE location also on SCAN_UPDATE
+ fix TDCF prologue/epilogue endianity struct definitions
+ rework SHMTI initialization and allocation
+ add snapshot suppport data structures
+ added alignment checks on SHMTII length size
+ fixed error string formatting
+ warn if less than expected SHMTIs are enumerated
+ improve memory area sanity checks
+ added missing initialization of intrvs->grp_id
+ bailout from group initialization when NO DEs were found
+ better handling of error path on groups init

Quoted 9 lines

+ drop usage of devres for FC iomapping
+ trigger full enumeration of DE lookups
+ new IS_TDE_TS_ macro helpers
+ add a dedicated scmi_telemetry_free_tdes_add helper
+ dropping needless __must_check
+ flag as fully enumerated only when ALL declared des were found
+ reworked error path in scmi_allocate_pending_event_handler
+ hardened core iterator parsing of multi-part reply

You can drop the change log for earlier versions(just last 3 should suffice) in the future postings and add links to them instead if anyone is really interested to go back. Don't worry about older links now, just do that in the future.

[...]

As mentioned in one of the thread, this is quite big series with not much feedback on the UABI part apart for Jonathan. So we need to take an approach of merging this in smaller parts initially.

Quoted 2 lines

Cristian Marussi (34):
firmware: arm_scmi: Harden iterators state parsing

The above looks good.

Quoted 2 lines

firmware: arm_scmi: Add new SCMIv4.0 error codes definitions
firmware: arm_scmi: Introduce a dedicated SCMI Errors header

As pointed out, better to swap the order of above 2.

Quoted 3 lines

firmware: arm_scmi: Allow registration of unknown-size events/reports
firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper
firmware: arm_scmi: Introduce protocol instance notifiers

All the above 3 refactor the code, so better to fix the Sashiko reported bugs around them before go for such additions/refactoring IMO.

Quoted 9 lines

dt-bindings: firmware: arm,scmi: Add support for telemetry protocol
include: trace: Add Telemetry trace events
firmware: arm_scmi: Add Telemetry basic attributes enumeration
firmware: arm_scmi: Add Telemetry resources enumeration
firmware: arm_scmi: Add Telemetry groups initialization
firmware: arm_scmi: Add Telemetry update intervals enumeration
firmware: arm_scmi: Add Telemetry SHMTI areas enumeration
firmware: arm_scmi: Add Telemetry TDCF areas parsing support
firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines

Quoted 8 lines

firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines
firmware: arm_scmi: Add Telemetry configuration operations
firmware: arm_scmi: Add Telemetry DataEvent read capabilities
firmware: arm_scmi: Add Telemetry reset logic
firmware: arm_scmi: Add Telemetry notification support
firmware: arm_scmi: Add Telemetry boot-on support
firmware: arm-scmi: Add Telemetry generic event support
firmware: arm_scmi: Add Telemetry generation counter event

I am thinking of initially merging upto the above commit initially so that no user ABI is established. I haven't done the thorough review yet.

Signature · 2 lines
Regards,
Sudeep
author reviewer
#85 lore raw
Quoted 3 lines · Sudeep Holla
Quoted 2 lines · Cristian Marussi

Hi all,

Hi,

Quoted 1 line

[snip]

Quoted 8 lines

+ hardened core iterator parsing of multi-part reply

Quoted 1 line

You can drop the change log for earlier versions(just last 3 should suffice) in the future postings and add links to them instead if anyone is really interested to go back. Don't worry about older links now, just do that in the future.

Ok.

Quoted 6 lines

[...]

As mentioned in one of the thread, this is quite big series with not much feedback on the UABI part apart for Jonathan. So we need to take an approach of merging this in smaller parts initially.

Yes I have already split put unused features from V16 both from the protocol layer and from the driver.

- no GROUPS
- no NOTIFICATION
- no SAMPLE READ (async delayed response)

This way the series is roughly 6500 lines (without docs/ksft/test tool)

...now I was starting going through residual Sashiko bugs of the initial part of the series (at least), assuming more discussion are needed around the ABI anyway (still to reply to latest Jonathan mail)

Quoted 10 lines
Quoted 2 lines

Cristian Marussi (34):
firmware: arm_scmi: Harden iterators state parsing

The above looks good.

Quoted 2 lines

firmware: arm_scmi: Add new SCMIv4.0 error codes definitions
firmware: arm_scmi: Introduce a dedicated SCMI Errors header

As pointed out, better to swap the order of above 2.

Ok.

Quoted 7 lines
Quoted 3 lines

firmware: arm_scmi: Allow registration of unknown-size events/reports
firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper
firmware: arm_scmi: Introduce protocol instance notifiers

All the above 3 refactor the code, so better to fix the Sashiko reported bugs around them before go for such additions/refactoring IMO.

I dropeed protocol protocol instance support and notification as discussed, the new series layout is roughly (with docs/ksft/tool still to apply split):

c1266f348da4 firmware: arm_scmi: Enable autoloading for System Telemetry driver 8ff6d68673ff firmware: arm_scmi: Add System Telemetry driver 2ab95adf4c0d uapi: Add ARM SCMI Telemetry definitions
8a79c0ca1d11 firmware: arm_scmi: Expose per-instance identifier ec676846f78c firmware: arm_scmi: Add Telemetry debugfs ABI documentation 6798c6701682 firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support 58cba74addfd firmware: arm_scmi: Add common per-protocol debugfs support fdfd27649a6e firmware: arm_scmi: Add Telemetry boot-on support 6737d7a797c0 firmware: arm_scmi: Add Telemetry Single/Bulk DEs reads 5507b8b44d15 firmware: arm_scmi: Add Telemetry global configuration support 7aa4c04a61a8 firmware: arm_scmi: Add Telemetry DEs configuration support e2eec907cddc firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines d3c453be30c6 firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines 328be9a8b32b firmware: arm_scmi: Add Telemetry TDCF areas parsing support e5d64de593ee firmware: arm_scmi: Add Telemetry SHMTI areas enumeration d5f25597262d firmware: arm_scmi: Add Telemetry global update intervals enumeration e23dffd6a103 firmware: arm_scmi: Add Telemetry resources enumeration dac0f7d33c76 firmware: arm_scmi: Add Telemetry basic attributes enumeration fa02803cbb1a include: trace: Add Telemetry trace events
4b510f42e44d dt-bindings: firmware: arm,scmi: Add support for telemetry protocol 11f799fe30a4 firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper 3a2706fedd66 firmware: arm_scmi: Allow registration of unknown-size events/reports 5d196fe1290e firmware: arm_scmi: Introduce a dedicated SCMI Errors header 1877db16c4f5 firmware: arm_scmi: Add new SCMIv4.0 error codes definitions 38e65d778a52 firmware: arm_scmi: Harden iterators state parsing

...BUT especially the removal of GROUPS led to considerable rework so the above commits does NOT really match the same commit in V15

Quoted 18 lines
Quoted 9 lines

dt-bindings: firmware: arm,scmi: Add support for telemetry protocol
include: trace: Add Telemetry trace events
firmware: arm_scmi: Add Telemetry basic attributes enumeration
firmware: arm_scmi: Add Telemetry resources enumeration
firmware: arm_scmi: Add Telemetry groups initialization
firmware: arm_scmi: Add Telemetry update intervals enumeration
firmware: arm_scmi: Add Telemetry SHMTI areas enumeration
firmware: arm_scmi: Add Telemetry TDCF areas parsing support
firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines

Quoted 8 lines

firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines
firmware: arm_scmi: Add Telemetry configuration operations
firmware: arm_scmi: Add Telemetry DataEvent read capabilities
firmware: arm_scmi: Add Telemetry reset logic
firmware: arm_scmi: Add Telemetry notification support
firmware: arm_scmi: Add Telemetry boot-on support
firmware: arm-scmi: Add Telemetry generic event support
firmware: arm_scmi: Add Telemetry generation counter event

Quoted 2 lines

I am thinking of initially merging upto the above commit initially so that no user ABI is established. I haven't done the thorough review yet.

Beside a lot of stuff that I removed (like groups all over) there are outstanding Sashiko issue in the V15/V16 code that I was going to address now.

Given that, as I understood the agreement was to shed a lot of still unused features the current V15 and next V16 will be sensibly different.

Thanks,
Cristian

#86 lore raw
In reply to Cristian Marussi
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

So, obviously we can ignore informative spec lines but that is a pretty strong sentence. I can't immediately think of what would go wrong if we ignored it
- maybe we'd not pick an exclusive PCC and fallback to a common one the firmware doesn't want us to use? But if it doesn't want us to use it why make Telemetry discoverable on it.

Should that be wired through from the ACPI parsing code?

Anyhow, not something I care that much about but thought I'd call it out as an oddity.

Jonathan

author reviewer
#87 lore raw
Quoted 4 lines · Jonathan Cameron
Quoted 1 line · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

Hi,

Quoted 33 lines
Quoted 7 lines

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

So, obviously we can ignore informative spec lines but that is a pretty strong sentence. I can't immediately think of what would go wrong if we ignored it
- maybe we'd not pick an exclusive PCC and fallback to a common one the firmware doesn't want us to use? But if it doesn't want us to use it why make Telemetry discoverable on it.

Quoted 5 lines

Should that be wired through from the ACPI parsing code?

Anyhow, not something I care that much about but thought I'd call it out as an oddity.

AFAICR, I think this is really down to some ambiguity elsewhere in the ACPI/PCC spec for SCMI, so the implementation deviates a bit from the behaviour we have on devicetree based SCMI systems where instead a non DT listed protocol is NOT activated even if provided by FW.

Sudeep has more details on this.

Thanks,
Cristian

maintainer
#88 lore raw
In reply to Jonathan Cameron
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

Quoted 6 lines

So, obviously we can ignore informative spec lines but that is a pretty strong sentence. I can't immediately think of what would go wrong if we ignored it
- maybe we'd not pick an exclusive PCC and fallback to a common one the firmware doesn't want us to use? But if it doesn't want us to use it why make Telemetry discoverable on it.

Indeed, falling back to the common channel lets us uncover any underlying issues in the firmware implementation. That is the exact scenario we hit on the test platform, which convinced me to hold back the patch.

Quoted 2 lines

Should that be wired through from the ACPI parsing code?

As mentioned, we certainly can, though I'm not sure we should. The "may not be" phrasing simply leaves the choice up to the OSPM rather than mandating a strict restriction.

Quoted 3 lines

Anyhow, not something I care that much about but thought I'd call it out as an oddity.

Thanks and well spotted. Much appreciated as it brought the information out which otherwise would have just got lost.

Signature · 2 lines
Regards,
Sudeep
#89 lore raw
Quoted 43 lines · On Wed, 18 Nov 2026 09:33:44 +0000 Sudeep Holla <[email protected]> wrote:
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

Quoted 4 lines

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

You can't merge it safely as at a later date because chances are high someone is relying on the current behavior and not presenting that (currently pointless) package in ACPI for some protocol or other.

I'm fine with a permanent decision not to check this but I don't see it as a thing that can ever change (except maybe now whilst there are not that many platforms out there using it!)

Jonathan

Quoted 27 lines
Quoted 7 lines

So, obviously we can ignore informative spec lines but that is a pretty strong sentence. I can't immediately think of what would go wrong if we ignored it
- maybe we'd not pick an exclusive PCC and fallback to a common one the firmware doesn't want us to use? But if it doesn't want us to use it why make Telemetry discoverable on it.

Indeed, falling back to the common channel lets us uncover any underlying issues in the firmware implementation. That is the exact scenario we hit on the test platform, which convinced me to hold back the patch.

Quoted 2 lines

Should that be wired through from the ACPI parsing code?

As mentioned, we certainly can, though I'm not sure we should. The "may not be" phrasing simply leaves the choice up to the OSPM rather than mandating a strict restriction.

Quoted 3 lines

Anyhow, not something I care that much about but thought I'd call it out as an oddity.

Thanks and well spotted. Much appreciated as it brought the information out which otherwise would have just got lost.

author reviewer
#90 lore raw
Quoted 51 lines · Jonathan Cameron
Quoted 43 lines · On Wed, 18 Nov 2026 09:33:44 +0000 Sudeep Holla <[email protected]> wrote:
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

Quoted 4 lines

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

Quoted 8 lines

You can't merge it safely as at a later date because chances are high someone is relying on the current behavior and not presenting that (currently pointless) package in ACPI for some protocol or other.

I'm fine with a permanent decision not to check this but I don't see it as a thing that can ever change (except maybe now whilst there are not that many platforms out there using it!)

Even though the change would be at the transport layer, given that it is NOT impacting the Base protocol, cant we anyway quirk it later on based on FW vendor/version as an extrema ratio so as to support anyway older FW leveraging the current behaviour ? (not ideal I agree...and I have to double check what changes could be needed in the quirk framework..)

Thanks,
Cristian

#91 lore raw
Quoted 61 lines · On Wed, 18 Nov 2026 18:39:16 +0000 Cristian Marussi <[email protected]>…
Quoted 51 lines · Jonathan Cameron
Quoted 43 lines · On Wed, 18 Nov 2026 09:33:44 +0000 Sudeep Holla <[email protected]> wrote:
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

Quoted 4 lines

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

Quoted 8 lines

You can't merge it safely as at a later date because chances are high someone is relying on the current behavior and not presenting that (currently pointless) package in ACPI for some protocol or other.

I'm fine with a permanent decision not to check this but I don't see it as a thing that can ever change (except maybe now whilst there are not that many platforms out there using it!)

Quoted 5 lines

Even though the change would be at the transport layer, given that it is NOT impacting the Base protocol, cant we anyway quirk it later on based on FW vendor/version as an extrema ratio so as to support anyway older FW leveraging the current behaviour ? (not ideal I agree...and I have to double check what changes could be needed in the quirk framework..)

Quirking after a change is a pain because you only find out that it was a problem when the regressions shouts start occurring.

I'd quirk the other way and paper over anyone who requires that record to hid some firmware bug. Their stuff doesn't work today, so no regression! :)

Quoted 3 lines

Thanks,
Cristian

maintainer
#92 lore raw
In reply to Cristian Marussi
Quoted 61 lines · Cristian Marussi
Quoted 51 lines · Jonathan Cameron
Quoted 43 lines · On Wed, 18 Nov 2026 09:33:44 +0000 Sudeep Holla <[email protected]> wrote:
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

Quoted 4 lines

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

Quoted 8 lines

You can't merge it safely as at a later date because chances are high someone is relying on the current behavior and not presenting that (currently pointless) package in ACPI for some protocol or other.

I'm fine with a permanent decision not to check this but I don't see it as a thing that can ever change (except maybe now whilst there are not that many platforms out there using it!)

Quoted 6 lines

Even though the change would be at the transport layer, given that it is NOT impacting the Base protocol, cant we anyway quirk it later on based on FW vendor/version as an extrema ratio so as to support anyway older FW leveraging the current behaviour ? (not ideal I agree...and I have to double check what changes could be needed in the quirk framework..)

Equally good point. I am worried as Jonathan say what we many platforms start to depend on current logic and end up skipping the ACPI property in the firmware which can be problematic to address in the future.

Let me think about it so that we can address possible f/w bug issue as well.

Signature · 2 lines
Regards,
Sudeep
maintainer
#93 lore raw
In reply to Jonathan Cameron
Quoted 46 lines · Jonathan Cameron
Quoted 43 lines · On Wed, 18 Nov 2026 09:33:44 +0000 Sudeep Holla <[email protected]> wrote:
Quoted 25 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 9 Nov 2026 09:11:46 +0000 Cristian Marussi <[email protected]>…

Hi all,

[TLDR Summary]
[V15 highlights]
- general cleanup and hardening driven by reviews
- improved TDCF access routines to minimize lost samples under load
- completed ABI docs

Quoted 5 lines

[V16 TODO]
- address any remaining V15 outstanding Sashiko/reviewers issues

The upcoming SCMI v4.0 specification [0] introduces a new SCMI protocol dedicated to System Telemetry.

This is one from the family of issues you find when reviewing ones own (well LLM generated) emulation, realizing it doesn't match the spec, and yet works.

This works fine without the required SCMI protocol property in ACPI. 2.2.2 of ACPI for System Control and Management Interface 1.0 Platform Design Document. 111115A 1.0

Quoted 6 lines

Now, in here is an informative statement...

Protocols not listed using a property may not be enumerate by the operating system.

But they are...

Correct, I intentionally left that out. I do have a patch that restricts it strictly to the listed property. However, I held off on pushing it because of an issue we saw on an internal test platform.

On that platform, the firmware advertised the protocol to the OSPM via the base protocol, even though it wasn't functional at all. Once they realized this, they simply dropped the entry from the ACPI SCMI device as a workaround instead of properly fixing the base protocol discovery. While understandable, relying on that workaround delays proper firmware fixes.

Quoted 9 lines
Quoted 4 lines

That is why I went with the non-mandatory "may not be" wording. I am happy to merge that restriction patch if a real production platform actually needs it, but until then, leaving it open helps catch and fix broken firmware implementations 😄.

You can't merge it safely as at a later date because chances are high someone is relying on the current behavior and not presenting that (currently pointless) package in ACPI for some protocol or other.

I agree, you have made a strong point.

Quoted 4 lines

I'm fine with a permanent decision not to check this but I don't see it as a thing that can ever change (except maybe now whilst there are not that many platforms out there using it!)

Indeed, I will push the change so that we can avoid any quirks we may need otherwise in the future.

Signature · 2 lines
Regards,
Sudeep