[Nouveau] [PATCH 3/6] mmu: map small pages into big pages(s) by IOMMU if possible
Terje Bergstrom
tbergstrom at nvidia.com
Mon Apr 20 09:47:09 PDT 2015
On 04/20/2015 12:49 AM, Alexandre Courbot wrote:
> Aha, looks like both Vince and I overlooked this point. So IIUC we
> would need to make sure a GPU buffer is only ever mapped once by the
> IOMMU. This means we either need to preemptively entilery map it at
> some point and just keep a reference count, or keep track of which
> 128k ranges are already mapped (again, with a reference count to know
> when to unmap them).
>
> First solution is tempting because it is simpler, but surely there is
> something wrong with it?
If you map the whole buffer to IOMMU at once, you can use map_sg style
calls, which would make your IOMMU mapping be faster. It also matches
how dma_buf_map_attachment() works. So one way would be to first check
if the buffer has already been mapped to GPU IOMMU space, and if so,
increment refcount and reuse address. If not, map the buffer for example
via dma_buf_map_attachment(), and stash the IOMMU address.
For me the trickiest to get right was freeing the buffer. When the user
space was done with buffer, can we ensure all mappings are torn down
first? Does that hold if user space just crashes?
More information about the Nouveau
mailing list