[PATCH v8 3/5] RDMA/uverbs: Add uverbs command for dma-buf based MR registration

Xiong, Jianxin jianxin.xiong at intel.com
Fri Nov 6 16:20:34 UTC 2020


> -----Original Message-----
> From: Jason Gunthorpe <jgg at ziepe.ca>
> Sent: Thursday, November 05, 2020 4:13 PM
> To: Xiong, Jianxin <jianxin.xiong at intel.com>
> Cc: linux-rdma at vger.kernel.org; dri-devel at lists.freedesktop.org; Doug Ledford <dledford at redhat.com>; Leon Romanovsky
> <leon at kernel.org>; Sumit Semwal <sumit.semwal at linaro.org>; Christian Koenig <christian.koenig at amd.com>; Vetter, Daniel
> <daniel.vetter at intel.com>
> Subject: Re: [PATCH v8 3/5] RDMA/uverbs: Add uverbs command for dma-buf based MR registration
> 
> On Thu, Nov 05, 2020 at 02:48:07PM -0800, Jianxin Xiong wrote:
> 
> > +	ret = ib_check_mr_access(access_flags);
> > +	if (ret)
> > +		return ret;
> 
> This should also reject unsupportable flags like ACCESS_ON_DEMAND and HUGETLB

Will do.

> 
> > +
> > +	mr = pd->device->ops.reg_user_mr_dmabuf(pd, offset, length, virt_addr,
> > +						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);
> 
> Fix intending when copying code please

It could be due to a mix of tab and space. They look aligned in the source file. Will fix.

> 
> > +
> > +	uobj->object = mr;
> 
> Also bit surprised this works at all, it needs to call
> 
>   uverbs_finalize_uobj_create()
> 
> Right here.
> 

Will fix.

> Seems like the core code is missing some check that the API is being used properly.
> 
> > +
> > +	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,
> 
> > @@ -253,6 +364,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_MR)(
> >  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),
> 
> I trie to keep these sorted, but I see it has become unsorted. You can re-sort it in this patch

Will do.

> 
> Jason


More information about the dri-devel mailing list