]> www.infradead.org Git - users/hch/misc.git/commit
nvme-pci: convert the data mapping to blk_rq_dma_map
authorChristoph Hellwig <hch@lst.de>
Sun, 15 Jun 2025 08:55:06 +0000 (10:55 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 17 Jun 2025 05:27:13 +0000 (07:27 +0200)
commit631f4db46b632f505e96a1ee96f49381ef98a6df
tree1c261f51b9aea1d7c6dfb5f0998961e6e3d64c4b
parentb9949e30245b5f75c4a56f4cc93b6c9a68ddfd5c
nvme-pci: convert the data mapping to blk_rq_dma_map

Use the blk_rq_dma_map API to DMA map requests instead of scatterlists.
This removes the need to allocate a scatterlist covering every segment,
and thus the overall transfer length limit based on the scatterlist
allocation.

Instead the DMA mapping is done by iterating the bio_vec chain in the
request directly.  The unmap is handled differently depending on how
we mapped:

 - when using an IOMMU only a single IOVA is used, and it is stored in
   iova_state
 - for direct mappings that don't use swiotlb and are cache coherent,
   unmap is not needed at all
 - for direct mappings that are not cache coherent or use swiotlb, the
   physical addresses are rebuild from the PRPs or SGL segments

The latter unfortunately adds a fair amount of code to the driver, but
it is code not used in the fast path.

The conversion only covers the data mapping path, and still uses a
scatterlist for the multi-segment metadata case.  I plan to convert that
as soon as we have good test coverage for the multi-segment metadata
path.

Thanks to Chaitanya Kulkarni for an initial attempt at a new DMA API
conversion for nvme-pci, Kanchan Joshi for bringing back the single
segment optimization, Leon Romanovsky for shepherding this through a
gazillion rebases and Nitesh Shetty for various improvements.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
drivers/nvme/host/pci.c