Re: [PATCH v15 09/35] firmware: arm_scmi: Add Telemetry basic attributes enumeration
From: Jonathan Cameron
Date: Mon Nov 09 2026 - 19:06:38 EST
On Mon, 9 Nov 2026 09:11:55 +0000
Cristian Marussi <cristian.marussi@xxxxxxx> wrote:
> Add SCMIv4.0 Telemetry basic support for minimal initialization and
> protocol attributes enumeration: expose telemetry instance descriptor
> via a simple information retrieval protocol operation.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>
A few minor things inline.
Thanks,
Jonathan
> diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h
> index d1f1bde8a7cc..77daedddaab7 100644
> --- a/drivers/firmware/arm_scmi/protocols.h
> +++ b/drivers/firmware/arm_scmi/protocols.h
> @@ -410,5 +410,6 @@ DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
> DECLARE_SCMI_REGISTER_UNREGISTER(voltage);
> DECLARE_SCMI_REGISTER_UNREGISTER(system);
> DECLARE_SCMI_REGISTER_UNREGISTER(powercap);
> +DECLARE_SCMI_REGISTER_UNREGISTER(telemetry);
>
> #endif /* _SCMI_PROTOCOLS_H */
> diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
> new file mode 100644
> index 000000000000..23eaac485691
> --- /dev/null
> +++ b/drivers/firmware/arm_scmi/telemetry.c
> @@ -0,0 +1,149 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * System Control and Management Interface (SCMI) Telemetry Protocol
> + *
> + * Copyright (C) 2026 ARM Ltd.
> + */
> +
> +#include <linux/atomic.h>
I'm not immediately spotting this being used. Perhaps take another
look at whether some of these should wait for later patches
where their usecases come in.
> +#include <linux/bitfield.h>
> +#include <linux/compiler_types.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/limits.h>
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +#include <linux/sprintf.h>
> +#include <linux/string.h>
> +#include <linux/uuid.h>
> +
> +#include "protocols.h"
> +#include "notify.h"
> +
> +/* Updated only after ALL the mandatory features for that version are merged */
> +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000
> +
> +#define SCMI_TLM_DE_IMPL_NUM_DWORDS 4
> +
> +/* An enum listing the protocol specific commands definitions */
> +enum scmi_telemetry_protocol_cmd {
> + TELEMETRY_LIST_SHMTI = 0x3,
> + TELEMETRY_DE_DESCRIPTION = 0x4,
> + TELEMETRY_LIST_UPDATE_INTERVALS = 0x5,
> + TELEMETRY_DE_CONFIGURE = 0x6,
> + TELEMETRY_DE_ENABLED_LIST = 0x7,
> + TELEMETRY_CONFIG_SET = 0x8,
> + TELEMETRY_READING_COMPLETE = TELEMETRY_CONFIG_SET,
> + TELEMETRY_CONFIG_GET = 0x9,
> + TELEMETRY_RESET = 0xA,
> +};
> +
> +struct scmi_msg_resp_telemetry_protocol_attributes {
I like clear names as much as anyone, but probably wouldn't lose much by
abbreviating a little?
struct scmi_msg_rsp_telemetry_prot_attr
perhaps?
> + __le32 de_num;
> + __le32 groups_num;
> + __le32 de_implem_rev_dword[SCMI_TLM_DE_IMPL_NUM_DWORDS];
> + __le32 attributes_1;
> +#define SUPPORTS_SINGLE_READ(x) (le32_get_bits((x), BIT(31)))
> +#define SUPPORTS_CONTINUOS_UPDATE(x) (le32_get_bits((x), BIT(30)))
> +#define SUPPORTS_PER_GROUP_CONFIG(x) (le32_get_bits((x), BIT(18)))
> +#define SUPPORTS_RESET(x) (le32_get_bits((x), BIT(17)))
> +#define SUPPORTS_FC(x) (le32_get_bits((x), BIT(16)))
I guess a local style thing but my normal inclination would be not hide
what is going on here and instead define
ATTRS1_SUPPORTS_FC BIT(16)
and use the le32_get_bits() inline. These helpers have lost the connection
with attributes_1.
> + __le32 default_blk_ts_rate;
> +};
> +
> +struct telemetry_info {
> + bool streaming_mode;
> + unsigned int num_shmti;
> + unsigned int num_des_tstamp;
> + unsigned int default_blk_ts_rate;
> + const struct scmi_protocol_handle *ph;
> + struct scmi_telemetry_info info;
> +};
> +
> +static int
> +scmi_telemetry_protocol_attributes_get(struct telemetry_info *ti)
> +{
> + struct scmi_msg_resp_telemetry_protocol_attributes *resp;
It feels like this is in the function scope rather than the if (!ret)
mostly because it has a really long type name. See above.
> + const struct scmi_protocol_handle *ph = ti->ph;
> + struct scmi_xfer *t;
> + int ret;
> +
> + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0,
> + sizeof(*resp), &t);
> + if (ret)
> + return ret;
> +
> + resp = t->rx.buf;
I think this would ideally be in the if (!ret) as well which makes
more sense if the declaration is in there.
> + ret = ph->xops->do_xfer(ph, t);
> + if (!ret) {
Maybe given long lines and indent, this is worth a helper function.
> + __le32 attr = resp->attributes_1;
> + __be32 de_impl_version[SCMI_TLM_DE_IMPL_NUM_DWORDS];
> +
> + ti->info.base.num_des = le32_to_cpu(resp->de_num);
> + ti->info.base.num_groups = le32_to_cpu(resp->groups_num);
> + for (int i = 0; i < SCMI_TLM_DE_IMPL_NUM_DWORDS; i++)
> + de_impl_version[i] =
> + cpu_to_be32(le32_to_cpu(resp->de_implem_rev_dword[i]));
> + import_uuid(&ti->info.base.primary_revision, (const __u8 *)&de_impl_version);
> + ti->info.single_read_support = SUPPORTS_SINGLE_READ(attr);
> + ti->info.continuous_update_support = SUPPORTS_CONTINUOS_UPDATE(attr);
> + ti->info.per_group_config_support = SUPPORTS_PER_GROUP_CONFIG(attr);
> + ti->info.reset_support = SUPPORTS_RESET(attr);
> + ti->info.fc_support = SUPPORTS_FC(attr);
> + ti->num_shmti = le32_get_bits(attr, GENMASK(15, 0));
I think that mask belongs up with the structure definition as people will want
to check the whole thing in one place.
> + ti->default_blk_ts_rate = le32_to_cpu(resp->default_blk_ts_rate);
> + }
> +
> + ph->xops->xfer_put(ph, t);
> +
> + return ret;
> +}
> diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
> index 3f7cc35eb861..f076ce5601cf 100644
> --- a/include/linux/scmi_protocol.h
> +++ b/include/linux/scmi_protocol.h
> @@ -2,17 +2,19 @@
> /*
> * SCMI Message Protocol driver header
> *
> - * Copyright (C) 2018-2021 ARM Ltd.
> + * Copyright (C) 2018-2026 ARM Ltd.
> */
>
> #ifndef _LINUX_SCMI_PROTOCOL_H
> #define _LINUX_SCMI_PROTOCOL_H
>
> #include <linux/bitfield.h>
> +#include <linux/bitops.h>
Not seeing use of that in this patch within the header.
Perhaps it should be included in a later patch or in the c file?
> #include <linux/device-id/scmi.h>
> #include <linux/device.h>
> #include <linux/notifier.h>
> #include <linux/types.h>
> +#include <linux/uuid.h>
>
> #define SCMI_MAX_STR_SIZE 64
> #define SCMI_SHORT_NAME_MAX_SIZE 16
> @@ -828,6 +830,35 @@ struct scmi_pinctrl_proto_ops {
> int (*pin_free)(const struct scmi_protocol_handle *ph, u32 pin);
> };
>
> +struct scmi_telemetry_base_info {
> + unsigned int version;
> + uuid_t primary_revision;
> + unsigned int num_des;
> + unsigned int num_groups;
> + unsigned int num_intervals;
> + unsigned int num_shmtis;
> +};
> +
> +struct scmi_telemetry_info {
> + bool single_read_support;
> + bool continuous_update_support;
> + bool per_group_config_support;
> + bool reset_support;
> + bool fc_support;
> + struct scmi_telemetry_base_info base;
> +};