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

Russell King - ARM Linux linux at arm.linux.org.uk
Tue Feb 15 08:32:32 EST 2011


On Tue, Feb 15, 2011 at 02:14:55PM +0100, Per Forlin wrote:
> outer_inv_range () is called twice for DMA_FROM_DEVICE.
> The first time to "get rid of potential writebacks" and the second
> time to "get rid of any stale speculative prefetches"

Correct.

> outer_inv_range() is a rather expensive operation. In the first case
> isn't it enough to just call cache_sync()?

No.  If the CPU speculatively fetches data from the DMA buffer after
it's been mapped for DMA, it will bring data into the L2 cache.  This
data may or may not be up to date with the DMA buffer contents once
DMA has completed.

As there is no way to know, we have to invalidate the L2 cache (and the
L1 cache) after the DMA has completed to avoid any possibility of data
corruption.



More information about the linux-arm-kernel mailing list