From: Arnd Bergmann <arnd@arndb.de>
To: Ming Lei <tom.leiming@gmail.com>
Cc: "Russell King - ARM Linux" <linux@arm.linux.org.uk>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Joerg Roedel <joerg.roedel@amd.com>,
fujita.tomonori@lab.ntt.co.jp, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org,
"linux-arm-kernel" <linux-arm-kernel@lists.arm.linux.org.uk>
Subject: Re: [PATCH][RFC] asm-generic:remove calling flush_write_buffers() in dma_sync_*_for_cpu
Date: Tue, 7 Jul 2009 17:30:45 +0200 [thread overview]
Message-ID: <200907071730.45661.arnd@arndb.de> (raw)
In-Reply-To: <d82e647a0907070755m150b8aa0x3ae8faf1c47587f9@mail.gmail.com>
On Tuesday 07 July 2009, Ming Lei wrote:
> > Note that actually you need to do writeback+invalidate in DMA_TO_DEVICE
>
> IMHO, writeback in dma map is enough for DMA_TO_DEVICE transfer.
Right. writeback+invalidate would only be needed for bidirectional
transfers but not for DMA_TO_DEVICE.
> > and at least an invalidate in DMA_FROM_DEVICE during dma_map_*.
> > For the unmap, I don't think you ever need to invalidate the cache.
>
> No, as Russell said that CPU speculative fetches can make cache "dirty" after
> dma map but before dma is over, then CPU may read inconsistent data
> after DMA_FROM_DEVICE transfer is finished if does not invalidate
> cache in
> dma unmap.
Hmm, I don't think any of the other architectures currently
try to prevent this. Is ARM special in this regard, or does that
mean that the others are broken? What kind of code would cause
a speculative read on a data section that the kernel (by convention)
must not access? Would it be enough to have an rmb() in dma_unmap_*
and dma_sync_*_for_cpu to prevent speculative accesses?
> > If you invalidate only at unmap time for DMA_FROM_DEVICE, a dirty
> > cache line might be accidentally flushed to the buffer after
> > the device has written to it.
>
> It seems you are reasonable, and we do need to invalidate cache in both dma
> map and dma unmap for DMA_FROM_DEVICE, don't we?
Is it guaranteed that a cache line from a speculative fetch will
never be written back? Otherwise it would still be broken.
Arnd <><
next prev parent reply other threads:[~2009-07-07 15:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-28 14:39 [PATCH][RFC] asm-generic:remove calling flush_write_buffers() in dma_sync_*_for_cpu tom.leiming
2009-06-28 15:34 ` Arnd Bergmann
2009-06-29 12:31 ` Joerg Roedel
2009-06-29 13:51 ` Ming Lei
2009-06-29 14:45 ` Joerg Roedel
2009-06-29 14:54 ` Ming Lei
2009-06-29 15:44 ` Joerg Roedel
2009-06-29 16:22 ` Arnd Bergmann
2009-06-29 16:31 ` Alan Cox
2009-06-29 16:45 ` Arnd Bergmann
2009-06-29 17:16 ` Alan Cox
2009-06-30 12:34 ` Arnd Bergmann
2009-06-30 12:40 ` Alan Cox
2009-06-30 12:48 ` Arnd Bergmann
2009-06-30 13:09 ` Alan Cox
2009-06-30 13:38 ` Arnd Bergmann
2009-07-07 1:54 ` Ming Lei
2009-07-07 7:48 ` Russell King - ARM Linux
2009-07-07 13:43 ` Ming Lei
2009-07-07 14:06 ` Arnd Bergmann
2009-07-07 14:55 ` Ming Lei
2009-07-07 15:30 ` Arnd Bergmann [this message]
2009-07-07 17:36 ` Russell King - ARM Linux
2009-07-07 17:33 ` Russell King - ARM Linux
2009-06-29 18:47 ` Joerg Roedel
2009-06-29 19:10 ` Alan Cox
2009-06-29 19:24 ` Joerg Roedel
2009-06-29 18:48 ` Joerg Roedel
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=200907071730.45661.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=joerg.roedel@amd.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=tom.leiming@gmail.com \
/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