public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] ARM: dma-mapping: outer cache is invalidated twice
Date: Tue, 15 Feb 2011 13:41:34 +0000	[thread overview]
Message-ID: <20110215134134.GA17208@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20110215133232.GI4152@n2100.arm.linux.org.uk>

On Tue, Feb 15, 2011 at 01:32:32PM +0000, Russell King - ARM Linux wrote:
> 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.

I should add: the solution to all of this is to have cache coherent DMA.

As the CPUs become more complex and start playing tricks like speculative
prefetching, we have seen cache maintainence for DMA becomes more expensive.
The only way to reduce the cost of that is to have cache coherency for DMA.

There is no way to safely avoid the double-invalidate for DMA_FROM_DEVICE.

  reply	other threads:[~2011-02-15 13:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15 13:14 [RFC] ARM: dma-mapping: outer cache is invalidated twice Per Forlin
2011-02-15 13:32 ` Russell King - ARM Linux
2011-02-15 13:41   ` Russell King - ARM Linux [this message]
2011-02-15 13:54     ` Per Forlin
2011-02-15 14:12       ` Russell King - ARM Linux
2011-02-15 15:11         ` Per Forlin
2011-02-15 15:46           ` Russell King - ARM Linux
2011-02-15 22:42             ` Per Forlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110215134134.GA17208@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox