linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Michal Kalderon <michal.kalderon@marvell.com>
Cc: ariel.elior@marvell.com, dledford@redhat.com,
	galpress@amazon.com, yishaih@mellanox.com, bmt@zurich.ibm.com,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH v12 rdma-next 4/8] RDMA/efa: Use the common mmap_xa helpers
Date: Tue, 5 Nov 2019 15:54:59 -0400	[thread overview]
Message-ID: <20191105195459.GA19938@ziepe.ca> (raw)
In-Reply-To: <20191030094417.16866-5-michal.kalderon@marvell.com>

On Wed, Oct 30, 2019 at 11:44:13AM +0200, Michal Kalderon wrote:

> @@ -116,6 +122,13 @@ struct efa_ah {
>  	u8 id[EFA_GID_SIZE];
>  };
>  
> +struct efa_user_mmap_entry {
> +	struct rdma_user_mmap_entry rdma_entry;
> +	u64 address;
> +	size_t length;
> +	u8 mmap_flag;
> +};

There is no reason to move this struct out of efa_verbs.c

length is redundant with rdma_entry.npages

>  static int qp_mmap_entries_setup(struct efa_qp *qp,
>  				 struct efa_dev *dev,
>  				 struct efa_ucontext *ucontext,
>  				 struct efa_com_create_qp_params *params,
>  				 struct efa_ibv_create_qp_resp *resp)
>  {
> -	/*
> -	 * Once an entry is inserted it might be mmapped, hence cannot be
> -	 * cleaned up until dealloc_ucontext.
> -	 */
> -	resp->sq_db_mmap_key =
> -		mmap_entry_insert(dev, ucontext, qp,
> -				  dev->db_bar_addr + resp->sq_db_offset,
> -				  PAGE_SIZE, EFA_MMAP_IO_NC);
> -	if (resp->sq_db_mmap_key == EFA_MMAP_INVALID)
> +	size_t length;
> +	u64 address;
> +
> +	address = dev->db_bar_addr + resp->sq_db_offset;
> +	qp->sq_db_mmap_entry =
> +		efa_user_mmap_entry_insert(&ucontext->ibucontext,
> +					   address,
> +					   PAGE_SIZE, EFA_MMAP_IO_NC,
> +					   &resp->sq_db_mmap_key);

I'm still confused how this is OK for the lifetime, 'sq_db_offset'
comes from the device, does the device prevent re-use of the same
db_offset until the ucontext is closed? If so that deserves a comment
in here.

>  static int __efa_mmap(struct efa_dev *dev, struct efa_ucontext *ucontext,
> -		      struct vm_area_struct *vma, u64 key, u64 length)
> +		      struct vm_area_struct *vma, u64 key, size_t length)
>  {
> -	struct efa_mmap_entry *entry;
> +	struct rdma_user_mmap_entry *rdma_entry;
> +	struct efa_user_mmap_entry *entry;
>  	unsigned long va;
> +	int err = 0;
>  	u64 pfn;
> -	int err;
>  
> -	entry = mmap_entry_get(dev, ucontext, key, length);
> -	if (!entry) {
> +	rdma_entry = rdma_user_mmap_entry_get(&ucontext->ibucontext, key,
> +					      vma);
> +	if (!rdma_entry) {
>  		ibdev_dbg(&dev->ibdev, "key[%#llx] does not have valid entry\n",
>  			  key);
>  		return -EINVAL;
>  	}
> +	entry = to_emmap(rdma_entry);
> +	if (entry->length != length) {
> +		ibdev_dbg(&dev->ibdev,
> +			  "key[%#llx] does not have valid length[%#zx] expected[%#zx]\n",
> +			  key, length, entry->length);
> +		err = -EINVAL;
> +		goto out;
> +	}

Should be in common code

Same with the VM_SHARED (whichi s only needed for the vm_insert_page
flow)

Also driver should not be messing with VM_EXEC as that is known to
cause problems.

> @@ -1648,16 +1615,16 @@ int efa_mmap(struct ib_ucontext *ibucontext,
>  {
>  	struct efa_ucontext *ucontext = to_eucontext(ibucontext);
>  	struct efa_dev *dev = to_edev(ibucontext->device);
> -	u64 length = vma->vm_end - vma->vm_start;
> +	size_t length = vma->vm_end - vma->vm_start;
>  	u64 key = vma->vm_pgoff << PAGE_SHIFT;
>  
>  	ibdev_dbg(&dev->ibdev,
> -		  "start %#lx, end %#lx, length = %#llx, key = %#llx\n",
> +		  "start %#lx, end %#lx, length = %#zx, key = %#llx\n",
>  		  vma->vm_start, vma->vm_end, length, key);
>  
>  	if (length % PAGE_SIZE != 0 || !(vma->vm_flags & VM_SHARED)) {

vm_end - vm_start is always page aligned

Jason

  reply	other threads:[~2019-11-05 19:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30  9:44 [PATCH v12 rdma-next 0/8] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 1/8] RDMA/core: Move core content from ib_uverbs to ib_core Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 2/8] RDMA/core: Create mmap database and cookie helper functions Michal Kalderon
2019-10-31 12:35   ` Yishai Hadas
2019-11-01 10:19     ` [EXT] " Michal Kalderon
2019-11-05 19:44   ` Jason Gunthorpe
2019-10-30  9:44 ` [PATCH v12 rdma-next 3/8] RDMA: Connect between the mmap entry and the umap_priv structure Michal Kalderon
2019-11-05 19:47   ` Jason Gunthorpe
2019-10-30  9:44 ` [PATCH v12 rdma-next 4/8] RDMA/efa: Use the common mmap_xa helpers Michal Kalderon
2019-11-05 19:54   ` Jason Gunthorpe [this message]
2019-11-06  8:20     ` Gal Pressman
2019-10-30  9:44 ` [PATCH v12 rdma-next 5/8] RDMA/siw: " Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 6/8] RDMA/qedr: Use the common mmap API Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 7/8] RDMA/qedr: Add doorbell overflow recovery support Michal Kalderon
2019-10-30  9:44 ` [PATCH v12 rdma-next 8/8] RDMA/qedr: Add iWARP doorbell " Michal Kalderon
2019-10-30 15:33 ` [PATCH v12 rdma-next 5/8] RDMA/siw: Use the common mmap_xa helpers Bernard Metzler
2019-11-05 20:41 ` [PATCH v12 rdma-next 0/8] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Jason Gunthorpe
2019-11-06 13:04   ` Michal Kalderon
2019-11-06 15:10     ` Jason Gunthorpe
2019-11-06 17:09     ` Jason Gunthorpe

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=20191105195459.GA19938@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=ariel.elior@marvell.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michal.kalderon@marvell.com \
    --cc=yishaih@mellanox.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;
as well as URLs for NNTP newsgroup(s).