Lines Matching refs: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;
158 * @a: sync_file a
159 * @b: sync_file b
161 * Creates a new sync_file which contains copies of all the fences in both
162 * @a and @b. @a and @b remain valid, independent sync_file. Returns the
163 * new merged sync_file or NULL in case of error.
165 static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
166 struct sync_file *b)
168 struct sync_file *sync_file;
171 sync_file = sync_file_alloc();
172 if (!sync_file)
177 fput(sync_file->file);
180 sync_file->fence = fence;
181 strscpy(sync_file->user_name, name, sizeof(sync_file->user_name));
182 return sync_file;
187 struct sync_file *sync_file = file->private_data;
189 if (test_bit(POLL_ENABLED, &sync_file->flags))
190 dma_fence_remove_callback(sync_file->fence, &sync_file->cb);
191 dma_fence_put(sync_file->fence);
192 kfree(sync_file);
199 struct sync_file *sync_file = file->private_data;
201 poll_wait(file, &sync_file->wq, wait);
203 if (list_empty(&sync_file->cb.node) &&
204 !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
205 if (dma_fence_add_callback(sync_file->fence, &sync_file->cb,
207 wake_up_all(&sync_file->wq);
210 return dma_fence_is_signaled(sync_file->fence) ? EPOLLIN : 0;
213 static long sync_file_ioctl_merge(struct sync_file *sync_file,
218 struct sync_file *fence2, *fence3;
241 fence3 = sync_file_merge(data.name, sync_file, fence2);
295 static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
313 dma_fence_unwrap_for_each(fence, &iter, sync_file->fence)
323 info.status = dma_fence_get_status(sync_file->fence);
338 dma_fence_unwrap_for_each(fence, &iter, sync_file->fence) {
352 sync_file_get_name(sync_file, info.name, sizeof(info.name));
366 static int sync_file_ioctl_set_deadline(struct sync_file *sync_file,
377 dma_fence_set_deadline(sync_file->fence, ns_to_ktime(ts.deadline_ns));
385 struct sync_file *sync_file = file->private_data;
389 return sync_file_ioctl_merge(sync_file, arg);
392 return sync_file_ioctl_fence_info(sync_file, arg);
395 return sync_file_ioctl_set_deadline(sync_file, arg);