All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haobin Jiang" <lemonoutput@foxmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v5] i2c: imx: honour I2C_M_IGNORE_NAK
Date: Wed, 28 Oct 2026 06:46:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-187567@kernel.org> (raw)
In-Reply-To: <tencent_E6D69775D91AD9FE45C994B3755CB1452506@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] i2c: imx: I2C_M_STOP accepted on non-final messages in i2c_imx_check_msgs()
--

commit ab5cce0d9e41776730132143f819ba3662b29234
Author: Haobin Jiang <lemonoutput@foxmail.com>

i2c: imx: honour I2C_M_IGNORE_NAK

This commit adds support for I2C_M_IGNORE_NAK on PIO transfers in the i.MX
I2C controller driver while keeping flagged messages out of the DMA path and
rejecting zero-length reads with I2C_M_IGNORE_NAK.

Link: https://lore.kernel.org/linux-i2c/tencent_877C99956190215D644EB959DF1663542A0A@qq.com/ # [1]

> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151f..1e2fd699f4fc6 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c

[ ... ]

> @@ -1613,8 +1621,9 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs,
>  	return ret;
>  }
>  
> +/* I2C_M_STOP is the controller's native behaviour; don't reject it. */
>  #define I2C_IMX_UNSUPPORTED_PROTOCOL_MANGLING_FLAGS \
> -	(I2C_M_IGNORE_NAK | I2C_M_NO_RD_ACK | I2C_M_STOP)
> +	I2C_M_NO_RD_ACK
>  
>  static int i2c_imx_check_msgs(struct i2c_msg *msgs, int num)
>  {
> @@ -1625,6 +1634,12 @@ static int i2c_imx_check_msgs(struct i2c_msg *msgs, int num)
>  		if (msgs[i].flags & I2C_IMX_UNSUPPORTED_PROTOCOL_MANGLING_FLAGS)
>  			return -EOPNOTSUPP;

[Severity: Medium]
Does removing I2C_M_STOP from I2C_IMX_UNSUPPORTED_PROTOCOL_MANGLING_FLAGS
cause i2c_imx_check_msgs() to accept multi-message transfers that set
I2C_M_STOP on a non-final message (i < num - 1) without actually generating
an inter-message STOP condition?

In i2c_imx_xfer_common(), is_lastmsg is only set when i == num - 1, and
i2c_imx_stop() is only called at the end of the entire transfer. For
intermediate messages, the controller keeps I2CR_MSTA asserted and emits a
repeated START on the next message:

drivers/i2c/busses/i2c-imx.c:i2c_imx_xfer_common() {
	for (i = 0; i < num; i++) {
		if (i == num - 1)
			is_lastmsg = true;

		if (i && !(msgs[i].flags & I2C_M_NOSTART)) {
			...
			temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
			temp |= I2CR_RSTA;
			imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
			...
		}
}

When callers such as SCCB client drivers (via I2C_CLIENT_SCCB in
i2c_smbus_xfer_emulated(), which sets I2C_M_STOP | I2C_M_IGNORE_NAK on msg[0]
of a two-message read) or userspace I2C_RDWR ioctls pass I2C_M_STOP on an
intermediate message, shouldn't i2c_imx_check_msgs() still reject I2C_M_STOP
when i < num - 1 unless i2c_imx_xfer_common() emits a STOP followed by a new
START between those messages?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_E6D69775D91AD9FE45C994B3755CB1452506@qq.com?part=1

      reply	other threads:[~2026-10-28  6:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  6:33 [PATCH v5] i2c: imx: honour I2C_M_IGNORE_NAK Haobin Jiang
2026-10-28  6:46 ` sashiko-bot [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=sashiko-outbox-187567@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=lemonoutput@foxmail.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.