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, struct dma_fence_cb *cb);
109 * @node: used by dma_fence_add_callback() to append this struct to fence::cb_list
121 * struct dma_fence_ops - operations implemented for fence
138 * for each fence, or build a cache of some sort.
142 const char *(*get_driver_name)(struct dma_fence *fence);
147 * Return the name of the context this fence belongs to. This is a
149 * having it to store permanently for each fence, or build a cache of
154 const char *(*get_timeline_name)(struct dma_fence *fence);
159 * Enable software signaling of fence.
161 * For fence implementations that have the capability for hw->hw
166 * dma_fence_wait() or dma_fence_add_callback() path to let the fence
173 * A return value of false indicates the fence already passed,
182 * dma_fence_signal() might result in the final fence reference being
185 * released when the fence is signalled (through e.g. the interrupt
191 bool (*enable_signaling)(struct dma_fence *fence);
196 * Peek whether the fence is signaled, as a fastpath optimization for
198 * callback does not need to make any guarantees beyond that a fence
200 * callback. This callback may return false even if the fence has
208 bool (*signaled)(struct dma_fence *fence);
216 * The dma_fence_default_wait implementation should work for any fence, as long
223 * interrupted, and remaining jiffies if fence has signaled, or 0 if wait
225 * which should be treated as if the fence is signaled. For example a hardware
230 signed long (*wait)(struct dma_fence *fence, bool intr, signed long timeout);
235 * Called on destruction of fence to release additional resources.
240 void (*release)(struct dma_fence *fence);
245 * Callback to fill in free-form debug info specific to this fence, like
250 void (*fence_value_str)(struct dma_fence *fence, char *str, int size);
256 * sequence number. Note that the specific fence passed to this function
260 void (*timeline_value_str)(struct dma_fence *fence, char *str, int size);
263 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, spinlock_t *lock, u64 context, u64 seqno);
266 void dma_fence_free(struct dma_fence *fence);
269 * dma_fence_put - decreases refcount of the fence
270 * @fence: fence to reduce refcount of
272 static inline void dma_fence_put(struct dma_fence *fence)
274 if (fence) {
275 kref_put(&fence->refcount, dma_fence_release);
280 * dma_fence_get - increases refcount of the fence
281 * @fence: fence to increase refcount of
283 * Returns the same fence, with refcount increased by 1.
285 static inline struct dma_fence *dma_fence_get(struct dma_fence *fence)
287 if (fence) {
288 kref_get(&fence->refcount);
290 return fence;
294 * dma_fence_get_rcu - get a fence from a dma_resv_list with
296 * @fence: fence to increase refcount of
298 * Function returns NULL if no refcount could be obtained, or the fence.
300 static inline struct dma_fence *dma_fence_get_rcu(struct dma_fence *fence)
302 if (kref_get_unless_zero(&fence->refcount)) {
303 return fence;
310 * dma_fence_get_rcu_safe - acquire a reference to an RCU tracked fence
311 * @fencep: pointer to fence to increase refcount of
313 * Function returns NULL if no refcount could be obtained, or the fence.
314 * This function handles acquiring a reference to a fence that may be
316 * so long as the caller is using RCU on the pointer to the fence.
321 * fence is acquired (as shown here).
328 struct dma_fence *fence;
330 fence = rcu_dereference(*fencep);
331 if (!fence) {
335 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);
357 dma_fence_put(fence);
378 int dma_fence_signal(struct dma_fence *fence);
379 int dma_fence_signal_locked(struct dma_fence *fence);
380 int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
381 int dma_fence_signal_timestamp_locked(struct dma_fence *fence, ktime_t timestamp);
382 signed long dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout);
383 int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func);
384 bool dma_fence_remove_callback(struct dma_fence *fence, struct dma_fence_cb *cb);
385 void dma_fence_enable_sw_signaling(struct dma_fence *fence);
388 * dma_fence_is_signaled_locked - Return an indication if the fence
390 * @fence: the fence to check
392 * Returns true if the fence was already signaled, false if not. Since this
401 static inline bool dma_fence_is_signaled_locked(struct dma_fence *fence)
403 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
407 if (fence->ops->signaled && fence->ops->signaled(fence)) {
408 dma_fence_signal_locked(fence);
416 * dma_fence_is_signaled - Return an indication if the fence is signaled yet.
417 * @fence: the fence to check
419 * Returns true if the fence was already signaled, false if not. Since this
431 static inline bool dma_fence_is_signaled(struct dma_fence *fence)
433 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
437 if (fence->ops->signaled && fence->ops->signaled(fence)) {
438 dma_fence_signal(fence);
447 * @f1: the first fence's seqno
448 * @f2: the second fence's seqno from the same context
469 * @f1: the first fence from the same context
470 * @f2: the second fence from the same context
485 * dma_fence_later - return the chronologically later fence
486 * @f1: the first fence from the same context
487 * @f2: the second fence from the same context
489 * Returns NULL if both fences are signaled, otherwise the fence that would be
513 * @fence: the dma_fence to query
516 * the fence (to indicate whether the fence was completed due to an error
518 * if the fence has been signaled, dma_fence_get_status_locked() first checks
521 * Returns 0 if the fence has not yet been signaled, 1 if the fence has
523 * if the fence has been completed in err.
525 static inline int dma_fence_get_status_locked(struct dma_fence *fence)
527 if (dma_fence_is_signaled_locked(fence)) {
528 return fence->error ?: 1;
534 int dma_fence_get_status(struct dma_fence *fence);
537 * dma_fence_set_error - flag an error condition on the fence
538 * @fence: the dma_fence
542 * the fence, to indicate that the fence was completed due to an error
547 static inline void dma_fence_set_error(struct dma_fence *fence, int error)
549 WARN_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags));
552 fence->error = error;
560 * dma_fence_wait - sleep until the fence gets signaled
561 * @fence: the fence to wait on
565 * or 0 if the fence was signaled. Other error values may be
568 * Performs a synchronous wait on this fence. It is assumed the caller
569 * directly or indirectly holds a reference to the fence, otherwise the
570 * fence might be freed before return, resulting in undefined behavior.
574 static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
582 ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);