Home | History | Annotate | Download | only in drm

Lines Matching refs:syncobj

34  * DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a
39 * The syncobj userspace API provides ioctls for several operations:
42 * - Import and export of syncobjs to/from a syncobj file descriptor
43 * - Import and export a syncobj's underlying fence to/from a sync file
44 * - Reset a syncobj (set its fence to NULL)
45 * - Signal a syncobj (set a trivially signaled fence)
46 * - Wait for a syncobj's fence to appear and be signaled
48 * At it's core, a syncobj is simply a wrapper around a pointer to a struct
50 * When a syncobj is first created, its pointer is either NULL or a pointer
54 * When GPU work which signals a syncobj is enqueued in a DRM driver,
55 * the syncobj fence is replaced with a fence which will be signaled by the
57 * When GPU work which waits on a syncobj is enqueued in a DRM driver, the
58 * driver retrieves syncobj's current fence at the time the work is enqueued
60 * If the syncobj's fence is NULL, the enqueue operation is expected to fail.
66 * manipulate a syncobj from the host by resetting its pointer to NULL or
73 * &DRM_IOCTL_SYNCOBJ_WAIT takes an array of syncobj handles and does a
74 * host-side wait on all of the syncobj fences simultaneously.
76 * all of the syncobj fences to be signaled before it returns.
77 * Otherwise, it returns once at least one syncobj fence has been signaled
81 * fence in a syncobj, if &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT is set,
82 * the host-side wait will first wait for the syncobj to receive a non-NULL
86 * Assuming the syncobj starts off with a NULL fence, this allows a client
99 * The first lets the client import or export an entire syncobj to a file
102 * syncobj between processes.
103 * All exported file descriptors and any syncobj handles created as a
105 * same underlying struct &drm_syncobj and the syncobj can be used
107 * The syncobj is freed only once the last reference is dropped.
108 * Unlike dma-buf, importing a syncobj creates a new handle (with its own
116 * import/export the syncobj's current fence from/to a &sync_file.
117 * When a syncobj is exported to a sync file, that sync file wraps the
119 * operations on the syncobj will not affect the exported sync file.
120 * When a sync file is imported into a syncobj, the syncobj's fence is set
122 * Because sync files are immutable, resetting or signaling the syncobj
124 * syncobj.
152 * syncobj->lock ???? fence lock
153 * syncobj->lock then wait->lock
156 * syncobj->lock serializes wait->node and wait->fence.
158 * interlocking with syncobj->lock, coordinates wakeups on
172 static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
180 * Returns a reference to the syncobj pointed to by handle or NULL. The
186 struct drm_syncobj *syncobj;
191 syncobj = idr_find(&file_private->syncobj_idr, handle);
192 if (syncobj)
193 drm_syncobj_get(syncobj);
197 return syncobj;
201 static void drm_syncobj_fence_add_wait(struct drm_syncobj *syncobj,
209 spin_lock(&syncobj->lock);
214 fence = dma_fence_get(rcu_dereference_protected(syncobj->fence, 1));
217 list_add_tail(&wait->node, &syncobj->cb_list);
223 spin_unlock(&syncobj->lock);
226 static void drm_syncobj_remove_wait(struct drm_syncobj *syncobj,
232 spin_lock(&syncobj->lock);
234 spin_unlock(&syncobj->lock);
238 * drm_syncobj_add_point - add new timeline point to the syncobj
239 * @syncobj: sync object to add timeline point do
244 * Add the chain node as new timeline point to the syncobj.
246 void drm_syncobj_add_point(struct drm_syncobj *syncobj,
256 spin_lock(&syncobj->lock);
258 prev = drm_syncobj_fence_get(syncobj);
263 rcu_assign_pointer(syncobj->fence, &chain->base);
265 list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node)
266 syncobj_wait_syncobj_func(syncobj, cur);
267 spin_unlock(&syncobj->lock);
277 * @syncobj: Sync object to replace fence in
282 void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
291 spin_lock(&syncobj->lock);
293 old_fence = rcu_dereference_protected(syncobj->fence,
294 lockdep_is_held(&syncobj->lock));
295 rcu_assign_pointer(syncobj->fence, fence);
298 list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node)
299 syncobj_wait_syncobj_func(syncobj, cur);
302 spin_unlock(&syncobj->lock);
310 * @syncobj: sync object to assign the fence on
314 static void drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
318 drm_syncobj_replace_fence(syncobj, fence);
343 struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
348 if (!syncobj)
351 *fence = drm_syncobj_fence_get(syncobj);
352 drm_syncobj_put(syncobj);
377 drm_syncobj_fence_add_wait(syncobj, &wait);
380 spin_lock(&syncobj->lock);
390 spin_unlock(&syncobj->lock);
397 spin_lock(&syncobj->lock);
414 spin_unlock(&syncobj->lock);
441 drm_syncobj_remove_wait(syncobj, &wait);
456 struct drm_syncobj *syncobj = container_of(kref,
459 drm_syncobj_replace_fence(syncobj, NULL);
460 spin_lock_destroy(&syncobj->lock);
461 kfree(syncobj);
466 * drm_syncobj_create - create a new syncobj
467 * @out_syncobj: returned syncobj
469 * @fence: if non-NULL, the syncobj will represent this fence
480 struct drm_syncobj *syncobj;
482 syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL);
483 if (!syncobj)
486 kref_init(&syncobj->refcount);
487 INIT_LIST_HEAD(&syncobj->cb_list);
488 spin_lock_init(&syncobj->lock);
491 drm_syncobj_assign_null_handle(syncobj);
494 drm_syncobj_replace_fence(syncobj, fence);
496 *out_syncobj = syncobj;
502 * drm_syncobj_get_handle - get a handle from a syncobj
504 * @syncobj: Sync object to export
513 struct drm_syncobj *syncobj, u32 *handle)
518 drm_syncobj_get(syncobj);
522 ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
528 drm_syncobj_put(syncobj);
541 struct drm_syncobj *syncobj;
543 ret = drm_syncobj_create(&syncobj, flags, NULL);
547 ret = drm_syncobj_get_handle(file_private, syncobj, handle);
548 drm_syncobj_put(syncobj);
555 struct drm_syncobj *syncobj;
558 syncobj = idr_remove(&file_private->syncobj_idr, handle);
561 if (!syncobj)
564 drm_syncobj_put(syncobj);
575 struct drm_syncobj *syncobj = file->f_data;
577 struct drm_syncobj *syncobj = file->private_data;
580 drm_syncobj_put(syncobj);
604 * drm_syncobj_get_fd - get a file descriptor from a syncobj
605 * @syncobj: Sync object to export
612 int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
626 file->f_data = syncobj;
635 syncobj, 0);
642 drm_syncobj_get(syncobj);
653 struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
656 if (!syncobj)
659 ret = drm_syncobj_get_fd(syncobj, p_fd);
660 drm_syncobj_put(syncobj);
667 struct drm_syncobj *syncobj;
686 syncobj = f.file->f_data;
688 syncobj = f.file->private_data;
690 drm_syncobj_get(syncobj);
694 ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
702 drm_syncobj_put(syncobj);
712 struct drm_syncobj *syncobj;
717 syncobj = drm_syncobj_find(file_private, handle);
718 if (!syncobj) {
723 drm_syncobj_replace_fence(syncobj, fence);
725 drm_syncobj_put(syncobj);
807 * drm_syncobj_open - initalizes syncobj file-private structures at devnode open time
823 struct drm_syncobj *syncobj = ptr;
825 drm_syncobj_put(syncobj);
1017 static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
1022 /* This happens inside the syncobj lock */
1023 fence = rcu_dereference_protected(syncobj->fence,
1024 lockdep_is_held(&syncobj->lock));
1038 KASSERT(spin_is_locked(&syncobj->lock));
1088 * a syncobj with a missing fence and then never have the chance of