2 * Copyright 2017 Red Hat
3 * Parts ported from amdgpu (fence wait code).
4 * Copyright 2016 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 * DRM synchronisation objects (syncobj, see struct &drm_syncobj) are
33 * persistent objects that contain an optional fence. The fence can be updated
34 * with a new fence, or be NULL.
36 * syncobj's can be waited upon, where it will wait for the underlying
39 * syncobj's can be export to fd's and back, these fd's are opaque and
40 * have no other use case, except passing the syncobj between processes.
42 * Their primary use-case is to implement Vulkan fences and semaphores.
44 * syncobj have a kref reference count, but also have an optional file.
45 * The file is only created once the syncobj is exported.
46 * The file takes a reference on the kref.
50 #include <linux/file.h>
52 #include <linux/anon_inodes.h>
53 #include <linux/sync_file.h>
54 #include <linux/sched/signal.h>
56 #include "drm_internal.h"
57 #include <drm/drm_syncobj.h>
60 * drm_syncobj_find - lookup and reference a sync object.
61 * @file_private: drm file private pointer
62 * @handle: sync object handle to lookup.
64 * Returns a reference to the syncobj pointed to by handle or NULL. The
65 * reference must be released by calling drm_syncobj_put().
67 struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
70 struct drm_syncobj *syncobj;
72 spin_lock(&file_private->syncobj_table_lock);
74 /* Check if we currently have a reference on the object */
75 syncobj = idr_find(&file_private->syncobj_idr, handle);
77 drm_syncobj_get(syncobj);
79 spin_unlock(&file_private->syncobj_table_lock);
83 EXPORT_SYMBOL(drm_syncobj_find);
85 static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,
86 struct drm_syncobj_cb *cb,
87 drm_syncobj_func_t func)
90 list_add_tail(&cb->node, &syncobj->cb_list);
93 static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
94 struct dma_fence **fence,
95 struct drm_syncobj_cb *cb,
96 drm_syncobj_func_t func)
100 *fence = drm_syncobj_fence_get(syncobj);
104 spin_lock(&syncobj->lock);
105 /* We've already tried once to get a fence and failed. Now that we
106 * have the lock, try one more time just to be sure we don't add a
107 * callback when a fence has already been set.
109 if (syncobj->fence) {
110 *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
111 lockdep_is_held(&syncobj->lock)));
115 drm_syncobj_add_callback_locked(syncobj, cb, func);
118 spin_unlock(&syncobj->lock);
124 * drm_syncobj_add_callback - adds a callback to syncobj::cb_list
125 * @syncobj: Sync object to which to add the callback
126 * @cb: Callback to add
127 * @func: Func to use when initializing the drm_syncobj_cb struct
129 * This adds a callback to be called next time the fence is replaced
131 void drm_syncobj_add_callback(struct drm_syncobj *syncobj,
132 struct drm_syncobj_cb *cb,
133 drm_syncobj_func_t func)
135 spin_lock(&syncobj->lock);
136 drm_syncobj_add_callback_locked(syncobj, cb, func);
137 spin_unlock(&syncobj->lock);
139 EXPORT_SYMBOL(drm_syncobj_add_callback);
142 * drm_syncobj_add_callback - removes a callback to syncobj::cb_list
143 * @syncobj: Sync object from which to remove the callback
144 * @cb: Callback to remove
146 void drm_syncobj_remove_callback(struct drm_syncobj *syncobj,
147 struct drm_syncobj_cb *cb)
149 spin_lock(&syncobj->lock);
150 list_del_init(&cb->node);
151 spin_unlock(&syncobj->lock);
153 EXPORT_SYMBOL(drm_syncobj_remove_callback);
156 * drm_syncobj_replace_fence - replace fence in a sync object.
157 * @syncobj: Sync object to replace fence in
158 * @fence: fence to install in sync file.
160 * This replaces the fence on a sync object.
162 void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
163 struct dma_fence *fence)
165 struct dma_fence *old_fence;
166 struct drm_syncobj_cb *cur, *tmp;
169 dma_fence_get(fence);
171 spin_lock(&syncobj->lock);
173 old_fence = rcu_dereference_protected(syncobj->fence,
174 lockdep_is_held(&syncobj->lock));
175 rcu_assign_pointer(syncobj->fence, fence);
177 if (fence != old_fence) {
178 list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
179 list_del_init(&cur->node);
180 cur->func(syncobj, cur);
184 spin_unlock(&syncobj->lock);
186 dma_fence_put(old_fence);
188 EXPORT_SYMBOL(drm_syncobj_replace_fence);
190 struct drm_syncobj_null_fence {
191 struct dma_fence base;
195 static const char *drm_syncobj_null_fence_get_name(struct dma_fence *fence)
197 return "syncobjnull";
200 static bool drm_syncobj_null_fence_enable_signaling(struct dma_fence *fence)
202 dma_fence_enable_sw_signaling(fence);
203 return !dma_fence_is_signaled(fence);
206 static const struct dma_fence_ops drm_syncobj_null_fence_ops = {
207 .get_driver_name = drm_syncobj_null_fence_get_name,
208 .get_timeline_name = drm_syncobj_null_fence_get_name,
209 .enable_signaling = drm_syncobj_null_fence_enable_signaling,
213 static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
215 struct drm_syncobj_null_fence *fence;
216 fence = kzalloc(sizeof(*fence), GFP_KERNEL);
220 spin_lock_init(&fence->lock);
221 dma_fence_init(&fence->base, &drm_syncobj_null_fence_ops,
223 dma_fence_signal(&fence->base);
225 drm_syncobj_replace_fence(syncobj, &fence->base);
227 dma_fence_put(&fence->base);
233 * drm_syncobj_find_fence - lookup and reference the fence in a sync object
234 * @file_private: drm file private pointer
235 * @handle: sync object handle to lookup.
236 * @fence: out parameter for the fence
238 * This is just a convenience function that combines drm_syncobj_find() and
239 * drm_syncobj_fence_get().
241 * Returns 0 on success or a negative error value on failure. On success @fence
242 * contains a reference to the fence, which must be released by calling
245 int drm_syncobj_find_fence(struct drm_file *file_private,
247 struct dma_fence **fence)
249 struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
255 *fence = drm_syncobj_fence_get(syncobj);
259 drm_syncobj_put(syncobj);
262 EXPORT_SYMBOL(drm_syncobj_find_fence);
265 * drm_syncobj_free - free a sync object.
266 * @kref: kref to free.
268 * Only to be called from kref_put in drm_syncobj_put.
270 void drm_syncobj_free(struct kref *kref)
272 struct drm_syncobj *syncobj = container_of(kref,
275 drm_syncobj_replace_fence(syncobj, NULL);
278 EXPORT_SYMBOL(drm_syncobj_free);
281 * drm_syncobj_create - create a new syncobj
282 * @out_syncobj: returned syncobj
283 * @flags: DRM_SYNCOBJ_* flags
284 * @fence: if non-NULL, the syncobj will represent this fence
286 * This is the first function to create a sync object. After creating, drivers
287 * probably want to make it available to userspace, either through
288 * drm_syncobj_get_handle() or drm_syncobj_get_fd().
290 * Returns 0 on success or a negative error value on failure.
292 int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
293 struct dma_fence *fence)
296 struct drm_syncobj *syncobj;
298 syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL);
302 kref_init(&syncobj->refcount);
303 INIT_LIST_HEAD(&syncobj->cb_list);
304 spin_lock_init(&syncobj->lock);
306 if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) {
307 ret = drm_syncobj_assign_null_handle(syncobj);
309 drm_syncobj_put(syncobj);
315 drm_syncobj_replace_fence(syncobj, fence);
317 *out_syncobj = syncobj;
320 EXPORT_SYMBOL(drm_syncobj_create);
323 * drm_syncobj_get_handle - get a handle from a syncobj
324 * @file_private: drm file private pointer
325 * @syncobj: Sync object to export
326 * @handle: out parameter with the new handle
328 * Exports a sync object created with drm_syncobj_create() as a handle on
329 * @file_private to userspace.
331 * Returns 0 on success or a negative error value on failure.
333 int drm_syncobj_get_handle(struct drm_file *file_private,
334 struct drm_syncobj *syncobj, u32 *handle)
338 /* take a reference to put in the idr */
339 drm_syncobj_get(syncobj);
341 idr_preload(GFP_KERNEL);
342 spin_lock(&file_private->syncobj_table_lock);
343 ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
344 spin_unlock(&file_private->syncobj_table_lock);
349 drm_syncobj_put(syncobj);
356 EXPORT_SYMBOL(drm_syncobj_get_handle);
358 static int drm_syncobj_create_as_handle(struct drm_file *file_private,
359 u32 *handle, uint32_t flags)
362 struct drm_syncobj *syncobj;
364 ret = drm_syncobj_create(&syncobj, flags, NULL);
368 ret = drm_syncobj_get_handle(file_private, syncobj, handle);
369 drm_syncobj_put(syncobj);
373 static int drm_syncobj_destroy(struct drm_file *file_private,
376 struct drm_syncobj *syncobj;
378 spin_lock(&file_private->syncobj_table_lock);
379 syncobj = idr_remove(&file_private->syncobj_idr, handle);
380 spin_unlock(&file_private->syncobj_table_lock);
385 drm_syncobj_put(syncobj);
389 static int drm_syncobj_file_release(struct inode *inode, struct file *file)
391 struct drm_syncobj *syncobj = file->private_data;
393 drm_syncobj_put(syncobj);
397 static const struct file_operations drm_syncobj_file_fops = {
398 .release = drm_syncobj_file_release,
402 * drm_syncobj_get_fd - get a file descriptor from a syncobj
403 * @syncobj: Sync object to export
404 * @p_fd: out parameter with the new file descriptor
406 * Exports a sync object created with drm_syncobj_create() as a file descriptor.
408 * Returns 0 on success or a negative error value on failure.
410 int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
415 fd = get_unused_fd_flags(O_CLOEXEC);
419 file = anon_inode_getfile("syncobj_file",
420 &drm_syncobj_file_fops,
424 return PTR_ERR(file);
427 drm_syncobj_get(syncobj);
428 fd_install(fd, file);
433 EXPORT_SYMBOL(drm_syncobj_get_fd);
435 static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
436 u32 handle, int *p_fd)
438 struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
444 ret = drm_syncobj_get_fd(syncobj, p_fd);
445 drm_syncobj_put(syncobj);
449 static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
452 struct drm_syncobj *syncobj;
460 if (file->f_op != &drm_syncobj_file_fops) {
465 /* take a reference to put in the idr */
466 syncobj = file->private_data;
467 drm_syncobj_get(syncobj);
469 idr_preload(GFP_KERNEL);
470 spin_lock(&file_private->syncobj_table_lock);
471 ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
472 spin_unlock(&file_private->syncobj_table_lock);
479 drm_syncobj_put(syncobj);
485 static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
488 struct dma_fence *fence = sync_file_get_fence(fd);
489 struct drm_syncobj *syncobj;
494 syncobj = drm_syncobj_find(file_private, handle);
496 dma_fence_put(fence);
500 drm_syncobj_replace_fence(syncobj, fence);
501 dma_fence_put(fence);
502 drm_syncobj_put(syncobj);
506 static int drm_syncobj_export_sync_file(struct drm_file *file_private,
507 int handle, int *p_fd)
510 struct dma_fence *fence;
511 struct sync_file *sync_file;
512 int fd = get_unused_fd_flags(O_CLOEXEC);
517 ret = drm_syncobj_find_fence(file_private, handle, &fence);
521 sync_file = sync_file_create(fence);
523 dma_fence_put(fence);
530 fd_install(fd, sync_file->file);
539 * drm_syncobj_open - initalizes syncobj file-private structures at devnode open time
540 * @file_private: drm file-private structure to set up
542 * Called at device open time, sets up the structure for handling refcounting
546 drm_syncobj_open(struct drm_file *file_private)
548 idr_init_base(&file_private->syncobj_idr, 1);
549 spin_lock_init(&file_private->syncobj_table_lock);
553 drm_syncobj_release_handle(int id, void *ptr, void *data)
555 struct drm_syncobj *syncobj = ptr;
557 drm_syncobj_put(syncobj);
562 * drm_syncobj_release - release file-private sync object resources
563 * @file_private: drm file-private structure to clean up
565 * Called at close time when the filp is going away.
567 * Releases any remaining references on objects by this filp.
570 drm_syncobj_release(struct drm_file *file_private)
572 idr_for_each(&file_private->syncobj_idr,
573 &drm_syncobj_release_handle, file_private);
574 idr_destroy(&file_private->syncobj_idr);
578 drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
579 struct drm_file *file_private)
581 struct drm_syncobj_create *args = data;
583 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
586 /* no valid flags yet */
587 if (args->flags & ~DRM_SYNCOBJ_CREATE_SIGNALED)
590 return drm_syncobj_create_as_handle(file_private,
591 &args->handle, args->flags);
595 drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
596 struct drm_file *file_private)
598 struct drm_syncobj_destroy *args = data;
600 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
603 /* make sure padding is empty */
606 return drm_syncobj_destroy(file_private, args->handle);
610 drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
611 struct drm_file *file_private)
613 struct drm_syncobj_handle *args = data;
615 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
621 if (args->flags != 0 &&
622 args->flags != DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
625 if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
626 return drm_syncobj_export_sync_file(file_private, args->handle,
629 return drm_syncobj_handle_to_fd(file_private, args->handle,
634 drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
635 struct drm_file *file_private)
637 struct drm_syncobj_handle *args = data;
639 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
645 if (args->flags != 0 &&
646 args->flags != DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
649 if (args->flags & DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
650 return drm_syncobj_import_sync_file_fence(file_private,
654 return drm_syncobj_fd_to_handle(file_private, args->fd,
658 struct syncobj_wait_entry {
659 struct task_struct *task;
660 struct dma_fence *fence;
661 struct dma_fence_cb fence_cb;
662 struct drm_syncobj_cb syncobj_cb;
665 static void syncobj_wait_fence_func(struct dma_fence *fence,
666 struct dma_fence_cb *cb)
668 struct syncobj_wait_entry *wait =
669 container_of(cb, struct syncobj_wait_entry, fence_cb);
671 wake_up_process(wait->task);
674 static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
675 struct drm_syncobj_cb *cb)
677 struct syncobj_wait_entry *wait =
678 container_of(cb, struct syncobj_wait_entry, syncobj_cb);
680 /* This happens inside the syncobj lock */
681 wait->fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
682 lockdep_is_held(&syncobj->lock)));
683 wake_up_process(wait->task);
686 static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
692 struct syncobj_wait_entry *entries;
693 struct dma_fence *fence;
695 uint32_t signaled_count, i;
697 entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
701 /* Walk the list of sync objects and initialize entries. We do
702 * this up-front so that we can properly return -EINVAL if there is
703 * a syncobj with a missing fence and then never have the chance of
704 * returning -EINVAL again.
707 for (i = 0; i < count; ++i) {
708 entries[i].task = current;
709 entries[i].fence = drm_syncobj_fence_get(syncobjs[i]);
710 if (!entries[i].fence) {
711 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
715 goto cleanup_entries;
719 if (dma_fence_is_signaled(entries[i].fence)) {
720 if (signaled_count == 0 && idx)
726 /* Initialize ret to the max of timeout and 1. That way, the
727 * default return value indicates a successful wait and not a
730 ret = max_t(signed long, timeout, 1);
732 if (signaled_count == count ||
733 (signaled_count > 0 &&
734 !(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL)))
735 goto cleanup_entries;
737 /* There's a very annoying laxness in the dma_fence API here, in
738 * that backends are not required to automatically report when a
739 * fence is signaled prior to fence->ops->enable_signaling() being
740 * called. So here if we fail to match signaled_count, we need to
741 * fallthough and try a 0 timeout wait!
744 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
745 for (i = 0; i < count; ++i) {
746 drm_syncobj_fence_get_or_add_callback(syncobjs[i],
748 &entries[i].syncobj_cb,
749 syncobj_wait_syncobj_func);
754 set_current_state(TASK_INTERRUPTIBLE);
757 for (i = 0; i < count; ++i) {
758 fence = entries[i].fence;
762 if (dma_fence_is_signaled(fence) ||
763 (!entries[i].fence_cb.func &&
764 dma_fence_add_callback(fence,
765 &entries[i].fence_cb,
766 syncobj_wait_fence_func))) {
767 /* The fence has been signaled */
768 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL) {
778 if (signaled_count == count)
782 /* If we are doing a 0 timeout wait and we got
783 * here, then we just timed out.
789 ret = schedule_timeout(ret);
791 if (ret > 0 && signal_pending(current))
796 __set_current_state(TASK_RUNNING);
799 for (i = 0; i < count; ++i) {
800 if (entries[i].syncobj_cb.func)
801 drm_syncobj_remove_callback(syncobjs[i],
802 &entries[i].syncobj_cb);
803 if (entries[i].fence_cb.func)
804 dma_fence_remove_callback(entries[i].fence,
805 &entries[i].fence_cb);
806 dma_fence_put(entries[i].fence);
814 * drm_timeout_abs_to_jiffies - calculate jiffies timeout from absolute value
816 * @timeout_nsec: timeout nsec component in ns, 0 for poll
818 * Calculate the timeout in jiffies from an absolute time in sec/nsec.
820 static signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec)
822 ktime_t abs_timeout, now;
823 u64 timeout_ns, timeout_jiffies64;
825 /* make 0 timeout means poll - absolute 0 doesn't seem valid */
826 if (timeout_nsec == 0)
829 abs_timeout = ns_to_ktime(timeout_nsec);
832 if (!ktime_after(abs_timeout, now))
835 timeout_ns = ktime_to_ns(ktime_sub(abs_timeout, now));
837 timeout_jiffies64 = nsecs_to_jiffies64(timeout_ns);
838 /* clamp timeout to avoid infinite timeout */
839 if (timeout_jiffies64 >= MAX_SCHEDULE_TIMEOUT - 1)
840 return MAX_SCHEDULE_TIMEOUT - 1;
842 return timeout_jiffies64 + 1;
845 static int drm_syncobj_array_wait(struct drm_device *dev,
846 struct drm_file *file_private,
847 struct drm_syncobj_wait *wait,
848 struct drm_syncobj **syncobjs)
850 signed long timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec);
854 ret = drm_syncobj_array_wait_timeout(syncobjs,
861 wait->first_signaled = first;
867 static int drm_syncobj_array_find(struct drm_file *file_private,
868 void __user *user_handles,
869 uint32_t count_handles,
870 struct drm_syncobj ***syncobjs_out)
872 uint32_t i, *handles;
873 struct drm_syncobj **syncobjs;
876 handles = kmalloc_array(count_handles, sizeof(*handles), GFP_KERNEL);
880 if (copy_from_user(handles, user_handles,
881 sizeof(uint32_t) * count_handles)) {
883 goto err_free_handles;
886 syncobjs = kmalloc_array(count_handles, sizeof(*syncobjs), GFP_KERNEL);
887 if (syncobjs == NULL) {
889 goto err_free_handles;
892 for (i = 0; i < count_handles; i++) {
893 syncobjs[i] = drm_syncobj_find(file_private, handles[i]);
896 goto err_put_syncobjs;
901 *syncobjs_out = syncobjs;
906 drm_syncobj_put(syncobjs[i]);
914 static void drm_syncobj_array_free(struct drm_syncobj **syncobjs,
918 for (i = 0; i < count; i++)
919 drm_syncobj_put(syncobjs[i]);
924 drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
925 struct drm_file *file_private)
927 struct drm_syncobj_wait *args = data;
928 struct drm_syncobj **syncobjs;
931 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
934 if (args->flags & ~(DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL |
935 DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT))
938 if (args->count_handles == 0)
941 ret = drm_syncobj_array_find(file_private,
942 u64_to_user_ptr(args->handles),
948 ret = drm_syncobj_array_wait(dev, file_private,
951 drm_syncobj_array_free(syncobjs, args->count_handles);
957 drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
958 struct drm_file *file_private)
960 struct drm_syncobj_array *args = data;
961 struct drm_syncobj **syncobjs;
965 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
971 if (args->count_handles == 0)
974 ret = drm_syncobj_array_find(file_private,
975 u64_to_user_ptr(args->handles),
981 for (i = 0; i < args->count_handles; i++)
982 drm_syncobj_replace_fence(syncobjs[i], NULL);
984 drm_syncobj_array_free(syncobjs, args->count_handles);
990 drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
991 struct drm_file *file_private)
993 struct drm_syncobj_array *args = data;
994 struct drm_syncobj **syncobjs;
998 if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
1004 if (args->count_handles == 0)
1007 ret = drm_syncobj_array_find(file_private,
1008 u64_to_user_ptr(args->handles),
1009 args->count_handles,
1014 for (i = 0; i < args->count_handles; i++) {
1015 ret = drm_syncobj_assign_null_handle(syncobjs[i]);
1020 drm_syncobj_array_free(syncobjs, args->count_handles);