On Tue, Jul 07, 2020 at 08:21:09AM -0300, Jason Gunthorpe wrote: > On Tue, Jul 07, 2020 at 07:42:03AM +0300, Leon Romanovsky wrote: > > On Mon, Jul 06, 2020 at 08:04:16PM -0300, Jason Gunthorpe wrote: > > > On Tue, Jun 30, 2020 at 01:18:53PM +0300, Leon Romanovsky wrote: > > > > @@ -916,21 +916,24 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs) > > > > goto err_put; > > > > } > > > > > > > > - mw = pd->device->ops.alloc_mw(pd, cmd.mw_type, &attrs->driver_udata); > > > > - if (IS_ERR(mw)) { > > > > - ret = PTR_ERR(mw); > > > > + mw = rdma_zalloc_drv_obj(ib_dev, ib_mw); > > > > + if (!mw) { > > > > + ret = -ENOMEM; > > > > goto err_put; > > > > } > > > > > > > > - mw->device = pd->device; > > > > - mw->pd = pd; > > > > + mw->device = ib_dev; > > > > + mw->pd = pd; > > > > mw->uobject = uobj; > > > > - atomic_inc(&pd->usecnt); > > > > - > > > > uobj->object = mw; > > > > + mw->type = cmd.mw_type; > > > > > > > > - memset(&resp, 0, sizeof(resp)); > > > > - resp.rkey = mw->rkey; > > > > + ret = pd->device->ops.alloc_mw(mw, &mw->rkey, &attrs->driver_udata); > > > > > > Why the strange &mw->rkey ? Can't the drivers just do mw->rkey = foo ? > > > > We can, if we want to allow drivers set fields in ib_* structures that > > there passed as part of alloc_* flows. > > This is better than passing weird loose pointers around I don't think that it is right approach, but I'll change. Thanks > > Jason