xref: /linux/include/linux/sync_file.h (revision 664b0bae0b87f69bc9deb098f5e0158b9cf18e04)
1460bfc41SGustavo Padovan /*
2460bfc41SGustavo Padovan  * include/linux/sync_file.h
3460bfc41SGustavo Padovan  *
4460bfc41SGustavo Padovan  * Copyright (C) 2012 Google, Inc.
5460bfc41SGustavo Padovan  *
6460bfc41SGustavo Padovan  * This program is distributed in the hope that it will be useful,
7460bfc41SGustavo Padovan  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8460bfc41SGustavo Padovan  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9460bfc41SGustavo Padovan  * GNU General Public License for more details.
10460bfc41SGustavo Padovan  *
11460bfc41SGustavo Padovan  */
12460bfc41SGustavo Padovan 
13460bfc41SGustavo Padovan #ifndef _LINUX_SYNC_FILE_H
14460bfc41SGustavo Padovan #define _LINUX_SYNC_FILE_H
15460bfc41SGustavo Padovan 
16460bfc41SGustavo Padovan #include <linux/types.h>
17460bfc41SGustavo Padovan #include <linux/ktime.h>
18460bfc41SGustavo Padovan #include <linux/list.h>
19460bfc41SGustavo Padovan #include <linux/spinlock.h>
20f54d1867SChris Wilson #include <linux/dma-fence.h>
21f54d1867SChris Wilson #include <linux/dma-fence-array.h>
22460bfc41SGustavo Padovan 
23460bfc41SGustavo Padovan /**
24460bfc41SGustavo Padovan  * struct sync_file - sync file to export to the userspace
25460bfc41SGustavo Padovan  * @file:		file representing this fence
26460bfc41SGustavo Padovan  * @sync_file_list:	membership in global file list
27460bfc41SGustavo Padovan  * @wq:			wait queue for fence signaling
28*300238ceSGustavo Padovan  * @flags:		flags for the sync_file
29a02b9dc9SGustavo Padovan  * @fence:		fence with the fences in the sync_file
30a02b9dc9SGustavo Padovan  * @cb:			fence callback information
31*300238ceSGustavo Padovan  *
32*300238ceSGustavo Padovan  * flags:
33*300238ceSGustavo Padovan  * POLL_ENABLED: whether userspace is currently poll()'ing or not
34460bfc41SGustavo Padovan  */
35460bfc41SGustavo Padovan struct sync_file {
36460bfc41SGustavo Padovan 	struct file		*file;
3771ebc9a3SChris Wilson 	/**
3871ebc9a3SChris Wilson 	 * @user_name:
3971ebc9a3SChris Wilson 	 *
4071ebc9a3SChris Wilson 	 * Name of the sync file provided by userspace, for merged fences.
4171ebc9a3SChris Wilson 	 * Otherwise generated through driver callbacks (in which case the
4271ebc9a3SChris Wilson 	 * entire array is 0).
4371ebc9a3SChris Wilson 	 */
4471ebc9a3SChris Wilson 	char			user_name[32];
45460bfc41SGustavo Padovan #ifdef CONFIG_DEBUG_FS
46460bfc41SGustavo Padovan 	struct list_head	sync_file_list;
47460bfc41SGustavo Padovan #endif
48460bfc41SGustavo Padovan 
49460bfc41SGustavo Padovan 	wait_queue_head_t	wq;
50db1fc97cSChris Wilson 	unsigned long		flags;
51460bfc41SGustavo Padovan 
52f54d1867SChris Wilson 	struct dma_fence	*fence;
53f54d1867SChris Wilson 	struct dma_fence_cb cb;
54460bfc41SGustavo Padovan };
55460bfc41SGustavo Padovan 
56db1fc97cSChris Wilson #define POLL_ENABLED 0
57e2416553SGustavo Padovan 
58f54d1867SChris Wilson struct sync_file *sync_file_create(struct dma_fence *fence);
59f54d1867SChris Wilson struct dma_fence *sync_file_get_fence(int fd);
6071ebc9a3SChris Wilson char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len);
61460bfc41SGustavo Padovan 
62460bfc41SGustavo Padovan #endif /* _LINUX_SYNC_H */
63