Lines Matching full:fence
51 struct vmw_fence_obj fence; member
55 * struct vmw_event_fence_action - fence action that delivers a drm event.
57 * @action: A struct vmw_fence_action to hook up to a fence.
59 * @fence: A referenced pointer to the fence to keep it alive while @action
63 * current time tv_sec val when the fence signals.
65 * be assigned the current time tv_usec val when the fence signals.
71 struct vmw_fence_obj *fence; member
79 fman_from_fence(struct vmw_fence_obj *fence) in fman_from_fence() argument
81 return container_of(fence->base.lock, struct vmw_fence_manager, lock); in fman_from_fence()
104 * a) When a new fence seqno has been submitted by the fifo code.
107 * irq is received. When the last fence waiter is gone, that IRQ is masked
111 * fence objects may not be signaled. This is perfectly OK, since there are
112 * no consumers of the signaled data, but that is NOT ok when there are fence
113 * actions attached to a fence. The fencing subsystem then makes use of the
114 * FENCE_GOAL irq and sets the fence goal seqno to that of the next fence
116 * the subsystem makes sure the fence goal seqno is updated.
118 * The fence goal seqno irq is on as long as there are unsignaled fence
124 struct vmw_fence_obj *fence = in vmw_fence_obj_destroy() local
126 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_destroy()
128 if (!list_empty(&fence->head)) { in vmw_fence_obj_destroy()
130 list_del_init(&fence->head); in vmw_fence_obj_destroy()
133 fence->destroy(fence); in vmw_fence_obj_destroy()
148 struct vmw_fence_obj *fence = in vmw_fence_enable_signaling() local
151 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_enable_signaling()
155 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) in vmw_fence_enable_signaling()
167 vmwgfx_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb) in vmwgfx_wait_cb() argument
179 struct vmw_fence_obj *fence = in vmw_fence_wait() local
182 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_wait()
187 if (likely(vmw_fence_obj_signaled(fence))) in vmw_fence_wait()
212 * fence spinlock. in vmw_fence_wait()
340 struct vmw_fence_obj *fence, u32 seqno, in vmw_fence_obj_init() argument
341 void (*destroy) (struct vmw_fence_obj *fence)) in vmw_fence_obj_init()
345 dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock, in vmw_fence_obj_init()
347 INIT_LIST_HEAD(&fence->seq_passed_actions); in vmw_fence_obj_init()
348 fence->destroy = destroy; in vmw_fence_obj_init()
355 list_add_tail(&fence->head, &fman->fence_list); in vmw_fence_obj_init()
384 * vmw_fence_goal_new_locked - Figure out a new device fence goal
387 * @fman: Pointer to a fence manager.
390 * This function should be called with the fence manager lock held.
392 * we might need to update the fence goal. It checks to see whether
393 * the current fence goal has already passed, and, in that case,
394 * scans through all unsignaled fences to get the next fence object with an
395 * action attached, and sets the seqno of that fence as a new fence goal.
403 struct vmw_fence_obj *fence, *next_fence; in vmw_fence_goal_new_locked() local
413 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) { in vmw_fence_goal_new_locked()
414 if (!list_empty(&fence->seq_passed_actions)) { in vmw_fence_goal_new_locked()
417 fence->base.seqno); in vmw_fence_goal_new_locked()
427 * vmw_fence_goal_check_locked - Replace the device fence goal seqno if
430 * @fence: Pointer to a struct vmw_fence_obj the seqno of which should be
431 * considered as a device fence goal.
433 * This function should be called with the fence manager lock held.
434 * It is typically called when an action has been attached to a fence to
435 * check whether the seqno of that fence should be used for a fence
436 * goal interrupt. This is typically needed if the current fence goal is
437 * invalid, or has a higher seqno than that of the current fence object.
441 static bool vmw_fence_goal_check_locked(struct vmw_fence_obj *fence) in vmw_fence_goal_check_locked() argument
443 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_goal_check_locked()
446 if (dma_fence_is_signaled_locked(&fence->base)) in vmw_fence_goal_check_locked()
451 goal_seqno - fence->base.seqno < VMW_FENCE_WRAP)) in vmw_fence_goal_check_locked()
454 vmw_fence_goal_write(fman->dev_priv, fence->base.seqno); in vmw_fence_goal_check_locked()
462 struct vmw_fence_obj *fence, *next_fence; in __vmw_fences_update() local
469 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) { in __vmw_fences_update()
470 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) { in __vmw_fences_update()
471 list_del_init(&fence->head); in __vmw_fences_update()
472 dma_fence_signal_locked(&fence->base); in __vmw_fences_update()
474 list_splice_init(&fence->seq_passed_actions, in __vmw_fences_update()
482 * Rerun if the fence goal seqno was updated, and the in __vmw_fences_update()
507 bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence) in vmw_fence_obj_signaled() argument
509 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_signaled()
511 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags)) in vmw_fence_obj_signaled()
516 return dma_fence_is_signaled(&fence->base); in vmw_fence_obj_signaled()
519 int vmw_fence_obj_wait(struct vmw_fence_obj *fence, bool lazy, in vmw_fence_obj_wait() argument
522 long ret = dma_fence_wait_timeout(&fence->base, interruptible, timeout); in vmw_fence_obj_wait()
532 static void vmw_fence_destroy(struct vmw_fence_obj *fence) in vmw_fence_destroy() argument
534 dma_fence_free(&fence->base); in vmw_fence_destroy()
541 struct vmw_fence_obj *fence; in vmw_fence_create() local
544 fence = kzalloc(sizeof(*fence), GFP_KERNEL); in vmw_fence_create()
545 if (unlikely(!fence)) in vmw_fence_create()
548 ret = vmw_fence_obj_init(fman, fence, seqno, in vmw_fence_create()
553 *p_fence = fence; in vmw_fence_create()
557 kfree(fence); in vmw_fence_create()
562 static void vmw_user_fence_destroy(struct vmw_fence_obj *fence) in vmw_user_fence_destroy() argument
565 container_of(fence, struct vmw_user_fence, fence); in vmw_user_fence_destroy()
575 struct vmw_fence_obj *fence = &ufence->fence; in vmw_user_fence_base_release() local
578 vmw_fence_obj_unreference(&fence); in vmw_user_fence_base_release()
598 ret = vmw_fence_obj_init(fman, &ufence->fence, seqno, in vmw_user_fence_create()
609 tmp = vmw_fence_obj_reference(&ufence->fence); in vmw_user_fence_create()
624 *p_fence = &ufence->fence; in vmw_user_fence_create()
629 tmp = &ufence->fence; in vmw_user_fence_create()
636 * vmw_fence_fifo_down - signal all unsignaled fence objects.
652 struct vmw_fence_obj *fence = in vmw_fence_fifo_down() local
655 dma_fence_get(&fence->base); in vmw_fence_fifo_down()
658 ret = vmw_fence_obj_wait(fence, false, false, in vmw_fence_fifo_down()
662 list_del_init(&fence->head); in vmw_fence_fifo_down()
663 dma_fence_signal(&fence->base); in vmw_fence_fifo_down()
665 list_splice_init(&fence->seq_passed_actions, in vmw_fence_fifo_down()
670 BUG_ON(!list_empty(&fence->head)); in vmw_fence_fifo_down()
671 dma_fence_put(&fence->base); in vmw_fence_fifo_down()
686 * vmw_fence_obj_lookup - Look up a user-space fence object
689 * @handle: A handle identifying the fence object.
693 * The fence object is looked up and type-checked. The caller needs
694 * to have opened the fence object first, but since that happens on
695 * creation and fence objects aren't shareable, that's not an
704 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
710 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
727 struct vmw_fence_obj *fence; in vmw_fence_obj_wait_ioctl() local
749 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_wait_ioctl()
753 ret = ((vmw_fence_obj_signaled(fence)) ? in vmw_fence_obj_wait_ioctl()
760 ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout); in vmw_fence_obj_wait_ioctl()
766 * Optionally unref the fence object. in vmw_fence_obj_wait_ioctl()
780 struct vmw_fence_obj *fence; in vmw_fence_obj_signaled_ioctl() local
789 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_signaled_ioctl()
790 fman = fman_from_fence(fence); in vmw_fence_obj_signaled_ioctl()
792 arg->signaled = vmw_fence_obj_signaled(fence); in vmw_fence_obj_signaled_ioctl()
821 * This function is called when the seqno of the fence where @action is
865 vmw_fence_obj_unreference(&eaction->fence); in vmw_event_fence_action_cleanup()
871 * vmw_fence_obj_add_action - Add an action to a fence object.
873 * @fence: The fence object.
879 static void vmw_fence_obj_add_action(struct vmw_fence_obj *fence, in vmw_fence_obj_add_action() argument
882 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_add_action()
889 if (dma_fence_is_signaled_locked(&fence->base)) { in vmw_fence_obj_add_action()
896 list_add_tail(&action->head, &fence->seq_passed_actions); in vmw_fence_obj_add_action()
902 run_update = vmw_fence_goal_check_locked(fence); in vmw_fence_obj_add_action()
919 * vmw_event_fence_action_queue - Post an event for sending when a fence
923 * @fence: The fence object on which to post the event.
927 * current time tv_sec val when the fence signals.
929 * be assigned the current time tv_usec val when the fence signals.
938 struct vmw_fence_obj *fence, in vmw_event_fence_action_queue() argument
945 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_queue()
957 eaction->fence = vmw_fence_obj_reference(fence); in vmw_event_fence_action_queue()
962 vmw_fence_obj_add_action(fence, &eaction->action); in vmw_event_fence_action_queue()
973 struct vmw_fence_obj *fence, in vmw_event_fence_action_create() argument
979 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_create()
1003 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1009 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1031 struct vmw_fence_obj *fence = NULL; in vmw_fence_event_ioctl() local
1041 * Look up an existing fence object, in vmw_fence_event_ioctl()
1052 fence = &(container_of(base, struct vmw_user_fence, in vmw_fence_event_ioctl()
1053 base)->fence); in vmw_fence_event_ioctl()
1054 (void) vmw_fence_obj_reference(fence); in vmw_fence_event_ioctl()
1060 DRM_ERROR("Failed to reference a fence " in vmw_fence_event_ioctl()
1070 * Create a new fence object. in vmw_fence_event_ioctl()
1072 if (!fence) { in vmw_fence_event_ioctl()
1074 &fence, in vmw_fence_event_ioctl()
1078 DRM_ERROR("Fence event failed to create fence.\n"); in vmw_fence_event_ioctl()
1083 BUG_ON(fence == NULL); in vmw_fence_event_ioctl()
1085 ret = vmw_event_fence_action_create(file_priv, fence, in vmw_fence_event_ioctl()
1091 DRM_ERROR("Failed to attach event to fence.\n"); in vmw_fence_event_ioctl()
1095 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence, in vmw_fence_event_ioctl()
1097 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()
1103 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()