mmc: sdhci: fix missing cache invalidation after reading by DMA 62/268162/2
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 14 Feb 2020 07:40:27 +0000 (16:40 +0900)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 16 Dec 2021 16:18:05 +0000 (17:18 +0100)
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.

Change-Id: I482691baa09ec07e119db4ae6b6be715a6c747eb
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/mmc/sdhci.c

index 18f1d822eedf07d63b937efe9b2755e96106cb15..2c2169717205ba5bd2b680518c8756623f9f3b1a 100644 (file)
@@ -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;
 }