From: "Xiong, Jianxin" <jianxin.xiong@intel.com>
To: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Sumit Semwal <sumit.semwal@linaro.org>,
Leon Romanovsky <leon@kernel.org>,
"Vetter, Daniel" <daniel.vetter@intel.com>,
Christian Koenig <christian.koenig@amd.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Subject: RE: [RFC PATCH v2 3/3] RDMA/uverbs: Add uverbs command for dma-buf based MR registration
Date: Tue, 30 Jun 2020 19:05:02 +0000 [thread overview]
Message-ID: <MW3PR11MB455545E6FD3E74A87C4442FAE56F0@MW3PR11MB4555.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1593451903-30959-4-git-send-email-jianxin.xiong@intel.com>
Cc'd drm people.
> -----Original Message-----
> From: Xiong, Jianxin <jianxin.xiong@intel.com>
> Sent: Monday, June 29, 2020 10:32 AM
> To: linux-rdma@vger.kernel.org
> Cc: Xiong, Jianxin <jianxin.xiong@intel.com>; Doug Ledford <dledford@redhat.com>; Jason Gunthorpe <jgg@ziepe.ca>; Sumit Semwal
> <sumit.semwal@linaro.org>; Leon Romanovsky <leon@kernel.org>; Vetter, Daniel <daniel.vetter@intel.com>
> Subject: [RFC PATCH v2 3/3] RDMA/uverbs: Add uverbs command for dma-buf based MR registration
>
> Add uverbs command for registering user memory region associated with a dma-buf file descriptor.
>
> Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
> Reviewed-by: Sean Hefty <sean.hefty@intel.com>
> Acked-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> ---
> drivers/infiniband/core/uverbs_std_types_mr.c | 112 ++++++++++++++++++++++++++
> include/uapi/rdma/ib_user_ioctl_cmds.h | 14 ++++
> 2 files changed, 126 insertions(+)
>
> diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c
> index c1286a5..2c9ff7c 100644
> --- a/drivers/infiniband/core/uverbs_std_types_mr.c
> +++ b/drivers/infiniband/core/uverbs_std_types_mr.c
> @@ -1,5 +1,6 @@
> /*
> * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved.
> + * Copyright (c) 2020, Intel Corporation. All rights reserved.
> *
> * This software is available to you under a choice of one of two
> * licenses. You may choose to be licensed under the terms of the GNU @@ -154,6 +155,85 @@ static int
> UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
> return ret;
> }
>
> +static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(
> + struct uverbs_attr_bundle *attrs)
> +{
> + struct ib_uobject *uobj =
> + uverbs_attr_get_uobject(attrs, UVERBS_ATTR_REG_DMABUF_MR_HANDLE);
> + struct ib_pd *pd =
> + uverbs_attr_get_obj(attrs, UVERBS_ATTR_REG_DMABUF_MR_PD_HANDLE);
> + struct ib_device *ib_dev = pd->device;
> +
> + u64 addr, length, hca_va;
> + u32 fd;
> + u32 access_flags;
> + struct ib_mr *mr;
> + int ret;
> +
> + if (!ib_dev->ops.reg_user_mr)
> + return -EOPNOTSUPP;
> +
> + ret = uverbs_copy_from(&addr, attrs, UVERBS_ATTR_REG_DMABUF_MR_ADDR);
> + if (ret)
> + return ret;
> +
> + ret = uverbs_copy_from(&length, attrs,
> + UVERBS_ATTR_REG_DMABUF_MR_LENGTH);
> + if (ret)
> + return ret;
> +
> + ret = uverbs_copy_from(&hca_va, attrs,
> + UVERBS_ATTR_REG_DMABUF_MR_HCA_VA);
> + if (ret)
> + return ret;
> +
> + ret = uverbs_copy_from(&fd, attrs,
> + UVERBS_ATTR_REG_DMABUF_MR_FD);
> + if (ret)
> + return ret;
> +
> + ret = uverbs_get_flags32(&access_flags, attrs,
> + UVERBS_ATTR_REG_DMABUF_MR_ACCESS_FLAGS,
> + IB_ACCESS_SUPPORTED);
> + if (ret)
> + return ret;
> +
> + ret = ib_check_mr_access(access_flags);
> + if (ret)
> + return ret;
> +
> + mr = pd->device->ops.reg_user_mr(pd, addr, length, hca_va,
> + (int)(s32)fd, access_flags,
> + &attrs->driver_udata);
> + if (IS_ERR(mr))
> + return PTR_ERR(mr);
> +
> + mr->device = pd->device;
> + mr->pd = pd;
> + mr->type = IB_MR_TYPE_USER;
> + mr->uobject = uobj;
> + atomic_inc(&pd->usecnt);
> +
> + uobj->object = mr;
> +
> + ret = uverbs_copy_to(attrs, UVERBS_ATTR_REG_DMABUF_MR_RESP_LKEY,
> + &mr->lkey, sizeof(mr->lkey));
> + if (ret)
> + goto err_dereg;
> +
> + ret = uverbs_copy_to(attrs, UVERBS_ATTR_REG_DMABUF_MR_RESP_RKEY,
> + &mr->rkey, sizeof(mr->rkey));
> + if (ret)
> + goto err_dereg;
> +
> + return 0;
> +
> +err_dereg:
> + ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs));
> +
> + return ret;
> +}
> +
> DECLARE_UVERBS_NAMED_METHOD(
> UVERBS_METHOD_ADVISE_MR,
> UVERBS_ATTR_IDR(UVERBS_ATTR_ADVISE_MR_PD_HANDLE,
> @@ -200,6 +280,37 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
> UVERBS_ATTR_TYPE(u32),
> UA_MANDATORY));
>
> +DECLARE_UVERBS_NAMED_METHOD(
> + UVERBS_METHOD_REG_DMABUF_MR,
> + UVERBS_ATTR_IDR(UVERBS_ATTR_REG_DMABUF_MR_HANDLE,
> + UVERBS_OBJECT_MR,
> + UVERBS_ACCESS_NEW,
> + UA_MANDATORY),
> + UVERBS_ATTR_IDR(UVERBS_ATTR_REG_DMABUF_MR_PD_HANDLE,
> + UVERBS_OBJECT_PD,
> + UVERBS_ACCESS_READ,
> + UA_MANDATORY),
> + UVERBS_ATTR_PTR_IN(UVERBS_ATTR_REG_DMABUF_MR_ADDR,
> + UVERBS_ATTR_TYPE(u64),
> + UA_MANDATORY),
> + UVERBS_ATTR_PTR_IN(UVERBS_ATTR_REG_DMABUF_MR_LENGTH,
> + UVERBS_ATTR_TYPE(u64),
> + UA_MANDATORY),
> + UVERBS_ATTR_PTR_IN(UVERBS_ATTR_REG_DMABUF_MR_HCA_VA,
> + UVERBS_ATTR_TYPE(u64),
> + UA_MANDATORY),
> + UVERBS_ATTR_PTR_IN(UVERBS_ATTR_REG_DMABUF_MR_FD,
> + UVERBS_ATTR_TYPE(u32),
> + UA_MANDATORY),
> + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_REG_DMABUF_MR_ACCESS_FLAGS,
> + enum ib_access_flags),
> + UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_REG_DMABUF_MR_RESP_LKEY,
> + UVERBS_ATTR_TYPE(u32),
> + UA_MANDATORY),
> + UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_REG_DMABUF_MR_RESP_RKEY,
> + UVERBS_ATTR_TYPE(u32),
> + UA_MANDATORY));
> +
> DECLARE_UVERBS_NAMED_METHOD_DESTROY(
> UVERBS_METHOD_MR_DESTROY,
> UVERBS_ATTR_IDR(UVERBS_ATTR_DESTROY_MR_HANDLE,
> @@ -210,6 +321,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(
> DECLARE_UVERBS_NAMED_OBJECT(
> UVERBS_OBJECT_MR,
> UVERBS_TYPE_ALLOC_IDR(uverbs_free_mr),
> + &UVERBS_METHOD(UVERBS_METHOD_REG_DMABUF_MR),
> &UVERBS_METHOD(UVERBS_METHOD_DM_MR_REG),
> &UVERBS_METHOD(UVERBS_METHOD_MR_DESTROY),
> &UVERBS_METHOD(UVERBS_METHOD_ADVISE_MR));
> diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
> index d4ddbe4..31aacbf 100644
> --- a/include/uapi/rdma/ib_user_ioctl_cmds.h
> +++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved.
> + * Copyright (c) 2020, Intel Corporation. All rights reserved.
> *
> * This software is available to you under a choice of one of two
> * licenses. You may choose to be licensed under the terms of the GNU @@ -161,6 +162,7 @@ enum uverbs_methods_mr {
> UVERBS_METHOD_DM_MR_REG,
> UVERBS_METHOD_MR_DESTROY,
> UVERBS_METHOD_ADVISE_MR,
> + UVERBS_METHOD_REG_DMABUF_MR,
> };
>
> enum uverbs_attrs_mr_destroy_ids {
> @@ -174,6 +176,18 @@ enum uverbs_attrs_advise_mr_cmd_attr_ids {
> UVERBS_ATTR_ADVISE_MR_SGE_LIST,
> };
>
> +enum uverbs_attrs_reg_dmabuf_mr_cmd_attr_ids {
> + UVERBS_ATTR_REG_DMABUF_MR_HANDLE,
> + UVERBS_ATTR_REG_DMABUF_MR_PD_HANDLE,
> + UVERBS_ATTR_REG_DMABUF_MR_ADDR,
> + UVERBS_ATTR_REG_DMABUF_MR_LENGTH,
> + UVERBS_ATTR_REG_DMABUF_MR_HCA_VA,
> + UVERBS_ATTR_REG_DMABUF_MR_FD,
> + UVERBS_ATTR_REG_DMABUF_MR_ACCESS_FLAGS,
> + UVERBS_ATTR_REG_DMABUF_MR_RESP_LKEY,
> + UVERBS_ATTR_REG_DMABUF_MR_RESP_RKEY,
> +};
> +
> enum uverbs_attrs_create_counters_cmd_attr_ids {
> UVERBS_ATTR_CREATE_COUNTERS_HANDLE,
> };
> --
> 1.8.3.1
next prev parent reply other threads:[~2020-06-30 19:05 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 17:31 [RFC PATCH v2 0/3] RDMA: add dma-buf support Jianxin Xiong
2020-06-29 17:31 ` [RFC PATCH v2 1/3] RDMA/umem: Support importing dma-buf as user memory region Jianxin Xiong
2020-06-30 19:04 ` Xiong, Jianxin
2020-06-29 17:31 ` [RFC PATCH v2 2/3] RDMA/core: Expand the driver method 'reg_user_mr' to support dma-buf Jianxin Xiong
2020-06-30 19:04 ` Xiong, Jianxin
2020-06-29 17:31 ` [RFC PATCH v2 3/3] RDMA/uverbs: Add uverbs command for dma-buf based MR registration Jianxin Xiong
2020-06-30 19:05 ` Xiong, Jianxin [this message]
2020-06-29 18:51 ` [RFC PATCH v2 0/3] RDMA: add dma-buf support Jason Gunthorpe
2020-06-30 17:21 ` Xiong, Jianxin
2020-06-30 17:34 ` Jason Gunthorpe
2020-06-30 18:46 ` Xiong, Jianxin
2020-06-30 19:17 ` Jason Gunthorpe
2020-06-30 20:08 ` Xiong, Jianxin
2020-07-02 12:27 ` Jason Gunthorpe
2020-07-01 9:03 ` Christian König
2020-07-01 12:07 ` Daniel Vetter
2020-07-01 12:14 ` Daniel Vetter
2020-07-01 12:39 ` Jason Gunthorpe
2020-07-01 12:55 ` Christian König
2020-07-01 15:42 ` Daniel Vetter
2020-07-01 17:15 ` Jason Gunthorpe
2020-07-02 13:10 ` Daniel Vetter
2020-07-02 13:29 ` Jason Gunthorpe
2020-07-02 14:50 ` Christian König
2020-07-02 18:15 ` Daniel Vetter
2020-07-03 12:03 ` Jason Gunthorpe
2020-07-03 12:52 ` Daniel Vetter
2020-07-03 13:14 ` Jason Gunthorpe
2020-07-03 13:21 ` Christian König
2020-07-07 21:58 ` Xiong, Jianxin
2020-07-08 9:38 ` Christian König
2020-07-08 9:49 ` Daniel Vetter
2020-07-08 14:20 ` Christian König
2020-07-08 14:33 ` Alex Deucher
2020-06-30 18:56 ` Xiong, Jianxin
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=MW3PR11MB455545E6FD3E74A87C4442FAE56F0@MW3PR11MB4555.namprd11.prod.outlook.com \
--to=jianxin.xiong@intel.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).