linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Doug Ledford <dledford@redhat.com>, Lijun Ou <oulijun@huawei.com>,
	linux-rdma@vger.kernel.org,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Weihang Li <liweihang@huawei.com>,
	"Wei Hu(Xavier)" <huwei87@hisilicon.com>,
	Yishai Hadas <yishaih@mellanox.com>
Subject: Re: [PATCH rdma-next v1 2/4] RDMA: Clean MW allocation and free flows
Date: Tue, 7 Jul 2020 15:15:50 +0300	[thread overview]
Message-ID: <20200707121550.GL207186@unreal> (raw)
In-Reply-To: <20200707112109.GL23676@nvidia.com>

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

  reply	other threads:[~2020-07-07 12:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 10:18 [PATCH rdma-next v1 0/4] ib_core allocation patches Leon Romanovsky
2020-06-30 10:18 ` [PATCH rdma-next v1 1/4] RDMA/core: Create and destroy counters in the ib_core Leon Romanovsky
2020-06-30 10:18 ` [PATCH rdma-next v1 2/4] RDMA: Clean MW allocation and free flows Leon Romanovsky
2020-07-06 23:04   ` Jason Gunthorpe
2020-07-07  4:42     ` Leon Romanovsky
2020-07-07 11:21       ` Jason Gunthorpe
2020-07-07 12:15         ` Leon Romanovsky [this message]
2020-06-30 10:18 ` [PATCH rdma-next v1 3/4] RDMA: Move XRCD to be under ib_core responsibility Leon Romanovsky
2020-06-30 10:18 ` [PATCH rdma-next v1 4/4] RDMA/core: Convert RWQ table logic to ib_core allocation scheme Leon Romanovsky
2020-06-30 11:31   ` Yishai Hadas
2020-06-30 11:42     ` Leon Romanovsky
2020-06-30 14:59 ` [PATCH rdma-next v1 0/4] ib_core allocation patches Leon Romanovsky
2020-07-06 23:13 ` 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=20200707121550.GL207186@unreal \
    --to=leon@kernel.org \
    --cc=bharat@chelsio.com \
    --cc=dledford@redhat.com \
    --cc=huwei87@hisilicon.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=liweihang@huawei.com \
    --cc=oulijun@huawei.com \
    --cc=yishaih@mellanox.com \
    /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;
as well as URLs for NNTP newsgroup(s).