Skip to content

Commit

Permalink
dma-buf/sync_file: add sync_file_get_fence()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Acked-by: Christian König <[email protected]>
Signed-off-by: Sumit Semwal <[email protected]>
  • Loading branch information
Gustavo Padovan authored and sumitsemwal committed Aug 11, 2016
1 parent a02b9dc commit 972526a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions drivers/dma-buf/sync_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ static struct sync_file *sync_file_fdget(int fd)
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)
{
Expand Down
1 change: 1 addition & 0 deletions include/linux/sync_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 972526a

Please sign in to comment.