]> www.infradead.org Git - users/hch/misc.git/commit
blk-mq: 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>
Sun, 11 May 2025 03:32:35 +0000 (05:32 +0200)
commit191d47e32446068f6d288c4da27041387cfb6076
tree1aaae0f5d02535a93bacb35b8f6b18fdd1f5ec3e
parent3686041e9744a13c3094d7137a4bd25b5c542333
blk-mq: 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].

The major downside of this API is that the IOVA collapsing only works
when the driver sets a virt_boundary that matches the IOMMU granule.

Note that struct blk_dma_vec, struct blk_dma_mapping and blk_rq_dma_unmap
aren't really block specific, but for they are kept with the only mapping
routine to keep things simple.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
block/blk-merge.c
include/linux/blk-mq-dma.h [new file with mode: 0644]