Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1435302 > unrolled thread
| Started by | Gustavo Padovan <gustavo@padovan.org> |
|---|---|
| First post | 2016-07-01 15:10 +0200 |
| Last post | 2016-07-01 15:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 3/4] dma-buf/sync_file: add sync_file_get_fence() Gustavo Padovan <gustavo@padovan.org> - 2016-07-01 15:10 +0200
Re: [PATCH v2 3/4] dma-buf/sync_file: add sync_file_get_fence() Chris Wilson <chris@chris-wilson.co.uk> - 2016-07-01 15:30 +0200
| From | Gustavo Padovan <gustavo@padovan.org> |
|---|---|
| Date | 2016-07-01 15:10 +0200 |
| Subject | [PATCH v2 3/4] dma-buf/sync_file: add sync_file_get_fence() |
| Message-ID | <rQ6mJ-72X-3@gated-at.bofh.it> |
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
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
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);
+ 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
[toc] | [next] | [standalone]
| From | Chris Wilson <chris@chris-wilson.co.uk> |
|---|---|
| Date | 2016-07-01 15:30 +0200 |
| Message-ID | <rQ6G6-79F-29@gated-at.bofh.it> |
| In reply to | #1435302 |
On Fri, Jul 01, 2016 at 10:05:06AM -0300, Gustavo Padovan wrote:
> 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
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> 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 <chris@chris-wilson.co.uk>
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web