Lines Matching refs:fence

31  * @refcount: refcount for this fence
32 * @ops: dma_fence_ops associated with this fence
33 * @rcu: used for releasing fence with kfree_rcu
36 * @context: execution context this fence belongs to, returned by
38 * @seqno: the sequence number of this fence inside the execution context,
39 * can be compared to decide which fence would be signaled later.
41 * @timestamp: Timestamp when the fence was signaled.
43 * dma_fence_signal, indicates that the fence has completed with an error.
49 * DMA_FENCE_FLAG_SIGNALED_BIT - fence is already signaled
50 * DMA_FENCE_FLAG_TIMESTAMP_BIT - timestamp recorded for fence signaling
53 * implementer of the fence for its own purposes. Can be used in different
54 * ways by different fence implementers, so do not rely on this.
70 * release the fence it is unused. No one should be adding to the
79 * and to read either you *must* hold a reference to the fence,
105 typedef void (*dma_fence_func_t)(struct dma_fence *fence,
110 * @node: used by dma_fence_add_callback() to append this struct to fence::cb_list
122 * struct dma_fence_ops - operations implemented for fence
139 * for each fence, or build a cache of some sort.
143 const char * (*get_driver_name)(struct dma_fence *fence);
148 * Return the name of the context this fence belongs to. This is a
150 * having it to store permanently for each fence, or build a cache of
155 const char * (*get_timeline_name)(struct dma_fence *fence);
160 * Enable software signaling of fence.
162 * For fence implementations that have the capability for hw->hw
167 * dma_fence_wait() or dma_fence_add_callback() path to let the fence
174 * A return value of false indicates the fence already passed,
183 * dma_fence_signal() might result in the final fence reference being
186 * released when the fence is signalled (through e.g. the interrupt
192 bool (*enable_signaling)(struct dma_fence *fence);
197 * Peek whether the fence is signaled, as a fastpath optimization for
199 * callback does not need to make any guarantees beyond that a fence
201 * callback. This callback may return false even if the fence has
209 bool (*signaled)(struct dma_fence *fence);
217 * The dma_fence_default_wait implementation should work for any fence, as long
224 * interrupted, and remaining jiffies if fence has signaled, or 0 if wait
226 * which should be treated as if the fence is signaled. For example a hardware
231 signed long (*wait)(struct dma_fence *fence,
237 * Called on destruction of fence to release additional resources.
242 void (*release)(struct dma_fence *fence);
247 * Callback to fill in free-form debug info specific to this fence, like
252 void (*fence_value_str)(struct dma_fence *fence, char *str, int size);
258 * sequence number. Note that the specific fence passed to this function
262 void (*timeline_value_str)(struct dma_fence *fence,
266 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
270 void dma_fence_free(struct dma_fence *fence);
273 * dma_fence_put - decreases refcount of the fence
274 * @fence: fence to reduce refcount of
276 static inline void dma_fence_put(struct dma_fence *fence)
278 if (fence)
279 kref_put(&fence->refcount, dma_fence_release);
283 * dma_fence_get - increases refcount of the fence
284 * @fence: fence to increase refcount of
286 * Returns the same fence, with refcount increased by 1.
288 static inline struct dma_fence *dma_fence_get(struct dma_fence *fence)
290 if (fence)
291 kref_get(&fence->refcount);
292 return fence;
296 * dma_fence_get_rcu - get a fence from a dma_resv_list with
298 * @fence: fence to increase refcount of
300 * Function returns NULL if no refcount could be obtained, or the fence.
302 static inline struct dma_fence *dma_fence_get_rcu(struct dma_fence *fence)
304 if (kref_get_unless_zero(&fence->refcount))
305 return fence;
311 * dma_fence_get_rcu_safe - acquire a reference to an RCU tracked fence
312 * @fencep: pointer to fence to increase refcount of
314 * Function returns NULL if no refcount could be obtained, or the fence.
315 * This function handles acquiring a reference to a fence that may be
317 * so long as the caller is using RCU on the pointer to the fence.
322 * fence is acquired (as shown here).
330 struct dma_fence *fence;
332 fence = rcu_dereference(*fencep);
333 if (!fence)
336 if (!dma_fence_get_rcu(fence))
342 * to the __rcu protected fence pointer so that if that
343 * pointer still matches the current fence, we know we
348 * fence remains valid for the RCU grace period, but it
351 * the right fence, as below.
353 if (fence == rcu_access_pointer(*fencep))
354 return rcu_pointer_handoff(fence);
356 dma_fence_put(fence);
373 int dma_fence_signal(struct dma_fence *fence);
374 int dma_fence_signal_locked(struct dma_fence *fence);
375 signed long dma_fence_default_wait(struct dma_fence *fence,
377 int dma_fence_add_callback(struct dma_fence *fence,
380 bool dma_fence_remove_callback(struct dma_fence *fence,
382 void dma_fence_enable_sw_signaling(struct dma_fence *fence);
385 * dma_fence_is_signaled_locked - Return an indication if the fence
387 * @fence: the fence to check
389 * Returns true if the fence was already signaled, false if not. Since this
399 dma_fence_is_signaled_locked(struct dma_fence *fence)
401 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
404 if (fence->ops->signaled && fence->ops->signaled(fence)) {
405 dma_fence_signal_locked(fence);
413 * dma_fence_is_signaled - Return an indication if the fence is signaled yet.
414 * @fence: the fence to check
416 * Returns true if the fence was already signaled, false if not. Since this
429 dma_fence_is_signaled(struct dma_fence *fence)
431 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
434 if (fence->ops->signaled && fence->ops->signaled(fence)) {
435 dma_fence_signal(fence);
444 * @f1: the first fence's seqno
445 * @f2: the second fence's seqno from the same context
466 * @f1: the first fence from the same context
467 * @f2: the second fence from the same context
482 * dma_fence_later - return the chronologically later fence
483 * @f1: the first fence from the same context
484 * @f2: the second fence from the same context
486 * Returns NULL if both fences are signaled, otherwise the fence that would be
509 * @fence: the dma_fence to query
512 * the fence (to indicate whether the fence was completed due to an error
514 * if the fence has been signaled, dma_fence_get_status_locked() first checks
517 * Returns 0 if the fence has not yet been signaled, 1 if the fence has
519 * if the fence has been completed in err.
521 static inline int dma_fence_get_status_locked(struct dma_fence *fence)
523 if (dma_fence_is_signaled_locked(fence))
524 return fence->error ?: 1;
529 int dma_fence_get_status(struct dma_fence *fence);
532 * dma_fence_set_error - flag an error condition on the fence
533 * @fence: the dma_fence
537 * the fence, to indicate that the fence was completed due to an error
542 static inline void dma_fence_set_error(struct dma_fence *fence,
545 WARN_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags));
548 fence->error = error;
559 * dma_fence_wait - sleep until the fence gets signaled
560 * @fence: the fence to wait on
564 * or 0 if the fence was signaled. Other error values may be
567 * Performs a synchronous wait on this fence. It is assumed the caller
568 * directly or indirectly holds a reference to the fence, otherwise the
569 * fence might be freed before return, resulting in undefined behavior.
573 static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
581 ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);