From: mike.looijmans@topic.nl (Mike Looijmans)
To: linux-arm-kernel@lists.infradead.org
Subject: dma_alloc_coherent versus streaming DMA, neither works satisfactory
Date: Thu, 7 May 2015 16:08:54 +0200 [thread overview]
Message-ID: <554B71F6.5000106@topic.nl> (raw)
In-Reply-To: <554B6917.40705@topic.nl>
?On 07-05-15 15:31, Mike Looijmans wrote:
> On 07-05-15 15:21, Daniel Drake wrote:
>> On Thu, May 7, 2015 at 5:18 AM, Mike Looijmans <mike.looijmans@topic.nl> wrote:
>>> I reverted all my patches and workarounds. Indeed, the kernel needs a
>>> "coherent" version of the dma_mmap routine, as the current version will map
>>> it as non-cachable, resulting in a big performance hit (and nullifying the
>>> whole idea behind it).
>>>
>>> I'll test it further on my 'hardware' and cook up a patch that correctly
>>> maps the coherent pages.
>>
>> Sorry that I have only read this thread briefly, but I wonder if this
>> is what you are looking for:
>> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-February/325489.html
>
> It's related, but targets another use case. This one does the same in case the
> driver requested non-consistent memory.
>
> My use case was that I have hardware implemented coherency (through ACP) so
> the CPU's and device's view on memory is already consistent, regardless of the
> status of the cache.
>
> The patches are complimentary, not overlapping.
>
> Thanks for the link though, it's something I was also looking into, as I don't
> always need coherency.
I read the rest of the thread, apparently it was never integrated.
The patch for "non-consistent" is a BUG FIX, not some feature request or so. I
was already wondering why my driver had to kalloc pages to get proper caching
on it.
From https://www.kernel.org/doc/Documentation/DMA-attributes.txt:
"""
DMA_ATTR_NON_CONSISTENT ... lets the platform to choose to return either
consistent or non-consistent memory as it sees fit. By using this API,
you are guaranteeing to the platform that you have all the correct and
necessary sync points for this memory in the driver.
"""
The current ARM implementation is to *always* return memory that is
non-cachable, even if the driver promises to do all the right things.
If the intention was that every implementation could get away with just
ignoring the flag, the flag would not have existed. So the implementation
should do the best it can do here, and the patch shows that it's just a simple
one-liner to make it implement the flag as intended.
As for use cases, IIO is a candidate for this too, as it has explicit
interfaces to move buffers to/from userspace without having to remap them over
and over again. My usecase here is Dyplo, which uses a similar interface. If
you do something as simple as "for (i=0;i<size;++i) sum += (char*)buffer[i];
in userspace on such a buffer, performance will collapse to about 1/20th
because of the memory being non-cachable. The whole point of IIO is to prevent
having to copy these buffers around.
(I'd rather add this plea to the that thread, but I'd have to figure out how
to reply to a thread from the web...)
Mike.
Kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
Telefax: +31 (0) 499 33 69 70
E-mail: mike.looijmans@topicproducts.com
Website: www.topicproducts.com
Please consider the environment before printing this e-mail
next prev parent reply other threads:[~2015-05-07 14:08 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 11:52 dma_alloc_coherent versus streaming DMA, neither works satisfactory Mike Looijmans
2015-04-23 12:32 ` Arnd Bergmann
2015-04-23 13:05 ` Mike Looijmans
2015-04-29 8:47 ` Mike Looijmans
2015-04-29 9:01 ` Arnd Bergmann
2015-04-29 9:17 ` Russell King - ARM Linux
2015-04-29 9:47 ` Mike Looijmans
2015-04-29 10:07 ` Arnd Bergmann
2015-04-29 10:33 ` Mike Looijmans
2015-04-29 10:41 ` Arnd Bergmann
2015-04-29 12:49 ` Mike Looijmans
2015-04-29 13:13 ` Arnd Bergmann
2015-04-30 13:50 ` Mike Looijmans
2015-04-30 13:54 ` Arnd Bergmann
2015-05-01 6:08 ` Mike Looijmans
2015-05-01 7:01 ` Mike Looijmans
2015-05-07 11:18 ` Mike Looijmans
2015-05-07 11:56 ` Arnd Bergmann
2015-05-07 13:21 ` Daniel Drake
2015-05-07 13:31 ` Mike Looijmans
2015-05-07 14:08 ` Mike Looijmans [this message]
2015-05-07 14:30 ` Russell King - ARM Linux
2015-05-08 5:55 ` Mike Looijmans
2015-05-08 7:54 ` Arnd Bergmann
2015-05-08 8:31 ` Mike Looijmans
2015-05-08 13:19 ` Arnd Bergmann
2015-05-08 14:18 ` Mike Looijmans
2015-05-08 14:27 ` Arnd Bergmann
2015-05-08 11:10 ` Russell King - ARM Linux
2015-05-08 12:17 ` Mike Looijmans
2015-04-29 11:09 ` Mike Looijmans
2015-04-29 12:35 ` Arnd Bergmann
2015-04-29 12:52 ` Mike Looijmans
2015-04-29 12:54 ` Arnd Bergmann
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=554B71F6.5000106@topic.nl \
--to=mike.looijmans@topic.nl \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.