developer | 9440fa7 | 2023-02-02 20:24:18 +0800 | [diff] [blame] | 1 | From 38d0cd2179791e27f06e1cfc6773f35b699ee99a Mon Sep 17 00:00:00 2001 |
| 2 | From: liya Li <ot_liya.li@mediatek.com> |
| 3 | Date: Thu, 2 Feb 2023 14:26:39 +0800 |
| 4 | Subject: [PATCH] [WCNCR00293802][kernel][MT7988] fix spi dma unmap |
| 5 | |
| 6 | [Description] |
| 7 | Use dma_unmap_single before memcpy to ensure that |
| 8 | CPU can get the latest and correct data |
| 9 | |
| 10 | [Release-log] |
| 11 | N/A |
| 12 | |
| 13 | Signed-off-by: liya Li <ot_liya.li@mediatek.com> |
| 14 | Change-Id: Ib0b51e34e289c670f0d020fb62a15078ed116203 |
| 15 | --- |
| 16 | drivers/spi/spi-mt65xx.c | 4 ++-- |
| 17 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 18 | |
| 19 | diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c |
| 20 | index 1b272d15cc..2034d19790 100644 |
| 21 | --- a/drivers/spi/spi-mt65xx.c |
| 22 | +++ b/drivers/spi/spi-mt65xx.c |
| 23 | @@ -978,12 +978,12 @@ static int mtk_spi_mem_exec_op(struct spi_mem *mem, |
| 24 | |
| 25 | unmap_rx_dma: |
| 26 | if (op->data.dir == SPI_MEM_DATA_IN) { |
| 27 | + dma_unmap_single(mdata->dev, mdata->rx_dma, |
| 28 | + op->data.nbytes, DMA_FROM_DEVICE); |
| 29 | if(!IS_ALIGNED((size_t)op->data.buf.in, 4)) { |
| 30 | memcpy(op->data.buf.in, rx_tmp_buf, op->data.nbytes); |
| 31 | kfree(rx_tmp_buf); |
| 32 | } |
| 33 | - dma_unmap_single(mdata->dev, mdata->rx_dma, |
| 34 | - op->data.nbytes, DMA_FROM_DEVICE); |
| 35 | } |
| 36 | unmap_tx_dma: |
| 37 | dma_unmap_single(mdata->dev, mdata->tx_dma, |
| 38 | -- |
| 39 | 2.18.0 |
| 40 | |