Skip to content

Commit 495758b

Browse files
lsgunthChristoph Hellwig
authored andcommitted
RDMA/core: introduce ib_dma_pci_p2p_dma_supported()
Introduce the helper function ib_dma_pci_p2p_dma_supported() to check if a given ib_device can be used in P2PDMA transfers. This ensures the ib_device is not using virt_dma and also that the underlying dma_device supports P2PDMA. Use the new helper in nvme-rdma to replace the existing check for ib_uses_virt_dma(). Adding the dma_pci_p2pdma_supported() check allows switching away from pci_p2pdma_[un]map_sg(). Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 91fb2b6 commit 495758b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/nvme/target/rdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev,
415415
if (ib_dma_mapping_error(ndev->device, r->send_sge.addr))
416416
goto out_free_rsp;
417417

418-
if (!ib_uses_virt_dma(ndev->device))
418+
if (ib_dma_pci_p2p_dma_supported(ndev->device))
419419
r->req.p2p_client = &ndev->device->dev;
420420
r->send_sge.length = sizeof(*r->req.cqe);
421421
r->send_sge.lkey = ndev->pd->local_dma_lkey;

include/rdma/ib_verbs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,6 +4013,17 @@ static inline bool ib_uses_virt_dma(struct ib_device *dev)
40134013
return IS_ENABLED(CONFIG_INFINIBAND_VIRT_DMA) && !dev->dma_device;
40144014
}
40154015

4016+
/*
4017+
* Check if a IB device's underlying DMA mapping supports P2PDMA transfers.
4018+
*/
4019+
static inline bool ib_dma_pci_p2p_dma_supported(struct ib_device *dev)
4020+
{
4021+
if (ib_uses_virt_dma(dev))
4022+
return false;
4023+
4024+
return dma_pci_p2pdma_supported(dev->dma_device);
4025+
}
4026+
40164027
/**
40174028
* ib_dma_mapping_error - check a DMA addr for error
40184029
* @dev: The device for which the dma_addr was created

0 commit comments

Comments
 (0)