Re: [PATCH v6 0/5] i3c: Improve CCC reliability with actual_len, validation, and Direct GET retry

From: Tommaso Merciai

Date: Mon Jul 13 2026 - 13:28:26 EST


On Wed, Jul 08, 2026 at 12:17:36AM -0700, tze.yee.ng@xxxxxxxxxx wrote:
> From: Tze Yee Ng <tze.yee.ng@xxxxxxxxxx>
>
> This series improves I3C Common Command Code (CCC) handling in the I3C
> core and master drivers. It separates requested and received GET payload
> lengths, validates GET responses centrally, and retries failed Direct GET
> CCCs once by default.
>
> The DesignWare I3C master driver reports standard I3C M0/M2 error codes so
> the core can decide when a retry is appropriate. Variable-length GET CCC
> rules (GETMRL, GETMXDS) are described by callers via optional_bytes.
>
> Patch 1/5 adds actual_len to struct i3c_ccc_cmd_payload.
>
> Patch 2/5 has all I3C master drivers set actual_len on successful GET
> transfers and updates core GET helpers to interpret results from actual_len
> instead of len.
>
> Patch 3/5 maps DesignWare CCC hardware errors to I3C M0/M2. M2 is reported
> only for broadcast address-header NACK (7'h7E). Target address NACK
> returns -EIO.
>
> Patch 4/5 adds retries to struct i3c_ccc_cmd, validates GET payload length
> in i3c_master_send_ccc_cmd_locked() after a successful transfer, and
> retries failed Direct GET CCCs when the driver reports failure or an I3C
> error. Validation failures are not retried.
>
> Patch 5/5 adds optional_bytes so callers describe variable-length GET CCC
> responses. GETMRL and GETMXDS set optional_bytes at the call site.
>
> Changes in v6:
> - Fix ADI and Cadence GET actual_len: store hardware-reported xfer bytes
> in cmd->rx_len and set actual_len from that, not from payload.len.
> - Fix Renesas GET actual_len: drain the response FIFO at rx_buf + rx_count
> in resp_isr, clamp rx_count to data_len before subtracting (avoids
> unsigned underflow when rx_isr reads round up to 32-bit words), and
> report actual_len from cmd->rx_count.
> - Fix dw_i3c_ccc_set() to use dw_i3c_ccc_map_err() so SET CCCs get the
> same M0/M2 mapping as GET.
>
> Changes in v5:
> - Split the series into five patches for clearer review:
> actual_len API, driver/core adoption, DW error mapping, core validation/
> retry, and optional_bytes.
> - Fix regression in v4 patch 1: keep actual_len assignment in
> dw_i3c_ccc_get(), not dw_i3c_ccc_set().
> - Move actual_len adoption in drivers/i3c/master.c into patch 2 so patch 2
> matches its title and works on its own.
> - Split optional_bytes into its own patch (5/5); patch 4/5 adds strict
> exact-length validation and retry only.
> - Do not retry on validation failure; retry only on driver/I3C errors.
> - Reset actual_len before each GET retry only when cmd->rnw is set.
> - Add @retries kernel-doc for struct i3c_ccc_cmd.
> - Simplify i3c_ccc_validate_payload_len() per review (drop redundant
> exact-length check when optional_bytes == 0).
> - Clarify GETMXDS fallback comment: with optional_bytes = 3, a 2-byte
> success on the first attempt no longer needs the shorter retry path.
> - Add Reviewed-by: Alexandre Mergnat on patch 3/5.
>
> Changes in v4:
> - Add actual_len to keep requested and received lengths separate.
> - Map M2 only for broadcast-address NACK; not for target-address NACK.
> - Replace CCC-ID-specific validation with generic actual_len /
> optional_bytes checks.
> - Retry Direct GET CCCs on any error (default once), not only M0/M2.
> - Add optional_bytes and cmd->retries to ccc.h; drop req_len and
> payload.len save/restore in the core.
> - Update SVC, Cadence, ADI, Renesas, and MIPI HCI master drivers.
>
> Changes in v3:
> - In dw_i3c_master_end_xfer_locked(), move RESPONSE_ERROR_ADDRESS_NACK to
> return -EIO.
>
> Changes in v2:
> - Split the monolithic patch into three patches (per review feedback).
> - Move GET payload validation and CCC retry from the DW driver to
> drivers/i3c/master.c.
> - Validate GET CCCs only; drop SET payload-length checks (DW
> RESPONSE_PORT_DATA_LEN is 0 on SET).
> - Retry GET CCCs only; do not repeat side-effecting SET CCCs.
> - Tighten GETMRL validation to exactly 2 or 3 bytes; add GETMXDS
> 2/5-byte handling.
> - Expand M0 mapping to CRC/parity/transfer-abort, not only frame
> errors.
> - Restore dests[].payload.len before retry and on error return.
> - Avoid kmalloc on the common single-destination GET path.
>
>
> Adrian Ng Ho Yin (5):
> i3c: ccc: Add actual_len to struct i3c_ccc_cmd_payload
> i3c: master: Report actual GET CCC payload length on success
> i3c: master: dw: Map CCC hardware errors to I3C M0/M2
> i3c: master: Validate GET CCC payload length and retry Direct GET once
> i3c: master: Add optional_bytes for variable-length GET CCC validation

Tested on RZ/G3E:

Tested-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>

Kind Regards,
Tommaso

>
> drivers/i3c/master.c | 97 ++++++++++++++++++++++----
> drivers/i3c/master/adi-i3c-master.c | 3 +
> drivers/i3c/master/dw-i3c-master.c | 31 ++++++--
> drivers/i3c/master/i3c-master-cdns.c | 3 +
> drivers/i3c/master/mipi-i3c-hci/core.c | 5 +-
> drivers/i3c/master/renesas-i3c.c | 16 +++--
> drivers/i3c/master/svc-i3c-master.c | 4 +-
> include/linux/i3c/ccc.h | 11 ++-
> 8 files changed, 142 insertions(+), 28 deletions(-)
>
> --
> 2.43.7
>