[PATCH v15 19/35] firmware: arm_scmi: Add Telemetry reset logic

Jonathan Cameron jonathan.cameron at oss.qualcomm.com
Tue Nov 10 14:07:39 PST 2026


On Mon,  9 Nov 2026 09:12:05 +0000
Cristian Marussi <cristian.marussi at arm.com> wrote:

> Add support for Telemetry operations needed to request platform to
> reset telemetry current configuration and data events values.
> 
> Signed-off-by: Cristian Marussi <cristian.marussi at arm.com>

Just one trivial thing that might be wrong anyway.
> ---
>  drivers/firmware/arm_scmi/telemetry.c | 81 +++++++++++++++++++++++++++
>  include/linux/scmi_protocol.h         |  2 +
>  2 files changed, 83 insertions(+)
> 
> diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
> index bf37faf99865..ebad4ec2afda 100644
> --- a/drivers/firmware/arm_scmi/telemetry.c
> +++ b/drivers/firmware/arm_scmi/telemetry.c
> @@ -3969,6 +3969,86 @@ static int scmi_telemetry_des_sample_get(const struct scmi_protocol_handle *ph,
>  	return ret;
>  }
>  
> +static void scmi_telemetry_local_resources_reset(struct telemetry_info *ti)
> +{
> +	struct scmi_telemetry_res_info *rinfo;
> +	unsigned int num_des;
> +
> +	ti->info.enabled = false;
> +	ti->info.current_mode = SCMI_TLM_ONDEMAND;
> +	ti->streaming_mode = false;
> +	ti->info.active_update_interval = 0;
> +
> +	/* Get rinfo without triggering an enumeration, cannot be NULL anyway */
> +	rinfo = __scmi_telemetry_resources_get(ti);
> +	/* Make sure to see the latest num_des */
> +	num_des = smp_load_acquire(&rinfo->num_des);
> +	/* Clear all local state...*/
> +	for (int i = 0; i < num_des; i++) {
> +		struct telemetry_de *tde = to_tde(rinfo->des[i]);
> +
> +		scoped_guard(mutex, &tde->mtx) {

Unless this gets more complex later,
		guard(mutex)(&tde->mtx);
and resulting drop in indent.

If it does get more complex ignore this.

> +			tde->last_ts = 0;
> +			tde->last_val = 0;
> +			tde->last_magic = 0;
> +			tde->cached_msg = false;
> +			if (!tde->de.fc_support) {
> +				tde->sid = SHMTI_ID_INVALID;
> +				tde->base = NULL;
> +				tde->offset = 0;
> +				tde->eplg = NULL;
> +			}
> +
> +			scmi_telemetry_de_state_update(ti, ENA_STATE,
> +						       &tde->de.enabled, false);
> +
> +			if (tde->de.tstamp_support)
> +				scmi_telemetry_de_state_update(ti, ENA_TSTAMP,
> +							       &tde->de.tstamp_enabled,
> +							       false);
> +
> +			/*
> +			 * Unlinking ONLY BLK_TS lines since, per the SCMI spec,
> +			 * the UUID/DE associations are permanent within the same
> +			 * session boot: after a reset has cleared the server-side
> +			 * configuration the next time SHMTIs will be re-populated,
> +			 * these same UUID/DE associations will be re-instated.
> +			 */
> +			scmi_telemetry_blkts_unlink(tde);
> +		}
> +	}
> +
> +	for (int i = 0; i < rinfo->num_groups; i++) {
> +		rinfo->grps[i].enabled = false;
> +		rinfo->grps[i].tstamp_enabled = false;
> +		rinfo->grps[i].current_mode = SCMI_TLM_ONDEMAND;
> +		rinfo->grps[i].active_update_interval = 0;
> +	}
> +}
> +
> +static int scmi_telemetry_reset(const struct scmi_protocol_handle *ph)
> +{
> +	struct telemetry_info *ti = ph->get_priv(ph);
> +	struct scmi_xfer *t;
> +	int ret;
> +
> +	/* Stall concurrent configuration request */
> +	guard(mutex)(&ti->config_mtx);
> +
> +	ret = ph->xops->xfer_get_init(ph, TELEMETRY_RESET, sizeof(u32), 0, &t);
> +	if (ret)
> +		return ret;
> +
> +	put_unaligned_le32(0, t->tx.buf);
> +	ret = ph->xops->do_xfer(ph, t);
> +	if (!ret)
> +		scmi_telemetry_local_resources_reset(ti);
> +
> +	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,
> @@ -3979,6 +4059,7 @@ static const struct scmi_telemetry_proto_ops tlm_proto_ops = {
>  	.de_data_read = scmi_telemetry_de_data_read,
>  	.des_bulk_read = scmi_telemetry_des_bulk_read,
>  	.des_sample_get = scmi_telemetry_des_sample_get,
> +	.reset = scmi_telemetry_reset,
>  };
>  
>  /**
> diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
> index 7177f739f062..012894e1d9be 100644
> --- a/include/linux/scmi_protocol.h
> +++ b/include/linux/scmi_protocol.h
> @@ -1024,6 +1024,7 @@ struct scmi_telemetry_de_sample {
>   *		    the ones belonging to a specific group when provided.
>   *		    This causes an immediate update platform-side of all the
>   *		    enabled DEs.
> + * @reset: reset configuration and telemetry data.
>   */
>  struct scmi_telemetry_proto_ops {
>  	const struct scmi_telemetry_info *(*info_get)
> @@ -1051,6 +1052,7 @@ struct scmi_telemetry_proto_ops {
>  	int __must_check (*des_sample_get)(const struct scmi_protocol_handle *ph,
>  					   int grp_id, unsigned int *num_samples,
>  					   struct scmi_telemetry_de_sample *samples);
> +	int (*reset)(const struct scmi_protocol_handle *ph);
>  };
>  
>  /**




More information about the linux-arm-kernel mailing list