Lines Matching full:fence

52 	struct vmw_fence_obj fence;  member
56 * struct vmw_event_fence_action - fence action that delivers a drm event.
58 * @action: A struct vmw_fence_action to hook up to a fence.
60 * @fence: A referenced pointer to the fence to keep it alive while @action
64 * current time tv_sec val when the fence signals.
66 * be assigned the current time tv_usec val when the fence signals.
72 struct vmw_fence_obj *fence; member
80 fman_from_fence(struct vmw_fence_obj *fence) in fman_from_fence() argument
82 return container_of(fence->base.lock, struct vmw_fence_manager, lock); in fman_from_fence()
105 * a) When a new fence seqno has been submitted by the fifo code.
108 * irq is received. When the last fence waiter is gone, that IRQ is masked
112 * fence objects may not be signaled. This is perfectly OK, since there are
113 * no consumers of the signaled data, but that is NOT ok when there are fence
114 * actions attached to a fence. The fencing subsystem then makes use of the
115 * FENCE_GOAL irq and sets the fence goal seqno to that of the next fence
117 * the subsystem makes sure the fence goal seqno is updated.
119 * The fence goal seqno irq is on as long as there are unsignaled fence
125 struct vmw_fence_obj *fence = in vmw_fence_obj_destroy() local
128 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_destroy()
131 list_del_init(&fence->head); in vmw_fence_obj_destroy()
134 fence->destroy(fence); in vmw_fence_obj_destroy()
149 struct vmw_fence_obj *fence = in vmw_fence_enable_signaling() local
152 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_enable_signaling()
156 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) in vmw_fence_enable_signaling()
168 vmwgfx_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb) in vmwgfx_wait_cb() argument
180 struct vmw_fence_obj *fence = in vmw_fence_wait() local
183 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_wait()
188 if (likely(vmw_fence_obj_signaled(fence))) in vmw_fence_wait()
213 * fence spinlock. in vmw_fence_wait()
342 struct vmw_fence_obj *fence, u32 seqno, in vmw_fence_obj_init() argument
343 void (*destroy) (struct vmw_fence_obj *fence)) in vmw_fence_obj_init()
347 dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock, in vmw_fence_obj_init()
349 INIT_LIST_HEAD(&fence->seq_passed_actions); in vmw_fence_obj_init()
350 fence->destroy = destroy; in vmw_fence_obj_init()
357 list_add_tail(&fence->head, &fman->fence_list); in vmw_fence_obj_init()
387 * vmw_fence_goal_new_locked - Figure out a new device fence goal
390 * @fman: Pointer to a fence manager.
393 * This function should be called with the fence manager lock held.
395 * we might need to update the fence goal. It checks to see whether
396 * the current fence goal has already passed, and, in that case,
397 * scans through all unsignaled fences to get the next fence object with an
398 * action attached, and sets the seqno of that fence as a new fence goal.
406 struct vmw_fence_obj *fence; in vmw_fence_goal_new_locked() local
416 list_for_each_entry(fence, &fman->fence_list, head) { in vmw_fence_goal_new_locked()
417 if (!list_empty(&fence->seq_passed_actions)) { in vmw_fence_goal_new_locked()
420 fence->base.seqno); in vmw_fence_goal_new_locked()
430 * vmw_fence_goal_check_locked - Replace the device fence goal seqno if
433 * @fence: Pointer to a struct vmw_fence_obj the seqno of which should be
434 * considered as a device fence goal.
436 * This function should be called with the fence manager lock held.
437 * It is typically called when an action has been attached to a fence to
438 * check whether the seqno of that fence should be used for a fence
439 * goal interrupt. This is typically needed if the current fence goal is
440 * invalid, or has a higher seqno than that of the current fence object.
444 static bool vmw_fence_goal_check_locked(struct vmw_fence_obj *fence) in vmw_fence_goal_check_locked() argument
446 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_goal_check_locked()
449 if (dma_fence_is_signaled_locked(&fence->base)) in vmw_fence_goal_check_locked()
454 goal_seqno - fence->base.seqno < VMW_FENCE_WRAP)) in vmw_fence_goal_check_locked()
457 vmw_fence_goal_write(fman->dev_priv, fence->base.seqno); in vmw_fence_goal_check_locked()
465 struct vmw_fence_obj *fence, *next_fence; in __vmw_fences_update() local
472 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) { in __vmw_fences_update()
473 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) { in __vmw_fences_update()
474 list_del_init(&fence->head); in __vmw_fences_update()
475 dma_fence_signal_locked(&fence->base); in __vmw_fences_update()
477 list_splice_init(&fence->seq_passed_actions, in __vmw_fences_update()
485 * Rerun if the fence goal seqno was updated, and the in __vmw_fences_update()
510 bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence) in vmw_fence_obj_signaled() argument
512 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_signaled()
514 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags)) in vmw_fence_obj_signaled()
519 return dma_fence_is_signaled(&fence->base); in vmw_fence_obj_signaled()
522 int vmw_fence_obj_wait(struct vmw_fence_obj *fence, bool lazy, in vmw_fence_obj_wait() argument
525 long ret = dma_fence_wait_timeout(&fence->base, interruptible, timeout); in vmw_fence_obj_wait()
535 static void vmw_fence_destroy(struct vmw_fence_obj *fence) in vmw_fence_destroy() argument
537 dma_fence_free(&fence->base); in vmw_fence_destroy()
544 struct vmw_fence_obj *fence; in vmw_fence_create() local
547 fence = kzalloc(sizeof(*fence), GFP_KERNEL); in vmw_fence_create()
548 if (unlikely(!fence)) in vmw_fence_create()
551 ret = vmw_fence_obj_init(fman, fence, seqno, in vmw_fence_create()
556 *p_fence = fence; in vmw_fence_create()
560 kfree(fence); in vmw_fence_create()
565 static void vmw_user_fence_destroy(struct vmw_fence_obj *fence) in vmw_user_fence_destroy() argument
568 container_of(fence, struct vmw_user_fence, fence); in vmw_user_fence_destroy()
578 struct vmw_fence_obj *fence = &ufence->fence; in vmw_user_fence_base_release() local
581 vmw_fence_obj_unreference(&fence); in vmw_user_fence_base_release()
601 ret = vmw_fence_obj_init(fman, &ufence->fence, seqno, in vmw_user_fence_create()
612 tmp = vmw_fence_obj_reference(&ufence->fence); in vmw_user_fence_create()
627 *p_fence = &ufence->fence; in vmw_user_fence_create()
632 tmp = &ufence->fence; in vmw_user_fence_create()
639 * vmw_fence_fifo_down - signal all unsignaled fence objects.
655 struct vmw_fence_obj *fence = in vmw_fence_fifo_down() local
658 dma_fence_get(&fence->base); in vmw_fence_fifo_down()
661 ret = vmw_fence_obj_wait(fence, false, false, in vmw_fence_fifo_down()
665 list_del_init(&fence->head); in vmw_fence_fifo_down()
666 dma_fence_signal(&fence->base); in vmw_fence_fifo_down()
668 list_splice_init(&fence->seq_passed_actions, in vmw_fence_fifo_down()
673 BUG_ON(!list_empty(&fence->head)); in vmw_fence_fifo_down()
674 dma_fence_put(&fence->base); in vmw_fence_fifo_down()
689 * vmw_fence_obj_lookup - Look up a user-space fence object
692 * @handle: A handle identifying the fence object.
696 * The fence object is looked up and type-checked. The caller needs
697 * to have opened the fence object first, but since that happens on
698 * creation and fence objects aren't shareable, that's not an
707 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
713 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
730 struct vmw_fence_obj *fence; in vmw_fence_obj_wait_ioctl() local
752 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_wait_ioctl()
756 ret = ((vmw_fence_obj_signaled(fence)) ? in vmw_fence_obj_wait_ioctl()
763 ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout); in vmw_fence_obj_wait_ioctl()
769 * Optionally unref the fence object. in vmw_fence_obj_wait_ioctl()
783 struct vmw_fence_obj *fence; in vmw_fence_obj_signaled_ioctl() local
792 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_signaled_ioctl()
793 fman = fman_from_fence(fence); in vmw_fence_obj_signaled_ioctl()
795 arg->signaled = vmw_fence_obj_signaled(fence); in vmw_fence_obj_signaled_ioctl()
824 * This function is called when the seqno of the fence where @action is
868 vmw_fence_obj_unreference(&eaction->fence); in vmw_event_fence_action_cleanup()
874 * vmw_fence_obj_add_action - Add an action to a fence object.
876 * @fence: The fence object.
882 static void vmw_fence_obj_add_action(struct vmw_fence_obj *fence, in vmw_fence_obj_add_action() argument
885 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_add_action()
892 if (dma_fence_is_signaled_locked(&fence->base)) { in vmw_fence_obj_add_action()
899 list_add_tail(&action->head, &fence->seq_passed_actions); in vmw_fence_obj_add_action()
905 run_update = vmw_fence_goal_check_locked(fence); in vmw_fence_obj_add_action()
922 * vmw_event_fence_action_queue - Post an event for sending when a fence
926 * @fence: The fence object on which to post the event.
930 * current time tv_sec val when the fence signals.
932 * be assigned the current time tv_usec val when the fence signals.
941 struct vmw_fence_obj *fence, in vmw_event_fence_action_queue() argument
948 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_queue()
960 eaction->fence = vmw_fence_obj_reference(fence); in vmw_event_fence_action_queue()
965 vmw_fence_obj_add_action(fence, &eaction->action); in vmw_event_fence_action_queue()
976 struct vmw_fence_obj *fence, in vmw_event_fence_action_create() argument
982 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_create()
1006 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1012 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1034 struct vmw_fence_obj *fence = NULL; in vmw_fence_event_ioctl() local
1044 * Look up an existing fence object, in vmw_fence_event_ioctl()
1055 fence = &(container_of(base, struct vmw_user_fence, in vmw_fence_event_ioctl()
1056 base)->fence); in vmw_fence_event_ioctl()
1057 (void) vmw_fence_obj_reference(fence); in vmw_fence_event_ioctl()
1063 DRM_ERROR("Failed to reference a fence " in vmw_fence_event_ioctl()
1073 * Create a new fence object. in vmw_fence_event_ioctl()
1075 if (!fence) { in vmw_fence_event_ioctl()
1077 &fence, in vmw_fence_event_ioctl()
1081 DRM_ERROR("Fence event failed to create fence.\n"); in vmw_fence_event_ioctl()
1086 BUG_ON(fence == NULL); in vmw_fence_event_ioctl()
1088 ret = vmw_event_fence_action_create(file_priv, fence, in vmw_fence_event_ioctl()
1094 DRM_ERROR("Failed to attach event to fence.\n"); in vmw_fence_event_ioctl()
1098 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence, in vmw_fence_event_ioctl()
1100 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()
1106 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()