From: Stefan Eichenberger <eichest@gmail.com>
To: Mehmet Fide <mehmet.fide@gmail.com>
Cc: Andi Shyti <andi.shyti@kernel.org>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Stefan Eichenberger <stefan.eichenberger@toradex.com>,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, mehmet.fide@screeningeagle.com
Subject: Re: [PATCH] i2c: imx: keep the error of a failed read
Date: Mon, 16 Nov 2026 19:25:01 +0100 [thread overview]
Message-ID: <avtKfW6vYmwl6D-s@eichest-laptop> (raw)
In-Reply-To: <20261116125940.1368194-1-mehmet.fide@gmail.com>
On Mon, Nov 16, 2026 at 01:59:40PM +0100, Mehmet Fide wrote:
> From: Mehmet Fide <mehmet.fide@screeningeagle.com>
>
> When the count byte of an SMBus block read is larger than
> I2C_SMBUS_BLOCK_MAX, i2c_imx_isr_read_block_data_len() sets -EPROTO and
> fails the read. The read of I2DR that took the count byte has started
> the reception of one more byte, and its interrupt comes in while the
> state is IMX_I2C_STATE_FAILED. i2c_imx_master_isr() has no case for
> that state, so the default case replaces -EPROTO with -EINVAL.
>
> Ignore interrupts in IMX_I2C_STATE_FAILED so that the first error is
> returned.
>
> Fixes: 5f5c2d4579ca ("i2c: imx: prevent rescheduling in non dma mode")
> Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
> ---
>
> Notes:
> Tested on a Colibri VF50 on the Iris carrier, kernel at this base plus
> "i2c: imx: acknowledge the count byte of an atomic block read" and
> "i2c: imx: do not acknowledge the last byte of a block read of one
> byte", with the M41T0 RTC at 0x68. A test-only hook passed the messages
> that i2c_smbus_xfer_emulated() builds for a block read to the adapter,
> alone and followed by a one byte read. Register 0x03 (0xae) as count
> byte: without the patch -EINVAL 40 of 40, and a print in the default
> case showed state IMX_I2C_STATE_FAILED with -EPROTO each time; with it
> -EPROTO 100 of 100, as the atomic read returns. Count bytes of 0, 1 and
> 0x13 read the same bytes as before, and the bus works after each
> failed read.
>
> drivers/i2c/busses/i2c-imx.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index ccf08cd63151..c7fef98934d4 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1142,6 +1142,9 @@ static irqreturn_t i2c_imx_master_isr(struct imx_i2c_struct *i2c_imx, unsigned i
> wake_up(&i2c_imx->queue);
> break;
>
> + case IMX_I2C_STATE_FAILED:
> + break;
> +
> default:
> i2c_imx->i2csr = status;
> i2c_imx->state = IMX_I2C_STATE_FAILED;
>
> base-commit: 25e7ab89f4774b0f842cee0e8a20c11f755924d5
> --
> 2.56.0
Looks good as well, thanks.
Reviewed-by: Stefan Eichenberger <eichest@gmail.com>
prev parent reply other threads:[~2026-11-16 18:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 12:59 [PATCH] i2c: imx: keep the error of a failed read Mehmet Fide
2026-11-16 18:25 ` Stefan Eichenberger [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=avtKfW6vYmwl6D-s@eichest-laptop \
--to=eichest@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=andi.shyti@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mehmet.fide@gmail.com \
--cc=mehmet.fide@screeningeagle.com \
--cc=o.rempel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=stefan.eichenberger@toradex.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox