[PATCH 4/4] spi: s3c64xx: Fix large transfers with DMA

Vincent Whitchurch vincent.whitchurch at axis.com
Fri Sep 16 04:39:51 PDT 2022


The COUNT_VALUE in the PACKET_CNT register is 16-bit so the maximum
value is 65535.  Asking the driver to transfer a larger size currently
leads to the DMA transfer timing out.  Fix this by splitting the
transfer as needed.

With this, the len>64 KiB tests in spi-loopback-test pass.

(Note that len==64 KiB tests work even without this patch for some reason.
 The driver programs 0 to the COUNT_VALUE field in that case, but it's
 unclear if it's by design, since the hardware documentation doesn't say
 anything about the behaviour when COUNT_VALUE == 0, so play it safe and
 split at 65535.)

Fixes: 230d42d422e7b69 ("spi: Add s3c64xx SPI Controller driver")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch at axis.com>
---
 drivers/spi/spi-s3c64xx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 7f346866614a..85e1d1f90109 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -701,6 +701,16 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master,
 	struct spi_device *spi = msg->spi;
 	struct s3c64xx_spi_csinfo *cs = spi->controller_data;
 
+	if (master->can_dma) {
+		int ret;
+
+		/* Limited by size of PACKET_CNT.COUNT_VALUE. */
+		ret = spi_split_transfers_maxsize(master, msg, 65535,
+						  GFP_KERNEL | GFP_DMA);
+		if (ret)
+			return ret;
+	}
+
 	/* Configure feedback delay */
 	if (!cs)
 		/* No delay if not defined */
-- 
2.34.1




More information about the linux-arm-kernel mailing list