From: Mehmet Fide 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 --- 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