[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190422181100.GB32490@lst.de>
Date: Mon, 22 Apr 2019 20:11:00 +0200
From: Christoph Hellwig <hch@....de>
To: laurentiu.tudor@....com
Cc: hch@....de, robin.murphy@....com, m.szyprowski@...sung.com,
iommu@...ts.linux-foundation.org, leoyang.li@....com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [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@....com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@....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.
Powered by blists - more mailing lists