From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752682AbcGANVi (ORCPT ); Fri, 1 Jul 2016 09:21:38 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35406 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbcGANVg (ORCPT ); Fri, 1 Jul 2016 09:21:36 -0400 Date: Fri, 1 Jul 2016 14:21:33 +0100 From: Chris Wilson To: Gustavo Padovan Cc: dri-devel@lists.freedesktop.org, marcheu@google.com, Daniel Stone , seanpaul@google.com, Daniel Vetter , linux-kernel@vger.kernel.org, laurent.pinchart@ideasonboard.com, Gustavo Padovan , John Harrison , m.chehab@samsung.com Subject: Re: [PATCH v2 3/4] dma-buf/sync_file: add sync_file_get_fence() Message-ID: <20160701132133.GE1306@nuc-i3427.alporthouse.com> Mail-Followup-To: Chris Wilson , Gustavo Padovan , dri-devel@lists.freedesktop.org, marcheu@google.com, Daniel Stone , seanpaul@google.com, Daniel Vetter , linux-kernel@vger.kernel.org, laurent.pinchart@ideasonboard.com, Gustavo Padovan , John Harrison , m.chehab@samsung.com References: <1467378307-28088-1-git-send-email-gustavo@padovan.org> <1467378307-28088-4-git-send-email-gustavo@padovan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1467378307-28088-4-git-send-email-gustavo@padovan.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 01, 2016 at 10:05:06AM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > Creates a function that given an sync file descriptor returns a > fence containing all fences in the sync_file. > > v2: Comments by Daniel Vetter > - Adapt to new version of fence_collection_init() > - Hold a reference for the fence we return > > v3: > - Adapt to use fput() directly > - rename to sync_file_get_fence() as we always return one fence > > v4: Adapt to use fence_array > > Signed-off-by: Gustavo Padovan > --- > drivers/dma-buf/sync_file.c | 24 ++++++++++++++++++++++++ > include/linux/sync_file.h | 1 + > 2 files changed, 25 insertions(+) > > diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c > index 12dbf17..3ffaea8 100644 > --- a/drivers/dma-buf/sync_file.c > +++ b/drivers/dma-buf/sync_file.c > @@ -116,6 +116,30 @@ err: > return NULL; > } > > +/** > + * sync_file_get_fence - get the fence related to the sync_file fd > + * @fd: sync_file fd to get the fence from > + * > + * Ensures @fd references a valid sync_file and returns a fence that > + * represents all fence in the sync_file. On error NULL is returned. > + */ > +struct fence *sync_file_get_fence(int fd) > +{ > + struct sync_file *sync_file; > + struct fence *fence; > + > + sync_file = sync_file_fdget(fd); > + if (!sync_file) > + return NULL; > + > + fence = sync_file->fence; > + fence_get(fence); Or just fence = get_fence(sync_file->fence); > + fput(sync_file->file); Reviewed-by: Chris Wilson Using fence-array for this works very nicely, as we can then inspect the fences returned and handle native fences for fd passed around. -Chris -- Chris Wilson, Intel Open Source Technology Centre