[RFC] ARM: dma-mapping: outer cache is invalidated twice

Russell King - ARM Linux linux at arm.linux.org.uk
Tue Feb 15 09:12:53 EST 2011


On Tue, Feb 15, 2011 at 02:54:21PM +0100, Per Forlin wrote:
> I don't fully understand this yet. I think you are right but I need a
> little help to get there myself.
> I agree, the cache (L1 and L2) must be invalidated after the DMA has completed.
> Before starting the DMA the write buffers must be drained (cache_sync).
> 
> Why invalidate the cache before starting the DMA?

Think about what happens if you have dirty cache lines in the DMA region.
These can be evicted when other cache lines are loaded, which will result
in them overwriting contents of memory.  If the DMA device has already
written to that memory, the result is data corruption.

So, the invalidate prior to DMA is to get rid of any dirty cache lines
which could be written back to memory.



More information about the linux-arm-kernel mailing list