Skip to content

Commit d2225b8

Browse files
zhuyjjgunthorpe
authored andcommitted
RDMA/irdma: Add support for dmabuf pin memory regions
This is a followup to the EFA dmabuf[1]. Irdma driver currently does not support on-demand-paging(ODP). So it uses habanalabs as the dmabuf exporter, and irdma as the importer to allow for peer2peer access through libibverbs. In this commit, the function ib_umem_dmabuf_get_pinned() is used. This function is introduced in EFA dmabuf[1] which allows the driver to get a dmabuf umem which is pinned and does not require move_notify callback implementation. The returned umem is pinned and DMA mapped like standard cpu umems, and is released through ib_umem_release(). [1]https://lore.kernel.org/lkml/[email protected]/t/ Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Shiraz Saleem <[email protected]> Signed-off-by: Zhu Yanjun <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 5ef1717 commit d2225b8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

drivers/infiniband/hw/irdma/verbs.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,47 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
29772977
return ERR_PTR(err);
29782978
}
29792979

2980+
static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
2981+
u64 len, u64 virt,
2982+
int fd, int access,
2983+
struct ib_udata *udata)
2984+
{
2985+
struct irdma_device *iwdev = to_iwdev(pd->device);
2986+
struct ib_umem_dmabuf *umem_dmabuf;
2987+
struct irdma_mr *iwmr;
2988+
int err;
2989+
2990+
if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
2991+
return ERR_PTR(-EINVAL);
2992+
2993+
umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd, access);
2994+
if (IS_ERR(umem_dmabuf)) {
2995+
err = PTR_ERR(umem_dmabuf);
2996+
ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n", err);
2997+
return ERR_PTR(err);
2998+
}
2999+
3000+
iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt, IRDMA_MEMREG_TYPE_MEM);
3001+
if (IS_ERR(iwmr)) {
3002+
err = PTR_ERR(iwmr);
3003+
goto err_release;
3004+
}
3005+
3006+
err = irdma_reg_user_mr_type_mem(iwmr, access);
3007+
if (err)
3008+
goto err_iwmr;
3009+
3010+
return &iwmr->ibmr;
3011+
3012+
err_iwmr:
3013+
irdma_free_iwmr(iwmr);
3014+
3015+
err_release:
3016+
ib_umem_release(&umem_dmabuf->umem);
3017+
3018+
return ERR_PTR(err);
3019+
}
3020+
29803021
/**
29813022
* irdma_reg_phys_mr - register kernel physical memory
29823023
* @pd: ibpd pointer
@@ -4483,6 +4524,7 @@ static const struct ib_device_ops irdma_dev_ops = {
44834524
.query_port = irdma_query_port,
44844525
.query_qp = irdma_query_qp,
44854526
.reg_user_mr = irdma_reg_user_mr,
4527+
.reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
44864528
.req_notify_cq = irdma_req_notify_cq,
44874529
.resize_cq = irdma_resize_cq,
44884530
INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),

0 commit comments

Comments
 (0)