Re: [PATCH v2 3/3] mctp i3c: Clamp transfer lengths to the controller limits
From: Frank Li
Date: Thu Nov 05 2026 - 17:11:21 EST
On Thu, Nov 05, 2026 at 02:24:25PM +0530, Shubham Patil wrote:
> 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@xxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> 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
>