summaryrefslogtreecommitdiffstats
path: root/drivers/mci/sdhci.c
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2023-09-11 14:11:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-09-12 11:18:59 +0200
commite8ccf976f13dc1ae659662cf42298e7d7b9a4e9a (patch)
tree21d3e29c9f812055b2eb2682ad94dcf15af02c3e /drivers/mci/sdhci.c
parent4b17ad98eb9655082962fa65dea6840a001c3a1c (diff)
downloadbarebox-e8ccf976f13dc1ae659662cf42298e7d7b9a4e9a.tar.gz
barebox-e8ccf976f13dc1ae659662cf42298e7d7b9a4e9a.tar.xz
mci: sdhci: unmap the DMA buffers actually used
At the end of sdhci_transfer_data_dma, sdhci_set_sdma_addr is called to set the next DMA address. Recently, the computation of the next DMA address was changed and instead of storing the next SDMA address into a dedicated local variable as before, it was stored into the existing `dma' variable. The dma variable is passed later though to dma_unmap_single(), so clobbering it results in a loss of cache coherency and thus potential memory corruption. It's worth noting that this next SDMA address is not actually used for DMA: Like Linux, barebox doesn't make use of this feature to chain (?) DMA requests, so we actually invalidated memory buffers that were never used for DMA. Fixes: 76aa243aad95 ("mci: sdhci: Add 64-bit DMA addressing suport for V4 mode") Fixes: 88f101358167 ("mci: sdhci: Force DMA update to the next block boundary") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230911121156.2632668-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/sdhci.c')
-rw-r--r--drivers/mci/sdhci.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index b0b83bfaa9..7b6466a3f4 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -292,14 +292,14 @@ int sdhci_transfer_data_dma(struct sdhci *sdhci, struct mci_data *data,
int boundary_cfg = (sdhci->sdma_boundary >> 12) & 0x7;
dma_addr_t boundary_size = 4096 << boundary_cfg;
/* Force update to the next DMA block boundary. */
- dma = (dma & ~(boundary_size - 1)) + boundary_size;
+ dma_addr_t next = (dma & ~(boundary_size - 1)) + boundary_size;
/*
* DMA engine has stopped on buffer boundary. Acknowledge
* the interrupt and kick the DMA engine again.
*/
sdhci_write32(sdhci, SDHCI_INT_STATUS, SDHCI_INT_DMA);
- sdhci_set_sdma_addr(sdhci, dma);
+ sdhci_set_sdma_addr(sdhci, next);
}
if (irqstat & SDHCI_INT_XFER_COMPLETE)