[COMMON] spi: s3c64xx: check xfer length in DMA spi_map and unmap
authormyung-su.cha <myung-su.cha@samsung.com>
Thu, 5 Jul 2018 04:55:54 +0000 (13:55 +0900)
committerJungi Lee <jungilsi.lee@samsung.com>
Tue, 17 Jul 2018 11:34:49 +0000 (20:34 +0900)
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 <myung-su.cha@samsung.com>
drivers/spi/spi-s3c64xx.c

index bf17f8e31c7a97466ec723f7a2bf74056802c598..0892201bfe35669a65dfb03503873bef0a3deca9 100644 (file)
@@ -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,