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: do not acknowledge the last byte of a block read of one byte
Date: Mon, 16 Nov 2026 12:59:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-217028@kernel.org> (raw)
In-Reply-To: <20261116124430.1358948-1-mehmet.fide@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] i2c: imx: premature NACK in i2c_imx_isr_read_block_data_len()
  with PEC
--

commit 5f9d6cebf7f9ee55cbfb82a72f126d816180c9da
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>

i2c: imx: do not acknowledge the last byte of a block read of one byte

This commit sets I2CR_TXAK in i2c_imx_isr_read_block_data_len() when the
received SMBus block length byte is 1 so that the following byte is not
acknowledged.

> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151f..0a59ebe70eb00 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1095,6 +1095,12 @@ static inline void i2c_imx_isr_read_block_data_len(struct imx_i2c_struct *i2c_im
>  	}
>  	i2c_imx->msg->len += len;
>  	i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = len;
> +
> +	if (len == 1) {
> +		temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> +		temp |= I2CR_TXAK;
> +		imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
> +	}
>  }

[Severity: Medium]
Does checking len == 1 rather than i2c_imx->msg->len == 2 prematurely NACK
the data byte on a 1-byte SMBus block read with PEC enabled?

When I2C_CLIENT_PEC is set, i2c_smbus_xfer_emulated() increments the
initial read msg->len from 1 to 2 to account for the trailing PEC byte.
A block count of 1 then updates i2c_imx->msg->len to 3 (count, data[0],
PEC), so data[0] must be ACKed and I2CR_TXAK should only be set on the
next interrupt in i2c_imx_isr_read_continue().  Setting I2CR_TXAK when
len == 1 NACKs data[0] instead of the PEC byte, causing the target to stop
transmitting and the read to fail with -EBADMSG.

Checking i2c_imx->msg->len == 2 (matching the i == (msgs->len - 2) check
at i == 0 in i2c_imx_atomic_read()) avoids NACKing early when PEC is
present.

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

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:44 [PATCH] i2c: imx: do not acknowledge the last byte of a block read of one byte Mehmet Fide
2026-11-16 12:59 ` sashiko-bot [this message]
2026-11-16 13:50 ` Mehmet Fide

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-217028@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.