lkml.org 
[lkml]   [2019]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] dma-mapping: create iommu mapping for newly allocated dma coherent mem
On Mon, Apr 22, 2019 at 07:51:25PM +0300, laurentiu.tudor@nxp.com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>
> If possible / available call into the DMA API to get a proper iommu
> mapping and a dma address for the newly allocated coherent dma memory.

I don't think this is so simple. The original use case of
dma_declare_coherent_memory was memory that is local to a device, where
we copy in data through a MMIO mapping and the device can then access
it. This use case still seems to be alive in the ohci-sm501 and
ohci-tmio drivers. Going through the iommu in those cases would be
counter productive.

The other use cases, including the OF ones seem to be (and Marek who
added that support should correct me if I'm wrong) normal host DRAM
that is just set aside for the device.

So if we want to support these prealloc pools with an iommu we need to
split the use cases. I have to say I really hate the way we do the DMA
"coherent" allocations, so I'm all in favor of that, it just hasn't
bubbled up towards the front of my todo list yet.

My highlevel plan here would be:

a) move the two OHCI drivers away from our current DMA declare
coherent code, and just use a trivial genalloc allocator for
their MMIO space, given that the USB layer already wraps the
dma_alloc/free APIs anyway
b) move the rest of the DMA coherent stuff into the actual dma
map ops, similar to how we handle CMA allocations. In fact
we should probably do this by a new page allocation helper
that tries CMA, "coherent" or the page allocator as fallback
b) also merge the OF-side handling of CMA vs "coherent" into a
single implementation. Preferably dropping the misleading
"coherent" name while we are at it.

\
 
 \ /
  Last update: 2019-04-22 20:12    [W:0.096 / U:6.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site