linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC] ARM DMA mapping TODO, v1
@ 2011-04-21 19:29 Arnd Bergmann
  2011-04-21 20:09 ` [Linaro-mm-sig] " Jesse Barnes
                   ` (4 more replies)
  0 siblings, 5 replies; 99+ messages in thread
From: Arnd Bergmann @ 2011-04-21 19:29 UTC (permalink / raw)
  To: linux-arm-kernel

I think the recent discussions on linaro-mm-sig and the BoF last week
at ELC have been quite productive, and at least my understanding
of the missing pieces has improved quite a bit. This is a list of
things that I think need to be done in the kernel. Please complain
if any of these still seem controversial:

1. Fix the arm version of dma_alloc_coherent. It's in use today and
   is broken on modern CPUs because it results in both cached and
   uncached mappings. Rebecca suggested different approaches how to
   get there.

2. Implement dma_alloc_noncoherent on ARM. Marek pointed out
   that this is needed, and it currently is not implemented, with
   an outdated comment explaining why it used to not be possible
   to do it.

3. Convert ARM to use asm-generic/dma-mapping-common.h. We need
   both IOMMU and direct mapped DMA on some machines.

4. Implement an architecture independent version of dma_map_ops
   based on the iommu.h API. As Joerg mentioned, this has been
   missing for some time, and it would be better to do it once
   than for each IOMMU separately. This is probably a lot of work.

5. Find a way to define per-device IOMMUs, if that is not actually
   possible already. We had conflicting statements for this.

6. Implement iommu_ops for each of the ARM platforms that has
   an IOMMU. Needs some modifications for MSM and a rewrite for
   OMAP. Implementation for Samsung is under work.

7. Extend the dma_map_ops to have a way for mapping a buffer
   from dma_alloc_{non,}coherent into user space. We have not
   discussed that yet, but after thinking this for some time, I
   believe this would be the right approach to map buffers into
   user space from code that doesn't care about the underlying
   hardware.

After all these are in place, building anything on top of
dma_alloc_{non,}coherent should be much easier. The question
of passing buffers between V4L and DRM is still completely
unsolved as far as I can tell, but that discussion might become
more focused if we can agree on the above points and assume
that it will be done.

I expect that I will have to update the list above as people
point out mistakes in my assumptions.

	Arnd

^ permalink raw reply	[flat|nested] 99+ messages in thread
* [Linaro-mm-sig] [RFC] ARM DMA mapping TODO, v1
@ 2011-05-03 14:35 Laurent Pinchart
  0 siblings, 0 replies; 99+ messages in thread
From: Laurent Pinchart @ 2011-05-03 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 27 April 2011 23:31:06 Benjamin Herrenschmidt wrote:
> On Thu, 2011-04-21 at 21:29 +0200, Arnd Bergmann wrote:
> > 7. Extend the dma_map_ops to have a way for mapping a buffer
> > 
> >    from dma_alloc_{non,}coherent into user space. We have not
> >    discussed that yet, but after thinking this for some time, I
> >    believe this would be the right approach to map buffers into
> >    user space from code that doesn't care about the underlying
> >    hardware.
> 
> Yes. There is a dma_mmap_coherent() call that's not part of the "Real"
> API but is implemented by some archs and used by Alsa (I added support
> for it on powerpc recently).
> 
> Maybe that should go into the dma ops.
> 
> The question remains, if we ever want to do more complex demand-paged
> operations, should we also expose a lower level set of functions to get
> struct page out of a dma_alloc_coherent() allocation and to get the
> pgprot for the user dma mapping ?
> 
> > After all these are in place, building anything on top of
> > dma_alloc_{non,}coherent should be much easier. The question
> > of passing buffers between V4L and DRM is still completely
> > unsolved as far as I can tell, but that discussion might become
> > more focused if we can agree on the above points and assume
> > that it will be done.
> 
> My gut feeling is that it should be done by having V4L use DRM buffers
> in the first place...

V4L2 needs to capture data to a wide variety of memory locations (system 
memory when you just want to process the data using the CPU, frame buffer 
memory, contiguous buffers that will be passed to a DSP for video encoding, 
GPU textures, ...). To allow those use cases (and more) the V4L2 API provides 
two ways to handle data buffers: applications can request the driver to 
allocate memory internally, and them mmap() the buffers to userspace, or pass 
arbitrary memory pointers (and sizes) to the driver to be used as video 
capture buffers.

In the first case drivers will allocate memory depending on their 
requirements. This could mean vmalloc_user() for USB drivers that use memcpy() 
in the kernel, vmalloc() for hardware that support SG-lists or IOMMUs, 
dma_alloc_coherent() for drivers that need contiguous memory, ...

In the second case the driver will verify that the memory it receives from the 
application matches its requirements (regarding contiguousness for instance) 
and will then use that memory.

I think we could target the second case only if we want to share buffers 
between V4L and DRM, as V4L2 (unlike DRM) is already pretty good at using 
buffers it didn't allocate itself. The current API will need to be extended to 
pass an opaque buffer handle instead of a memory address, as we want to avoid 
requiring a userspace mapping for the buffer when not necessary. That's the 
whole point of the initial memory management discussion.

We will of course need to make sure that the DRM buffers fullfil the V4L2 
needs.

> > I expect that I will have to update the list above as people
> > point out mistakes in my assumptions.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2011-05-03 15:31 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-21 19:29 [RFC] ARM DMA mapping TODO, v1 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
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 at vt.edu
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
  -- strict thread matches above, loose matches on Subject: below --
2011-05-03 14:35 [Linaro-mm-sig] " Laurent Pinchart

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).