From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: For the problem when using swiotlb
Date: Tue, 25 Nov 2014 11:29:05 +0000 [thread overview]
Message-ID: <20141125112905.GC3836@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20141125105815.GB18858@e104818-lin.cambridge.arm.com>
On Tue, Nov 25, 2014 at 10:58:15AM +0000, Catalin Marinas wrote:
> Since we don't have a coherent_dma_supported() function, we defer the
> validity check of coherent_dma_mask to dma_alloc_coherent() (and here we
> can remove bouncing since swiotlb has relatively small buffers).
Bouncing of coherent DMA buffers is insane; if you have to bounce them,
they're by definition not coherent.
Think about one of the common uses of coherent DMA buffers: ring buffers,
where both the CPU and the DMA agent write to the ring:
- CPU writes to ring, loading address and length, then writing to the
status word for the ring entry.
- DMA reads the ring status word, sees it owns the entry, processes it,
DMA writes to the ring status word to give it back.
What this means is that if you are bouncing the buffer, you are copying
it whole-sale between the CPU visible version and the DMA visible
version, which means that you can miss DMA updates to it. So, bouncing
a coherent DMA buffer is simply not an acceptable implementation for
dma_alloc_coherent().
As for validity of masks, it is defined in the DMA API documentation that
if a DMA mask is suitable for the streaming APIs, then it is also suitable
for the coherent APIs. The reverse is left open, and so may not
necessarily be true.
In other words:
err = dma_set_mask(dev, mask);
if (err == 0)
assert(dma_set_coherent_mask(dev, mask) == 0);
must always succeed, but reversing the two calls has no guarantee.
Note that there seems to be only one driver which has different coherent
and streaming DMA masks today:
drivers/media/pci/sta2x11/sta2x11_vip.c:
if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(26))) {
err = dma_set_coherent_mask(&vip->pdev->dev, DMA_BIT_MASK(29));
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2014-11-25 11:29 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 11:56 For the problem when using swiotlb Ding Tianhong
2014-11-17 12:18 ` Arnd Bergmann
2014-11-17 18:09 ` Catalin Marinas
2014-11-19 3:17 ` Ding Tianhong
2014-11-19 8:45 ` Arnd Bergmann
2014-11-19 11:29 ` Catalin Marinas
2014-11-19 12:48 ` Arnd Bergmann
2014-11-19 15:46 ` Catalin Marinas
2014-11-19 15:56 ` Arnd Bergmann
2014-11-21 11:06 ` Catalin Marinas
2014-11-21 11:26 ` Arnd Bergmann
2014-11-21 11:36 ` Catalin Marinas
2014-11-21 12:27 ` Arnd Bergmann
2014-11-20 2:57 ` Ding Tianhong
2014-11-20 7:40 ` Arnd Bergmann
2014-11-20 8:34 ` Ding Tianhong
2014-11-20 9:02 ` Arnd Bergmann
2014-11-20 9:21 ` Ding Tianhong
2014-11-21 9:35 ` Catalin Marinas
2014-11-21 10:32 ` Catalin Marinas
2014-11-21 12:48 ` Arnd Bergmann
2014-11-21 16:57 ` Catalin Marinas
2014-11-21 17:04 ` Arnd Bergmann
2014-11-21 17:51 ` Catalin Marinas
2014-11-21 18:09 ` Catalin Marinas
2014-11-24 20:12 ` Arnd Bergmann
2014-11-25 10:58 ` Catalin Marinas
2014-11-25 11:29 ` Russell King - ARM Linux [this message]
2014-11-25 12:23 ` Catalin Marinas
2014-11-27 2:36 ` Ding Tianhong
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=20141125112905.GC3836@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;
as well as URLs for NNTP newsgroup(s).