Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456852

[PATCH v5 3/5] dma-buf/sync_file: add sync_file_get_fence()

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Gustavo Padovan <gustavo@padovan.org>
Newsgroups linux.kernel
Subject [PATCH v5 3/5] dma-buf/sync_file: add sync_file_get_fence()
Date Fri, 05 Aug 2016 04:40:01 +0200
Message-ID <s2Ddf-1xK-9@gated-at.bofh.it> (permalink)
References <s2D3z-1uF-1@gated-at.bofh.it>
X-Greylist delayed 805 seconds by postgrey-1.27 at vger.kernel.org; Thu, 04 Aug 2016 22:38:06 EDT
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=te9JsCKiipmykE8EF+vdtng8IoweijLeNHQ4S04m4Pc=; b=KwL4bWJTgTGVs8mHcALPoYwZagZn9aY+oGMucU3QmCQyFe04vndZItLMxDpQzgMThs I6z8scNV1NV0YfSBawCNRh1fxCgfei4vkGuF18ScyDBV5qYIghGZb1yHuj5NYMRWjuQJ Po2aYsXKpnDokeieDb2akdGlrYnG9upisgGCDNY8DwxXooTlxLzbln3w4k2BJSZnUnBo Zw3l7mvSZz6bLDyotNGSnYIiIkbo6oiRNsjFYTKB8ZDDYwhTrq0a+F9ytH7PYOVH1jfu RViMMRWMo8RFe7UtH4HHpOiN4/psHS/EIbZUyR+01CGHpsJuXJvgJTaCOLeEGrii0sim swvw==
X-Gm-Message-State AEkoousIN0A1h8Hw08FSfjrULR2tmjS3CwvBcsZWtAdIAKRkTXG890MYaetIHq2GcUF/aA==
X-Received by 10.37.77.86 with SMTP id a83mr35162875ybb.169.1470363880654; Thu, 04 Aug 2016 19:24:40 -0700 (PDT)
X-Mailer git-send-email 2.5.5
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 72
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, Daniel Stone <daniels@collabora.com>, Daniel Vetter <daniel.vetter@ffwll.ch>, Rob Clark <robdclark@gmail.com>, Greg Hackmann <ghackmann@google.com>, John Harrison <John.C.Harrison@Intel.com>, laurent.pinchart@ideasonboard.com, seanpaul@google.com, marcheu@google.com, m.chehab@samsung.com, Sumit Semwal <sumit.semwal@linaro.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Gustavo Padovan <gustavo.padovan@collabora.co.uk>
X-Original-Date Thu, 4 Aug 2016 23:24:12 -0300
X-Original-Message-ID <1470363854-7846-3-git-send-email-gustavo@padovan.org>
X-Original-References <1470363854-7846-1-git-send-email-gustavo@padovan.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1456852

Show key headers only | View raw


From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

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

v5: set fence through fence_get()

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/sync_file.c | 23 +++++++++++++++++++++++
 include/linux/sync_file.h   |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index ac9c250..2873760 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -116,6 +116,29 @@ 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 = fence_get(sync_file->fence);
+	fput(sync_file->file);
+
+	return fence;
+}
+EXPORT_SYMBOL(sync_file_get_fence);
+
 static int sync_file_set_fence(struct sync_file *sync_file,
 			       struct fence **fences, int num_fences)
 {
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index 2efc5ec..f7de5a0 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -46,5 +46,6 @@ struct sync_file {
 };
 
 struct sync_file *sync_file_create(struct fence *fence);
+struct fence *sync_file_get_fence(int fd);
 
 #endif /* _LINUX_SYNC_H */
-- 
2.5.5

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v5 1/5] dma-buf/fence-array: add fence_is_array() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 04:30 +0200
  [PATCH v5 4/5] Documentation: add doc for sync_file_get_fence() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 04:30 +0200
    Re: [PATCH v5 4/5] Documentation: add doc for sync_file_get_fence() Chris Wilson <chris@chris-wilson.co.uk> - 2016-08-05 09:30 +0200
  [PATCH v5 5/5] dma-buf/sync_file: only enable fence signalling on poll() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 04:30 +0200
    Re: [PATCH v5 5/5] dma-buf/sync_file: only enable fence signalling  on poll() Chris Wilson <chris@chris-wilson.co.uk> - 2016-08-05 09:30 +0200
      Re: [PATCH v5 5/5] dma-buf/sync_file: only enable fence signalling  on poll() Chris Wilson <chris@chris-wilson.co.uk> - 2016-08-05 09:50 +0200
  [PATCH v5 2/5] dma-buf/sync_file: refactor fence storage in struct sync_file Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 04:30 +0200
  [PATCH v5 3/5] dma-buf/sync_file: add sync_file_get_fence() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 04:40 +0200

csiph-web