Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
To: tze.yee.ng@altera.com
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Jorge Marques" <jorge.marques@analog.com>,
	"Przemysław Gaj" <pgaj@cadence.com>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Adrian Ng Ho Yin" <adrian.ho.yin.ng@altera.com>,
	"Felix Gu" <ustc.gu@gmail.com>,
	"Manikanta Guntupalli" <manikanta.guntupalli@amd.com>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Jarkko Nikula" <jarkko.nikula@linux.intel.com>,
	imx@lists.linux.dev
Subject: Re: [PATCH v6 0/5] i3c: Improve CCC reliability with actual_len, validation, and Direct GET retry
Date: Mon, 13 Jul 2026 19:27:59 +0200	[thread overview]
Message-ID: <alUgH73gxpKQPOIF@tom-desktop> (raw)
In-Reply-To: <cover.1783493867.git.tze.yee.ng@altera.com>

On Wed, Jul 08, 2026 at 12:17:36AM -0700, tze.yee.ng@altera.com wrote:
> From: Tze Yee Ng <tze.yee.ng@altera.com>
> 
> 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@bp.renesas.com>

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
> 

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

      parent reply	other threads:[~2026-07-13 17:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  7:17 [PATCH v6 0/5] i3c: Improve CCC reliability with actual_len, validation, and Direct GET retry tze.yee.ng
2026-07-08  7:17 ` [PATCH v6 1/5] i3c: ccc: Add actual_len to struct i3c_ccc_cmd_payload tze.yee.ng
2026-07-08 13:11   ` Frank Li
2026-07-08 14:52   ` Alexandre Mergnat
2026-07-08  7:17 ` [PATCH v6 2/5] i3c: master: Report actual GET CCC payload length on success tze.yee.ng
2026-07-08  9:44   ` sashiko-bot
2026-07-08 13:16   ` Frank Li
2026-07-08 14:52   ` Alexandre Mergnat
2026-07-08  7:17 ` [PATCH v6 3/5] i3c: master: dw: Map CCC hardware errors to I3C M0/M2 tze.yee.ng
2026-07-08 13:20   ` Frank Li
2026-07-08  7:17 ` [PATCH v6 4/5] i3c: master: Validate GET CCC payload length and retry Direct GET once tze.yee.ng
2026-07-08 10:01   ` sashiko-bot
2026-07-08 14:53   ` Frank Li
2026-07-08 15:19   ` Alexandre Mergnat
2026-07-08  7:17 ` [PATCH v6 5/5] i3c: master: Add optional_bytes for variable-length GET CCC validation tze.yee.ng
2026-07-08 15:01   ` Frank Li
2026-07-09  2:56     ` NG, TZE YEE
2026-07-09  3:37       ` Frank Li
2026-07-09 11:32   ` Alexandre Mergnat
2026-07-13 13:58 ` [PATCH v6 0/5] i3c: Improve CCC reliability with actual_len, validation, and Direct GET retry claudiu beznea
2026-07-13 17:27 ` Tommaso Merciai [this message]

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=alUgH73gxpKQPOIF@tom-desktop \
    --to=tommaso.merciai.xr@bp.renesas.com \
    --cc=Frank.Li@nxp.com \
    --cc=adrian.ho.yin.ng@altera.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=imx@lists.linux.dev \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jorge.marques@analog.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manikanta.guntupalli@amd.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=pgaj@cadence.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tze.yee.ng@altera.com \
    --cc=ustc.gu@gmail.com \
    --cc=wsa+renesas@sang-engineering.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