All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mehmet Fide" <mehmet.fide@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] i2c: imx: acknowledge the count byte of an atomic block read
Date: Mon, 16 Nov 2026 12:44:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-217021@kernel.org> (raw)
In-Reply-To: <20261116122707.1349139-1-mehmet.fide@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] i2c: imx: missing TXAK for 1-byte block read in
  i2c_imx_isr_read_block_data_len() [1]
--

commit 0b842b7d356553521b725411a4e465612a28658b
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>

i2c: imx: acknowledge the count byte of an atomic block read

This commit clears I2CR_TXAK in i2c_imx_prepare_read() when I2C_M_RECV_LEN
is set so that atomic SMBus block reads acknowledge the initial count byte.

> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151f..1a3fc245d6ba7 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1283,7 +1283,7 @@ static int i2c_imx_prepare_read(struct imx_i2c_struct *i2c_imx,
>  	 * Reset the I2CR_TXAK flag initially for SMBus block read since the
>  	 * length is unknown
>  	 */
> -	if (msgs->len - 1)
> +	if ((msgs->len - 1) || (msgs->flags & I2C_M_RECV_LEN))
>  		temp &= ~I2CR_TXAK;
>  	if (use_dma)
>  		temp |= I2CR_DMAEN;

[Severity: Medium]
This problem wasn't introduced by this patch, but on the interrupt-driven
path, does i2c_imx_isr_read_block_data_len() fail to set I2CR_TXAK
[1] when an SMBus block read without PEC returns a block length of
1 byte?

Reading the count byte from IMX_I2C_I2DR immediately starts clocking in the
single payload byte.  When len is 1 and the initial msg->len is 1,
i2c_imx_isr_read_block_data_len() updates msg->len to 2 and msg_buf_idx to
1 without setting I2CR_TXAK:

drivers/i2c/busses/i2c-imx.c:i2c_imx_isr_read_block_data_len() {
	...
	i2c_imx->msg->len += len;
	i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = len;
}

On the next interrupt, i2c_imx_isr_read_continue() sees
msg_buf_idx == msg->len - 1 and misses the msg->len - 2 branch that sets
I2CR_TXAK.  The controller then acknowledges the final byte before
generating a stop condition, which can cause the target device to hold SDA
low and wedge the bus.

[1] https://sashiko.dev/#/bug/linux-8e52fb9c-78a7-426b-ad34-b729995ff1c3

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116122707.1349139-1-mehmet.fide@gmail.com?part=1

  reply	other threads:[~2026-11-16 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:27 [PATCH] i2c: imx: acknowledge the count byte of an atomic block read Mehmet Fide
2026-11-16 12:44 ` sashiko-bot [this message]
2026-11-16 17:59 ` Stefan Eichenberger

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=sashiko-outbox-217021@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=mehmet.fide@gmail.com \
    --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.