All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Billy Tsai" <billy_tsai@aspeedtech.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	Frank.Li@kernel.org, linux-i3c@lists.infradead.org
Subject: Re: [PATCH 7/8] i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization
Date: Tue, 01 Sep 2026 11:51:20 +0000	[thread overview]
Message-ID: <20260901115121.622F71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-b4-i3c-hci-ast2700-v1-7-19909e7cbd7e@aspeedtech.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Calling `of_device_is_compatible()` via the `is_aspeed()` helper inside the high-speed PIO TX data transfer loop causes severe CPU overhead and latency.
- [High] Hardware TOCTOU / Stale write pointer read leading to FIFO overflow.
--

commit 3be95193756af176407d7f4071b09a591d9a4eb3
Author: Billy Tsai <billy_tsai@aspeedtech.com>

i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization

This commit updates the MIPI I3C HCI driver to improve TX FIFO utilization
for the AST2700 controller. It introduces a vendor-specific check to poll
the exact number of free FIFO entries using hardware read/write pointers
instead of relying on a half-empty threshold.

> diff --git a/drivers/i3c/master/mipi-i3c-hci/pio.c b/drivers/i3c/master/mipi-i3c-hci/pio.c
> index 6bd5e43364a1d..3d70257dcc1dc 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/pio.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/pio.c

[ ... ]

> @@ -295,11 +296,23 @@ static bool hci_pio_do_tx(struct i3c_hci *hci, struct hci_pio_data *pio)
>  	p += (xfer->data_len - xfer->data_left) / 4;
>  
>  	while (xfer->data_left >= 4) {
> -		/* bail out if FIFO free space is below set threshold */
> -		if (!(pio_reg_read(INTR_STATUS) & STAT_TX_THLD))
> +		unsigned int avail = pio->tx_thresh_size;
> +
> +		if (is_aspeed(hci)) {

[Severity: High]
Does calling of_device_is_compatible() inside this fastpath byte-transfer
loop cause significant CPU overhead and latency?

Looking at is_aspeed() in vendor_aspeed.h, it parses the Device Tree and
performs string matching:

static inline bool is_aspeed(struct i3c_hci *hci)
{
	return of_device_is_compatible(hci->master.dev.of_node,
					"aspeed,ast2700-i3c-hci");
}

Since this executes repeatedly for every 4 bytes transferred, it might ruin
throughput, especially for non-Aspeed controllers where it gets evaluated
constantly. Would it be better to check compatibility exactly once during
probe and cache the result as a quirk flag?

> +			/*
> +			 * The vendor FIFO pointers give the exact free space,
> +			 * allowing better TX FIFO utilization than the
> +			 * threshold status.
> +			 */
> +			avail = aspeed_i3c_avail_tx_entries(hci);

[Severity: High]
Could this read of the hardware write pointer immediately after posting a
write lead to a FIFO overflow?

Memory-mapped I/O writes over buses like AHB/AXI are posted, and the
hardware controller might need a few clock cycles to commit the data and
update its pointers. 

If aspeed_i3c_avail_tx_entries() reads QUEUE_PTR0 before the hardware
increments the write pointer, won't avail remain artificially high?
If it does, the loop will immediately push another chunk of data,
potentially overflowing the 32-entry hardware FIFO. 

Should the driver locally track and deduct the number of words written from
the available space during the active transfer instead of re-polling the
hardware register?

> +			if (!avail)
> +				return false;
> +		} else if (!(pio_reg_read(INTR_STATUS) & STAT_TX_THLD)) {

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-b4-i3c-hci-ast2700-v1-0-19909e7cbd7e@aspeedtech.com?part=7

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Billy Tsai" <billy_tsai@aspeedtech.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	Frank.Li@kernel.org, linux-i3c@lists.infradead.org
Subject: Re: [PATCH 7/8] i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization
Date: Tue, 01 Sep 2026 11:51:20 +0000	[thread overview]
Message-ID: <20260901115121.622F71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-b4-i3c-hci-ast2700-v1-7-19909e7cbd7e@aspeedtech.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Calling `of_device_is_compatible()` via the `is_aspeed()` helper inside the high-speed PIO TX data transfer loop causes severe CPU overhead and latency.
- [High] Hardware TOCTOU / Stale write pointer read leading to FIFO overflow.
--

commit 3be95193756af176407d7f4071b09a591d9a4eb3
Author: Billy Tsai <billy_tsai@aspeedtech.com>

i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization

This commit updates the MIPI I3C HCI driver to improve TX FIFO utilization
for the AST2700 controller. It introduces a vendor-specific check to poll
the exact number of free FIFO entries using hardware read/write pointers
instead of relying on a half-empty threshold.

> diff --git a/drivers/i3c/master/mipi-i3c-hci/pio.c b/drivers/i3c/master/mipi-i3c-hci/pio.c
> index 6bd5e43364a1d..3d70257dcc1dc 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/pio.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/pio.c

[ ... ]

> @@ -295,11 +296,23 @@ static bool hci_pio_do_tx(struct i3c_hci *hci, struct hci_pio_data *pio)
>  	p += (xfer->data_len - xfer->data_left) / 4;
>  
>  	while (xfer->data_left >= 4) {
> -		/* bail out if FIFO free space is below set threshold */
> -		if (!(pio_reg_read(INTR_STATUS) & STAT_TX_THLD))
> +		unsigned int avail = pio->tx_thresh_size;
> +
> +		if (is_aspeed(hci)) {

[Severity: High]
Does calling of_device_is_compatible() inside this fastpath byte-transfer
loop cause significant CPU overhead and latency?

Looking at is_aspeed() in vendor_aspeed.h, it parses the Device Tree and
performs string matching:

static inline bool is_aspeed(struct i3c_hci *hci)
{
	return of_device_is_compatible(hci->master.dev.of_node,
					"aspeed,ast2700-i3c-hci");
}

Since this executes repeatedly for every 4 bytes transferred, it might ruin
throughput, especially for non-Aspeed controllers where it gets evaluated
constantly. Would it be better to check compatibility exactly once during
probe and cache the result as a quirk flag?

> +			/*
> +			 * The vendor FIFO pointers give the exact free space,
> +			 * allowing better TX FIFO utilization than the
> +			 * threshold status.
> +			 */
> +			avail = aspeed_i3c_avail_tx_entries(hci);

[Severity: High]
Could this read of the hardware write pointer immediately after posting a
write lead to a FIFO overflow?

Memory-mapped I/O writes over buses like AHB/AXI are posted, and the
hardware controller might need a few clock cycles to commit the data and
update its pointers. 

If aspeed_i3c_avail_tx_entries() reads QUEUE_PTR0 before the hardware
increments the write pointer, won't avail remain artificially high?
If it does, the loop will immediately push another chunk of data,
potentially overflowing the 32-entry hardware FIFO. 

Should the driver locally track and deduct the number of words written from
the available space during the active transfer instead of re-polling the
hardware register?

> +			if (!avail)
> +				return false;
> +		} else if (!(pio_reg_read(INTR_STATUS) & STAT_TX_THLD)) {

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-b4-i3c-hci-ast2700-v1-0-19909e7cbd7e@aspeedtech.com?part=7

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

  reply	other threads:[~2026-09-01 11:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 11:35 [PATCH 0/8] i3c: mipi-i3c-hci: Add Aspeed AST2700 support Billy Tsai
2026-09-01 11:35 ` Billy Tsai
2026-09-01 11:35 ` [PATCH 1/8] dt-bindings: i3c: Document the AST2700 I3C controller Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 20:41   ` Frank Li
2026-09-01 20:41     ` Frank Li
2026-09-09  5:33     ` 回覆: " Billy Tsai
2026-09-09  5:33       ` Billy Tsai
2026-09-07  6:28   ` Krzysztof Kozlowski
2026-09-07  6:28     ` Krzysztof Kozlowski
2026-09-09  5:35     ` 回覆: " Billy Tsai
2026-09-09  5:35       ` Billy Tsai
2026-09-01 11:35 ` [PATCH 2/8] i3c: mipi-i3c-hci: Support address-indexed DAT slots Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:49   ` sashiko-bot
2026-09-01 11:49     ` sashiko-bot
2026-09-01 20:47   ` Frank Li
2026-09-01 20:47     ` Frank Li
2026-09-09  5:36     ` 回覆: " Billy Tsai
2026-09-09  5:36       ` Billy Tsai
2026-09-01 11:35 ` [PATCH 3/8] i3c: mipi-i3c-hci: Add a quirk for 64-bit DMA addressing Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:55   ` sashiko-bot
2026-09-01 11:55     ` sashiko-bot
2026-09-01 20:51   ` Frank Li
2026-09-01 20:51     ` Frank Li
2026-09-09  5:37     ` 回覆: " Billy Tsai
2026-09-09  5:37       ` Billy Tsai
2026-09-01 11:35 ` [PATCH 4/8] i3c: mipi-i3c-hci: Add a quirk to clear the TX start threshold Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:49   ` sashiko-bot
2026-09-01 11:49     ` sashiko-bot
2026-09-01 20:58   ` Frank Li
2026-09-01 20:58     ` Frank Li
2026-09-09  5:37     ` 回覆: " Billy Tsai
2026-09-09  5:37       ` Billy Tsai
2026-09-01 11:35 ` [PATCH 5/8] i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:52   ` sashiko-bot
2026-09-01 11:52     ` sashiko-bot
2026-09-01 21:18   ` Frank Li
2026-09-01 21:18     ` Frank Li
2026-09-09  5:38     ` 回覆: " Billy Tsai
2026-09-09  5:38       ` Billy Tsai
2026-09-01 11:35 ` [PATCH 6/8] i3c: mipi-i3c-hci: Program AST2700 IBI termination threshold Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:35 ` [PATCH 7/8] i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization Billy Tsai
2026-09-01 11:35   ` Billy Tsai
2026-09-01 11:51   ` sashiko-bot [this message]
2026-09-01 11:51     ` sashiko-bot
2026-09-01 11:35 ` [PATCH 8/8] i3c: mipi-i3c-hci: Support the AST2700 internal pull-ups Billy Tsai
2026-09-01 11:35   ` Billy Tsai

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=20260901115121.622F71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=billy_tsai@aspeedtech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-i3c@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.