From: Shubham Patil <shubhamsanjay.patil@amd.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Frank Li <Frank.Li@nxp.com>
Cc: <linux-i3c@lists.infradead.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <meaganlloyd@linux.microsoft.com>,
<git@amd.com>, Shubham Patil <shubhamsanjay.patil@amd.com>
Subject: [PATCH v2 3/3] mctp i3c: Clamp transfer lengths to the controller limits
Date: Thu, 5 Nov 2026 14:24:25 +0530 [thread overview]
Message-ID: <20261105085425.3418230-4-shubhamsanjay.patil@amd.com> (raw)
In-Reply-To: <20261105085425.3418230-1-shubhamsanjay.patil@amd.com>
mctp_i3c_setup() takes the maximum read and write lengths straight from
GETMRL and GETMWL. Those describe the endpoint alone, so on a controller
with a smaller limit every read can be built too large and rejected.
Transmit packets can similarly reach the controller even when they are
larger than its transmit buffer. The receive path also allocates an skb
for data the hardware can never deliver.
Use i3c_device_get_max_read_xfer_bytes() and
i3c_device_get_max_write_xfer_bytes() instead, which return the smaller
of the endpoint and controller limits.
Behaviour is unchanged when neither reports a limit, as the helpers
return 0 exactly as the GETMRL and GETMWL fields do today.
Signed-off-by: Shubham Patil <shubhamsanjay.patil@amd.com>
---
drivers/net/mctp/mctp-i3c.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mctp/mctp-i3c.c b/drivers/net/mctp/mctp-i3c.c
index 88d9e36cd4a2..6d08898e1d21 100644
--- a/drivers/net/mctp/mctp-i3c.c
+++ b/drivers/net/mctp/mctp-i3c.c
@@ -81,9 +81,9 @@ struct mctp_i3c_device {
bool have_mdb;
/* I3C dynamic address */
u8 addr;
- /* Maximum read length */
+ /* Maximum read length, limited by the device MRL and the controller */
u16 mrl;
- /* Maximum write length */
+ /* Maximum write length, limited by the device MWL and the controller */
u16 mwl;
/* Provisioned ID */
u64 pid;
@@ -214,8 +214,8 @@ static int mctp_i3c_setup(struct mctp_i3c_device *mi)
i3c_device_get_info(mi->i3c, &info);
mi->have_mdb = info.bcr & BIT(2);
mi->addr = info.dyn_addr;
- mi->mwl = info.max_write_len;
- mi->mrl = info.max_read_len;
+ mi->mwl = i3c_device_get_max_write_xfer_bytes(mi->i3c);
+ mi->mrl = i3c_device_get_max_read_xfer_bytes(mi->i3c);
mi->pid = info.pid;
rc = i3c_device_request_ibi(mi->i3c, &ibi);
--
2.34.1
next prev parent reply other threads:[~2026-11-05 8:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 8:54 [PATCH v2 0/3] i3c: account for controller transfer limits Shubham Patil
2026-11-05 8:54 ` [PATCH v2 1/3] i3c: Add helpers to get the maximum transfer size for a device Shubham Patil
2026-11-05 22:04 ` Frank Li
2026-11-05 8:54 ` [PATCH v2 2/3] i3c: dw: Track the transmit and receive buffer depths separately Shubham Patil
2026-11-05 8:54 ` Shubham Patil [this message]
2026-11-05 22:10 ` [PATCH v2 3/3] mctp i3c: Clamp transfer lengths to the controller limits Frank Li
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=20261105085425.3418230-4-shubhamsanjay.patil@amd.com \
--to=shubhamsanjay.patil@amd.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=git@amd.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=meaganlloyd@linux.microsoft.com \
/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®