Re: dma_mmap_fault discussion

From: Christoph Hellwig
Date: Fri Sep 06 2019 - 02:32:12 EST


On Thu, Sep 05, 2019 at 07:05:43PM +0200, Thomas Hellström (VMware) wrote:
> I took a quick look at the interfaces and have two questions:
>
> 1) dma_mmap_prepare(), would it be possible to drop the references to the
> actual coherent region? The thing is that TTM doesn't know at mmap time what
> memory will be backing the region. It can be VRAM, coherent memory or system

I guess we can shift the argument checking into the fault handler.

> 2) @cpu_addr and @dma_addr are the values pointing at the beginning of an
> allocated chunk, right?

Yes.

> The reason I'm asking is that TTM's coherent memory
> pool is sub-allocating from larger chunks into smaller PAGE_SIZE chunks,
> which means that a TTM buffer object may be randomly split across larger
> chunks, which means we have to store these values for each PAGE_SiZE chunk.

For implementations that remap non-contigous regions using vmap we need the
start cpu address passed, as that is used to find the vm_struct structure
for it. That being said I don't see a problem with you keeping track
of the original start and offset into in your suballocation helpers.