Re: [PATCH] dma-buf: Provide wrappers for reservation's lock

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

 



On Tue, Nov 15, 2016 at 10:43:34PM +0100, Daniel Vetter wrote:
> On Tue, Nov 15, 2016 at 03:46:42PM +0000, Chris Wilson wrote:
> > Joonas complained that writing ww_mutex_lock(&resv->lock, ctx) was too
> > intrusive compared to reservation_object_lock(resv, ctx);
> > 
> > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> > Cc: Sumit Semwal <sumit.semwal@xxxxxxxxxx>
> > Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
> > ---
> >  include/linux/reservation.h | 34 ++++++++++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> > 
> > diff --git a/include/linux/reservation.h b/include/linux/reservation.h
> > index ed238961e1bf..9cfc0d857862 100644
> > --- a/include/linux/reservation.h
> > +++ b/include/linux/reservation.h
> > @@ -129,6 +129,40 @@ reservation_object_fini(struct reservation_object *obj)
> >  }
> >  
> >  /**
> > + * reservation_object_lock - lock the reservation object
> > + * @obj: the reservation object
> > + * @ctx: the locking context
> > + *
> > + * Locks the reservation object for exclusive access and modification. Note,
> > + * that the lock is only against other writers, readers will run concurrently
> > + * with a writer under RCU. The seqlock is used to notify readers if they
> > + * overlap with a writer.
> > + *
> > + * As the reservation object may be locked by multiple parties in an
> > + * undefined order, a #ww_acquire_ctx is passed to unwind if a cycle
> 
> s/#/&/ for struct references. Otherwise the magic hotlink won't appear
> (once we get around to pulling all the core docs into the overall sphinx
> build). I can fix this while applying if everyone else is ok with the
> patch - imo it makes sense.

Anyone want to second these ww_mutex wrappers for reservation objects?

> > + * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation
> > + * object may be locked by itself by passing NULL as @ctx.
> > + */
> > +static inline int
> > +reservation_object_lock(struct reservation_object *obj,
> > +			struct ww_acquire_ctx *ctx)
> > +{
> > +	return ww_mutex_lock(&obj->lock, ctx);
> > +}
> > +
> > +/**
> > + * reservation_object_unlock - unlock the reservation object
> > + * @obj: the reservation object
> > + *
> > + * Unlocks the reservation object following exclusive access.
> > + */
> > +static inline void
> > +reservation_object_unlock(struct reservation_object *obj)
> > +{
> > +	ww_mutex_unlock(&obj->lock);
> > +}
> > +
> > +/**
> >   * reservation_object_get_excl - get the reservation object's
> >   * exclusive fence, with update-side lock held
> >   * @obj: the reservation object

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux