Skip to content

Commit f3530f2

Browse files
Patrice Chotardbroonie
authored andcommitted
spi: stm32-qspi: Trigger DMA only if more than 4 bytes to transfer
In order to optimize accesses to spi flashes, trigger a DMA only if more than 4 bytes has to be transferred. DMA transfer preparation's cost becomes negligible above 4 bytes to transfer. Below this threshold, indirect transfer give more throughput. mtd_speedtest shows that page write throughtput increases : - from 779 to 853 KiB/s (~9.5%) with s25fl512s SPI-NOR. - from 5283 to 5666 KiB/s (~7.25%) with Micron SPI-NAND. Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://lore.kernel.org/r/20210419121541.11617-3-patrice.chotard@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 102e9d1 commit f3530f2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/spi/spi-stm32-qspi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ static int stm32_qspi_tx(struct stm32_qspi *qspi, const struct spi_mem_op *op)
269269

270270
if (qspi->fmode == CCR_FMODE_MM)
271271
return stm32_qspi_tx_mm(qspi, op);
272-
else if ((op->data.dir == SPI_MEM_DATA_IN && qspi->dma_chrx) ||
273-
(op->data.dir == SPI_MEM_DATA_OUT && qspi->dma_chtx))
272+
else if (((op->data.dir == SPI_MEM_DATA_IN && qspi->dma_chrx) ||
273+
(op->data.dir == SPI_MEM_DATA_OUT && qspi->dma_chtx)) &&
274+
op->data.nbytes > 4)
274275
if (!stm32_qspi_tx_dma(qspi, op))
275276
return 0;
276277

0 commit comments

Comments
 (0)