From: sashiko-bot@kernel.org
To: "Vincent Jardin" <vjardin@free.fr>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v3 1/2] i2c: imx: fix locked bus on SMBus block-read of 0 (atomic)
Date: Mon, 13 Jul 2026 18:26:37 +0000 [thread overview]
Message-ID: <20260713182637.8A9141F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713-for-upstream-i2c-lx2160-fix-v1-v3-1-073ac9e103a5@free.fr>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] `i2c_imx_prepare_read()` fails to clear `I2CR_TXAK` for SMBus block reads, causing the block length byte to be incorrectly NACKed.
- [High] The interrupt-driven SMBus block read path (`i2c_imx_isr_read_block_data_len`) fails to properly terminate the transaction when receiving an invalid length (0 or > I2C_SMBUS_BLOCK_MAX), leaving the I2C bus stuck.
--
--- Patch [1]: [PATCH v3 1/2] i2c: imx: fix locked bus on SMBus block-read of 0 (atomic) ---
commit a24ce0b5e738f113eb95ff9fc04f3d425bba30ce
Author: Vincent Jardin <vjardin@free.fr>
i2c: imx: fix locked bus on SMBus block-read of 0 (atomic)
SMBus 3.1 6.5.7 allows a Block Read byte count of 0, but the atomic
path rejects it as -EPROTO and returns without sending a nack and stop.
This patch properly handles the in-flight dummy byte by extending the
message length to emit a stop, releasing the bus.
> SMBus 3.1 6.5.7 allows a Block Read byte count of 0, but the atomic
> (polling) path rejects it as -EPROTO. Worse, it returns without a
> NACK+STOP: the next receive cycle has already started, so the target
> keeps holding SDA and the bus stays stuck until a power cycle for
> this i2c controller.
>
> Reading I2DR to obtain the count likewise arms the next byte on the
> count > I2C_SMBUS_BLOCK_MAX path, which also returned -EPROTO directly
> and left the bus held.
>
> Handle both: NACK the in-flight dummy byte (TXAK) and extend msgs->len so
> the existing last-byte handling emits STOP; the dummy byte is discarded.
> A count of 0 is a valid empty block read; a count above
> I2C_SMBUS_BLOCK_MAX is still reported as -EPROTO, but only after the bus
> has been released.
>
> The interrupt-driven path has the same flaw from a later commit and is
> fixed separately, as it carries a different Fixes: tag and stable range.
[Severity: High]
This isn't a bug introduced by this patch, but does the interrupt-driven
SMBus block read path in i2c_imx_isr_read_block_data_len() fail to properly
terminate the transaction when receiving an invalid length?
When a length of 0 or greater than I2C_SMBUS_BLOCK_MAX is returned:
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX) {
i2c_imx->isr_result = -EPROTO;
i2c_imx->state = IMX_I2C_STATE_FAILED;
wake_up(&i2c_imx->queue);
}
This aborts the transfer and wakes up the thread to clear MSTA without
gracefully nacking the in-flight dummy byte. Clearing MSTA while a
byte reception is in flight causes the controller to drop its master
state while the bus remains physically locked with SCL and SDA held low.
I see the commit message acknowledges this flaw exists in the interrupt
path but defers fixing it to a separate patch. Since that patch is not
included in this series, the hang remains active in the codebase.
>
> Fixes: 8e8782c71595 ("i2c: imx: add SMBus block read support")
> Cc: stable@vger.kernel.org # v3.16+
> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Acked-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Stefan Eichenberger <eichest@gmail.com>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
>
> ---
> drivers/i2c/busses/i2c-imx.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 28313d0fad37e..cfd1e63359e75 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1415,6 +1415,7 @@ static int i2c_imx_atomic_read(struct imx_i2c_struct *i2c_imx,
> int i, result;
> unsigned int temp;
> int block_data = msgs->flags & I2C_M_RECV_LEN;
> + int block_err = 0;
>
> result = i2c_imx_prepare_read(i2c_imx, msgs, false);
[Severity: High]
This is a pre-existing issue, but does i2c_imx_prepare_read() fail to clear
I2CR_TXAK for SMBus block reads?
In i2c_imx_prepare_read(), there is no check for I2C_M_RECV_LEN:
if (msgs->len - 1)
temp &= ~I2CR_TXAK;
For an I2C_M_RECV_LEN transaction without PEC, the core initializes
msgs->len to 1. This evaluates to 0, which leaves TXAK set and causes the
controller to nack the very first byte (the length byte).
A compliant SMBus slave will immediately abort the transaction upon receiving
a nack, causing all subsequent data bytes to read as 0xFF. Should this check
include the I2C_M_RECV_LEN flag to properly clear TXAK?
> if (result)
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713-for-upstream-i2c-lx2160-fix-v1-v3-0-073ac9e103a5@free.fr?part=1
next prev parent reply other threads:[~2026-07-13 18:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 18:11 [PATCH v3 0/2] i2c: imx: fix SMBus block-read of 0 locking the bus Vincent Jardin
2026-07-13 18:11 ` [PATCH v3 1/2] i2c: imx: fix locked bus on SMBus block-read of 0 (atomic) Vincent Jardin
2026-07-13 18:26 ` sashiko-bot [this message]
2026-07-13 19:39 ` Vincent Jardin
2026-07-13 18:12 ` [PATCH v3 2/2] i2c: imx: fix locked bus on SMBus block-read of 0 (IRQ) Vincent Jardin
2026-07-13 18:29 ` sashiko-bot
2026-07-13 19:50 ` Vincent Jardin
2026-07-14 15:00 ` [PATCH v3 0/2] i2c: imx: fix SMBus block-read of 0 locking the bus Andi Shyti
2026-07-14 15:18 ` Vincent Jardin
2026-07-14 15:45 ` Wolfram Sang
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=20260713182637.8A9141F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vjardin@free.fr \
/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.