Re: [PATCH for-rc 1/2] RDMA/device: Expose ib_device_try_get(()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 15, 2019 at 09:53:49PM +0000, Parav Pandit wrote:
> 
> 
> > From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> > 
> > It turns out future patches need this capability quite widely now, not just for
> > netlink, so provide two global functions to manage the registration lock
> > refcount.
> > 
> > This also moves the point the lock becomes 1 to within ib_register_device()
> > so that the semantics of the public API are very sane and clear. Calling
> > ib_device_try_get() will fail on devices that are only allocated but not yet
> > registered.
> > 
> > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> >  drivers/infiniband/core/core_priv.h |  1 -
> >  drivers/infiniband/core/device.c    |  6 +++---
> >  include/rdma/ib_verbs.h             | 24 ++++++++++++++++++++++--
> >  3 files changed, 25 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/core_priv.h
> > b/drivers/infiniband/core/core_priv.h
> > index 3cd830d52967eb..616734313f0c69 100644
> > +++ b/drivers/infiniband/core/core_priv.h
> > @@ -267,7 +267,6 @@ static inline int ib_mad_enforce_security(struct
> > ib_mad_agent_private *map,  #endif
> > 
> >  struct ib_device *ib_device_get_by_index(u32 ifindex); -void
> > ib_device_put(struct ib_device *device);
> >  /* RDMA device netlink */
> >  void nldev_init(void);
> >  void nldev_exit(void);
> > diff --git a/drivers/infiniband/core/device.c
> > b/drivers/infiniband/core/device.c
> > index 8872453e26c07c..9b5c72d3c85a88 100644
> > +++ b/drivers/infiniband/core/device.c
> > @@ -156,8 +156,7 @@ struct ib_device *ib_device_get_by_index(u32 index)
> >  	down_read(&lists_rwsem);
> >  	device = __ib_device_get_by_index(index);
> >  	if (device) {
> > -		/* Do not return a device if unregistration has started. */
> > -		if (!refcount_inc_not_zero(&device->refcount))
> > +		if (!ib_device_try_get(device))
> >  			device = NULL;
> >  	}
> >  	up_read(&lists_rwsem);
> > @@ -169,6 +168,7 @@ void ib_device_put(struct ib_device *device)
> 
> Please add below hunk comment block for exported symbol.
> 
> +/**
> + * ib_device_put - Release IB device reference
> + * @device:	device whose reference to be released
> + *
> + * ib_device_put() releases reference to the IB device to allow
> + * it to be unregistered and eventually free.
> + */

Okay, did both. I'll send a V2 when Moni settles if advise_mr needs
this patch in -rc or not..

Thanks,
Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux