diff options
author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2016-08-05 09:39:36 -0400 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2016-08-11 06:03:24 -0400 |
commit | 972526a4093243fdaf77dd7c6f8b11fba5b15864 (patch) | |
tree | 49121dcbbcec8f6c7acc8cd6762395e81183c18b | |
parent | a02b9dc90d844cc7df7b63264e7920cc425052d9 (diff) |
dma-buf/sync_file: add sync_file_get_fence()
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>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
-rw-r--r-- | drivers/dma-buf/sync_file.c | 23 | ||||
-rw-r--r-- | include/linux/sync_file.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index ac9c250af302..2873760e02a9 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c | |||
@@ -116,6 +116,29 @@ err: | |||
116 | return NULL; | 116 | return NULL; |
117 | } | 117 | } |
118 | 118 | ||
119 | /** | ||
120 | * sync_file_get_fence - get the fence related to the sync_file fd | ||
121 | * @fd: sync_file fd to get the fence from | ||
122 | * | ||
123 | * Ensures @fd references a valid sync_file and returns a fence that | ||
124 | * represents all fence in the sync_file. On error NULL is returned. | ||
125 | */ | ||
126 | struct fence *sync_file_get_fence(int fd) | ||
127 | { | ||
128 | struct sync_file *sync_file; | ||
129 | struct fence *fence; | ||
130 | |||
131 | sync_file = sync_file_fdget(fd); | ||
132 | if (!sync_file) | ||
133 | return NULL; | ||
134 | |||
135 | fence = fence_get(sync_file->fence); | ||
136 | fput(sync_file->file); | ||
137 | |||
138 | return fence; | ||
139 | } | ||
140 | EXPORT_SYMBOL(sync_file_get_fence); | ||
141 | |||
119 | static int sync_file_set_fence(struct sync_file *sync_file, | 142 | static int sync_file_set_fence(struct sync_file *sync_file, |
120 | struct fence **fences, int num_fences) | 143 | struct fence **fences, int num_fences) |
121 | { | 144 | { |
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h index 2efc5ec60575..f7de5a0b3d12 100644 --- a/include/linux/sync_file.h +++ b/include/linux/sync_file.h | |||
@@ -46,5 +46,6 @@ struct sync_file { | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct sync_file *sync_file_create(struct fence *fence); | 48 | struct sync_file *sync_file_create(struct fence *fence); |
49 | struct fence *sync_file_get_fence(int fd); | ||
49 | 50 | ||
50 | #endif /* _LINUX_SYNC_H */ | 51 | #endif /* _LINUX_SYNC_H */ |