Re: [PATCH] lib/scatterlist: Provide a DMA page iterator

From: hch@xxxxxx
Date: Tue Jan 15 2019 - 15:58:07 EST


On Tue, Jan 15, 2019 at 07:13:11PM +0000, Koenig, Christian wrote:
> Thomas is correct that the interface you propose here doesn't work at
> all for GPUs.
>
> The kernel driver is not informed of flush/sync, but rather just setups
> coherent mappings between system memory and devices.
>
> In other words you have an array of struct pages and need to map that to
> a specific device and so create dma_addresses for the mappings.

If you want a coherent mapping you need to use dma_alloc_coherent
and dma_mmap_coherent and you are done, that is not the problem.
That actually is one of the vmgfx modes, so I don't understand what
problem we are trying to solve if you don't actually want a non-coherent
mapping. Although last time I had that discussion with Daniel Vetter
I was under the impressions that GPUs really wanted non-coherent
mappings.

But if you want a coherent mapping you can't go to a struct page,
because on many systems you can't just map arbitrary memory as
uncachable. It might either come from very special limited pools,
or might need other magic applied to it so that it is not visible
in the normal direct mapping, or at least not access through it.