From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: 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,
jonathan.cameron@oss.qualcomm.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,
Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v17 04/34] firmware: arm_scmi: Add centralized detection of truncated replies
Date: Tue, 24 Nov 2026 19:48:10 +0000 [thread overview]
Message-ID: <20261124194841.1147072-5-cristian.marussi@arm.com> (raw)
In-Reply-To: <20261124194841.1147072-1-cristian.marussi@arm.com>
When an xfer is allocated with a very well known fixed reply size by
providing a non-zero rx_size parameter to xfer_get_init(), it becomes
possible to verify if the effectively received reply was truncated.
Add the logic to detect and report truncated replies.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v16 --> v17
- use %zu
- consider expected_size when reset_rx_to_max
---
drivers/firmware/arm_scmi/driver.c | 14 +++++++++++++-
drivers/firmware/arm_scmi/protocols.h | 8 ++++++++
drivers/firmware/arm_scmi/raw_mode.c | 1 +
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 6dd249c08f5f..35adee6a7a15 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -1356,6 +1356,16 @@ static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc,
}
}
+ /* Check for truncated messages..it will be logged by the caller */
+ if (!ret && !xfer->hdr.status && xfer->expected_rx_len &&
+ xfer->expected_rx_len != xfer->rx.len) {
+ dev_dbg(dev,
+ "Truncated reply - HDR:%08X expected:%zu received:%zu\n",
+ pack_scmi_header(&xfer->hdr), xfer->expected_rx_len,
+ xfer->rx.len);
+ xfer->hdr.status = SCMI_ERR_COMMS;
+ }
+
return ret;
}
@@ -1508,7 +1518,7 @@ static void reset_rx_to_maxsz(const struct scmi_protocol_handle *ph,
const struct scmi_protocol_instance *pi = ph_to_pi(ph);
struct scmi_info *info = handle_to_scmi_info(pi->handle);
- xfer->rx.len = info->desc->max_msg_size;
+ xfer->rx.len = xfer->expected_rx_len ?: info->desc->max_msg_size;
}
/**
@@ -1616,6 +1626,8 @@ static int xfer_get_init(const struct scmi_protocol_handle *ph,
xfer->tx.len = tx_size;
xfer->rx.len = rx_size ? : info->desc->max_msg_size;
+ /* When a specific rx_size was specified, check for truncation */
+ xfer->expected_rx_len = rx_size ? : 0;
xfer->hdr.type = MSG_TYPE_COMMAND;
xfer->hdr.id = msg_id;
xfer->hdr.poll_completion = false;
diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h
index c15ec188291a..50b89c56e309 100644
--- a/drivers/firmware/arm_scmi/protocols.h
+++ b/drivers/firmware/arm_scmi/protocols.h
@@ -106,6 +106,13 @@ struct scmi_msg_hdr {
* @rx: Receive message, the buffer should be pre-allocated to store
* message. If request-ACK protocol is used, we can reuse the same
* buffer for the rx path as we use for the tx path.
+ * @expected_rx_len: The expected length of the payload in the reply, excluding
+ * the status field. When set to a non-zero value this is used
+ * to evaluate if a reply had been possibly truncated due to a
+ * misconfigured transport: it is only set to some meaningful
+ * non-zero value for replies having a very well known fixed
+ * size, definitely not for variable-sized xfers with an RX
+ * len initialized to max_msg_size.
* @done: command message transmit completion event
* @async_done: pointer to delayed response message received event completion,
* or NULL when no delayed response is expected. Protected by
@@ -139,6 +146,7 @@ struct scmi_xfer {
struct scmi_msg_hdr hdr;
struct scmi_msg tx;
struct scmi_msg rx;
+ size_t expected_rx_len;
struct completion done;
struct completion *async_done;
bool pending;
diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c
index 7e42dd6cc2af..45206edff446 100644
--- a/drivers/firmware/arm_scmi/raw_mode.c
+++ b/drivers/firmware/arm_scmi/raw_mode.c
@@ -574,6 +574,7 @@ static int scmi_xfer_raw_get_init(struct scmi_raw_mode_info *raw, void *buf,
xfer->hdr.status = SCMI_SUCCESS;
xfer->tx.len = tx_size;
xfer->rx.len = raw->desc->max_msg_size;
+ xfer->expected_rx_len = 0;
/* Clear the whole TX buffer */
memset(xfer->tx.buf, 0x00, raw->desc->max_msg_size);
if (xfer->tx.len)
--
2.54.0
next prev parent reply other threads:[~2026-11-24 19:50 UTC|newest]
Thread overview: 35+ 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 19:48 ` [PATCH v17 02/34] [RFC] firmware: arm_scmi: Additional iterators consistency checks Cristian Marussi
2026-11-24 19:48 ` [PATCH v17 03/34] firmware: arm_scmi: Make Clock attributes size deterministic Cristian Marussi
2026-11-24 19:48 ` Cristian Marussi [this message]
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
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=20261124194841.1147072-5-cristian.marussi@arm.com \
--to=cristian.marussi@arm.com \
--cc=arm-scmi@vger.kernel.org \
--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=jonathan.cameron@oss.qualcomm.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®