]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: qcom-qspi: Correct max DMA length to avoid 64K boundary failure
authorVijaya Krishna Nivarthi <vijaya.nivarthi@oss.qualcomm.com>
Wed, 22 Jul 2026 09:23:58 +0000 (14:53 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 23 Jul 2026 18:03:04 +0000 (19:03 +0100)
The maximum size for a DMA data descriptor is 64KB-1 because the size
field in HW is 16 bits wide. For this reason, transfers fail at 64KB
and beyond.

Lower max_dma_len to 60KB so larger transfers are split into multiple
DMA blocks and do not hit the failing 64KB boundary. 60KB is chosen as
a safe round number below the 64KB-1 hardware limit while satisfying
alignment requirements.

Tested on x1e80100 (Hamoa) with SPI-NOR flash (/dev/mtd0):

Without patch:
  dd if=/dev/mtd0 of=/tmp/spi_dump.bin bs=32768 count=2  # works
  dd if=/dev/mtd0 of=/tmp/spi_dump.bin bs=65536 count=1  # fails

With patch:
  dd if=/dev/mtd0 of=/tmp/spi_dump.bin bs=65536 count=1  # works

Fixes: b5762d95607e ("spi: spi-qcom-qspi: Add DMA mode support")
Cc: stable@vger.kernel.org
Signed-off-by: Vijaya Krishna Nivarthi <vijaya.nivarthi@oss.qualcomm.com>
Link: https://patch.msgid.link/20260722092358.459943-1-vnivarth@qti.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-qcom-qspi.c

index caf55a6f70b3137e23e677c3d166bcc4f0f7cbdf..e9fdefa9d65dc909b1053b44468cdbb35b528497 100644 (file)
@@ -775,7 +775,8 @@ static int qcom_qspi_probe(struct platform_device *pdev)
                return dev_err_probe(dev, ret, "could not set DMA mask\n");
 
        host->max_speed_hz = 300000000;
-       host->max_dma_len = 65536; /* as per HPG */
+       /* as per HPG, it is 64KB, limit to 60KB to avoid boundary condition failures */
+       host->max_dma_len = 0xf000;
        host->dma_alignment = QSPI_ALIGN_REQ;
        host->num_chipselect = QSPI_NUM_CS;
        host->bus_num = -1;