Re: [PATCH] i2c: imx: test the block read flag of the message that is read
From: Stefan Eichenberger
Date: Mon Nov 16 2026 - 04:51:45 EST
Hi Mehmet,
On Fri, Nov 13, 2026 at 12:05:01PM +0100, Mehmet Fide wrote:
> From: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>
>
> i2c_imx_xfer_common() decides between the DMA and the interrupt driven
> read with I2C_M_RECV_LEN of the first message of the transfer instead of
> the message at hand. A block read of DMA_THRESHOLD bytes or more that
> follows another message is therefore done with DMA, which reads the
> initial length and does not look at the count byte.
>
> Fixes: b460b15b3cc2 ("i2c: imx: separate atomic, dma and non-dma use case")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>
> ---
> Reported by the Sashiko review of another i2c-imx patch:
> https://sashiko.dev/#/bug/linux-f62df5ed-ad96-43f2-872a-ae2c0100b73f
>
> Tested on a Colibri VF50 (i2c0 with DMA) with a v6.12.117 kernel that
> carries the i2c-imx changes of v6.13 and later as backports; on this
> base compile tested only. An I2C_RDWR transfer of a one byte write
> followed by a read with I2C_M_RECV_LEN and an initial length of 16:
> without the patch 16 bytes are read and the count byte is taken as data,
> with it the count byte is evaluated (here -EPROTO, the device answers
> with 0x25).
>
> The line is from v6.13, the patch applies to 6.18.y and 7.3.y.
>
> drivers/i2c/busses/i2c-imx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151..9abe0a26c877 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1713,7 +1713,7 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
> msgs[i].flags & I2C_M_DMA_SAFE &&
> !(msgs[i].flags & I2C_M_NOSTART);
> if (msgs[i].flags & I2C_M_RD) {
> - int block_data = msgs->flags & I2C_M_RECV_LEN;
> + int block_data = msgs[i].flags & I2C_M_RECV_LEN;
>
> if (atomic)
> result = i2c_imx_atomic_read(i2c_imx, &msgs[i], is_lastmsg);
>
> base-commit: 25e7ab89f4774b0f842cee0e8a20c11f755924d5
> --
> 2.56.0
Thanks a lot for the fix, it makes sense to me.
Reviewed-by: Stefan Eichenberger <eichest@xxxxxxxxx>