Lines Matching refs:fence
55 struct vmw_fence_obj fence;
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;
85 fman_from_fence(struct vmw_fence_obj *fence)
87 return container_of(fence->base.lock, struct vmw_fence_manager, lock);
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 =
117 struct vmw_fence_manager *fman = fman_from_fence(fence);
120 list_del_init(&fence->head);
123 fence->destroy(fence);
138 struct vmw_fence_obj *fence =
141 struct vmw_fence_manager *fman = fman_from_fence(fence);
146 if (seqno - fence->base.seqno < VMW_FENCE_WRAP)
160 vmwgfx_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
172 struct vmw_fence_obj *fence =
175 struct vmw_fence_manager *fman = fman_from_fence(fence);
180 if (likely(vmw_fence_obj_signaled(fence)))
206 * fence spinlock.
340 struct vmw_fence_obj *fence, u32 seqno,
341 void (*destroy) (struct vmw_fence_obj *fence))
345 dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
347 INIT_LIST_HEAD(&fence->seq_passed_actions);
348 fence->destroy = destroy;
355 list_add_tail(&fence->head, &fman->fence_list);
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;
416 list_for_each_entry(fence, &fman->fence_list, head) {
417 if (!list_empty(&fence->seq_passed_actions)) {
419 vmw_mmio_write(fence->base.seqno,
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)
446 struct vmw_fence_manager *fman = fman_from_fence(fence);
450 if (dma_fence_is_signaled_locked(&fence->base))
456 goal_seqno - fence->base.seqno < VMW_FENCE_WRAP))
459 vmw_mmio_write(fence->base.seqno, fifo_mem + SVGA_FIFO_FENCE_GOAL);
467 struct vmw_fence_obj *fence, *next_fence;
475 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) {
476 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) {
477 list_del_init(&fence->head);
478 dma_fence_signal_locked(&fence->base);
480 list_splice_init(&fence->seq_passed_actions,
488 * Rerun if the fence goal seqno was updated, and the
513 bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence)
515 struct vmw_fence_manager *fman = fman_from_fence(fence);
517 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags))
522 return dma_fence_is_signaled(&fence->base);
525 int vmw_fence_obj_wait(struct vmw_fence_obj *fence, bool lazy,
528 long ret = dma_fence_wait_timeout(&fence->base, interruptible, timeout);
538 void vmw_fence_obj_flush(struct vmw_fence_obj *fence)
540 struct vmw_private *dev_priv = fman_from_fence(fence)->dev_priv;
545 static void vmw_fence_destroy(struct vmw_fence_obj *fence)
547 dma_fence_free(&fence->base);
554 struct vmw_fence_obj *fence;
557 fence = kzalloc(sizeof(*fence), GFP_KERNEL);
558 if (unlikely(!fence))
561 ret = vmw_fence_obj_init(fman, fence, seqno,
566 *p_fence = fence;
570 kfree(fence);
575 static void vmw_user_fence_destroy(struct vmw_fence_obj *fence)
578 container_of(fence, struct vmw_user_fence, fence);
579 struct vmw_fence_manager *fman = fman_from_fence(fence);
594 struct vmw_fence_obj *fence = &ufence->fence;
597 vmw_fence_obj_unreference(&fence);
632 ret = vmw_fence_obj_init(fman, &ufence->fence, seqno,
643 tmp = vmw_fence_obj_reference(&ufence->fence);
657 *p_fence = &ufence->fence;
662 tmp = &ufence->fence;
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)
687 if (dma_fence_is_signaled(fence))
690 if (!dma_fence_is_array(fence))
691 return dma_fence_wait(fence, true);
693 /* From i915: Note that if the fence-array was created in
695 * fences. However, we don't currently store which mode the fence-array
697 * private to amdgpu and we should not see any incoming fence-array
701 fence_array = to_dma_fence_array(fence);
716 * vmw_fence_fifo_down - signal all unsignaled fence objects.
732 struct vmw_fence_obj *fence =
735 dma_fence_get(&fence->base);
738 ret = vmw_fence_obj_wait(fence, false, false,
742 list_del_init(&fence->head);
743 dma_fence_signal(&fence->base);
745 list_splice_init(&fence->seq_passed_actions,
750 BUG_ON(!list_empty(&fence->head));
751 dma_fence_put(&fence->base);
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",
790 pr_err("Invalid fence object handle 0x%08lx.\n",
807 struct vmw_fence_obj *fence;
829 fence = &(container_of(base, struct vmw_user_fence, base)->fence);
833 ret = ((vmw_fence_obj_signaled(fence)) ?
840 ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout);
846 * Optionally unref the fence object.
861 struct vmw_fence_obj *fence;
870 fence = &(container_of(base, struct vmw_user_fence, base)->fence);
871 fman = fman_from_fence(fence);
873 arg->signaled = vmw_fence_obj_signaled(fence);
903 * This function is called when the seqno of the fence where @action is
947 vmw_fence_obj_unreference(&eaction->fence);
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,
964 struct vmw_fence_manager *fman = fman_from_fence(fence);
971 if (dma_fence_is_signaled_locked(&fence->base)) {
978 list_add_tail(&action->head, &fence->seq_passed_actions);
984 run_update = vmw_fence_goal_check_locked(fence);
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,
1023 struct vmw_fence_manager *fman = fman_from_fence(fence);
1035 eaction->fence = vmw_fence_obj_reference(fence);
1040 vmw_fence_obj_add_action(fence, &eaction->action);
1051 struct vmw_fence_obj *fence,
1057 struct vmw_fence_manager *fman = fman_from_fence(fence);
1081 ret = vmw_event_fence_action_queue(file_priv, fence,
1087 ret = vmw_event_fence_action_queue(file_priv, fence,
1109 struct vmw_fence_obj *fence = NULL;
1119 * Look up an existing fence object,
1130 fence = &(container_of(base, struct vmw_user_fence,
1131 base)->fence);
1132 (void) vmw_fence_obj_reference(fence);
1138 DRM_ERROR("Failed to reference a fence "
1148 * Create a new fence object.
1150 if (!fence) {
1152 &fence,
1156 DRM_ERROR("Fence event failed to create fence.\n");
1161 BUG_ON(fence == NULL);
1163 ret = vmw_event_fence_action_create(file_priv, fence,
1169 DRM_ERROR("Failed to attach event to fence.\n");
1173 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence,
1175 vmw_fence_obj_unreference(&fence);
1181 vmw_fence_obj_unreference(&fence);