[PATCH v16 18/31] firmware: arm_scmi: Add Telemetry global configuration support

From: Cristian Marussi

Date: Sat Nov 21 2026 - 18:44:54 EST


Add support to configure Telemetry globally by setting its enabled state
and the requested update interval.

Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>
---
v15 --> v16
- fix mode check logic
---
drivers/firmware/arm_scmi/telemetry.c | 68 +++++++++++++++++++++++++++
include/linux/scmi_protocol.h | 15 ++++++
2 files changed, 83 insertions(+)

diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
index 1453adee393c..2c71c090588d 100644
--- a/drivers/firmware/arm_scmi/telemetry.c
+++ b/drivers/firmware/arm_scmi/telemetry.c
@@ -3046,12 +3046,80 @@ static int scmi_telemetry_state_set(const struct scmi_protocol_handle *ph,
return 0;
}

+static int
+scmi_telemetry_collection_configure(const struct scmi_protocol_handle *ph,
+ unsigned int res_id, const bool *enable,
+ const unsigned int *update_interval_ms,
+ const enum scmi_telemetry_collection *mode)
+{
+ enum scmi_telemetry_collection *current_mode, next_mode;
+ struct telemetry_info *ti = ph->get_priv(ph);
+ struct scmi_msg_telemetry_config_set *msg;
+ bool tlm_enable, *current_state, is_group;
+ unsigned int *active_update_interval;
+ struct scmi_xfer *t;
+ __le32 interval;
+ u32 control;
+ int ret;
+
+ /* Stall concurrent configuration request */
+ guard(mutex)(&ti->config_mtx);
+
+ if (mode && (*mode != SCMI_TLM_ONDEMAND))
+ return -EOPNOTSUPP;
+
+ is_group = res_id != SCMI_TLM_GRP_INVALID;
+ if (is_group)
+ return -EOPNOTSUPP;
+
+ active_update_interval = &ti->info.active_update_interval;
+ current_mode = &ti->info.current_mode;
+ current_state = &ti->info.enabled;
+
+ if (!enable && !update_interval_ms && (!mode || *mode == *current_mode))
+ return 0;
+
+ ret = ph->xops->xfer_get_init(ph, TELEMETRY_CONFIG_SET,
+ sizeof(*msg), 0, &t);
+ if (ret)
+ return ret;
+
+ if (!update_interval_ms)
+ interval = cpu_to_le32(*active_update_interval);
+ else
+ interval = cpu_to_le32(*update_interval_ms);
+
+ tlm_enable = enable ? *enable : *current_state;
+ next_mode = mode ? *mode : *current_mode;
+
+ msg = t->tx.buf;
+ msg->group_identifier = cpu_to_le32(res_id);
+ control = tlm_enable ? TELEMETRY_ENABLE : 0;
+ control |= !is_group ? TELEMETRY_SET_SELECTOR_ALL : TELEMETRY_SET_SELECTOR_GROUP;
+ control |= TELEMETRY_MODE_SET(next_mode);
+ msg->control = cpu_to_le32(control);
+ msg->sampling_rate = interval;
+ ret = ph->xops->do_xfer(ph, t);
+ if (!ret) {
+ *current_mode = next_mode;
+ *current_state = tlm_enable;
+ ti->streaming_mode = *current_mode == SCMI_TLM_NOTIFICATION;
+ if (update_interval_ms)
+ *active_update_interval = le32_to_cpu(interval);
+ }
+
+ ph->xops->xfer_put(ph, t);
+
+ return ret;
+}
+
static const struct scmi_telemetry_proto_ops tlm_proto_ops = {
.info_get = scmi_telemetry_info_get,
.de_lookup = scmi_telemetry_de_lookup,
.res_get = scmi_telemetry_resources_get,
.state_get = scmi_telemetry_state_get,
.state_set = scmi_telemetry_state_set,
+ .collection_configure = scmi_telemetry_collection_configure,
};

/**
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index c111b8ff87db..9a1257185309 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -888,6 +888,12 @@ enum scmi_telemetry_compo_type {
#define SCMI_TLM_BUILD_UPDATE_INTERVAL(s, e) \
(FIELD_PREP(GENMASK(20, 5), (s)) | FIELD_PREP(GENMASK(4, 0), (e)))

+enum scmi_telemetry_collection {
+ SCMI_TLM_ONDEMAND,
+ SCMI_TLM_NOTIFICATION,
+ SCMI_TLM_SINGLE_READ,
+};
+
#define SCMI_TLM_GRP_INVALID 0xFFFFFFFF

struct scmi_telemetry_intervals {
@@ -959,6 +965,8 @@ struct scmi_telemetry_info {
struct scmi_telemetry_shmti_info **shmtis;
unsigned int num_uuids;
uuid_t * __rcu *uuids;
+ bool enabled;
+ enum scmi_telemetry_collection current_mode;
};

/**
@@ -972,6 +980,9 @@ struct scmi_telemetry_info {
* cumulative state of all DEs. Global group state can be looked-up
* directly from @scmi_telemetry_info via @info_get.
* @state_set: enable/disable the specific DE or GROUP with or without timestamps.
+ * @collection_configure: choose a sampling rate and enable SHMTI/FC sampling
+ * for on demand collection via @de_data_read or async
+ * notificatioins for all the enabled DEs.
*/
struct scmi_telemetry_proto_ops {
const struct scmi_telemetry_info *(*info_get)
@@ -987,6 +998,10 @@ struct scmi_telemetry_proto_ops {
bool is_group, u32 id, const bool *enable,
const bool *tstamp, u32 *sid, u32 *offset,
uuid_t *uuid);
+ int (*collection_configure)(const struct scmi_protocol_handle *ph,
+ unsigned int res_id, const bool *enable,
+ const unsigned int *update_interval_ms,
+ const enum scmi_telemetry_collection *mode);
};

/**
--
2.54.0