All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] MX28: MMC: Avoid DMA DCache race condition
@ 2012-09-01  2:18 Marek Vasut
  2012-09-06 12:20 ` Stefano Babic
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2012-09-01  2:18 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Stefano Babic <sbabic@denx.de>
---
 drivers/mmc/mxsmmc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index 9a98c6b..c80b41b 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -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);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] MX28: MMC: Avoid DMA DCache race condition
  2012-09-01  2:18 [U-Boot] [PATCH] MX28: MMC: Avoid DMA DCache race condition Marek Vasut
@ 2012-09-06 12:20 ` Stefano Babic
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Babic @ 2012-09-06 12:20 UTC (permalink / raw)
  To: u-boot

On 01/09/2012 04:18, Marek Vasut wrote:
> 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.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Otavio Salvador <otavio@ossystems.com.br>
> Cc: Stefano Babic <sbabic@denx.de>
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic



-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-06 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-01  2:18 [U-Boot] [PATCH] MX28: MMC: Avoid DMA DCache race condition Marek Vasut
2012-09-06 12:20 ` Stefano Babic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.