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 v17 02/34] [RFC] firmware: arm_scmi: Additional iterators consistency checks
Date: Tue, 24 Nov 2026 15:08:35 -0800 [thread overview]
Message-ID: <20261124150835.000060be@oss.qualcomm.com> (raw)
In-Reply-To: <20261124194841.1147072-3-cristian.marussi@arm.com>
On Tue, 24 Nov 2026 19:48:08 +0000
Cristian Marussi <cristian.marussi@arm.com> wrote:
> Add a few more consistency checks around the number of returned and
> remaining items during the life of an iteration: this is useful to spot
> prematurely terminated iterations that would produce shorter than expected
> results.
>
> Handling these anomalies in the platform multi-part replies within the
> core SCMI iterators machinery avoids the need to address such issues
> multiple times at the protocol layer.
>
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
> ---
> RFC because this is another fix that is potentially disrupting for any
> non compliant SCMI platform deployed in the wild.
Looks sensible to me and cutting out weirdness as early as possible should
make everything more resilient. If there is a broken implementation out there
(and to hit these is not definitely not great) then quirk that when it surfaces.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> ---
> drivers/firmware/arm_scmi/driver.c | 36 ++++++++++++++++++++++++++----
> 1 file changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 55d9cc487916..6dd249c08f5f 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -1852,7 +1852,7 @@ static int __scmi_iterator_run(void *iter, unsigned int *start, unsigned int *en
> const struct scmi_protocol_handle *ph;
> struct scmi_iterator_state *st;
> struct scmi_iterator *i;
> - unsigned int n;
> + unsigned int n, i_start, i_max, i_returned;
>
> if (!iter)
> return -EINVAL;
> @@ -1862,10 +1862,15 @@ static int __scmi_iterator_run(void *iter, unsigned int *start, unsigned int *en
> ph = i->ph;
> st = &i->state;
>
> + /* Initialize iteration counters used to check consistency */
> + i_max = 0;
> + i_returned = 0;
> + i_start = start ? *start : 0;
> +
> /* Reinitialize state for next run */
> st->num_returned = 0;
> st->num_remaining = 0;
> - st->desc_index = start ? *start : 0;
> + st->desc_index = i_start;
>
> do {
> iops->prepare_message(i->msg, st->desc_index, i->priv);
> @@ -1883,11 +1888,34 @@ static int __scmi_iterator_run(void *iter, unsigned int *start, unsigned int *en
> if (ret)
> return ret;
>
> - if (!st->num_returned && st->num_remaining) {
> - dev_err(ph->dev, "Inconsistent multi-part reply.\n");
> + /*
> + * Initialize max items expectation for this run based on
> + * values returned on first message exchange: during the
> + * following iterations consistency will be validated against
> + * these parameters, so as to spot FW anomalies like sudden
> + * termination or unplausible conditions.
> + */
> + if (!i_max)
> + i_max = i_start + st->num_returned + st->num_remaining;
> +
> + if ((!st->num_returned && st->num_remaining) ||
> + (i_max != i_start + i_returned + st->num_returned + st->num_remaining)) {
> + dev_err(ph->dev,
> + "Inconsistent multi-part reply. max:%u i_max:%u i_start:%u i_returned:%u returned:%u remaining:%u desc_index:%u\n",
> + st->max_resources, i_max, i_start, i_returned,
> + st->num_returned, st->num_remaining,
> + st->desc_index);
> return -EINVAL;
> }
>
> + dev_dbg(ph->dev,
> + "Multi-part - max:%u i_max:%u i_start:%u i_returned:%u returned:%u remaining:%u desc_index:%u\n",
> + st->max_resources, i_max, i_start, i_returned,
> + st->num_returned, st->num_remaining, st->desc_index);
> +
> + /* Account for last batch received */
> + i_returned += st->num_returned;
> +
> if (st->num_returned > st->max_resources - st->desc_index) {
> dev_err(ph->dev,
> "No. of resources can't exceed %d\n",
next prev parent reply other threads:[~2026-11-24 23:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 19:48 [PATCH v17 00/34] Introduce SCMI Telemetry support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 01/34] firmware: arm_scmi: Harden iterators state parsing Cristian Marussi
2026-11-24 22:54 ` Jonathan Cameron
2026-11-24 19:48 ` [PATCH v17 02/34] [RFC] firmware: arm_scmi: Additional iterators consistency checks Cristian Marussi
2026-11-24 23:08 ` Jonathan Cameron [this message]
2026-11-24 19:48 ` [PATCH v17 03/34] firmware: arm_scmi: Make Clock attributes size deterministic Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 04/34] firmware: arm_scmi: Add centralized detection of truncated replies Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 05/34] firmware: arm_scmi: Introduce a dedicated SCMI Errors header Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 06/34] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 07/34] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 08/34] firmware: arm_scmi: Refactor __scmi_event_handler_get_ops helper Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 09/34] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 10/34] include: trace: Add Telemetry trace events Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 11/34] firmware: arm_scmi: Add Telemetry basic attributes enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 12/34] firmware: arm_scmi: Add Telemetry resources enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 13/34] firmware: arm_scmi: Add Telemetry global update intervals enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 14/34] firmware: arm_scmi: Add Telemetry SHMTI areas enumeration Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 15/34] firmware: arm_scmi: Add Telemetry TDCF areas parsing support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 16/34] firmware: arm_scmi: Add Telemetry TDCF parsing for BLK_TS lines Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 17/34] firmware: arm_scmi: Add Telemetry TDCF parsing for UUID lines Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 18/34] firmware: arm_scmi: Add Telemetry DEs configuration support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 19/34] firmware: arm_scmi: Add Telemetry global " Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 20/34] firmware: arm_scmi: Add Telemetry Single/Bulk DEs reads Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 21/34] firmware: arm_scmi: Add Telemetry boot-on support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 22/34] firmware: arm_scmi: Invoke proper protocol cleanup on failure Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 23/34] firmware: arm_scmi: Refactor protocol allocation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 24/34] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 25/34] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 26/34] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 27/34] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 28/34] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 29/34] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 30/34] firmware: arm_scmi: Enable autoloading for " Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 31/34] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 32/34] [RFC] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 33/34] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 34/34] [RFC] tools/testing/scmi: Add SCMI Telemetry testing tool Cristian Marussi
2026-11-24 22:53 ` [PATCH v17 00/34] Introduce SCMI Telemetry support 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=20261124150835.000060be@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