[][Fix spi dma unmap]
[Description]
Change where dma_unmap_single is called,use dma_unmap_single before memcpy to ensure that CPU can get the latest and correct data
[Release-log]
N/A
Change-Id: Ie3470c050432452d3a18e819c696b079ebb51d0c
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7088823
diff --git a/target/linux/mediatek/patches-5.4/0920-kernel-MT7988-fix-spi-dma-unmap.patch b/target/linux/mediatek/patches-5.4/0920-kernel-MT7988-fix-spi-dma-unmap.patch
new file mode 100644
index 0000000..5129e37
--- /dev/null
+++ b/target/linux/mediatek/patches-5.4/0920-kernel-MT7988-fix-spi-dma-unmap.patch
@@ -0,0 +1,40 @@
+From 38d0cd2179791e27f06e1cfc6773f35b699ee99a Mon Sep 17 00:00:00 2001
+From: liya Li <ot_liya.li@mediatek.com>
+Date: Thu, 2 Feb 2023 14:26:39 +0800
+Subject: [PATCH] [WCNCR00293802][kernel][MT7988] fix spi dma unmap
+
+[Description]
+Use dma_unmap_single before memcpy to ensure that
+CPU can get the latest and correct data
+
+[Release-log]
+N/A
+
+Signed-off-by: liya Li <ot_liya.li@mediatek.com>
+Change-Id: Ib0b51e34e289c670f0d020fb62a15078ed116203
+---
+ drivers/spi/spi-mt65xx.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
+index 1b272d15cc..2034d19790 100644
+--- a/drivers/spi/spi-mt65xx.c
++++ b/drivers/spi/spi-mt65xx.c
+@@ -978,12 +978,12 @@ static int mtk_spi_mem_exec_op(struct spi_mem *mem,
+
+ unmap_rx_dma:
+ if (op->data.dir == SPI_MEM_DATA_IN) {
++ dma_unmap_single(mdata->dev, mdata->rx_dma,
++ op->data.nbytes, DMA_FROM_DEVICE);
+ if(!IS_ALIGNED((size_t)op->data.buf.in, 4)) {
+ memcpy(op->data.buf.in, rx_tmp_buf, op->data.nbytes);
+ kfree(rx_tmp_buf);
+ }
+- dma_unmap_single(mdata->dev, mdata->rx_dma,
+- op->data.nbytes, DMA_FROM_DEVICE);
+ }
+ unmap_tx_dma:
+ dma_unmap_single(mdata->dev, mdata->tx_dma,
+--
+2.18.0
+