From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
Marek Szyprowski <m.szyprowski@samsung.com>,
"'Benjamin Herrenschmidt'" <benh@kernel.crashing.org>,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [Linaro-mm-sig] [RFC] ARM DMA mapping TODO, v1
Date: Thu, 28 Apr 2011 15:58:16 +0100 [thread overview]
Message-ID: <20110428145816.GR17290@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <201104281640.00107.arnd@arndb.de>
On Thu, Apr 28, 2011 at 04:39:59PM +0200, Arnd Bergmann wrote:
> On Thursday 28 April 2011, Russell King - ARM Linux wrote:
> > On Thu, Apr 28, 2011 at 04:29:52PM +0200, Arnd Bergmann wrote:
> > > Given that people still want to have an interface that does what I
> > > though this one did, I guess we have two options:
> > >
> > > * Kill off dma_cache_sync and replace it with calls to dma_sync_*
> > > so we can start using dma_alloc_noncoherent on ARM
> >
> > I don't think this is an option as dma_sync_*() is part of the streaming
> > DMA mapping API (dma_map_*) which participates in the idea of buffer
> > ownership, which the noncoherent API doesn't appear to.
>
> I thought the problem was in fact that the noncoherent API cannot be
> implemented on architectures like ARM specifically because there is
> no concept of buffer ownership. The obvious way to fix that would
> be to redefine the API. What am I missing?
You are partially correct. With the streaming interface, we're fairly
strict with the buffer ownership stuff, as the most effective way to
implement it across all our CPUs is to deal with the mapping, sync and
unmapping in terms of buffers being passed from CPU control to DMA device
control and back again.
With the noncoherent interface, there is less of a buffer ownership idea.
For instance, to read from a noncoherent buffer, the following is required
(in order, I'm not considering the effects of weakly ordered stuff):
/* dma happens, signalled complete */
dma_cache_invalidate(buffer, size);
/* cpu can now see up to date data */
message = *buffer;
Unlike the streaming API, we don't need to hand the buffer back to the
device before the CPU can repeat the above code sequence.
If we want to write to a noncoherent buffer, then we need:
*buffer = value;
dma_cache_writeback(buffer, size);
/* dma can only now see new value */
and again, the same thing applies.
There is an additional problem lurking in amongst this though - a buffer
which is both read and written by the CPU has to be extremely careful of
cache writebacks - this for instance would not be legal:
*buffer = value;
...
/* dma from device */
dma_cache_invalidate(buffer, size);
message = *buffer;
as it is not predictable whether we'll see 'value' or the DMA data - that
depends on the relative ordering of the DMA writing to RAM vs the cache
eviction of the CPU write.
So, there is a kind of buffer ownership here:
/* cpu owns */
dma_cache_writeback(buffer, size);
/* dma owns */
dma_cache_invalidate(buffer, size);
/* cpu owns */
but as shown above it doesn't need to be as strict as the streaming API.
Also note that there's a problem lurking here with DMA cache line size:
| int
| dma_get_cache_alignment(void)
|
| Returns the processor cache alignment. This is the absolute minimum
| alignment *and* width that you must observe when either mapping
| memory or doing partial flushes.
|
| Notes: This API may return a number *larger* than the actual cache
| line, but it will guarantee that one or more cache lines fit exactly
| into the width returned by this call. It will also always be a power
| of two for easy alignment.
$ grep -L dma_get_cache_alignment $(grep dma_alloc_noncoherent drivers/ -lr)
drivers/base/dma-mapping.c
drivers/scsi/sgiwd93.c
drivers/scsi/53c700.c
drivers/net/au1000_eth.c
drivers/net/sgiseeq.c
drivers/net/lasi_82596.c
drivers/video/au1200fb.c
so we have a bunch of drivers which presumably don't take any notice of
the DMA cache line size, which may be very important. 53c700 for instance
aligns its buffers using L1_CACHE_ALIGN(), which may be smaller than
what's actually required...
next prev parent reply other threads:[~2011-04-28 14:58 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 19:29 Arnd Bergmann
2011-04-21 20:09 ` [Linaro-mm-sig] " Jesse Barnes
2011-04-21 21:52 ` Zach Pfeffer
2011-04-22 0:34 ` KyongHo Cho
2011-04-26 14:29 ` Arnd Bergmann
2011-04-26 14:28 ` Arnd Bergmann
2011-04-26 14:26 ` Arnd Bergmann
2011-04-26 15:39 ` Jesse Barnes
2011-04-27 7:35 ` Russell King - ARM Linux
2011-04-27 8:56 ` Arnd Bergmann
2011-04-27 9:09 ` Russell King - ARM Linux
2011-04-27 11:02 ` Arnd Bergmann
2011-04-27 16:16 ` [Linaro-mm-sig] " Alex Deucher
2011-04-27 17:44 ` Anca Emanuel
2011-04-27 20:27 ` Russell King - ARM Linux
2011-04-27 20:16 ` Russell King - ARM Linux
2011-04-27 20:21 ` Arnd Bergmann
2011-04-27 20:26 ` Russell King - ARM Linux
2011-04-27 20:48 ` Arnd Bergmann
2011-04-27 21:41 ` Benjamin Herrenschmidt
2011-04-28 9:30 ` Russell King - ARM Linux
2011-04-28 21:07 ` Benjamin Herrenschmidt
2011-04-29 11:26 ` Arnd Bergmann
2011-04-29 11:47 ` Benjamin Herrenschmidt
2011-04-29 11:56 ` Alan Cox
2011-04-29 22:51 ` Benjamin Herrenschmidt
2011-04-29 12:06 ` [Linaro-mm-sig] " Thomas Hellstrom
2011-04-29 13:34 ` Jerome Glisse
2011-04-29 22:55 ` Benjamin Herrenschmidt
2011-04-29 22:53 ` Benjamin Herrenschmidt
2011-04-27 10:51 ` Marek Szyprowski
2011-04-27 21:37 ` Benjamin Herrenschmidt
2011-04-28 6:40 ` [Linaro-mm-sig] " Arnd Bergmann
2011-04-28 6:46 ` FUJITA Tomonori
2011-04-28 9:37 ` Russell King - ARM Linux
2011-04-28 10:32 ` [Linaro-mm-sig] " Marek Szyprowski
2011-04-28 10:51 ` Russell King - ARM Linux
2011-04-28 12:28 ` Arnd Bergmann
2011-04-28 13:15 ` Russell King - ARM Linux
2011-04-28 14:29 ` Arnd Bergmann
2011-04-28 14:34 ` Russell King - ARM Linux
2011-04-28 14:39 ` Arnd Bergmann
2011-04-28 14:58 ` Russell King - ARM Linux [this message]
2011-04-28 19:37 ` Jerome Glisse
2011-04-29 0:29 ` Benjamin Herrenschmidt
2011-04-29 5:50 ` Thomas Hellstrom
2011-04-29 7:35 ` Benjamin Herrenschmidt
2011-04-29 10:55 ` Thomas Hellstrom
2011-04-29 22:50 ` Benjamin Herrenschmidt
2011-04-29 16:27 ` Jesse Barnes
2011-04-29 22:46 ` Benjamin Herrenschmidt
2011-04-30 2:45 ` Jesse Barnes
2011-04-29 7:59 ` Russell King - ARM Linux
2011-04-29 16:32 ` Jesse Barnes
2011-04-29 18:29 ` Arnd Bergmann
2011-04-29 22:15 ` Russell King - ARM Linux
2011-05-02 4:42 ` David Brown
2011-05-02 11:26 ` Arnd Bergmann
2011-04-29 22:37 ` Benjamin Herrenschmidt
2011-04-29 13:42 ` Joerg Roedel
2011-04-29 14:19 ` Jerome Glisse
2011-04-29 15:37 ` Jordan Crouse
2011-04-28 14:38 ` FUJITA Tomonori
2011-04-29 0:25 ` Benjamin Herrenschmidt
2011-04-29 11:21 ` Arnd Bergmann
2011-04-28 10:41 ` Joerg Roedel
2011-04-28 11:01 ` Russell King - ARM Linux
2011-04-28 12:25 ` Joerg Roedel
2011-04-28 12:42 ` Russell King - ARM Linux
2011-04-28 12:59 ` Joerg Roedel
2011-04-28 13:02 ` Arnd Bergmann
2011-04-28 13:19 ` Russell King - ARM Linux
2011-04-28 13:56 ` Joerg Roedel
2011-04-28 14:30 ` Russell King - ARM Linux
2011-04-27 9:52 ` Catalin Marinas
2011-04-27 10:43 ` Arnd Bergmann
2011-04-27 11:08 ` Catalin Marinas
2011-04-28 0:15 ` Valdis.Kletnieks
2011-04-28 8:27 ` Catalin Marinas
2011-04-28 12:12 ` Arnd Bergmann
2011-04-28 12:36 ` Russell King - ARM Linux
2011-04-28 12:48 ` Arnd Bergmann
2011-05-03 14:45 ` Dave Martin
2011-04-29 15:41 ` [Linaro-mm-sig] " Arnd Bergmann
2011-04-29 16:42 ` Catalin Marinas
2011-05-03 15:05 ` [Linaro-mm-sig] " Laurent Pinchart
2011-05-03 15:31 ` Arnd Bergmann
2011-04-27 14:06 ` FUJITA Tomonori
2011-04-27 14:29 ` Catalin Marinas
2011-04-27 14:34 ` FUJITA Tomonori
2011-04-27 20:29 ` Russell King - ARM Linux
2011-04-27 21:45 ` Benjamin Herrenschmidt
2011-04-28 7:24 ` [Linaro-mm-sig] " KyongHo Cho
2011-04-28 8:31 ` Catalin Marinas
2011-04-27 21:31 ` Benjamin Herrenschmidt
2011-04-28 9:42 ` Russell King - ARM Linux
2011-04-28 10:27 ` Joerg Roedel
2011-04-28 12:15 ` Arnd Bergmann
2011-05-03 14:35 [Linaro-mm-sig] " Laurent Pinchart
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=20110428145816.GR17290@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.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
all inboxes | Powered by JetHome®