diff mbox series

[9/9] mmc: sdhci: fix missing cache invalidation after reading by DMA

Message ID 20200204110906.9377-10-yamada.masahiro@socionext.com
State Superseded
Delegated to: Peng Fan
Headers show
Series mmc: sdhci: code clean-up and fix cache coherency problem. | expand

Commit Message

Masahiro Yamada Feb. 4, 2020, 11:09 a.m. UTC
This driver currently performs cache operation before the DMA start,
but does nothing after the DMA completion.

When reading data by DMA, the cache invalidation is needed also after
finishing the DMA transfer. Otherwise, the CPU might read data from
the cache instead of from the main memory when speculative memory read
or memory prefetch occurs.

Instead of calling the cache operation directly, this commit adds
dma_unmap_single(), which performs cache invalidation internally,
but drivers do not need which operation is being run.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/sdhci.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 193f402b516f..f31f6628870f 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -215,6 +215,10 @@  static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data)
 			return -ETIMEDOUT;
 		}
 	} while (!(stat & SDHCI_INT_DATA_END));
+
+	dma_unmap_single(host->start_addr, data->blocks * data->blocksize,
+			 mmc_get_dma_dir(data));
+
 	return 0;
 }