dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock
@ 2017-02-21  9:30 Chris Wilson
  2017-02-21 12:38 ` Joonas Lahtinen
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2017-02-21  9:30 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, intel-gfx, Joonas Lahtinen

In a similar fashion to reservation_object_lock() and
reservation_object_unlock(), ww_mutex_trylock is also useful and so is
worth wrapping for consistency.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 include/linux/reservation.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index 24da961b085d..28d544364e52 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -151,6 +151,26 @@ reservation_object_lock(struct reservation_object *obj,
 }
 
 /**
+ * reservation_object_trylock - trylock the reservation object
+ * @obj: the reservation object
+ *
+ * Tries to lock 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.
+ *
+ * Also note that since no context is provided, no deadlock protection is
+ * possible.
+ *
+ * Returns true if the lock was acquired, false otherwise.
+ */
+static inline bool
+reservation_object_trylock(struct reservation_object *obj)
+{
+	return ww_mutex_trylock(&obj->lock);
+}
+
+/**
  * reservation_object_unlock - unlock the reservation object
  * @obj: the reservation object
  *
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock
  2017-02-21  9:30 [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock Chris Wilson
@ 2017-02-21 12:38 ` Joonas Lahtinen
  2017-02-26 21:39   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Joonas Lahtinen @ 2017-02-21 12:38 UTC (permalink / raw)
  To: Chris Wilson, dri-devel; +Cc: Daniel Vetter, intel-gfx

On ti, 2017-02-21 at 09:30 +0000, Chris Wilson wrote:
> In a similar fashion to reservation_object_lock() and
> reservation_object_unlock(), ww_mutex_trylock is also useful and so is
> worth wrapping for consistency.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

<SNIP>

> @@ -151,6 +151,26 @@ reservation_object_lock(struct reservation_object *obj,
>  }
>  
>  /**
> + * reservation_object_trylock - trylock the reservation object
> + * @obj: the reservation object
> + *
> + * Tries to lock 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.
> + *
> + * Also note that since no context is provided, no deadlock protection is
> + * possible.
> + *
> + * Returns true if the lock was acquired, false otherwise.
> + */
> +static inline bool

I'd carry over the __must_check flag, with that;

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas

> +reservation_object_trylock(struct reservation_object *obj)
> +{
> +	return ww_mutex_trylock(&obj->lock);
> +}
> +
> +/**
>   * reservation_object_unlock - unlock the reservation object
>   * @obj: the reservation object
>   *
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock
  2017-02-21 12:38 ` Joonas Lahtinen
@ 2017-02-26 21:39   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2017-02-26 21:39 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: Daniel Vetter, intel-gfx, Sumit Semwal, dri-devel

On Tue, Feb 21, 2017 at 02:38:07PM +0200, Joonas Lahtinen wrote:
> On ti, 2017-02-21 at 09:30 +0000, Chris Wilson wrote:
> > In a similar fashion to reservation_object_lock() and
> > reservation_object_unlock(), ww_mutex_trylock is also useful and so is
> > worth wrapping for consistency.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Sumit Semwal <sumit.semwal@linaro.org>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> <SNIP>
> 
> > @@ -151,6 +151,26 @@ reservation_object_lock(struct reservation_object *obj,
> >  }
> >  
> >  /**
> > + * reservation_object_trylock - trylock the reservation object
> > + * @obj: the reservation object
> > + *
> > + * Tries to lock 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.
> > + *
> > + * Also note that since no context is provided, no deadlock protection is
> > + * possible.
> > + *
> > + * Returns true if the lock was acquired, false otherwise.
> > + */
> > +static inline bool
> 
> I'd carry over the __must_check flag, with that;

Done and applied, thanks.
-Daniel

> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> Regards, Joonas
> 
> > +reservation_object_trylock(struct reservation_object *obj)
> > +{
> > +	return ww_mutex_trylock(&obj->lock);
> > +}
> > +
> > +/**
> >   * reservation_object_unlock - unlock the reservation object
> >   * @obj: the reservation object
> >   *
> -- 
> Joonas Lahtinen
> Open Source Technology Center
> Intel Corporation

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-26 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-21  9:30 [PATCH] dma-buf/reservation: Wrap ww_mutex_trylock Chris Wilson
2017-02-21 12:38 ` Joonas Lahtinen
2017-02-26 21:39   ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox