From: Jason Gunthorpe <jgg@ziepe.ca>
To: "Xiong, Jianxin" <jianxin.xiong@intel.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Doug Ledford <dledford@redhat.com>,
Leon Romanovsky <leon@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Christian Koenig <christian.koenig@amd.com>,
"Vetter, Daniel" <daniel.vetter@intel.com>
Subject: Re: [PATCH v10 1/6] RDMA/umem: Support importing dma-buf as user memory region
Date: Fri, 13 Nov 2020 08:49:06 -0400 [thread overview]
Message-ID: <20201113124906.GC244516@ziepe.ca> (raw)
In-Reply-To: <MW3PR11MB45558223F95CCE4ABF57B9BCE5E60@MW3PR11MB4555.namprd11.prod.outlook.com>
On Fri, Nov 13, 2020 at 03:30:04AM +0000, Xiong, Jianxin wrote:
> > From: Jason Gunthorpe <jgg@ziepe.ca>
> > Sent: Thursday, November 12, 2020 4:31 PM
> > To: Xiong, Jianxin <jianxin.xiong@intel.com>
> > Cc: linux-rdma@vger.kernel.org; dri-devel@lists.freedesktop.org; Doug Ledford <dledford@redhat.com>; Leon Romanovsky
> > <leon@kernel.org>; Sumit Semwal <sumit.semwal@linaro.org>; Christian Koenig <christian.koenig@amd.com>; Vetter, Daniel
> > <daniel.vetter@intel.com>
> > Subject: Re: [PATCH v10 1/6] RDMA/umem: Support importing dma-buf as user memory region
> >
> > On Tue, Nov 10, 2020 at 01:41:12PM -0800, Jianxin Xiong wrote:
> > > +struct ib_umem *ib_umem_dmabuf_get(struct ib_device *device,
> > > + unsigned long offset, size_t size,
> > > + int fd, int access,
> > > + const struct dma_buf_attach_ops *ops) {
> > > + struct dma_buf *dmabuf;
> > > + struct ib_umem_dmabuf *umem_dmabuf;
> > > + struct ib_umem *umem;
> > > + unsigned long end;
> > > + long ret;
> > > +
> > > + if (check_add_overflow(offset, (unsigned long)size, &end))
> > > + return ERR_PTR(-EINVAL);
> > > +
> > > + if (unlikely(PAGE_ALIGN(end) < PAGE_SIZE))
> > > + return ERR_PTR(-EINVAL);
> >
> > This is weird, what does it do?
>
> This sequence is modeled after the following code from ib_umem_init_odp():
>
> if (check_add_overflow(umem_odp->umem.address,
> (unsigned long)umem_odp->umem.length,
> &end))
> return -EOVERFLOW;
> end = ALIGN(end, page_size);
> if (unlikely(end < page_size))
> return -EOVERFLOW;
>
> The weird part seems to be checking if 'end' is 0, but that should have been covered
> by check_add_overflow() already.
I think the
+ if (unlikely(!ib_umem_num_pages(umem))) {
Catches the same condition, no need to do it twice
Jason
next prev parent reply other threads:[~2020-11-13 12:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 21:41 [PATCH v10 0/6] RDMA: Add dma-buf support Jianxin Xiong
2020-11-10 21:41 ` [PATCH v10 1/6] RDMA/umem: Support importing dma-buf as user memory region Jianxin Xiong
2020-11-13 0:30 ` Jason Gunthorpe
2020-11-13 3:30 ` Xiong, Jianxin
2020-11-13 12:49 ` Jason Gunthorpe [this message]
2020-11-10 21:41 ` [PATCH v10 2/6] RDMA/core: Add device method for registering dma-buf based " Jianxin Xiong
2020-11-10 21:41 ` [PATCH v10 3/6] RDMA/uverbs: Add uverbs command for dma-buf based MR registration Jianxin Xiong
2020-11-13 0:33 ` Jason Gunthorpe
2020-11-13 4:02 ` Xiong, Jianxin
2020-11-10 21:41 ` [PATCH v10 4/6] RDMA/mlx5: Support dma-buf based userspace memory region Jianxin Xiong
2020-11-13 0:39 ` Jason Gunthorpe
2020-11-13 3:51 ` Xiong, Jianxin
2020-11-13 13:06 ` Jason Gunthorpe
2020-11-13 17:28 ` Xiong, Jianxin
2020-11-10 21:41 ` [PATCH v10 5/6] dma-buf: Reject attach request from importers that use dma_virt_ops Jianxin Xiong
2020-11-10 21:41 ` [PATCH v10 6/6] dma-buf: Document that dma-buf size is fixed Jianxin Xiong
2020-11-11 16:33 ` Daniel Vetter
2020-11-12 13:25 ` Jason Gunthorpe
2020-11-13 20:41 ` Daniel Vetter
2020-11-13 0:42 ` [PATCH v10 0/6] RDMA: Add dma-buf support 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=20201113124906.GC244516@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jianxin.xiong@intel.com \
--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