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 <georgy.vla...@baikalelectronics.ru>
Signed-off-by: Georgy Vlasov <georgy.vla...@baikalelectronics.ru>
Signed-off-by: Serge Semin <sergey.se...@baikalelectronics.ru>
Cc: Ramil Zaripov <ramil.zari...@baikalelectronics.ru>
Cc: Alexey Malahov <alexey.mala...@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbog...@alpha.franken.de>
Cc: Paul Burton <paulbur...@kernel.org>
Cc: Ralf Baechle <r...@linux-mips.org>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Allison Randal <alli...@lohutok.net>
Cc: Andy Shevchenko <andriy.shevche...@linux.intel.com>
Cc: Gareth Williams <gareth.williams...@renesas.com>
Cc: Rob Herring <robh...@kernel.org>
Cc: linux-m...@vger.kernel.org
Cc: devicet...@vger.kernel.org
---
 drivers/spi/spi-dw-mid.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 0c597b6bb154..1902336cb8d6 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -293,19 +293,23 @@ static struct dma_async_tx_descriptor 
*dw_spi_dma_prepare_rx(struct dw_spi *dws,
 
 static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)
 {
-       u16 dma_ctrl = 0;
+       u16 imr = 0, dma_ctrl = 0;
 
        dw_writel(dws, DW_SPI_DMARDLR, 0xf);
        dw_writel(dws, DW_SPI_DMATDLR, 0x10);
 
-       if (xfer->tx_buf)
+       if (xfer->tx_buf) {
                dma_ctrl |= SPI_DMA_TDMAE;
-       if (xfer->rx_buf)
+               imr |= SPI_INT_TXOI;
+       }
+       if (xfer->rx_buf) {
                dma_ctrl |= SPI_DMA_RDMAE;
+               imr |= SPI_INT_RXUI | SPI_INT_RXOI;
+       }
        dw_writel(dws, DW_SPI_DMACR, dma_ctrl);
 
        /* Set the interrupt mask */
-       spi_umask_intr(dws, SPI_INT_TXOI | SPI_INT_RXUI | SPI_INT_RXOI);
+       spi_umask_intr(dws, imr);
 
        dws->transfer_handler = dma_transfer;
 
-- 
2.25.1

Reply via email to