From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 3/3] dma-buf/fence: add signal_on_any to the fence array Date: Mon, 23 May 2016 15:50:50 +0200 Message-ID: <20160523135049.GA27098@phenom.ffwll.local> References: <1464002722-4989-1-git-send-email-deathsimple@vodafone.de> <1464002722-4989-3-git-send-email-deathsimple@vodafone.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <1464002722-4989-3-git-send-email-deathsimple@vodafone.de> Sender: linux-kernel-owner@vger.kernel.org To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, daniel@ffwll.ch, gustavo@padovan.org, chris@chris-wilson.co.uk List-Id: dri-devel@lists.freedesktop.org On Mon, May 23, 2016 at 01:25:22PM +0200, Christian K=F6nig wrote: > From: Christian K=F6nig >=20 > If @signal_on_any is true the fence array signals if any fence in the= array > signals, otherwise it signals when all fences in the array signal. What do you need this for? Sounds neat, but I can't come up with a use case. And that use case imo should be both in the commit message and kerneldoc. -Daniel >=20 > Signed-off-by: Christian K=F6nig > --- > drivers/dma-buf/fence-array.c | 23 ++++++++++++++++------- > include/linux/fence-array.h | 3 ++- > 2 files changed, 18 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/dma-buf/fence-array.c b/drivers/dma-buf/fence-ar= ray.c > index bbcf79f..726e840 100644 > --- a/drivers/dma-buf/fence-array.c > +++ b/drivers/dma-buf/fence-array.c > @@ -41,6 +41,7 @@ static void fence_array_cb_func(struct fence *f, st= ruct fence_cb *cb) > =20 > if (atomic_dec_and_test(&array->num_pending)) > fence_signal(&array->base); > + fence_put(&array->base); > } > =20 > static bool fence_array_enable_signaling(struct fence *fence) > @@ -51,10 +52,13 @@ static bool fence_array_enable_signaling(struct f= ence *fence) > =20 > for (i =3D 0; i < array->num_fences; ++i) { > cb[i].array =3D array; > + fence_get(&array->base); > if (!fence_add_callback(array->fences[i], &cb[i].cb, > - fence_array_cb_func)) > + fence_array_cb_func)) { > + fence_put(&array->base); > if (atomic_dec_and_test(&array->num_pending)) > return false; > + } > } > =20 > return true; > @@ -90,10 +94,11 @@ const struct fence_ops fence_array_ops =3D { > =20 > /** > * fence_array_create - Create a custom fence array > - * @num_fences: [in] number of fences to add in the array > - * @fences: [in] array containing the fences > - * @context: [in] fence context to use > - * @seqno: [in] sequence number to use > + * @num_fences: [in] number of fences to add in the array > + * @fences: [in] array containing the fences > + * @context: [in] fence context to use > + * @seqno: [in] sequence number to use > + * @signal_on_any [in] signal on any fence in the array > * > * Allocate a fence_array object and initialize the base fence with = fence_init(). > * In case of error it returns NULL. > @@ -101,9 +106,13 @@ const struct fence_ops fence_array_ops =3D { > * The caller should allocte the fences array with num_fences size > * and fill it with the fences it wants to add to the object. Owners= hip of this > * array is take and fence_put() is used on each fence on release. > + * > + * If @signal_on_any is true the fence array signals if any fence in= the array > + * signals, otherwise it signals when all fences in the array signal= =2E > */ > struct fence_array *fence_array_create(int num_fences, struct fence = **fences, > - u64 context, unsigned seqno) > + u64 context, unsigned seqno, > + bool signal_on_any) > { > struct fence_array *array; > size_t size =3D sizeof(*array); > @@ -119,7 +128,7 @@ struct fence_array *fence_array_create(int num_fe= nces, struct fence **fences, > context, seqno); > =20 > array->num_fences =3D num_fences; > - atomic_set(&array->num_pending, num_fences); > + atomic_set(&array->num_pending, signal_on_any ? 1 : num_fences); > array->fences =3D fences; > =20 > return array; > diff --git a/include/linux/fence-array.h b/include/linux/fence-array.= h > index 593ab98..86baaa4 100644 > --- a/include/linux/fence-array.h > +++ b/include/linux/fence-array.h > @@ -67,6 +67,7 @@ static inline struct fence_array *to_fence_array(st= ruct fence *fence) > } > =20 > struct fence_array *fence_array_create(int num_fences, struct fence = **fences, > - u64 context, unsigned seqno); > + u64 context, unsigned seqno, > + bool signal_on_any); > =20 > #endif /* __LINUX_FENCE_ARRAY_H */ > --=20 > 2.5.0 >=20 --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch