Lines Matching refs:fence
38 static const char *vgem_fence_get_driver_name(struct dma_fence *fence)
43 static const char *vgem_fence_get_timeline_name(struct dma_fence *fence)
50 struct vgem_fence *fence = container_of(base, typeof(*fence), base);
52 del_timer_sync(&fence->timer);
53 dma_fence_free(&fence->base);
56 static void vgem_fence_value_str(struct dma_fence *fence, char *str, int size)
58 snprintf(str, size, "%llu", fence->seqno);
61 static void vgem_fence_timeline_value_str(struct dma_fence *fence, char *str,
65 dma_fence_is_signaled(fence) ? fence->seqno : 0);
79 struct vgem_fence *fence = from_timer(fence, t, timer);
81 dma_fence_signal(&fence->base);
87 struct vgem_fence *fence;
89 fence = kzalloc(sizeof(*fence), GFP_KERNEL);
90 if (!fence)
93 spin_lock_init(&fence->lock);
94 dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
97 timer_setup(&fence->timer, vgem_fence_timeout, 0);
99 /* We force the fence to expire within 10s to prevent driver hangs */
100 mod_timer(&fence->timer, jiffies + VGEM_FENCE_TIMEOUT);
102 return &fence->base;
108 * Create and attach a fence to the vGEM handle. This fence is then exposed
110 * dma-buf. If the flags contain VGEM_FENCE_WRITE, the fence indicates the
112 * fence, otherwise the fence indicates the client is current reading from the
114 * completion. Note that if a conflicting fence is already on the dma-buf (i.e.
115 * an exclusive fence when adding a read, or any fence when adding a write),
119 * This returns the handle for the new fence that must be signaled within 10
133 struct dma_fence *fence;
146 fence = vgem_fence_create(vfile, arg->flags);
147 if (!fence) {
152 /* Check for a conflicting fence */
160 /* Expose the fence via the dma-buf */
164 dma_resv_add_excl_fence(resv, fence);
166 dma_resv_add_shared_fence(resv, fence);
169 /* Record the fence in our idr for later signaling */
172 ret = idr_alloc(&vfile->fence_idr, fence, 1, 0, GFP_KERNEL);
181 dma_fence_signal(fence);
182 dma_fence_put(fence);
192 * Signal and consume a fence ealier attached to a vGEM handle using
198 * Signaling a fence indicates to all consumers of the dma-buf that the
199 * client has completed the operation associated with the fence, and that the
202 * If the fence does not exist (or has already been signaled by the client),
211 struct dma_fence *fence;
218 fence = idr_replace(&vfile->fence_idr, NULL, arg->fence);
220 if (!fence)
222 if (IS_ERR(fence))
223 return PTR_ERR(fence);
225 if (dma_fence_is_signaled(fence))
228 dma_fence_signal(fence);
229 dma_fence_put(fence);