ARM: dma-mapping: fix for speculative prefetching
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 31 Oct 2009 16:52:16 +0000 (16:52 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 15 Feb 2010 15:22:25 +0000 (15:22 +0000)
commit2ffe2da3e71652d4f4cae19539b5c78c2a239136
tree1b69404360a47369c858e54643bab6836015ddbd
parent702b94bff3c50542a6e4ab9a4f4cef093262fe65
ARM: dma-mapping: fix for speculative prefetching

ARMv6 and ARMv7 CPUs can perform speculative prefetching, which makes
DMA cache coherency handling slightly more interesting.  Rather than
being able to rely upon the CPU not accessing the DMA buffer until DMA
has completed, we now must expect that the cache could be loaded with
possibly stale data from the DMA buffer.

Where DMA involves data being transferred to the device, we clean the
cache before handing it over for DMA, otherwise we invalidate the buffer
to get rid of potential writebacks.  On DMA Completion, if data was
transferred from the device, we invalidate the buffer to get rid of
any stale speculative prefetches.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-By: Santosh Shilimkar <santosh.shilimkar@ti.com>
arch/arm/mm/cache-v6.S
arch/arm/mm/cache-v7.S
arch/arm/mm/dma-mapping.c