Skip to content

Commit 1224e29

Browse files
vwaxbroonie
authored andcommitted
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. Implement ->max_transfer_size() and have the core split the transfer as needed. Fixes: 230d42d ("spi: Add s3c64xx SPI Controller driver") Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> Link: https://lore.kernel.org/r/20220927112117.77599-5-vincent.whitchurch@axis.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8d699ff commit 1224e29

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/spi/spi-s3c64xx.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#define S3C64XX_SPI_ST_TX_FIFORDY (1<<0)
8585

8686
#define S3C64XX_SPI_PACKET_CNT_EN (1<<16)
87+
#define S3C64XX_SPI_PACKET_CNT_MASK GENMASK(15, 0)
8788

8889
#define S3C64XX_SPI_PND_TX_UNDERRUN_CLR (1<<4)
8990
#define S3C64XX_SPI_PND_TX_OVERRUN_CLR (1<<3)
@@ -711,6 +712,13 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master,
711712
return 0;
712713
}
713714

715+
static size_t s3c64xx_spi_max_transfer_size(struct spi_device *spi)
716+
{
717+
struct spi_controller *ctlr = spi->controller;
718+
719+
return ctlr->can_dma ? S3C64XX_SPI_PACKET_CNT_MASK : SIZE_MAX;
720+
}
721+
714722
static int s3c64xx_spi_transfer_one(struct spi_master *master,
715723
struct spi_device *spi,
716724
struct spi_transfer *xfer)
@@ -1152,6 +1160,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
11521160
master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
11531161
master->prepare_message = s3c64xx_spi_prepare_message;
11541162
master->transfer_one = s3c64xx_spi_transfer_one;
1163+
master->max_transfer_size = s3c64xx_spi_max_transfer_size;
11551164
master->num_chipselect = sci->num_cs;
11561165
master->use_gpio_descriptors = true;
11571166
master->dma_alignment = 8;

0 commit comments

Comments
 (0)