All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Jardin <vjardin@free.fr>
To: sashiko-reviews@lists.linux.dev
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH RESEND v2] i2c: imx: add I2C_M_REV_DIR_ADDR and I2C_M_NOSTART
Date: Fri, 23 Oct 2026 16:25:45 +0200	[thread overview]
Message-ID: <attuac0-PDBA9X8p@L30177.local> (raw)
In-Reply-To: <sashiko-outbox-182524@kernel.org>

Hi M. Bot,


> > +}
> 
> [Severity: Medium]
> What happens if a caller splits a read across two messages, passing
> msgs[i - 1] with I2C_M_RD followed by msgs[i] with I2C_M_RD | I2C_M_NOSTART?
> 
> In i2c_imx_check_msgs(), that sequence is accepted as long as i > 0 and
> msgs[i].len > 0. However, the read paths for msgs[i - 1]
> (i2c_imx_setup_read(), i2c_imx_isr_read_continue(), i2c_imx_prepare_read(),
> i2c_imx_atomic_read(), and i2c_imx_dma_read()) unconditionally set I2CR_TXAK
> on the last byte of msgs[i - 1] and set I2CR_MTX before reading the final byte
> from IMX_I2C_I2DR:
> 
> drivers/i2c/busses/i2c-imx.c:i2c_imx_isr_read_continue() {
> 	if ((i2c_imx->msg->len - 1) == i2c_imx->msg_buf_idx) {
> 		...
> 		temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> 		temp |= I2CR_MTX;
> 		imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
> 		next_state = IMX_I2C_STATE_DONE;
> 	} else if (i2c_imx->msg_buf_idx == (i2c_imx->msg->len - 2)) {
> 		temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> 		temp |= I2CR_TXAK;
> 		imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
> 	}
> }
> 
> Because the controller sends a NACK at the end of msgs[i - 1], the target
> device aborts transmission and releases SDA. When msgs[i] then runs
> i2c_imx_setup_read() (or i2c_imx_prepare_read() in atomic mode), it clears
> I2CR_MTX, performs another dummy read of IMX_I2C_I2DR, and clocks in 0xff for
> the remainder of the transfer.
> 
> Should i2c_imx_check_msgs() reject I2C_M_RD | I2C_M_NOSTART when preceded by
> an I2C_M_RD message (or conversely, when a non-final read message is followed
> by I2C_M_NOSTART), or should the read state machine suppress I2CR_TXAK,
> I2CR_MTX, and the second dummy read across the message boundary?

hmm, ok, updated into the v3

thank you,

      reply	other threads:[~2026-10-23 14:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  8:05 [PATCH RESEND v2] i2c: imx: add I2C_M_REV_DIR_ADDR and I2C_M_NOSTART Vincent Jardin via B4 Relay
2026-10-23  8:05 ` Vincent Jardin
2026-10-23  8:34 ` sashiko-bot
2026-10-23 14:25   ` Vincent Jardin [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=attuac0-PDBA9X8p@L30177.local \
    --to=vjardin@free.fr \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --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.