Skip to content

Commit 686fe77

Browse files
committed
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: #5696 Signed-off-by: Phil Elwell <[email protected]>
1 parent f9f480b commit 686fe77

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
@@ -275,8 +275,10 @@ static void dw_spi_dma_tx_done(void *arg)
275275
struct dw_spi *dws = arg;
276276

277277
clear_bit(DW_SPI_TX_BUSY, &dws->dma_chan_busy);
278-
if (test_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy))
278+
if (test_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy)) {
279+
dw_writel(dws, DW_SPI_DMARDLR, 0);
279280
return;
281+
}
280282

281283
complete(&dws->dma_completion);
282284
}
@@ -602,6 +604,8 @@ static int dw_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)
602604

603605
nents = max(xfer->tx_sg.nents, xfer->rx_sg.nents);
604606

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

0 commit comments

Comments
 (0)