From: Jason Gunthorpe <jgg@nvidia.com>
To: Wenpeng Liang <liangwenpeng@huawei.com>
Cc: dledford@redhat.com, linux-rdma@vger.kernel.org, linuxarm@huawei.com
Subject: Re: [PATCH for-next 1/1] RDMA/hns: Add a new mmap implementation
Date: Wed, 6 Oct 2021 19:44:31 -0300 [thread overview]
Message-ID: <20211006224431.GA2775740@nvidia.com> (raw)
In-Reply-To: <20210930083608.18981-2-liangwenpeng@huawei.com>
On Thu, Sep 30, 2021 at 04:36:08PM +0800, Wenpeng Liang wrote:
> From: Chengchang Tang <tangchengchang@huawei.com>
>
> Add a new implementation for mmap by using the new mmap entry API.
>
> The new implementation prepares for subsequent features and is compatible
> with the old implementation. And the old implementation using hard-coded
> offset will not be extended in the future.
>
> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
> drivers/infiniband/hw/hns/hns_roce_device.h | 21 +++
> drivers/infiniband/hw/hns/hns_roce_main.c | 148 +++++++++++++++++++-
> include/uapi/rdma/hns-abi.h | 21 ++-
> 3 files changed, 184 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
> index 9467c39e3d28..ca456948b2d8 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
> @@ -225,11 +225,23 @@ struct hns_roce_uar {
> unsigned long logic_idx;
> };
>
> +struct hns_user_mmap_entry {
> + struct rdma_user_mmap_entry rdma_entry;
> + u64 address;
> + u8 mmap_flag;
> +};
> +
> +enum hns_roce_mmap_type {
> + HNS_ROCE_MMAP_TYPE_DB = 1,
> +};
> +
> struct hns_roce_ucontext {
> struct ib_ucontext ibucontext;
> struct hns_roce_uar uar;
> struct list_head page_list;
> struct mutex page_mutex;
> + bool mmap_key_support;
> + struct rdma_user_mmap_entry *db_mmap_entry;
This should be struct hns_user_mmap_entry
> +struct rdma_user_mmap_entry *hns_roce_user_mmap_entry_insert(
> + struct ib_ucontext *ucontext, u64 address,
> + size_t length, u8 mmap_flag)
And this should return the hns_user_mmap_entry too
> +static void ucontext_get_config(struct hns_roce_ucontext *context,
> + struct hns_roce_ib_alloc_ucontext *ucmd)
> +{
> + struct hns_roce_dev *hr_dev = to_hr_dev(context->ibucontext.device);
> +
> + if (ucmd->comp & HNS_ROCE_ALLOC_UCTX_COMP_CONFIG &&
> + hr_dev->hw_rev != HNS_ROCE_HW_VER1)
> + context->mmap_key_support = !!(ucmd->config &
> + HNS_ROCE_UCTX_REQ_MMAP_KEY_EN);
No need for !! when in a bool context
>
> +static int hns_roce_mmap(struct ib_ucontext *uctx, struct vm_area_struct *vma)
> +{
> + struct hns_roce_ucontext *context = to_hr_ucontext(uctx);
> + struct hns_roce_dev *hr_dev = to_hr_dev(uctx->device);
> + struct ib_device *ibdev = &hr_dev->ib_dev;
> + struct rdma_user_mmap_entry *rdma_entry;
> + struct hns_user_mmap_entry *entry;
> + phys_addr_t pfn;
> + pgprot_t prot;
> + int ret;
> +
> + if (!context->mmap_key_support)
> + return hns_roce_legacy_mmap(uctx, vma);
This shouldn't be necessary,
Just call rdma_user_mmap_entry_insert_range() to insert the two pages
at 0 and 1 when in legacy mode and always keep the mmap routine in new
mode
Jason
next prev parent reply other threads:[~2021-10-06 22:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 8:36 [PATCH for-next 0/1] RDMA/hns: Add a new mmap implementation Wenpeng Liang
2021-09-30 8:36 ` [PATCH for-next 1/1] " Wenpeng Liang
2021-10-06 22:44 ` Jason Gunthorpe [this message]
2021-10-09 12:18 ` Wenpeng Liang
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=20211006224431.GA2775740@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=liangwenpeng@huawei.com \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox