From: Marek Szyprowski <m.szyprowski@samsung.com>
To: 'Russell King - ARM Linux' <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org,
linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org,
'Kyungmin Park' <kyungmin.park@samsung.com>,
'Arnd Bergmann' <arnd@arndb.de>, 'Joerg Roedel' <joro@8bytes.org>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: RE: [PATCH 1/8] ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops
Date: Tue, 26 Jul 2011 14:56:38 +0200 [thread overview]
Message-ID: <00c401cc4b93$75bae4c0$6130ae40$%szyprowski@samsung.com> (raw)
In-Reply-To: <20110703152826.GL21898@n2100.arm.linux.org.uk>
Hello,
On Sunday, July 03, 2011 5:28 PM Russell King wrote:
> On Mon, Jun 20, 2011 at 09:50:06AM +0200, Marek Szyprowski wrote:
> > This patch removes the need for offset parameter in dma bounce
> > functions. This is required to let dma-mapping framework on ARM
> > architecture use common, generic dma-mapping helpers.
>
> I really don't like this. Really as in hate. Why? I've said in the past
> that the whole idea of getting rid of the sub-range functions is idiotic.
>
> If you have to deal with cache coherence, what you _really_ want is an
> API which tells you the size of the original buffer and the section of
> that buffer which you want to handle - because the edges of the buffer
> need special handling.
>
> Lets say that you have a buffer which is 256 bytes long, misaligned to
> half a cache line. Let's first look at the sequence for whole-buffer:
>
> 1. You map it for DMA from the device. This means you writeback the
> first and last cache lines to perserve any data shared in the
> overlapping cache line. The remainder you can just invalidate.
>
> 2. You want to access the buffer, so you use the sync_for_cpu function.
> If your CPU doesn't do any speculative prefetching, then you don't
> need to do anything. If you do, you have to invalidate the buffer,
> but you must preserve the overlapping cache lines which again must
> be written back.
>
> 3. You transfer ownership back to the device using sync_for_device.
> As you may have caused cache lines to be read in, again you need to
> invalidate, and the overlapping cache lines must be written back.
>
> Now, if you ask for a sub-section of the buffer to be sync'd, you can
> actually eliminate those writebacks which are potentially troublesome,
> and which could corrupt neighbouring data.
>
> If you get rid of the sub-buffer functions and start using the whole
> buffer functions for that purpose, you no longer know whether the
> partial cache lines are part of the buffer or not, so you have to write
> those back every time too.
>
> So far, we haven't had any reports of corruption of this type (maybe
> folk using the sync functions are rare on ARM - thankfully) but getting
> rid of the range sync functions means that solving this becomes a lot
> more difficult because we've lost the information to make the decision.
Well, right now I haven't heard anyone who wants to remove
dma_sync_single_range_for_{cpu,device}. All this is about internal
implementation and dma_map_ops which uses the simplified calls, not
exposed to the drivers or any public API.
I also see no reason why we loose the information. All drivers are still
required to call dma_map_{single,page} to aquire dma address first. This
way DMA mapping subsystem perfectly knows that the range from returned
dma_addr to dma_addr+size has been used for dma operations. All calls to
dma_sync_single_* operations takes dma_addr as one of the arguments, so
there is no problem to check which dma range this particular sync
operation fits.
In my patch I have shown that it is perfectly possible to use the common
dma_map_ops structure on ARM and unify dma mapping implementation a bit
with other architectures.
IMHO this is the right way. There is a need for custom dma mapping
implementations (mainly related to taking the advantage of iommu controllers
available on newer SoCs). I would really like to avoid another set of ifdefs
or sequences of "if (iommu_supported())" all over the dma-mapping code. Even
now all this code is hard to understand in the first read (due to coherent/
non-coherent sub-architectures and dmabounce code mixed in).
> So I've always believed - and continue to do so - that those who want
> to get rid of the range sync functions are misguided and are storing up
> problems for the future.
I never said that I want to remove these operations from drivers API.
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
next prev parent reply other threads:[~2011-07-26 12:56 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-20 7:50 [PATCH/RFC 0/8] ARM: DMA-mapping framework redesign Marek Szyprowski
2011-06-20 7:50 ` [PATCH 1/8] ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops Marek Szyprowski
2011-06-20 8:35 ` Michal Nazarewicz
2011-06-20 10:46 ` Marek Szyprowski
2011-06-20 10:46 ` Marek Szyprowski
2011-07-03 15:28 ` Russell King - ARM Linux
2011-07-03 15:28 ` Russell King - ARM Linux
2011-07-26 12:56 ` Marek Szyprowski [this message]
2011-06-20 7:50 ` [PATCH 2/8] ARM: dma-mapping: implement dma_map_single on top of dma_map_page Marek Szyprowski
2011-06-20 14:39 ` Russell King - ARM Linux
2011-06-20 14:39 ` Russell King - ARM Linux
2011-06-20 15:15 ` Marek Szyprowski
2011-06-24 15:24 ` Arnd Bergmann
2011-06-24 15:24 ` Arnd Bergmann
2011-06-27 14:29 ` Marek Szyprowski
2011-06-27 14:53 ` Arnd Bergmann
2011-06-27 14:53 ` Arnd Bergmann
2011-06-27 15:06 ` Marek Szyprowski
2011-06-20 7:50 ` [PATCH 3/8] ARM: dma-mapping: use asm-generic/dma-mapping-common.h Marek Szyprowski
2011-06-20 14:33 ` [Linaro-mm-sig] " KyongHo Cho
2011-06-21 11:47 ` Marek Szyprowski
2011-06-21 11:47 ` Marek Szyprowski
2011-06-24 8:39 ` 'Joerg Roedel'
2011-06-24 8:39 ` 'Joerg Roedel'
2011-06-24 15:36 ` Arnd Bergmann
2011-06-24 15:36 ` Arnd Bergmann
2011-06-27 12:18 ` Marek Szyprowski
2011-06-27 12:18 ` Marek Szyprowski
2011-06-27 13:19 ` Arnd Bergmann
2011-06-27 13:19 ` Arnd Bergmann
2011-07-07 12:09 ` Lennert Buytenhek
2011-07-07 12:09 ` Lennert Buytenhek
2011-07-07 12:38 ` Russell King - ARM Linux
2011-07-07 12:38 ` Russell King - ARM Linux
2011-07-15 0:10 ` Lennert Buytenhek
2011-07-15 9:27 ` Russell King - ARM Linux
2011-07-15 9:27 ` Russell King - ARM Linux
2011-07-15 21:53 ` Lennert Buytenhek
2011-06-20 7:50 ` [PATCH 4/8] ARM: dma-mapping: implement dma sg methods on top of generic dma ops Marek Szyprowski
2011-06-20 7:50 ` Marek Szyprowski
2011-06-20 14:37 ` KyongHo Cho
2011-06-20 14:40 ` Russell King - ARM Linux
2011-06-20 14:40 ` Russell King - ARM Linux
2011-06-20 15:23 ` Marek Szyprowski
2011-06-20 7:50 ` [PATCH 5/8] ARM: dma-mapping: move all dma bounce code to separate dma ops structure Marek Szyprowski
2011-06-20 14:42 ` Russell King - ARM Linux
2011-06-20 15:31 ` Marek Szyprowski
2011-06-20 15:31 ` Marek Szyprowski
2011-06-24 15:47 ` Arnd Bergmann
2011-06-24 15:47 ` Arnd Bergmann
2011-06-27 14:20 ` Marek Szyprowski
2011-06-27 14:20 ` Marek Szyprowski
2011-06-20 7:50 ` [PATCH 6/8] ARM: dma-mapping: remove redundant code and cleanup Marek Szyprowski
2011-06-20 7:50 ` [PATCH 7/8] common: dma-mapping: change alloc/free_coherent method to more generic alloc/free_attrs Marek Szyprowski
2011-06-20 14:45 ` KyongHo Cho
2011-06-20 15:06 ` Russell King - ARM Linux
2011-06-20 15:06 ` Russell King - ARM Linux
2011-06-20 15:14 ` [Linaro-mm-sig] " KyongHo Cho
2011-06-21 11:23 ` Marek Szyprowski
2011-06-22 0:00 ` [Linaro-mm-sig] " KyongHo Cho
2011-06-24 7:20 ` Marek Szyprowski
2011-06-24 15:51 ` Arnd Bergmann
2011-06-24 15:51 ` Arnd Bergmann
2011-06-24 16:15 ` James Bottomley
2011-06-24 16:23 ` Arnd Bergmann
2011-06-27 12:23 ` Marek Szyprowski
2011-06-27 12:23 ` Marek Szyprowski
2011-06-27 13:22 ` Arnd Bergmann
2011-06-27 13:22 ` Arnd Bergmann
2011-06-27 13:30 ` Marek Szyprowski
2011-06-27 13:30 ` Marek Szyprowski
2011-06-24 15:53 ` Arnd Bergmann
2011-06-24 15:53 ` Arnd Bergmann
2011-06-27 14:41 ` Marek Szyprowski
2011-06-20 7:50 ` [PATCH 8/8] ARM: dma-mapping: use alloc, mmap, free from dma_ops Marek Szyprowski
2011-06-22 6:53 ` [Linaro-mm-sig] " KyongHo Cho
2011-06-22 4:53 ` [Linaro-mm-sig] [PATCH/RFC 0/8] ARM: DMA-mapping framework redesign Subash Patel
2011-06-22 6:59 ` Marek Szyprowski
2011-06-22 6:59 ` Marek Szyprowski
2011-06-22 8:53 ` Subash Patel
2011-06-22 9:27 ` Marek Szyprowski
2011-06-22 16:00 ` Jordan Crouse
2011-06-23 13:09 ` Subash Patel
2011-06-23 13:09 ` Subash Patel
2011-06-23 16:24 ` Michael K. Edwards
2011-06-23 22:09 ` Michael K. Edwards
2011-06-25 5:23 ` Jonathan Morton
2011-06-25 5:23 ` Jonathan Morton
2011-06-25 9:55 ` Michael K. Edwards
2011-06-26 0:06 ` Jonathan Morton
2011-06-24 15:20 ` Arnd Bergmann
2011-06-24 15:20 ` Arnd Bergmann
2011-06-24 9:18 ` Joerg Roedel
2011-06-24 14:26 ` Marek Szyprowski
-- strict thread matches above, loose matches on Subject: below --
2011-10-18 17:19 [PATCH 0/8 v3] " Marek Szyprowski
2011-10-18 17:19 ` [PATCH 1/8] ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops Marek Szyprowski
2011-12-09 16:39 [PATCH 0/8 v4] ARM: DMA-mapping framework redesign Marek Szyprowski
2011-12-09 16:39 ` [PATCH 1/8] ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops Marek Szyprowski
2011-12-09 16:39 ` Marek Szyprowski
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='00c401cc4b93$75bae4c0$6130ae40$%szyprowski@samsung.com' \
--to=m.szyprowski@samsung.com \
--cc=arnd@arndb.de \
--cc=joro@8bytes.org \
--cc=kyungmin.park@samsung.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
/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).