linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: 'Subash Patel' <subashrp@gmail.com>
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>,
	'Russell King - ARM Linux' <linux@arm.linux.org.uk>,
	'Joerg Roedel' <joro@8bytes.org>, 'Arnd Bergmann' <arnd@arndb.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: RE: [Linaro-mm-sig] [PATCH/RFC 0/8] ARM: DMA-mapping framework redesign
Date: Wed, 22 Jun 2011 11:27:55 +0200	[thread overview]
Message-ID: <002701cc30be$ab296cc0$017c4640$%szyprowski@samsung.com> (raw)
In-Reply-To: <4E01AD7B.3070806@gmail.com>

Hello,

On Wednesday, June 22, 2011 10:53 AM Subash Patel wrote:

> On 06/22/2011 12:29 PM, Marek Szyprowski wrote:
> > Hello,
> >
> > On Wednesday, June 22, 2011 6:53 AM Subash Patel wrote:
> >
> >> On 06/20/2011 01:20 PM, Marek Szyprowski wrote:
> >>> Hello,
> >>>
> >>> This patch series is a continuation of my works on implementing generic
> >>> IOMMU support in DMA mapping framework for ARM architecture. Now I
> >>> focused on the DMA mapping framework itself. It turned out that adding
> >>> support for common dma_map_ops structure was not that hard as I
> initally
> >>> thought. After some modification most of the code fits really well to
> >>> the generic dma_map_ops methods.
> >>>
> >>> The only change required to dma_map_ops is a new alloc function. During
> >>> the discussion on Linaro Memory Management meeting in Budapest we got
> >>> the idea that we can have only one alloc/free/mmap function with
> >>> additional attributes argument. This way all different kinds of
> >>> architecture specific buffer mappings can be hidden behind the
> >>> attributes without the need of creating several versions of dma_alloc_
> >>> function. I also noticed that the dma_alloc_noncoherent() function can
> >>> be also implemented this way with DMA_ATTRIB_NON_COHERENT attribute.
> >>> Systems that just defines dma_alloc_noncoherent as dma_alloc_coherent
> >>> will just ignore such attribute.
> >>>
> >>> Another good use case for alloc methods with attributes is the
> >>> possibility to allocate buffer without a valid kernel mapping. There
> are
> >>> a number of drivers (mainly V4L2 and ALSA) that only exports the DMA
> >>> buffers to user space. Such drivers don't touch the buffer data at all.
> >>> For such buffers we can avoid the creation of a mapping in kernel
> >>> virtual address space, saving precious vmalloc area. Such buffers might
> >>> be allocated once a new attribute DMA_ATTRIB_NO_KERNEL_MAPPING.
> >>
> >> Are you trying to say here, that the buffer would be allocated in the
> >> user space, and we just use it to map it to the device in DMA+IOMMU
> >> framework?
> >
> > Nope. I proposed an extension which would allow you to allocate a buffer
> > without creating the kernel mapping for it. Right now
> dma_alloc_coherent()
> > performs 3 operations:
> > 1. allocates memory for the buffer
> > 2. creates coherent kernel mapping for the buffer
> > 3. translates physical buffer address to DMA address that can be used by
> > the hardware.
> >
> > dma_mmap_coherent makes additional mapping for the buffer in user process
> > virtual address space.
> >
> > I want make the step 2 in dma_alloc_coherent() optional to save virtual
> > address space: it is really limited resource. I really want to avoid
> > wasting it for mapping 128MiB buffers just to create full-HD processing
> > hardware pipeline, where no drivers will use kernel mapping at all.
> >
> 
> I think by (2) above, you are referring to
> __dma_alloc_remap()->arm_vmregion_alloc() to allocate the kernel virtual
> address for the drivers use. That makes sense now.

Well, this is particular implementation which is used on ARM. Other 
architectures might implement it differently, that's why I used generic 
description and didn't point to any particular function.

> I have a query in similar lines, but related to user virtual address
> space. Is it feasible to extend these DMA interfaces(and IOMMU), to map
> a user allocated buffer into the hardware?

This can be done with the current API, although it may not look so 
straightforward. You just need to create a scatter list of user pages
(these can be gathered with get_user_pages function) and use dma_map_sg()
function. If the dma-mapping support iommu, it can map all these pages
into a single contiguous buffer on device (DMA) address space.

Some additional 'magic' might be required to get access to pages that are
mapped with pure PFN (VM_PFNMAP flag), but imho it still can be done.

I will try to implement this feature in videobuf2-dma-config allocator
together with the next version of my patches for dma-mapping&iommu.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

  reply	other threads:[~2011-06-22  9:28 UTC|newest]

Thread overview: 94+ 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
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 [this message]
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

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='002701cc30be$ab296cc0$017c4640$%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 \
    --cc=subashrp@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;
as well as URLs for NNTP newsgroup(s).