Lines Matching defs:sync_file

3  * drivers/dma-buf/sync_file.c
18 #include <linux/sync_file.h>
19 #include <uapi/linux/sync_file.h>
23 static struct sync_file *sync_file_alloc(void)
25 struct sync_file *sync_file;
27 sync_file = kzalloc(sizeof(*sync_file), GFP_KERNEL);
28 if (!sync_file)
31 sync_file->file = anon_inode_getfile("sync_file", &sync_file_fops,
32 sync_file, 0);
33 if (IS_ERR(sync_file->file))
36 init_waitqueue_head(&sync_file->wq);
38 INIT_LIST_HEAD(&sync_file->cb.node);
40 return sync_file;
43 kfree(sync_file);
49 struct sync_file *sync_file;
51 sync_file = container_of(cb, struct sync_file, cb);
53 wake_up_all(&sync_file->wq);
60 * Creates a sync_file containg @fence. This function acquires and additional
61 * reference of @fence for the newly-created &sync_file, if it succeeds. The
62 * sync_file can be released with fput(sync_file->file). Returns the
63 * sync_file or NULL in case of error.
65 struct sync_file *sync_file_create(struct dma_fence *fence)
67 struct sync_file *sync_file;
69 sync_file = sync_file_alloc();
70 if (!sync_file)
73 sync_file->fence = dma_fence_get(fence);
75 return sync_file;
79 static struct sync_file *sync_file_fdget(int fd)
97 * sync_file_get_fence - get the fence related to the sync_file fd
98 * @fd: sync_file fd to get the fence from
100 * Ensures @fd references a valid sync_file and returns a fence that
101 * represents all fence in the sync_file. On error NULL is returned.
105 struct sync_file *sync_file;
108 sync_file = sync_file_fdget(fd);
109 if (!sync_file)
112 fence = dma_fence_get(sync_file->fence);
113 fput(sync_file->file);
120 * sync_file_get_name - get the name of the sync_file
121 * @sync_file: sync_file to get the fence from
122 * @buf: destination buffer to copy sync_file name into
125 * Each sync_file may have a name assigned either by the user (when merging
132 char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len)
134 if (sync_file->user_name[0]) {
135 strscpy(buf, sync_file->user_name, len);
137 struct dma_fence *fence = sync_file->fence;
152 * @a: sync_file a
153 * @b: sync_file b
155 * Creates a new sync_file which contains copies of all the fences in both
156 * @a and @b. @a and @b remain valid, independent sync_file. Returns the
157 * new merged sync_file or NULL in case of error.
159 static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
160 struct sync_file *b)
162 struct sync_file *sync_file;
165 sync_file = sync_file_alloc();
166 if (!sync_file)
171 fput(sync_file->file);
174 sync_file->fence = fence;
175 strscpy(sync_file->user_name, name, sizeof(sync_file->user_name));
176 return sync_file;
181 struct sync_file *sync_file = file->private_data;
183 if (test_bit(POLL_ENABLED, &sync_file->flags))
184 dma_fence_remove_callback(sync_file->fence, &sync_file->cb);
185 dma_fence_put(sync_file->fence);
186 kfree(sync_file);
193 struct sync_file *sync_file = file->private_data;
195 poll_wait(file, &sync_file->wq, wait);
197 if (list_empty(&sync_file->cb.node) &&
198 !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
199 if (dma_fence_add_callback(sync_file->fence, &sync_file->cb,
201 wake_up_all(&sync_file->wq);
204 return dma_fence_is_signaled(sync_file->fence) ? EPOLLIN : 0;
207 static long sync_file_ioctl_merge(struct sync_file *sync_file,
212 struct sync_file *fence2, *fence3;
235 fence3 = sync_file_merge(data.name, sync_file, fence2);
279 static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
297 dma_fence_unwrap_for_each(fence, &iter, sync_file->fence)
307 info.status = dma_fence_get_status(sync_file->fence);
322 dma_fence_unwrap_for_each(fence, &iter, sync_file->fence) {
336 sync_file_get_name(sync_file, info.name, sizeof(info.name));
350 static int sync_file_ioctl_set_deadline(struct sync_file *sync_file,
361 dma_fence_set_deadline(sync_file->fence, ns_to_ktime(ts.deadline_ns));
369 struct sync_file *sync_file = file->private_data;
373 return sync_file_ioctl_merge(sync_file, arg);
376 return sync_file_ioctl_fence_info(sync_file, arg);
379 return sync_file_ioctl_set_deadline(sync_file, arg);