]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Provide a new two step DMA mapping API
authorLeon Romanovsky <leon@kernel.org>
Mon, 12 May 2025 09:04:15 +0000 (05:04 -0400)
committerLeon Romanovsky <leon@kernel.org>
Mon, 12 May 2025 09:04:15 +0000 (05:04 -0400)
Currently the only efficient way to map a complex memory description through
the DMA API is by using the scatter list APIs. The SG APIs are unique in that
they efficiently combine the two fundamental operations of sizing and allocating
a large IOVA window from the IOMMU and processing all the per-address
swiotlb/flushing/p2p/map details.

This uniqueness has been a long standing pain point as the scatter list API
is mandatory, but expensive to use. It prevents any kind of optimization or
feature improvement (such as avoiding struct page for P2P) due to the
impossibility of improving the scatter list.

Several approaches have been explored to expand the DMA API with additional
scatterlist-like structures (BIO, rlist), instead split up the DMA API
to allow callers to bring their own data structure.

The API is split up into parts:
 - Allocate IOVA space:
    To do any pre-allocation required. This is done based on the caller
    supplying some details about how much IOMMU address space it would need
    in worst case.
 - Map and unmap relevant structures to pre-allocated IOVA space:
    Perform the actual mapping into the pre-allocated IOVA. This is very
    similar to dma_map_page().

Thanks

Signed-off-by: Leon Romanovsky <leon@kernel.org>

Trivial merge