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. It doesn't feel right to me to mix different layers. Thanks > > Jason