From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Cristian Marussi <cristian.marussi@arm.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
linux-doc@vger.kernel.org, sudeep.holla@kernel.org,
james.quinlan@broadcom.com, f.fainelli@gmail.com,
vincent.guittot@linaro.org, etienne.carriere@st.com,
peng.fan@oss.nxp.com, michal.simek@amd.com, d-gole@ti.com,
elif.topuz@arm.com, lukasz.luba@arm.com, philip.radford@arm.com,
david@kernel.org, souvik.chakravarty@arm.com, leitao@kernel.org,
kas@kernel.org, puranjay@kernel.org, usama.arif@linux.dev,
kernel-team@meta.com
Subject: Re: [PATCH v15 12/35] firmware: arm_scmi: Add Telemetry update intervals enumeration
Date: Mon, 9 Nov 2026 18:07:50 -0800 [thread overview]
Message-ID: <20261109180750.0000150a@oss.qualcomm.com> (raw)
In-Reply-To: <20261109091221.2532706-13-cristian.marussi@arm.com>
On Mon, 9 Nov 2026 09:11:58 +0000
Cristian Marussi <cristian.marussi@arm.com> wrote:
> Add support to enumerate available Telemetry update intervals.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
> ---
> v14 --> v15
> - removed unused dev reference in interval parsing
> - added missing initialization of intrvs->grp_id
> v13 --> v14
> - splitted out of the old Basic Telemetry patch, contains the
> update_intervals enumeration routines
> ---
> drivers/firmware/arm_scmi/telemetry.c | 198 ++++++++++++++++++++++++++
> include/linux/scmi_protocol.h | 21 +++
> 2 files changed, 219 insertions(+)
>
> diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
> index 9944506652f5..e57534c93b26 100644
> --- a/drivers/firmware/arm_scmi/telemetry.c
> +++ b/drivers/firmware/arm_scmi/telemetry.c
> @@ -92,6 +92,21 @@ struct scmi_msg_resp_telemetry_de_description {
> struct scmi_de_desc desc[];
> };
>
> +struct scmi_msg_telemetry_update_intervals {
> + __le32 index;
> + __le32 group_identifier;
> +#define ALL_DES_NO_GROUP 0x0
> +#define SPECIFIC_GROUP_DES 0x1
> +#define ALL_DES_ANY_GROUP 0x2
For previous defines like this they have followed the value they are in.
So I think these belong after flags. (That fits with common practice for
this sort of thing which is why I looked).
> + __le32 flags;
> +};
> +
> +struct scmi_msg_resp_telemetry_update_intervals {
> + __le32 flags;
> +#define INTERVALS_DISCRETE(x) (le32_get_bits((x), BIT(12)) == 0)
> + __le32 intervals[];
> +};
> +
> #define IS_TDE_TSTAMP_TYPE(__t, __ttype) ((__t)->ts_type == (__ttype))
> #define IS_TDE_TS_NONE(_t) (IS_TDE_TSTAMP_TYPE((_t), TSTAMP_NONE))
> #define IS_TDE_TS_LINE(_t) (IS_TDE_TSTAMP_TYPE((_t), TSTAMP_LINE))
> @@ -693,6 +708,176 @@ static int scmi_telemetry_de_descriptors_get(struct telemetry_info *ti)
> return scmi_telemetry_de_groups_init(ti);
> }
>
> +struct scmi_tlm_ivl_priv {
> + struct scmi_telemetry_intervals **intrvs;
> + unsigned int grp_id;
> + unsigned int flags;
Given these are fixed size, maybe u32 for each of them just to
make sure that matches up.
> +};
> +
> +static void iter_intervals_prepare_message(void *message,
> + unsigned int desc_index,
> + const void *priv)
> +{
> + struct scmi_msg_telemetry_update_intervals *msg = message;
> + const struct scmi_tlm_ivl_priv *p = priv;
> +
> + msg->index = cpu_to_le32(desc_index);
> + msg->group_identifier = cpu_to_le32(p->grp_id);
> + msg->flags = cpu_to_le32(FIELD_PREP(GENMASK(3, 0), p->flags));
Need the mask? It's valid but I'd expect the protection on sanity
to be at the point of p->flags being written rather than here.
> +}
> +
> +static int iter_intervals_update_state(struct scmi_iterator_state *st,
> + const void *response, void *priv)
> +{
> + const struct scmi_msg_resp_telemetry_update_intervals *r = response;
> +
> + st->num_returned = le32_get_bits(r->flags, GENMASK(11, 0));
> + st->num_remaining = le32_get_bits(r->flags, GENMASK(31, 16));
> +
> + if (st->rx_len < (sizeof(*r) + sizeof(r->intervals[0]) * st->num_returned))
> + return -EINVAL;
> +
> + /*
> + * total intervals is not declared previously anywhere so we
> + * assume it's returned+remaining on first call.
> + */
> + if (!st->max_resources) {
> + struct scmi_tlm_ivl_priv *p = priv;
> + struct scmi_telemetry_intervals *intrvs;
> + bool discrete;
> + int inum;
> +
> + discrete = INTERVALS_DISCRETE(r->flags);
> + /* Check consistency on first call */
> + if (!discrete && (st->num_returned != 3 || st->num_remaining != 0))
> + return -EINVAL;
> +
> + inum = st->num_returned + st->num_remaining;
> + intrvs = kzalloc_flex(*intrvs, update_intervals, inum);
> + if (!intrvs)
> + return -ENOMEM;
> +
> + intrvs->num_intervals = inum;
> + intrvs->discrete = discrete;
> + intrvs->grp_id = p->grp_id;
> + st->max_resources = intrvs->num_intervals;
> +
> + *p->intrvs = intrvs;
> + }
> +
> + return 0;
> +}
> +
> +static int
> +iter_intervals_process_response(const struct scmi_protocol_handle *ph,
> + const void *response,
> + struct scmi_iterator_state *st, void *priv)
> +{
> + const struct scmi_msg_resp_telemetry_update_intervals *r = response;
> + struct scmi_tlm_ivl_priv *p = priv;
> + struct scmi_telemetry_intervals *intrvs = *p->intrvs;
> + unsigned int idx = st->loop_idx;
> +
> + intrvs->update_intervals[st->desc_index + idx] =
> + le32_to_cpu(r->intervals[idx]);
I'd go a bit long and put that on one line.
> +
> + return 0;
> +}
> +static int
> +scmi_telemetry_enumerate_common_intervals(struct telemetry_info *ti)
> +{
> + unsigned int flags;
> + int ret;
> +
> + flags = !ti->info.per_group_config_support ?
> + ALL_DES_ANY_GROUP : ALL_DES_NO_GROUP;
Why not flip the condition and reverse the values?
This thing is weird enough I'd add a comment or rename them
to be more helpful. ALL_DES_THAT_HAVE_NO_GROUP for example.
> +
> + ret = scmi_tlm_enumerate_update_intervals(ti, &ti->info.intervals,
> + SCMI_TLM_GRP_INVALID, flags);
> + if (ret)
> + return ret;
> +
> + /* A copy for UAPI access... */
> + ti->info.base.num_intervals = ti->info.intervals->num_intervals;
> +
> + /* Delegate freeing of allocated intervals to unbind time */
> + return devm_add_action_or_reset(ti->ph->dev,
> + scmi_telemetry_intervals_free,
> + ti->info.intervals);
> +}
> /**
next prev parent reply other threads:[~2026-11-10 2:07 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 9:11 [PATCH v15 00/35] Introduce SCMI Telemetry support Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 01/35] firmware: arm_scmi: Harden iterators state parsing Cristian Marussi
2026-11-09 21:57 ` Jonathan Cameron
2026-11-10 8:19 ` Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 02/35] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 03/35] firmware: arm_scmi: Introduce a dedicated SCMI Errors header Cristian Marussi
2026-11-09 22:01 ` Jonathan Cameron
2026-11-10 8:23 ` Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 04/35] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-11-09 22:07 ` Jonathan Cameron
2026-11-10 8:27 ` Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 05/35] firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 06/35] firmware: arm_scmi: Introduce protocol instance notifiers Cristian Marussi
2026-11-09 23:32 ` Jonathan Cameron
2026-11-09 9:11 ` [PATCH v15 07/35] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 08/35] include: trace: Add Telemetry trace events Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 09/35] firmware: arm_scmi: Add Telemetry basic attributes enumeration Cristian Marussi
2026-11-09 23:57 ` Jonathan Cameron
2026-11-09 9:11 ` [PATCH v15 10/35] firmware: arm_scmi: Add Telemetry resources enumeration Cristian Marussi
2026-11-10 1:36 ` Jonathan Cameron
2026-11-10 15:33 ` Cristian Marussi
2026-11-12 18:01 ` Jonathan Cameron
2026-11-12 19:56 ` Cristian Marussi
2026-11-09 9:11 ` [PATCH v15 11/35] firmware: arm_scmi: Add Telemetry groups initialization Cristian Marussi
2026-11-10 1:53 ` Jonathan Cameron
2026-11-09 9:11 ` [PATCH v15 12/35] firmware: arm_scmi: Add Telemetry update intervals enumeration Cristian Marussi
2026-11-10 2:07 ` Jonathan Cameron [this message]
2026-11-09 9:11 ` [PATCH v15 13/35] firmware: arm_scmi: Add Telemetry SHMTI areas enumeration Cristian Marussi
2026-11-10 2:26 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 14/35] firmware: arm_scmi: Add Telemetry TDCF areas parsing support Cristian Marussi
2026-11-10 18:15 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 15/35] firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines Cristian Marussi
2026-11-10 18:33 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 16/35] firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines Cristian Marussi
2026-11-10 18:49 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 17/35] firmware: arm_scmi: Add Telemetry configuration operations Cristian Marussi
2026-11-10 20:07 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 18/35] firmware: arm_scmi: Add Telemetry DataEvent read capabilities Cristian Marussi
2026-11-10 21:59 ` Jonathan Cameron
2026-11-12 4:30 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 19/35] firmware: arm_scmi: Add Telemetry reset logic Cristian Marussi
2026-11-10 22:07 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 20/35] firmware: arm_scmi: Add Telemetry notification support Cristian Marussi
2026-11-10 22:16 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 21/35] firmware: arm_scmi: Add Telemetry boot-on support Cristian Marussi
2026-11-10 22:25 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 22/35] firmware: arm-scmi: Add Telemetry generic event support Cristian Marussi
2026-11-10 22:33 ` Jonathan Cameron
2026-11-12 19:58 ` Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 23/35] firmware: arm_scmi: Add Telemetry generation counter event Cristian Marussi
2026-11-10 22:46 ` Jonathan Cameron
2026-11-12 20:17 ` Cristian Marussi
2026-11-12 21:44 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 24/35] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-11-10 22:50 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 25/35] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-11-10 22:54 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 26/35] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-11-10 22:55 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 27/35] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-11-10 22:57 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 28/35] firmware: arm_scmi: Add un-managed methods to get/put protocols operations Cristian Marussi
2026-11-10 23:01 ` Jonathan Cameron
2026-11-10 23:18 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 29/35] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-11-10 23:13 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 30/35] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-11-10 23:46 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 31/35] firmware: arm_scmi: Enable autoloading for " Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 32/35] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 33/35] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-11-10 23:54 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 34/35] [RFC] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
2026-11-11 0:13 ` Jonathan Cameron
2026-11-09 9:12 ` [PATCH v15 35/35] [RFC] tools/testing/scmi: Add SCMI Telemetry testing tool Cristian Marussi
2026-11-11 0:16 ` Jonathan Cameron
2026-11-11 0:38 ` [PATCH v15 00/35] Introduce SCMI Telemetry support Jonathan Cameron
2026-11-11 9:51 ` Sudeep Holla
2026-11-11 10:15 ` Cristian Marussi
2026-11-11 18:39 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261109180750.0000150a@oss.qualcomm.com \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=d-gole@ti.com \
--cc=david@kernel.org \
--cc=elif.topuz@arm.com \
--cc=etienne.carriere@st.com \
--cc=f.fainelli@gmail.com \
--cc=james.quinlan@broadcom.com \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=leitao@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=philip.radford@arm.com \
--cc=puranjay@kernel.org \
--cc=souvik.chakravarty@arm.com \
--cc=sudeep.holla@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.