Lines Matching refs:fence
62 struct vmw_fence_obj fence;
66 * struct vmw_event_fence_action - fence action that delivers a drm event.
69 * @action: A struct vmw_fence_action to hook up to a fence.
70 * @fence: A referenced pointer to the fence to keep it alive while @action
76 * current time tv_sec val when the fence signals.
78 * be assigned the current time tv_usec val when the fence signals.
84 struct vmw_fence_obj *fence;
92 fman_from_fence(struct vmw_fence_obj *fence)
94 return container_of(fence->base.lock, struct vmw_fence_manager, lock);
101 * a) When a new fence seqno has been submitted by the fifo code.
104 * irq is received. When the last fence waiter is gone, that IRQ is masked
108 * fence objects may not be signaled. This is perfectly OK, since there are
109 * no consumers of the signaled data, but that is NOT ok when there are fence
110 * actions attached to a fence. The fencing subsystem then makes use of the
111 * FENCE_GOAL irq and sets the fence goal seqno to that of the next fence
113 * the subsystem makes sure the fence goal seqno is updated.
115 * The fence goal seqno irq is on as long as there are unsignaled fence
121 struct vmw_fence_obj *fence =
124 struct vmw_fence_manager *fman = fman_from_fence(fence);
127 list_del_init(&fence->head);
130 fence->destroy(fence);
145 struct vmw_fence_obj *fence =
148 struct vmw_fence_manager *fman = fman_from_fence(fence);
153 if (seqno - fence->base.seqno < VMW_FENCE_WRAP)
171 vmwgfx_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
177 DRM_SPIN_WAKEUP_ALL(&wait->wq, fence->lock);
187 struct vmw_fence_obj *fence =
190 struct vmw_fence_manager *fman = fman_from_fence(fence);
195 if (likely(vmw_fence_obj_signaled(fence)))
237 * fence spinlock.
378 struct vmw_fence_obj *fence, u32 seqno,
379 void (*destroy) (struct vmw_fence_obj *fence))
383 dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
385 INIT_LIST_HEAD(&fence->seq_passed_actions);
386 fence->destroy = destroy;
393 list_add_tail(&fence->head, &fman->fence_list);
423 * vmw_fence_goal_new_locked - Figure out a new device fence goal
426 * @fman: Pointer to a fence manager.
429 * This function should be called with the fence manager lock held.
431 * we might need to update the fence goal. It checks to see whether
432 * the current fence goal has already passed, and, in that case,
433 * scans through all unsignaled fences to get the next fence object with an
434 * action attached, and sets the seqno of that fence as a new fence goal.
443 struct vmw_fence_obj *fence;
454 list_for_each_entry(fence, &fman->fence_list, head) {
455 if (!list_empty(&fence->seq_passed_actions)) {
457 vmw_mmio_write(fence->base.seqno,
468 * vmw_fence_goal_check_locked - Replace the device fence goal seqno if
471 * @fence: Pointer to a struct vmw_fence_obj the seqno of which should be
472 * considered as a device fence goal.
474 * This function should be called with the fence manager lock held.
475 * It is typically called when an action has been attached to a fence to
476 * check whether the seqno of that fence should be used for a fence
477 * goal interrupt. This is typically needed if the current fence goal is
478 * invalid, or has a higher seqno than that of the current fence object.
482 static bool vmw_fence_goal_check_locked(struct vmw_fence_obj *fence)
484 struct vmw_fence_manager *fman = fman_from_fence(fence);
488 if (dma_fence_is_signaled_locked(&fence->base))
494 goal_seqno - fence->base.seqno < VMW_FENCE_WRAP))
497 vmw_mmio_write(fence->base.seqno, fifo_mem + SVGA_FIFO_FENCE_GOAL);
505 struct vmw_fence_obj *fence, *next_fence;
513 list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) {
514 if (seqno - fence->base.seqno < VMW_FENCE_WRAP) {
515 list_del_init(&fence->head);
516 dma_fence_signal_locked(&fence->base);
518 list_splice_init(&fence->seq_passed_actions,
526 * Rerun if the fence goal seqno was updated, and the
551 bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence)
553 struct vmw_fence_manager *fman = fman_from_fence(fence);
555 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags))
560 return dma_fence_is_signaled(&fence->base);
563 int vmw_fence_obj_wait(struct vmw_fence_obj *fence, bool lazy,
566 long ret = dma_fence_wait_timeout(&fence->base, interruptible, timeout);
576 void vmw_fence_obj_flush(struct vmw_fence_obj *fence)
578 struct vmw_private *dev_priv = fman_from_fence(fence)->dev_priv;
583 static void vmw_fence_destroy(struct vmw_fence_obj *fence)
585 dma_fence_free(&fence->base);
592 struct vmw_fence_obj *fence;
595 fence = kzalloc(sizeof(*fence), GFP_KERNEL);
596 fence))
599 ret = vmw_fence_obj_init(fman, fence, seqno,
604 *p_fence = fence;
608 kfree(fence);
613 static void vmw_user_fence_destroy(struct vmw_fence_obj *fence)
616 container_of(fence, struct vmw_user_fence, fence);
617 struct vmw_fence_manager *fman = fman_from_fence(fence);
632 struct vmw_fence_obj *fence = &ufence->fence;
635 vmw_fence_obj_unreference(&fence);
670 ret = vmw_fence_obj_init(fman, &ufence->fence, seqno,
681 tmp = vmw_fence_obj_reference(&ufence->fence);
695 *p_fence = &ufence->fence;
700 tmp = &ufence->fence;
709 * vmw_wait_dma_fence - Wait for a dma fence
711 * @fman: pointer to a fence manager
712 * @fence: DMA fence to wait on
714 * This function handles the case when the fence is actually a fence
715 * array. If that's the case, it'll wait on each of the child fence
718 struct dma_fence *fence)
725 if (dma_fence_is_signaled(fence))
728 if (!dma_fence_is_array(fence))
729 return dma_fence_wait(fence, true);
731 /* From i915: Note that if the fence-array was created in
733 * fences. However, we don't currently store which mode the fence-array
735 * private to amdgpu and we should not see any incoming fence-array
739 fence_array = to_dma_fence_array(fence);
754 * vmw_fence_fifo_down - signal all unsignaled fence objects.
770 struct vmw_fence_obj *fence =
773 dma_fence_get(&fence->base);
776 ret = vmw_fence_obj_wait(fence, false, false,
780 list_del_init(&fence->head);
781 dma_fence_signal(&fence->base);
783 list_splice_init(&fence->seq_passed_actions,
788 BUG_ON(!list_empty(&fence->head));
789 dma_fence_put(&fence->base);
804 * vmw_fence_obj_lookup - Look up a user-space fence object
807 * @handle: A handle identifying the fence object.
811 * The fence object is looked up and type-checked. The caller needs
812 * to have opened the fence object first, but since that happens on
813 * creation and fence objects aren't shareable, that's not an
822 pr_err("Invalid fence object handle 0x%08lx.\n",
828 pr_err("Invalid fence object handle 0x%08lx.\n",
845 struct vmw_fence_obj *fence;
867 fence = &(container_of(base, struct vmw_user_fence, base)->fence);
871 ret = ((vmw_fence_obj_signaled(fence)) ?
878 ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout);
884 * Optionally unref the fence object.
899 struct vmw_fence_obj *fence;
908 fence = &(container_of(base, struct vmw_user_fence, base)->fence);
909 fman = fman_from_fence(fence);
911 arg->signaled = vmw_fence_obj_signaled(fence);
944 * This function is called when the seqno of the fence where @action is
988 vmw_fence_obj_unreference(&eaction->fence);
994 * vmw_fence_obj_add_action - Add an action to a fence object.
996 * @fence - The fence object.
1002 static void vmw_fence_obj_add_action(struct vmw_fence_obj *fence,
1005 struct vmw_fence_manager *fman = fman_from_fence(fence);
1012 if (dma_fence_is_signaled_locked(&fence->base)) {
1019 list_add_tail(&action->head, &fence->seq_passed_actions);
1025 run_update = vmw_fence_goal_check_locked(fence);
1042 * vmw_event_fence_action_create - Post an event for sending when a fence
1046 * @fence: The fence object on which to post the event.
1057 struct vmw_fence_obj *fence,
1064 struct vmw_fence_manager *fman = fman_from_fence(fence);
1076 eaction->fence = vmw_fence_obj_reference(fence);
1081 vmw_fence_obj_add_action(fence, &eaction->action);
1092 struct vmw_fence_obj *fence,
1098 struct vmw_fence_manager *fman = fman_from_fence(fence);
1122 ret = vmw_event_fence_action_queue(file_priv, fence,
1128 ret = vmw_event_fence_action_queue(file_priv, fence,
1150 struct vmw_fence_obj *fence = NULL;
1160 * Look up an existing fence object,
1171 fence = &(container_of(base, struct vmw_user_fence,
1172 base)->fence);
1173 (void) vmw_fence_obj_reference(fence);
1179 DRM_ERROR("Failed to reference a fence "
1189 * Create a new fence object.
1191 if (!fence) {
1193 &fence,
1197 DRM_ERROR("Fence event failed to create fence.\n");
1202 BUG_ON(fence == NULL);
1204 ret = vmw_event_fence_action_create(file_priv, fence,
1210 DRM_ERROR("Failed to attach event to fence.\n");
1214 vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence,
1216 vmw_fence_obj_unreference(&fence);
1222 vmw_fence_obj_unreference(&fence);