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 15/35] firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines
Date: Tue, 10 Nov 2026 10:33:56 -0800 [thread overview]
Message-ID: <20261110103356.00003a29@oss.qualcomm.com> (raw)
In-Reply-To: <20261109091221.2532706-16-cristian.marussi@arm.com>
On Mon, 9 Nov 2026 09:12:01 +0000
Cristian Marussi <cristian.marussi@arm.com> wrote:
> Add support to parse, track and link TDCF BLK_TS lines to the related
> discovered DataEvents.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
A few minor things inline. + I think some of previous patch belongs
in here. Getting patch break up perfect is sometimes a pain, but it
really helps keep things logically together for reviewers and on
a massive set like this, anything that keeps the reviewers happy
is the way to go!
Jonathan
> ---
> drivers/firmware/arm_scmi/telemetry.c | 317 +++++++++++++++++++++++++-
> 1 file changed, 313 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
> index 810195889484..e3fbcb1e6ea7 100644
> --- a/drivers/firmware/arm_scmi/telemetry.c
> +++ b/drivers/firmware/arm_scmi/telemetry.c
> +
> +static inline void scmi_telemetry_line_free(struct telemetry_line *line)
> +{
> + void *blob;
> +
> + switch (line->type) {
> + case TDCF_BLK_TS_LINE:
> + blob = to_blkts(line);
> + kfree(blob);
The local variable isn't adding much over
kfree(to_blkts(line));
> + break;
> + default:
> + WARN_ON(1);
> + break;
> + }
> +}
> +
> +static struct telemetry_block_ts *
> +scmi_telemetry_blkts_create(struct telemetry_shmti *shmti, unsigned long offset)
> +{
> + struct telemetry_block_ts *bts;
> + int ret;
> +
> + bts = kzalloc_obj(*bts);
Use a __free() here and then no_free_ptr() on the return.
> + if (!bts)
> + return NULL;
> +
> + ret = scmi_telemetry_line_init(shmti, &bts->line, offset, TDCF_BLK_TS_LINE);
> + if (ret) {
> + kfree(bts);
> + return NULL;
> + }
> +
> + trace_scmi_tlm_collect(0, shmti->info.sid, offset, "SHMTI_NEW_BLKTS");
> +
> + return bts;
> +}
> +
> +/**
> + * scmi_telemetry_tdcf_blkts_parse - A BLK_TS line parser
> + *
> + * @ti: A reference to the telemetry_info descriptor
> + * @bts_payld: TDCF payld line to process
> + * @snap: A reference to the working SHMTI snapshot that will be processed
> + * @active_bts: Input/output reference to keep track of the last blk_ts found
> + *
> + * Process a valid TDCF BLK_TS line and, after having looked up or created a
> + * blk_ts descriptor, update the related data and return it as the currently
> + * active blk_ts, given that it is effectively the last found during this
> + * scan.
> + */
> +static void scmi_telemetry_tdcf_blkts_parse(struct telemetry_info *ti,
> + struct payload *bts_payld,
> + struct shmti_snap *snap,
> + struct telemetry_block_ts **active_bts)
> +{
> + struct telemetry_block_ts *bts, *previous = *active_bts;
> + struct telemetry_shmti *shmti = snap->shmti;
> + u32 meta = PAYLD_META_RAW(bts_payld);
> + unsigned long offset;
> +
> + /* Check for spec compliance */
> + if (BLK_TS_INVALID_RAW(meta)) {
> + trace_scmi_tlm_access(0, "BLK_TS_INVALID", 0, meta);
> + return;
> + }
> +
> + offset = TDCF_OFFS(snap->base, bts_payld);
> + /* A BLK_TS descriptor MUST be returned: it is found or it is created */
> + bts = scmi_telemetry_blkts_get_or_create(shmti, offset);
> + /*
> + * On error processing the new BLK_TS bailout taking care to clear
> + * the previous last active BLK_TS to avoid mistakenly binding to the
> + * next data lines.
> + */
> + if (WARN_ON(!bts))
> + goto out;
> +
> + /* Update the descriptor with the lastest TS */
> + scmi_telemetry_blkts_update_snap(ti, bts, bts_payld, snap->magic);
> +
> +out:
> + /* Drop one refcount on the previous active since we found a new one */
I'd have this mention where the reference was taken as then it's clear why
it makes sense to drop one here. Something like
/*
* Drop one refcount on previous active to match with the one take
* in creation as no longer need to keep it around for potential new
* users.
*/
> + if (previous)
> + scmi_telemetry_line_put(&previous->line);
> +
> + *active_bts = bts;
> }
>
> static inline struct telemetry_de *
> @@ -1561,7 +1801,8 @@ scmi_telemetry_line_data_parse(struct telemetry_de *tde, struct shmti_snap *snap
> *tstamp = 0;
> if (USE_BLK_TS_RAW(meta)) {
> /* Read out the actual BLK_TS */
> - *tstamp = scmi_telemetry_blkts_read(magic, tde);
> + *tstamp = scmi_telemetry_blkts_read(magic, tde,
> + bts_payld, snap);
Noted in review of previous patch that I'd just have all the parameters
back there rather than adding these two here. It isn't consistent in that
some parameters were used and others not, as in that patch magic wasn't used
either!
> } else if (LINE_TS_VALID_RAW(meta)) {
> /*
> * Note that LINE_TS_VALID implies HAS_LINE_EXT and that
> @@ -1906,6 +2187,15 @@ scmi_telemetry_shmti_refresh(struct telemetry_shmti *shmti, int *idx)
> return work;
> }
>
> +static inline void
> +scmi_telemetry_reset_active_lines(struct telemetry_block_ts **active_bts)
> +{
> + if (*active_bts) {
> + scmi_telemetry_line_put(&(*active_bts)->line);
> + *active_bts = NULL;
> + }
> +}
> +
> /**
> * scmi_telemetry_shmti_scan - Full SHMTI scan
> * @ti: A reference to the telemetry info descriptor
> @@ -1976,6 +2266,7 @@ static int scmi_telemetry_shmti_scan(struct telemetry_info *ti,
> qwords -= used_qwords;
> }
>
> + scmi_telemetry_reset_active_lines(&active_bts);
It's only resetting one. Maybe reset_active_line?
> srcu_read_unlock(&shmti->srcu, idx);
>
> if (ret)
> @@ -2120,6 +2411,22 @@ static void scmi_telemetry_resources_free(struct telemetry_info *ti)
> dev_dbg(ti->ph->dev, "SCMI Telemetry resources freed for instance\n");
> }
>
> +static void scmi_telemetry_lines_cleanup(struct telemetry_info *ti)
> +{
> + for (int id = 0; id < ti->num_shmti; id++) {
> + struct telemetry_shmti *shmti = &ti->shmti[id];
> + struct telemetry_line *line;
> + unsigned long idx;
> +
> + guard(mutex)(&shmti->lines_mtx);
> + /* Drop all remaining currently unbound lines and their containers */
I'd avoid the comment. It's a _put so should be clear there may be references
held that keep it alive for now. The comment kind of invites questions about what
it means to drop unbound ones here, and what the lifetimes of others look like.
> + xa_for_each(&shmti->xa_lines, idx, line)
> + __scmi_telemetry_line_put(line);
> +
> + xa_destroy(&shmti->xa_lines);
> + }
> +}
next prev parent reply other threads:[~2026-11-10 18:34 UTC|newest]
Thread overview: 53+ 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-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
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 [this message]
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-09 9:12 ` [PATCH v15 19/35] firmware: arm_scmi: Add Telemetry reset logic Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 20/35] firmware: arm_scmi: Add Telemetry notification support Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 21/35] firmware: arm_scmi: Add Telemetry boot-on support Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 22/35] firmware: arm-scmi: Add Telemetry generic event support Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 23/35] firmware: arm_scmi: Add Telemetry generation counter event Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 24/35] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 25/35] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 26/35] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 27/35] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
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-09 9:12 ` [PATCH v15 29/35] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 30/35] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
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-09 9:12 ` [PATCH v15 34/35] [RFC] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
2026-11-09 9:12 ` [PATCH v15 35/35] [RFC] tools/testing/scmi: Add SCMI Telemetry testing tool Cristian Marussi
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=20261110103356.00003a29@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®