Thread (4 messages) 4 messages, 2 authors, 2026-01-16

Re: [PATCH V2 2/2] i2c: imx: add abort path for invalid block length

From: Daniel Baluta <hidden>
Date: 2026-01-16 09:25:17
Also in: imx, linux-i2c, lkml

On Fri, Jan 16, 2026 at 11:19 AM LI Qingwu
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
When a block read returns an invalid length (0 or >I2C_SMBUS_BLOCK_MAX),
the current implementation leaves the bus hanging with SDA held low,
blocking all further I2C communication on the bus.

Add a dedicated IMX_I2C_STATE_READ_BLOCK_DATA_ABORT state and ISR
handler to properly terminate the transfer when an invalid block length
is detected:
  - Set TXAK and receive the next byte with NACK
  - On the following interrupt, generate a Stop condition
  - Read and discard the final byte
  - Report -EPROTO to the caller

This ensures the bus is released correctly and allows other devices on
the bus to continue operating normally.

Tested on i.MX 8M Plus with continuous block read operations.

Signed-off-by: LI Qingwu <redacted>
---
 drivers/i2c/busses/i2c-imx.c | 55 ++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 85f554044cf1..71457dbffb7a 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -233,6 +233,7 @@ enum imx_i2c_state {
        IMX_I2C_STATE_READ_CONTINUE,
        IMX_I2C_STATE_READ_BLOCK_DATA,
        IMX_I2C_STATE_READ_BLOCK_DATA_LEN,
+       IMX_I2C_STATE_READ_BLOCK_DATA_ABORT
Please add the comma at the end of the last line so that we still have
nice diffs
next time we add an element at the end of the enum.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help