blob: 5129e370902d187e64dbbe2b97eeed0a13bd8976 [file] [log] [blame]
developer9440fa72023-02-02 20:24:18 +08001From 38d0cd2179791e27f06e1cfc6773f35b699ee99a Mon Sep 17 00:00:00 2001
2From: liya Li <ot_liya.li@mediatek.com>
3Date: Thu, 2 Feb 2023 14:26:39 +0800
4Subject: [PATCH] [WCNCR00293802][kernel][MT7988] fix spi dma unmap
5
6[Description]
7Use dma_unmap_single before memcpy to ensure that
8CPU can get the latest and correct data
9
10[Release-log]
11N/A
12
13Signed-off-by: liya Li <ot_liya.li@mediatek.com>
14Change-Id: Ib0b51e34e289c670f0d020fb62a15078ed116203
15---
16 drivers/spi/spi-mt65xx.c | 4 ++--
17 1 file changed, 2 insertions(+), 2 deletions(-)
18
19diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
20index 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--
392.18.0
40