]> www.infradead.org Git - users/hch/misc.git/commit
block: add scatterlist-less DMA mapping helpers
authorChristoph Hellwig <hch@lst.de>
Sun, 27 Oct 2024 14:21:57 +0000 (16:21 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 10 Jun 2025 04:51:29 +0000 (06:51 +0200)
commitb49ba82f30c66fba9ade8d84d89c84b6ba6f7ed0
treec9d26db5e73a157d795687a49524ff12d4a7ff6d
parent2c953c3eb6ff8cc9a60b947fb45d4e6406bec285
block: add scatterlist-less DMA mapping helpers

Add a new blk_rq_dma_map / blk_rq_dma_unmap pair that does away with
the wasteful scatterlist structure.  Instead it uses the mapping iterator
to either add segments to the IOVA for IOMMU operations, or just maps
them one by one for the direct mapping.  For the IOMMU case instead of
a scatterlist with an entry for each segment, only a single [dma_addr,len]
pair needs to be stored for processing a request, and for the direct
mapping the per-segment allocation shrinks from
[page,offset,len,dma_addr,dma_len] to just [dma_addr,len].

One big difference to the scatterlist API, which could be considered
downside, is that the IOVA collapsing only works when the driver sets
a virt_boundary that matches the IOMMU granule.  For NVMe this is done
already so it works perfectly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-mq-dma.c
include/linux/blk-mq-dma.h [new file with mode: 0644]