From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: "Saleem, Shiraz" <shiraz.saleem@intel.com>,
"Zhu, Yanjun" <yanjun.zhu@intel.com>,
"Ismail, Mustafa" <mustafa.ismail@intel.com>,
"jgg@ziepe.ca" <jgg@ziepe.ca>,
"leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Subject: Re: [PATCHv3 for-next 1/1] RDMA/irdma: Add support for dmabuf pin memory regions
Date: Fri, 17 Feb 2023 09:27:34 +0800 [thread overview]
Message-ID: <c8d1b8a3-3e19-f4dc-fd41-249aa447a9b1@linux.dev> (raw)
In-Reply-To: <MWHPR11MB0029CFC36AECD29382B4ABC5E9A39@MWHPR11MB0029.namprd11.prod.outlook.com>
在 2023/2/15 21:38, Saleem, Shiraz 写道:
>> Subject: [PATCHv3 for-next 1/1] RDMA/irdma: Add support for dmabuf pin
>> memory regions
>>
>> From: Zhu Yanjun <yanjun.zhu@linux.dev>
>>
>> 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/20211007114018.GD2688930@ziepe.ca/t/
>>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
>> ---
>> V2->V3: Remove unnecessary variable initialization;
>> Use error handler;
>> V1->V2: Thanks Shiraz Saleem, he gave me a lot of good suggestions.
>> This commit is based on the shared functions from refactored
>> irdma_reg_user_mr.
>> ---
>> drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++++
>> 1 file changed, 45 insertions(+)
>>
>> diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
>> index 6982f38596c8..7525f4cdf6fb 100644
>> --- a/drivers/infiniband/hw/irdma/verbs.c
>> +++ b/drivers/infiniband/hw/irdma/verbs.c
>> @@ -2977,6 +2977,50 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd
>> *pd, u64 start, u64 len,
>> return ERR_PTR(err);
>> }
>>
>> +static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
>> + u64 len, u64 virt,
>> + int fd, int access,
>> + struct ib_udata *udata)
>> +{
>> + struct irdma_device *iwdev = to_iwdev(pd->device);
>> + struct ib_umem_dmabuf *umem_dmabuf;
>> + struct irdma_mr *iwmr;
>> + int err;
>> +
>> + if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
>> + return ERR_PTR(-EINVAL);
>> +
>> + if (udata->inlen < IRDMA_MEM_REG_MIN_REQ_LEN)
>> + return ERR_PTR(-EINVAL);
> Do we need this? we don't copy anything from udata. There is no info passed via ABI struct irdma_mem_reg_req.
Got it. I will remove the inlen test and send a new commit out.
>
>> +
>> + umem_dmabuf = ib_umem_dmabuf_get_pinned(pd->device, start, len, fd,
>> access);
>> + if (IS_ERR(umem_dmabuf)) {
>> + err = PTR_ERR(umem_dmabuf);
>> + ibdev_dbg(&iwdev->ibdev, "Failed to get dmabuf umem[%d]\n",
>> err);
>> + return ERR_PTR(err);
>> + }
>> +
>> + iwmr = irdma_alloc_iwmr(&umem_dmabuf->umem, pd, virt,
>> IRDMA_MEMREG_TYPE_MEM);
>> + if (IS_ERR(iwmr)) {
>> + err = PTR_ERR(iwmr);
>> + goto err_release;
>> + }
>> +
>> + err = irdma_reg_user_mr_type_mem(iwmr, access);
>> + if (err)
>> + goto err_iwmr;
>> +
>> + return &iwmr->ibmr;
>> +
>> +err_iwmr:
>> + irdma_free_iwmr(iwmr);
>> +
>> +err_release:
>> + ib_umem_release(&umem_dmabuf->umem);
>> +
>> + return ERR_PTR(err);
>> +}
>> +
>> /**
>> * irdma_reg_phys_mr - register kernel physical memory
>> * @pd: ibpd pointer
>> @@ -4483,6 +4527,7 @@ static const struct ib_device_ops irdma_dev_ops = {
>> .query_port = irdma_query_port,
>> .query_qp = irdma_query_qp,
>> .reg_user_mr = irdma_reg_user_mr,
>> + .reg_user_mr_dmabuf = irdma_reg_user_mr_dmabuf,
>> .req_notify_cq = irdma_req_notify_cq,
>> .resize_cq = irdma_resize_cq,
>> INIT_RDMA_OBJ_SIZE(ib_pd, irdma_pd, ibpd),
>> --
> Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Thanks.
Zhu Yanjun
>
next prev parent reply other threads:[~2023-02-17 1:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 3:21 [PATCHv3 for-next 1/1] RDMA/irdma: Add support for dmabuf pin memory regions Zhu Yanjun
2023-02-03 3:16 ` Zhu Yanjun
2023-02-15 13:38 ` Saleem, Shiraz
2023-02-17 1:27 ` Zhu Yanjun [this message]
2023-02-16 15:03 ` Jason Gunthorpe
2023-02-17 0:46 ` Zhu Yanjun
2023-02-17 2:23 ` Jason Gunthorpe
-- strict thread matches above, loose matches on Subject: below --
2023-01-05 22:37 Zhu Yanjun
2023-01-05 13:37 ` Jason Gunthorpe
2023-01-07 6:22 ` Yanjun Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8d1b8a3-3e19-f4dc-fd41-249aa447a9b1@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mustafa.ismail@intel.com \
--cc=shiraz.saleem@intel.com \
--cc=yanjun.zhu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.