MX28: MMC: Avoid DMA DCache race condition
Subsystems (2)
PATCH 1/1 MX28: MMC: Avoid DMA DCache race condition
This patch prevents dcache-related problem. The problem manifested itself on the SPI driver, this is just a port to the MMC driver.
The scenario is the same. In case an "mmc read" is issued to a buffer which was written right before it and data cache is enabled, the cache eviction might happen during the DMA transfer into the buffer, therefore corrupting the buffer. Clear any cache lines that might contain the buffer to prevent such issue.
--- drivers/mmc/mxsmmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/mxsmmc.c +4 -0
@@ -119,6 +119,10 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) (uint32_t)(priv->desc->cmd.address + cache_data_count)); } +/* Invalidate the area, so no writeback into the RAM races with DMA */ +invalidate_dcache_range ((uint32_t )priv->desc->cmd.address, + (uint32_t )(priv->desc->cmd.address + cache_data_count)); + priv->desc->cmd.data |=MXS_DMA_DESC_IRQ |MXS_DMA_DESC_DEC_SEM | (data_count <<MXS_DMA_DESC_BYTES_OFFSET );
Signature · 1 line
1.7.10.4
PATCH 1/1 MX28: MMC: Avoid DMA DCache race condition
Quoted 9 lines · Marek Vasut
This patch prevents dcache-related problem. The problem manifested itself on the SPI driver, this is just a port to the MMC driver.
The scenario is the same. In case an "mmc read" is issued to a buffer which was written right before it and data cache is enabled, the cache eviction might happen during the DMA transfer into the buffer, therefore corrupting the buffer. Clear any cache lines that might contain the buffer to prevent such issue.
Quoted 5 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Otavio Salvador <[email protected]>Cc Stefano Babic <[email protected]>---
Applied to u-boot-imx, thanks.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================