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 v7 4/5] RDMA/mlx5: Support dma-buf based userspace memory region
Date: Thu, 5 Nov 2020 10:22:06 -0400 [thread overview]
Message-ID: <20201105142206.GA36674@ziepe.ca> (raw)
In-Reply-To: <MW3PR11MB4555C4C6A58F0D054C69FEADE5EE0@MW3PR11MB4555.namprd11.prod.outlook.com>
On Thu, Nov 05, 2020 at 12:36:25AM +0000, Xiong, Jianxin wrote:
> > From: Jason Gunthorpe <jgg@ziepe.ca>
> > Sent: Wednesday, November 04, 2020 4:07 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 v7 4/5] RDMA/mlx5: Support dma-buf based userspace memory region
> >
> > On Wed, Nov 04, 2020 at 02:06:34PM -0800, Jianxin Xiong wrote:
> > > + umem = ib_umem_dmabuf_get(&dev->ib_dev, offset, length, fd, access_flags,
> > > + &mlx5_ib_dmabuf_attach_ops);
> > > + if (IS_ERR(umem)) {
> > > + mlx5_ib_dbg(dev, "umem get failed (%ld)\n", PTR_ERR(umem));
> > > + return ERR_PTR(PTR_ERR(umem));
> > > + }
> > > +
> > > + mr = alloc_mr_from_cache(pd, umem, virt_addr, access_flags);
> >
> > It is very subtle, but this calls mlx5_umem_find_best_pgsz() which calls ib_umem_find_best_pgsz() which goes over the SGL to determine
> > the page size to use.
> >
>
> When this is called here, the umem sglist is still NULL because dma_buf_map_attachment()
> is not called until a page fault occurs. In patch 1/5, the function ib_umem_find_best_pgsz()
> has been modified to always return PAGE_SIZE for dma-buf based MR.
Oh.. That isn't a good idea.
ib_umem_find_best_pgsz() must be run on any SGL list to validate it
against the constraints, making it un-runable for the dmabuf case
means we can never support large page size or even validate that the
SGL is properly formed.
So I think this need to change the alloc_mr_from_cache() to early exit
for dma_buf ones
And it still need to call ib_umem_find_best_pgsz() but
just check the page size.
> > Edit the last SGE to have a reduced length
>
> Do you still think modifying the SGL in place needed given the above
> explanation? I do see some benefits of doing so -- hiding the
> discrepancy of sgl and addr/length from the device drivers and avoid
> special handling in the code that use the sgl.
Yes, a umem SGL should always be properly formed or I will have a
meltdown trying to keep all the drivers working :\
Jason
next prev parent reply other threads:[~2020-11-05 14:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-04 22:06 [PATCH v7 0/5] RDMA: Add dma-buf support Jianxin Xiong
2020-11-04 22:06 ` [PATCH v7 1/5] RDMA/umem: Support importing dma-buf as user memory region Jianxin Xiong
2020-11-04 22:06 ` [PATCH v7 2/5] RDMA/core: Add device method for registering dma-buf based " Jianxin Xiong
2020-11-04 22:06 ` [PATCH v7 3/5] RDMA/uverbs: Add uverbs command for dma-buf based MR registration Jianxin Xiong
2020-11-04 22:06 ` [PATCH v7 4/5] RDMA/mlx5: Support dma-buf based userspace memory region Jianxin Xiong
2020-11-05 0:07 ` Jason Gunthorpe
2020-11-05 0:36 ` Xiong, Jianxin
2020-11-05 14:22 ` Jason Gunthorpe [this message]
2020-11-04 22:06 ` [PATCH v7 5/5] dma-buf: Reject attach request from importers that use dma_virt_ops Jianxin Xiong
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=20201105142206.GA36674@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