PCI/P2PDMA: Introduce helpers for dma_map_sg implementations
authorLogan Gunthorpe <logang@deltatee.com>
Fri, 8 Jul 2022 16:50:54 +0000 (10:50 -0600)
committerChristoph Hellwig <hch@lst.de>
Tue, 26 Jul 2022 11:27:47 +0000 (07:27 -0400)
commit5e180ff326b43bd3fb72892e1083b2707159aa6e
treeeaf2785b8c22cf57840c2666668e76aa5fb04013
parent719c98658058f4aca0f7663ff11f2606e99cce4f
PCI/P2PDMA: Introduce helpers for dma_map_sg implementations

Add pci_p2pdma_map_segment() as a helper for dma_map_sg()
implementations. It takes an scatterlist segment that must point to a
pci_p2pdma struct page and will map it if the mapping requires a bus
address.

The return value indicates whether the mapping required a bus address
or whether the caller still needs to map the segment normally. If the
segment should not be mapped, -EREMOTEIO is returned.

This helper uses a state structure to track the changes to the
pgmap across calls and avoid needing to lookup into the xarray for
every page.

The prototype for the helper is added to dma-map-ops.h as it is only
useful to dma map implementations and don't need to pollute the public
pci-p2pdma header.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/pci/p2pdma.c
include/linux/dma-map-ops.h