]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
spi: imx: support dynamic burst length for ECSPI DMA mode
authorCarlos Song <carlos.song@nxp.com>
Wed, 3 Dec 2025 08:59:48 +0000 (16:59 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 14 Dec 2025 10:38:51 +0000 (19:38 +0900)
commitfaa8e404ad8e686cb98c51dc507fdcacfb8020ce
tree2830c476adb234018e49ff6ba3e6f78c847bd8ed
parenta450c8b77f929f5f9f5236861761a8c5cab22023
spi: imx: support dynamic burst length for ECSPI DMA mode

ECSPI transfers only one word per frame in DMA mode, causing SCLK stalls
between words due to BURST_LENGTH updates, which significantly impacts
performance.

To improve throughput, configure BURST_LENGTH as large as possible (up to
512 bytes per frame) instead of word length. This avoids delays between
words. When transfer length is not 4-byte aligned, use bounce buffers to
align data for DMA. TX uses aligned words for TXFIFO, while RX trims DMA
buffer data after transfer completion.

Introduce a new dma_package structure to store:
  1. BURST_LENGTH values for each DMA request
  2. Variables for DMA submission
  3. DMA transmission length and actual data length

Handle three cases:
  - len <= 512 bytes: one package, BURST_LENGTH = len * 8 - 1
  - len > 512 and aligned: one package, BURST_LENGTH = max (512 bytes)
  - len > 512 and unaligned: two packages, second for tail data

Performance test (spidev_test @10MHz, 4KB):
  Before: tx/rx ~6651.9 kbps
  After:  tx/rx ~9922.2 kbps (~50% improvement)

For compatibility with slow SPI devices, add configurable word delay in
DMA mode. When word delay is set, dynamic burst is disabled and
BURST_LENGTH equals word length.

Signed-off-by: Carlos Song <carlos.song@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251203085949.2922166-6-carlos.song@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c