Skip to content

Commit 43dba9f

Browse files
fancerbroonie
authored andcommitted
spi: dw: Enable interrupts in accordance with DMA xfer mode
It's pointless to track the Tx overrun interrupts if Rx-only SPI transfer is issued. Similarly there is no need in handling the Rx overrun/underrun interrupts if Tx-only SPI transfer is executed. So lets unmask the interrupts only if corresponding SPI transactions are implied. Co-developed-by: Georgy Vlasov <[email protected]> Signed-off-by: Georgy Vlasov <[email protected]> Signed-off-by: Serge Semin <[email protected]> Cc: Ramil Zaripov <[email protected]> Cc: Alexey Malahov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 05897c7 commit 43dba9f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/spi/spi-dw-mid.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,23 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,
243243

244244
static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)
245245
{
246-
u16 dma_ctrl = 0;
246+
u16 imr = 0, dma_ctrl = 0;
247247

248248
dw_writel(dws, DW_SPI_DMARDLR, 0xf);
249249
dw_writel(dws, DW_SPI_DMATDLR, 0x10);
250250

251-
if (xfer->tx_buf)
251+
if (xfer->tx_buf) {
252252
dma_ctrl |= SPI_DMA_TDMAE;
253-
if (xfer->rx_buf)
253+
imr |= SPI_INT_TXOI;
254+
}
255+
if (xfer->rx_buf) {
254256
dma_ctrl |= SPI_DMA_RDMAE;
257+
imr |= SPI_INT_RXUI | SPI_INT_RXOI;
258+
}
255259
dw_writel(dws, DW_SPI_DMACR, dma_ctrl);
256260

257261
/* Set the interrupt mask */
258-
spi_umask_intr(dws, SPI_INT_TXOI | SPI_INT_RXUI | SPI_INT_RXOI);
262+
spi_umask_intr(dws, imr);
259263

260264
dws->transfer_handler = dma_transfer;
261265

0 commit comments

Comments
 (0)