* [PATCH] i2c: imx: do not acknowledge the last byte of a block read of one byte
@ 2026-11-16 12:44 Mehmet Fide
2026-11-16 13:50 ` Mehmet Fide
0 siblings, 1 reply; 2+ messages in thread
From: Mehmet Fide @ 2026-11-16 12:44 UTC (permalink / raw)
To: Andi Shyti, Oleksij Rempel
Cc: Pengutronix Kernel Team, Frank Li, Sascha Hauer, Fabio Estevam,
Stefan Eichenberger, Stefan Eichenberger, linux-i2c, imx,
linux-arm-kernel, linux-kernel, stable, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
In the interrupt driven read, the read of I2DR that takes the count byte
of an SMBus block read starts the reception of the next byte. With a
count of 1 that byte is the last one, but I2CR_TXAK is only set in
i2c_imx_isr_read_continue() for the byte after it, so the last byte is
acknowledged and the target goes on sending. The read fails with
-ETIMEDOUT, the bus stays busy and the following transfers on it fail
too.
Set I2CR_TXAK after taking a count of 1, as the read before the
interrupt driven state machine did and the atomic read still does.
Fixes: 5f5c2d4579ca ("i2c: imx: prevent rescheduling in non dma mode")
Cc: stable@vger.kernel.org # v6.13+
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", 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 0x05 (0x01) as count byte:
without the patch 40 of 40 failed (35 -ETIMEDOUT, 2 -EAGAIN, 3 -EINVAL),
after which the RTC driver could not read the time any more; with it
01 01 and, in the second case, the byte after it, 200 of 200. A count
of 0x13 (register 0x04) reads the same bytes as before.
drivers/i2c/busses/i2c-imx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index ccf08cd63151..0a59ebe70eb0 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);
+ }
}
static irqreturn_t i2c_imx_master_isr(struct imx_i2c_struct *i2c_imx, unsigned int status)
base-commit: 25e7ab89f4774b0f842cee0e8a20c11f755924d5
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] i2c: imx: do not acknowledge the last byte of a block read of one byte
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 13:50 ` Mehmet Fide
0 siblings, 0 replies; 2+ messages in thread
From: Mehmet Fide @ 2026-11-16 13:50 UTC (permalink / raw)
To: Andi Shyti, Oleksij Rempel
Cc: Pengutronix Kernel Team, Frank Li, Sascha Hauer, Fabio Estevam,
Stefan Eichenberger, Stefan Eichenberger, linux-i2c, imx,
linux-arm-kernel, linux-kernel, stable, mehmet.fide
Sashiko is right: with PEC this NACKs the data byte. v2 will test
i2c_imx->msg->len == 2 instead.
Mehmet
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 13:50 ` Mehmet Fide
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®