[RFC PATCH v2 06/11] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg
Christoph Hellwig
hch at lst.de
Tue Mar 16 08:11:56 GMT 2021
On Thu, Mar 11, 2021 at 04:31:36PM -0700, Logan Gunthorpe wrote:
> for_each_sg(sgl, sg, nents, i) {
> + if (is_pci_p2pdma_page(sg_page(sg))) {
> + if (sg_page(sg)->pgmap != pgmap) {
> + pgmap = sg_page(sg)->pgmap;
> + map = pci_p2pdma_dma_map_type(dev, pgmap);
> + bus_off = pci_p2pdma_bus_offset(sg_page(sg));
> + }
> +
> + if (map < 0) {
> + sg->dma_address = DMA_MAPPING_ERROR;
> + ret = -EREMOTEIO;
> + goto out_unmap;
> + }
> +
> + if (map) {
> + sg->dma_address = sg_phys(sg) + sg->offset -
> + bus_off;
> + sg_dma_len(sg) = sg->length;
> + sg_mark_pci_p2pdma(sg);
> + continue;
> + }
> + }
This code needs to go into a separate noinline helper to reduce the impact
on the fast path. Also as Robin noted the offset is already
accounted for in sg_phys. We also don't ever set the dma_address in
the scatterlist to DMA_MAPPING_ERROR, that is just a return value
for the single entry mapping routines.
More information about the Linux-nvme
mailing list