Re: [PATCH v15 20/35] firmware: arm_scmi: Add Telemetry notification support

From: Jonathan Cameron

Date: Tue Nov 10 2026 - 17:17:10 EST


On Mon, 9 Nov 2026 09:12:06 +0000
Cristian Marussi <cristian.marussi@xxxxxxx> wrote:

> Add support for notifications to Telemetry protocol and register an
> internal notifier during protocol initialization: any DE value received
> inside a notification payload will be cached for future user consumption.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>

Trivial things inline.

> drivers/firmware/arm_scmi/telemetry.c | 184 +++++++++++++++++++++++++-
> include/linux/scmi_protocol.h | 9 ++
> 2 files changed, 190 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
> index ebad4ec2afda..918067e225d5 100644
> --- a/drivers/firmware/arm_scmi/telemetry.c
> +++ b/drivers/firmware/arm_scmi/telemetry.c

> static struct scmi_telemetry_res_info *
> __scmi_telemetry_resources_get(struct telemetry_info *ti);
>
> @@ -3831,9 +3843,9 @@ scmi_telemetry_msg_payld_process(struct telemetry_info *ti,
> while (next < num_dwords) {
> struct payload *payld = (struct payload *)&dwords[next];
> struct scmi_telemetry_de_sample sample = {};
> + u32 de_id, meta = le32_to_cpu(payld->meta);
> struct scmi_telemetry_de *de;
> struct telemetry_de *tde;
> - u32 de_id, meta = le32_to_cpu(payld->meta);
> unsigned int wlen;
>
> wlen = LINE_LENGTH_WORDS_RAW(meta);
> @@ -3874,7 +3886,6 @@ scmi_telemetry_msg_payld_process(struct telemetry_info *ti,
> }
>
> tde->cached_msg = cacheable;
> -

If you want this, figure out which patch to push it back to.

> sample.val = LINE_DATA_GET_RAW(&payld->tsl);
> sample.tstamp = HAS_LINE_EXT_RAW(meta) &&
> LINE_TS_VALID_RAW(meta) ? LINE_TSTAMP_GET_RAW(&payld->tsl) : 0;
> @@ -3882,6 +3893,10 @@ scmi_telemetry_msg_payld_process(struct telemetry_info *ti,
> /* Update the cache holding the TDE mutex */
> scmi_telemetry_tde_cache_update(tde, &sample, NULL);
>
> + /* Link notifications to Primary UUID */
> + if (cacheable)
> + scmi_telemetry_uuid_link(tde, ti->primary_uuid);
> +
> trace_scmi_tlm_collect(sample.tstamp, de->info->id, sample.val,
> "MESSAGE");
> }
> @@ -4062,6 +4077,148 @@ static const struct scmi_telemetry_proto_ops tlm_proto_ops = {
> .reset = scmi_telemetry_reset,
> };


> +
> +static int scmi_telemetry_notifier(struct notifier_block *nb,
> + unsigned long event, void *data)
> +{
> + struct scmi_telemetry_update_report *er = data;
> + struct telemetry_info *ti = telemetry_nb_to_info(nb);
> +
> + /*
> + * PARTIAL_ERRORs are reported as -EBADMSG and related lines,
> + * marked as DATA_INVALID, will be properly skipped by
> + * scmi_telemetry_msg_payld_process.

Doesn't matter much given it will still be 3 lines, but inconsistent short wrap.

> + */
> + if (er->status && er->status != -EBADMSG) {
> + trace_scmi_tlm_access(0, "BAD_NOTIF_MSG", 0, 0);
> + return NOTIFY_DONE;

> /**
> * scmi_telemetry_resources_alloc - Resources allocation
> * @ti: A reference to the telemetry info descriptor for this instance
> @@ -4488,7 +4645,27 @@ static int scmi_telemetry_protocol_init(const struct scmi_protocol_handle *ph)
>
> ti->info.base.version = ph->version;
>
> - return ph->set_priv(ph, ti);
> + ret = ph->set_priv(ph, ti);
> + if (ret)
> + return ret;

Can drive this change back to original introduction to avoid a bit of churn.

> +
> + /*
> + * Register a notifier anyway straight upon protocol initialization
> + * since there could be some DEs that are ONLY reported by notifications
> + * even though the chosen collection method was SHMTI/FCs.
> + */
> + if (ti->info.continuous_update_support) {
> + ti->telemetry_nb.notifier_call = &scmi_telemetry_notifier;
> + ret = ph->instance_notifier_register(ph, SCMI_EVENT_TELEMETRY_UPDATE,
> + NULL, &ti->telemetry_nb);
> + if (ret) {
> + dev_err(ph->dev,
> + "Could NOT register Telemetry notifier\n");
> + return ret;
> + }
> + }
> +
> + return 0;
> }

> struct scmi_power_state_changed_report {
> @@ -1342,4 +1343,12 @@ struct scmi_powercap_meas_changed_report {
> unsigned int domain_id;
> unsigned int power;
> };
> +
> +struct scmi_telemetry_update_report {
> + ktime_t timestamp;
> + unsigned int agent_id;
> + int status;
> + unsigned int num_dwords;
> + unsigned int dwords[];

__counted_by?

> +};
> #endif /* _LINUX_SCMI_PROTOCOL_H */