Merge tag 'pci-v4.20-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
[platform/kernel/linux-rpi.git] / drivers / infiniband / core / rw.c
index 683e6d1..d22c4a2 100644 (file)
@@ -12,6 +12,7 @@
  */
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
+#include <linux/pci-p2pdma.h>
 #include <rdma/mr_pool.h>
 #include <rdma/rw.h>
 
@@ -280,7 +281,11 @@ int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num,
        struct ib_device *dev = qp->pd->device;
        int ret;
 
-       ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
+       if (is_pci_p2pdma_page(sg_page(sg)))
+               ret = pci_p2pdma_map_sg(dev->dma_device, sg, sg_cnt, dir);
+       else
+               ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
+
        if (!ret)
                return -ENOMEM;
        sg_cnt = ret;
@@ -602,7 +607,9 @@ void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num,
                break;
        }
 
-       ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
+       /* P2PDMA contexts do not need to be unmapped */
+       if (!is_pci_p2pdma_page(sg_page(sg)))
+               ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir);
 }
 EXPORT_SYMBOL(rdma_rw_ctx_destroy);