[PATCH v2 0/3] i2c: imx: fixes for a DMA write that is not acknowledged
From: Mehmet Fide
Date: Thu Nov 19 2026 - 08:43:03 EST
From: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>
A write of DMA_THRESHOLD bytes or more to an address that does not
answer leaves the interrupt status behind, so that the next DMA read
returns 0xff for every byte without an error (patch 1). It also leaves
its DMA buffer mapped, as every terminated DMA transfer does (patch 2),
and it blocks for DMA_TIMEOUT before it fails with -ETIMEDOUT instead
of -ENXIO (patch 3). Patch 3 needs patches 1 and 2.
Tested on a Colibri VF50 on the Iris carrier (i2c0 with DMA, M41T0 RTC
at 0x68) with this base, the other i2c-imx fixes on the list [1-4],
PROVE_LOCKING and DMA_API_DEBUG. Each round wrote 20 bytes to an unused
address and read 16 bytes of the RTC:
without the series, 200 rounds: 124 writes failed with -ETIMEDOUT
after up to 1.08 s, none with -ENXIO, 163 reads failed, 128 more
DMA mappings in use afterwards
with the series, 200 + 300 rounds: every write failed with -ENXIO
within 10 ms, every read was right, 4 more DMA mappings in use
after the first 200 rounds and none more after the next 300
On a v6.12 product kernel with the series backported, 200 rounds that
also wrote 18 bytes to a device that acknowledges them: every NACKed
write failed with -ENXIO at once and every acknowledged write went
through. A NACK of the last byte the DMA writes could not be provoked
on either board, so that path is not tested.
For stable: 6.12.y and older need backports, as noted on v1; I can
send them once the patches are in mainline.
Changes in v2:
- 2/3: new. Sashiko on v1 2/2: the new -ENXIO path left the DMA buffer
mapped, as the timeout path already did
- 3/3 (v1 2/2): a NACK of the last byte the DMA writes was missed
(Sashiko). Its acknowledge is now checked once the byte is out,
before the final byte is sent
- 1/3: no change
- rebased on v7.4-rc3+ (4405c18c95d2) and tested on that base; v1
was compile tested on its base only
v1: https://lore.kernel.org/linux-i2c/20261113073250.1037215-1-mehmet.fide@xxxxxxxxx/
[1] https://lore.kernel.org/linux-i2c/20261113110501.1142036-1-mehmet.fide@xxxxxxxxx/
[2] https://lore.kernel.org/linux-i2c/20261116122707.1349139-1-mehmet.fide@xxxxxxxxx/
[3] https://lore.kernel.org/linux-i2c/20261116125940.1368194-1-mehmet.fide@xxxxxxxxx/
[4] https://lore.kernel.org/linux-i2c/20261119130542.180192-1-mehmet.fide@xxxxxxxxx/
Mehmet Fide (3):
i2c: imx: do not carry the interrupt status over to the next transfer
i2c: imx: unmap the DMA buffer when a transfer is terminated
i2c: imx: return -ENXIO at once when a DMA write is not acknowledged
drivers/i2c/busses/i2c-imx.c | 52 +++++++++++++++++++++++-------------
1 file changed, 34 insertions(+), 18 deletions(-)
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
--
2.56.0