Re: [PATCH v4 3/3] i3c: master: Validate GET CCC payload length and retry Direct GET once
From: NG, TZE YEE
Date: Fri Jul 03 2026 - 05:16:35 EST
On 1/7/2026 6:37 pm, Alexandre Mergnat wrote:
> [You don't often get email from amergnat@xxxxxxxxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Tue, 30 Jun 2026 06:20:27 -0700, tze.yee.ng@xxxxxxxxxx <tze.yee.ng@xxxxxxxxxx> wrote:
>> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
>> index 6b8df8089a35..3ad8a232340e 100644
>> --- a/drivers/i3c/master.c
>> +++ b/drivers/i3c/master.c
>> @@ -914,17 +916,55 @@ static void i3c_ccc_cmd_dest_cleanup(struct i3c_ccc_cmd_dest *dest)
>> [ ... skip 44 lines ... ]
>> + continue;
>> +
>> + min_len = p->len - p->optional_bytes;
>> + if (p->actual_len < min_len ||
>> + (!p->optional_bytes && p->actual_len != p->len))
>> + return -EIO;
>
> Unless I'm misreading, the second condition looks already covered by the
> checks above: when optional_bytes == 0, min_len == len, so
> `actual_len < min_len` rejects anything below len while the earlier
> `actual_len > len` check rejects anything above, leaving only
> actual_len == len. Could `(!p->optional_bytes && p->actual_len != p->len)`
> be dropped to simplify? Not a correctness concern.
>
Hi Alexandre,
Agreed — you read it correctly. When optional_bytes == 0, min_len == len
and the surrounding checks already leave only actual_len == len. I will
drop the redundant condition in v5.
>> @@ -1371,19 +1437,21 @@ static int i3c_master_getmxds_locked(struct i3c_master_controller *master,
>> * while expecting shorter length from this CCC command.
>> */
>> dest.payload.len -= 3;
>
> Now that optional_bytes = 3 lets a 2-byte GETMXDS response pass
> i3c_ccc_validate_payload_len() directly, this fallback only triggers
> when the controller/device returns an error on the longer (5-byte)
> request rather than a short read. Is that the intended remaining case? A
> one-line note here would help; otherwise the fallback may now be
> redundant.
>
> --
> Alexandre Mergnat <amergnat@xxxxxxxxxxxx>
Yes — with optional_bytes = 3, a 2-byte success on the first attempt no
longer needs the fallback. It remains for when the 5-byte request fails
rather than returning a short read. I will add a clarifying comment in v5.
Thanks,
Tze Yee