From e96495028f040c961285387ae5a171d820fb669b Mon Sep 17 00:00:00 2001 From: "myung-su.cha" Date: Thu, 5 Jul 2018 13:55:54 +0900 Subject: [PATCH] [COMMON] spi: s3c64xx: check xfer length in DMA spi_map and unmap When transfer length is smaller than fifo-size in DMA mode, it is transferred by CPU mode not DMA. This patch makes spi_map function not executed in this case. Change-Id: Iec9f52f83b1a8abefed67af3276f2194df90e9e4 Signed-off-by: myung-su.cha --- drivers/spi/spi-s3c64xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index bf17f8e31c7a..0892201bfe35 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -865,6 +865,9 @@ static int s3c64xx_spi_map_one_msg(struct s3c64xx_spi_driver_data *sdd, if ((msg->is_dma_mapped) || (sci->dma_mode != DMA_MODE)) return 0; + if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1)) + return 0; + if (xfer->tx_buf != NULL) { xfer->tx_dma = dma_map_single(dev, (void *)xfer->tx_buf, xfer->len, @@ -901,6 +904,9 @@ static void s3c64xx_spi_unmap_one_msg(struct s3c64xx_spi_driver_data *sdd, if ((msg->is_dma_mapped) || (sci->dma_mode != DMA_MODE)) return; + if (xfer->len <= ((FIFO_LVL_MASK(sdd) >> 1) + 1)) + return; + if (xfer->rx_buf != NULL && xfer->rx_dma != XFER_DMAADDR_INVALID) dma_unmap_single(dev, xfer->rx_dma, -- 2.20.1