[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220916113951.228398-5-vincent.whitchurch@axis.com>
Date: Fri, 16 Sep 2022 13:39:51 +0200
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: <broonie@...nel.org>, <krzysztof.kozlowski@...aro.org>,
<andi@...zian.org>
CC: <kernel@...s.com>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
<alim.akhtar@...sung.com>, <linux-spi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<linux-samsung-soc@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>
Subject: [PATCH 4/4] spi: s3c64xx: Fix large transfers with DMA
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@...s.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
Powered by blists - more mailing lists