8000 spi: dw-dma: Get the last DMA scoop out of the FIFO · pelwell/linux@6aab06f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6aab06f

Browse files
pelwellpopcornmix
authored andcommitted
spi: dw-dma: Get the last DMA scoop out of the FIFO
With a DMA FIFO threshold greater than 1 (encoded as 0), it is possible for data in the FIFO to be inaccessible, causing the transfer to fail after a timeout. If the transfer includes a transmission, reduce the RX threshold when the TX completes, otherwise use 1 for the whole transfer (inefficient, but not catastrophic at SPI data rates). See: raspberrypi#5696 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent f61d5d2 commit 6aab06f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/spi/spi-dw-dma.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@ static void dw_spi_dma_tx_done(void *arg)
315315
struct dw_spi *dws = arg;
316316

317317
clear_bit(DW_SPI_TX_BUSY, &dws->dma_chan_busy);
318-
if (test_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy))
318+
if (test_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy)) {
319+
dw_writel(dws, DW_SPI_DMARDLR, 0);
319320
return;
321+
}
320322

321323
complete(&dws->dma_completion);
322324
}
@@ -642,6 +644,8 @@ static int dw_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)
642644

643645
nents = max(xfer->tx_sg.nents, xfer->rx_sg.nents);
644646

647+
dw_writel(dws, DW_SPI_DMARDLR, xfer->tx_buf ? (dws->rxburst - 1) : 0);
648+
645649
/*
646650
* Execute normal DMA-based transfer (which submits the Rx and Tx SG
647651
* lists directly to the DMA engine at once) if either full hardware

0 commit comments

Comments
 (0)
0