Lines Matching full:fence
55 struct vmw_fence_obj fence; member
59 * struct vmw_event_fence_action - fence action that delivers a drm event.
62 * @action: A struct vmw_fence_action to hook up to a fence.
63 * @fence: A referenced pointer to the fence to keep it alive while @action
69 * current time tv_sec val when the fence signals.
71 * be assigned the current time tv_usec val when the fence signals.
77 struct vmw_fence_obj *fence; member
85 fman_from_fence(struct vmw_fence_obj *fence) in fman_from_fence() argument
87 return container_of(fence->base.lock, struct vmw_fence_manager, lock); in fman_from_fence()
94 * a) When a new fence seqno has been submitted by the fifo code.
97 * irq is received. When the last fence waiter is gone, that IRQ is masked
101 * fence objects may not be signaled. This is perfectly OK, since there are
102 * no consumers of the signaled data, but that is NOT ok when there are fence
103 * actions attached to a fence. The fencing subsystem then makes use of the
104 * FENCE_GOAL irq and sets the fence goal seqno to that of the next fence
106 * the subsystem makes sure the fence goal seqno is updated.
108 * The fence goal seqno irq is on as long as there are unsignaled fence
114 struct vmw_fence_obj *fence = in vmw_fence_obj_destroy() local
117 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_destroy()
120 list_del_init(&fence->head); in vmw_fence_obj_destroy()
123 fence->destroy(fence); in vmw_fence_obj_destroy()
138 struct vmw_fence_obj *fence = in vmw_fence_enable_signaling() local
141 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_enable_signaling()
146 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) in vmw_fence_enable_signaling()
160 vmwgfx_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb) in vmwgfx_wait_cb() argument
172 struct vmw_fence_obj *fence = in vmw_fence_wait() local
175 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_wait()
180 if (likely(vmw_fence_obj_signaled(fence))) in vmw_fence_wait()
206 * 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()
385 * vmw_fence_goal_new_locked - Figure out a new device fence goal
388 * @fman: Pointer to a fence manager.
391 * This function should be called with the fence manager lock held.
393 * we might need to update the fence goal. It checks to see whether
394 * the current fence goal has already passed, and, in that case,
395 * scans through all unsignaled fences to get the next fence object with an
396 * action attached, and sets the seqno of that fence as a new fence goal.
405 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()
419 vmw_mmio_write(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()
450 if (dma_fence_is_signaled_locked(&fence->base)) in vmw_fence_goal_check_locked()
456 goal_seqno - fence->base.seqno < VMW_FENCE_WRAP)) in vmw_fence_goal_check_locked()
459 vmw_mmio_write(fence->base.seqno, fifo_mem + SVGA_FIFO_FENCE_GOAL); in vmw_fence_goal_check_locked()
467 struct vmw_fence_obj *fence, *next_fence; in __vmw_fences_update() local
475 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) { in __vmw_fences_update()
476 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) { in __vmw_fences_update()
477 list_del_init(&fence->head); in __vmw_fences_update()
478 dma_fence_signal_locked(&fence->base); in __vmw_fences_update()
480 list_splice_init(&fence->seq_passed_actions, in __vmw_fences_update()
488 * Rerun if the fence goal seqno was updated, and the in __vmw_fences_update()
513 bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence) in vmw_fence_obj_signaled() argument
515 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_signaled()
517 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags)) in vmw_fence_obj_signaled()
522 return dma_fence_is_signaled(&fence->base); in vmw_fence_obj_signaled()
525 int vmw_fence_obj_wait(struct vmw_fence_obj *fence, bool lazy, in vmw_fence_obj_wait() argument
528 long ret = dma_fence_wait_timeout(&fence->base, interruptible, timeout); in vmw_fence_obj_wait()
538 void vmw_fence_obj_flush(struct vmw_fence_obj *fence) in vmw_fence_obj_flush() argument
540 struct vmw_private *dev_priv = fman_from_fence(fence)->dev_priv; in vmw_fence_obj_flush()
545 static void vmw_fence_destroy(struct vmw_fence_obj *fence) in vmw_fence_destroy() argument
547 dma_fence_free(&fence->base); in vmw_fence_destroy()
554 struct vmw_fence_obj *fence; in vmw_fence_create() local
557 fence = kzalloc(sizeof(*fence), GFP_KERNEL); in vmw_fence_create()
558 if (unlikely(!fence)) in vmw_fence_create()
561 ret = vmw_fence_obj_init(fman, fence, seqno, in vmw_fence_create()
566 *p_fence = fence; in vmw_fence_create()
570 kfree(fence); in vmw_fence_create()
575 static void vmw_user_fence_destroy(struct vmw_fence_obj *fence) in vmw_user_fence_destroy() argument
578 container_of(fence, struct vmw_user_fence, fence); in vmw_user_fence_destroy()
579 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_user_fence_destroy()
594 struct vmw_fence_obj *fence = &ufence->fence; in vmw_user_fence_base_release() local
597 vmw_fence_obj_unreference(&fence); in vmw_user_fence_base_release()
632 ret = vmw_fence_obj_init(fman, &ufence->fence, seqno, in vmw_user_fence_create()
643 tmp = vmw_fence_obj_reference(&ufence->fence); in vmw_user_fence_create()
657 *p_fence = &ufence->fence; in vmw_user_fence_create()
662 tmp = &ufence->fence; in vmw_user_fence_create()
671 * vmw_wait_dma_fence - Wait for a dma fence
673 * @fman: pointer to a fence manager
674 * @fence: DMA fence to wait on
676 * This function handles the case when the fence is actually a fence
677 * array. If that's the case, it'll wait on each of the child fence
680 struct dma_fence *fence) in vmw_wait_dma_fence() argument
687 if (dma_fence_is_signaled(fence)) in vmw_wait_dma_fence()
690 if (!dma_fence_is_array(fence)) in vmw_wait_dma_fence()
691 return dma_fence_wait(fence, true); in vmw_wait_dma_fence()
693 /* From i915: Note that if the fence-array was created in in vmw_wait_dma_fence()
695 * fences. However, we don't currently store which mode the fence-array in vmw_wait_dma_fence()
697 * private to amdgpu and we should not see any incoming fence-array in vmw_wait_dma_fence()
701 fence_array = to_dma_fence_array(fence); in vmw_wait_dma_fence()
716 * vmw_fence_fifo_down - signal all unsignaled fence objects.
732 struct vmw_fence_obj *fence = in vmw_fence_fifo_down() local
735 dma_fence_get(&fence->base); in vmw_fence_fifo_down()
738 ret = vmw_fence_obj_wait(fence, false, false, in vmw_fence_fifo_down()
742 list_del_init(&fence->head); in vmw_fence_fifo_down()
743 dma_fence_signal(&fence->base); in vmw_fence_fifo_down()
745 list_splice_init(&fence->seq_passed_actions, in vmw_fence_fifo_down()
750 BUG_ON(!list_empty(&fence->head)); in vmw_fence_fifo_down()
751 dma_fence_put(&fence->base); in vmw_fence_fifo_down()
766 * vmw_fence_obj_lookup - Look up a user-space fence object
769 * @handle: A handle identifying the fence object.
773 * The fence object is looked up and type-checked. The caller needs
774 * to have opened the fence object first, but since that happens on
775 * creation and fence objects aren't shareable, that's not an
784 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
790 pr_err("Invalid fence object handle 0x%08lx.\n", in vmw_fence_obj_lookup()
807 struct vmw_fence_obj *fence; in vmw_fence_obj_wait_ioctl() local
829 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_wait_ioctl()
833 ret = ((vmw_fence_obj_signaled(fence)) ? in vmw_fence_obj_wait_ioctl()
840 ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout); in vmw_fence_obj_wait_ioctl()
846 * Optionally unref the fence object. in vmw_fence_obj_wait_ioctl()
861 struct vmw_fence_obj *fence; in vmw_fence_obj_signaled_ioctl() local
870 fence = &(container_of(base, struct vmw_user_fence, base)->fence); in vmw_fence_obj_signaled_ioctl()
871 fman = fman_from_fence(fence); in vmw_fence_obj_signaled_ioctl()
873 arg->signaled = vmw_fence_obj_signaled(fence); in vmw_fence_obj_signaled_ioctl()
903 * This function is called when the seqno of the fence where @action is
947 vmw_fence_obj_unreference(&eaction->fence); in vmw_event_fence_action_cleanup()
953 * vmw_fence_obj_add_action - Add an action to a fence object.
955 * @fence - The fence object.
961 static void vmw_fence_obj_add_action(struct vmw_fence_obj *fence, in vmw_fence_obj_add_action() argument
964 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_fence_obj_add_action()
971 if (dma_fence_is_signaled_locked(&fence->base)) { in vmw_fence_obj_add_action()
978 list_add_tail(&action->head, &fence->seq_passed_actions); in vmw_fence_obj_add_action()
984 run_update = vmw_fence_goal_check_locked(fence); in vmw_fence_obj_add_action()
1001 * vmw_event_fence_action_create - Post an event for sending when a fence
1005 * @fence: The fence object on which to post the event.
1016 struct vmw_fence_obj *fence, in vmw_event_fence_action_queue() argument
1023 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_queue()
1035 eaction->fence = vmw_fence_obj_reference(fence); in vmw_event_fence_action_queue()
1040 vmw_fence_obj_add_action(fence, &eaction->action); in vmw_event_fence_action_queue()
1051 struct vmw_fence_obj *fence, in vmw_event_fence_action_create() argument
1057 struct vmw_fence_manager *fman = fman_from_fence(fence); in vmw_event_fence_action_create()
1081 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1087 ret = vmw_event_fence_action_queue(file_priv, fence, in vmw_event_fence_action_create()
1109 struct vmw_fence_obj *fence = NULL; in vmw_fence_event_ioctl() local
1119 * Look up an existing fence object, in vmw_fence_event_ioctl()
1130 fence = &(container_of(base, struct vmw_user_fence, in vmw_fence_event_ioctl()
1131 base)->fence); in vmw_fence_event_ioctl()
1132 (void) vmw_fence_obj_reference(fence); in vmw_fence_event_ioctl()
1138 DRM_ERROR("Failed to reference a fence " in vmw_fence_event_ioctl()
1148 * Create a new fence object. in vmw_fence_event_ioctl()
1150 if (!fence) { in vmw_fence_event_ioctl()
1152 &fence, in vmw_fence_event_ioctl()
1156 DRM_ERROR("Fence event failed to create fence.\n"); in vmw_fence_event_ioctl()
1161 BUG_ON(fence == NULL); in vmw_fence_event_ioctl()
1163 ret = vmw_event_fence_action_create(file_priv, fence, in vmw_fence_event_ioctl()
1169 DRM_ERROR("Failed to attach event to fence.\n"); in vmw_fence_event_ioctl()
1173 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence, in vmw_fence_event_ioctl()
1175 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()
1181 vmw_fence_obj_unreference(&fence); in vmw_fence_event_ioctl()