On Thu, Jan 29, 2009 at 09:36:13PM +0900, Atsushi Nemoto wrote:
> On Wed, 28 Jan 2009 18:30:47 +0000, Ralf Baechle <email@example.com> wrote:
> > --- a/arch/mips/lib/memcpy.S
> > +++ b/arch/mips/lib/memcpy.S
> > @@ -21,7 +21,7 @@
> > * end of memory on some systems. It's also a seriously bad idea on non
> > * dma-coherent systems.
> > */
> > -#if !defined(CONFIG_DMA_COHERENT) || !defined(CONFIG_DMA_IP27)
> > +#ifdef CONFIG_DMA_NONCOHERENT
> > #undef CONFIG_CPU_HAS_PREFETCH
> > #endif
> > #ifdef CONFIG_MIPS_MALTA
> This makes IP27 (and all other coherent platforms) use prefetch. Is
> prefetch OK for all of them?
> I suppose memcpy_fromio() should not use PREFETCH, at least.
The idea here is that we have two issues with prefetching:
o Prefetching beyond the end of the source or destination range on a
in-coherent range might bring back stale values from a DMA I/O
buffer resulting in data corruption. Hardware DMA coherency will
avoid this issue.
o IP27 has full blown hardware coherency. Historically CONFIG_DMA_COHERENT
was not able to cope with something of the complexity of IP27, so
there was a separate CONFIG_DMA_IP27 and the broken logic expression
was meant to treat CONFIG_DMA_COHERENT and CONFIG_DMA_IP27 the same
as for prefetching.
o Prefetching beyond the end of physical memory can cause exceptions on
some systems. The Malta has this problem.
Thus no prefetching on Malta or non-coherent systems.