Skip to content

i2c: imx: prevent rescheduling in non-dma mode

Stefan Eichenberger imx linux-arm-kernel linux-i2c lkml 5 versions – Applied

Status from this message: Merged to i2c/i2c-host.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 1 replyApplied
  2. v44 patches 7 repliesSuperseded
  3. v34 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches21 repliesSuperseded
v13 patches4 repliesSuperseded

Changes in v5 from the cover letter

- Drop patch 3 use relaxed readb and writeb (Arnd)
- Make multi master default again and use simple-master as property (Lucas)
- Print a debug message instead of an error if read and write fails. An error message would spam the kernel log when using i2cdetect -r -y 0.
- Fix error message in read (read instead of write)

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/3i2c: imx: do not poll for bus busy in single master modedrivers/i2c/busses/i2c-imx.c+13 -20 replies
2/3i2c: imx: separate atomic, dma and non-dma use casedrivers/i2c/busses/i2c-imx.c+70 -370 replies
3/3i2c: imx: prevent rescheduling in non dma modedrivers/i2c/busses/i2c-imx.c+249 -230 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchFrank LiOleksij Rempel
1/3R-b A-b
2/3R-b A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/3] i2c: imx: prevent rescheduling in non-dma mode

While running tests on an i.MX8M Mini connected to a TI ADS1015 ADC, we found that the ADC would stop responding to i2c requests because it would timeout after the bus was idle for 25ms. This timeout could be traced back to the rescheduling events in the i2c-imx driver. The problem is that if the system is under heavy load, the schedule call and the wait_event_timeout may be rescheduled too late to reach the 25ms timeout. The same problem may occur with other SMBus devices. Therefore, this patchset removes the scheduling calls for non-DMA mode by handling the interrupt events directly in the ISR instead of scheduling a task to handle the events.

This patch will introduce some bigger changes because the logic for handling events in the ISR had to be rewritten. Therefore we have tested the following combinations:
- i.MX8M Mini with dma
- i.MX8M Mini without dma
- i.MX8M Plus with dma
- i.MX8M Plus without dma
- i.MX7D with dma
- i.MX7D without dma
- i.MX7D atomic mode

Because we do not have any devices that use the SMBus block transfer mode, we were not able to test it.

The ideas are based on the RFC:
https://lore.kernel.org/all/[email protected]/
However, the handling of events in the ISR is new, because further testing showed that it was not enough to simply remove the schedule call.

Changes since v4:
- Drop patch 3 use relaxed readb and writeb (Arnd)
- Make multi master default again and use simple-master as property (Lucas)
- Print a debug message instead of an error if read and write fails. An error message would spam the kernel log when using i2cdetect -r -y 0.
- Fix error message in read (read instead of write)

Changes since v3:
- Fixed style issues with checkpatch.pl --strict (Andi)
- Add comments to explain the code (Andi)

Changes since v2:
- Add Acked-by tags from Oleksij
- Renamed i2c_imx_start_read to i2c_imx_prepare_read
- I did not add a Fixes tag because the issues from Flavio have a different root cause and are not fixed by this patchset

Changes since v1:
- Add Reviewed-by tags from Frank
- Add new patch to use readb_relaxed and writeb_relaxed (Frank)
- Update commit message for patch 1 with some clarifications (Frank)

Stefan Eichenberger (3):
i2c: imx: do not poll for bus busy in single master mode
i2c: imx: separate atomic, dma and non-dma use case
i2c: imx: prevent rescheduling in non dma mode

 drivers/i2c/busses/i2c-imx.c | 370 ++++++++++++++++++++++++++++++-----
 1 file changed, 320 insertions(+), 50 deletions(-)
Signature · 1 line
2.43.0