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);
222 * interrupted, and remaining jiffies if fence has signaled, or 0 if wait
224 * which should be treated as if the fence is signaled. For example a hardware
227 signed long (*wait)(struct dma_fence *fence,
233 * Called on destruction of fence to release additional resources.
238 void (*release)(struct dma_fence *fence);
243 * Callback to fill in free-form debug info specific to this fence, like
248 void (*fence_value_str)(struct dma_fence *fence, char *str, int size);
254 * sequence number. Note that the specific fence passed to this function
258 void (*timeline_value_str)(struct dma_fence *fence,
264 * Callback to allow a fence waiter to inform the fence signaler of
266 * would prefer the fence to be signaled by. This is intended to
267 * give feedback to the fence signaler to aid in power management
279 void (*set_deadline)(struct dma_fence *fence, ktime_t deadline);
282 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
286 void dma_fence_free(struct dma_fence *fence);
287 void dma_fence_describe(struct dma_fence *fence, struct seq_file *seq);
290 * dma_fence_put - decreases refcount of the fence
291 * @fence: fence to reduce refcount of
293 static inline void dma_fence_put(struct dma_fence *fence)
295 if (fence)
296 kref_put(&fence->refcount, dma_fence_release);
300 * dma_fence_get - increases refcount of the fence
301 * @fence: fence to increase refcount of
303 * Returns the same fence, with refcount increased by 1.
305 static inline struct dma_fence *dma_fence_get(struct dma_fence *fence)
307 if (fence)
308 kref_get(&fence->refcount);
309 return fence;
313 * dma_fence_get_rcu - get a fence from a dma_resv_list with
315 * @fence: fence to increase refcount of
317 * Function returns NULL if no refcount could be obtained, or the fence.
319 static inline struct dma_fence *dma_fence_get_rcu(struct dma_fence *fence)
321 if (kref_get_unless_zero(&fence->refcount))
322 return fence;
328 * dma_fence_get_rcu_safe - acquire a reference to an RCU tracked fence
329 * @fencep: pointer to fence to increase refcount of
331 * Function returns NULL if no refcount could be obtained, or the fence.
332 * This function handles acquiring a reference to a fence that may be
334 * so long as the caller is using RCU on the pointer to the fence.
339 * fence is acquired (as shown here).
347 struct dma_fence *fence;
349 fence = rcu_dereference(*fencep);
350 if (!fence)
353 if (!dma_fence_get_rcu(fence))
359 * to the __rcu protected fence pointer so that if that
360 * pointer still matches the current fence, we know we
365 * fence remains valid for the RCU grace period, but it
368 * the right fence, as below.
370 if (fence == rcu_access_pointer(*fencep))
371 return rcu_pointer_handoff(fence);
373 dma_fence_put(fence);
390 int dma_fence_signal(struct dma_fence *fence);
391 int dma_fence_signal_locked(struct dma_fence *fence);
392 int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
393 int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
395 signed long dma_fence_default_wait(struct dma_fence *fence,
397 int dma_fence_add_callback(struct dma_fence *fence,
400 bool dma_fence_remove_callback(struct dma_fence *fence,
402 void dma_fence_enable_sw_signaling(struct dma_fence *fence);
405 * dma_fence_is_signaled_locked - Return an indication if the fence
407 * @fence: the fence to check
409 * Returns true if the fence was already signaled, false if not. Since this
419 dma_fence_is_signaled_locked(struct dma_fence *fence)
421 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
424 if (fence->ops->signaled && fence->ops->signaled(fence)) {
425 dma_fence_signal_locked(fence);
433 * dma_fence_is_signaled - Return an indication if the fence is signaled yet.
434 * @fence: the fence to check
436 * Returns true if the fence was already signaled, false if not. Since this
449 dma_fence_is_signaled(struct dma_fence *fence)
451 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
454 if (fence->ops->signaled && fence->ops->signaled(fence)) {
455 dma_fence_signal(fence);
464 * @f1: the first fence's seqno
465 * @f2: the second fence's seqno from the same context
486 * @f1: the first fence from the same context
487 * @f2: the second fence from the same context
503 * @f1: the first fence from the same context
504 * @f2: the second fence from the same context
506 * Returns true if f1 is chronologically later than f2 or the same fence. Both
517 * dma_fence_later - return the chronologically later fence
518 * @f1: the first fence from the same context
519 * @f2: the second fence from the same context
521 * Returns NULL if both fences are signaled, otherwise the fence that would be
544 * @fence: the dma_fence to query
547 * the fence (to indicate whether the fence was completed due to an error
549 * if the fence has been signaled, dma_fence_get_status_locked() first checks
552 * Returns 0 if the fence has not yet been signaled, 1 if the fence has
554 * if the fence has been completed in err.
556 static inline int dma_fence_get_status_locked(struct dma_fence *fence)
558 if (dma_fence_is_signaled_locked(fence))
559 return fence->error ?: 1;
564 int dma_fence_get_status(struct dma_fence *fence);
567 * dma_fence_set_error - flag an error condition on the fence
568 * @fence: the dma_fence
572 * the fence, to indicate that the fence was completed due to an error
577 static inline void dma_fence_set_error(struct dma_fence *fence,
580 WARN_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags));
583 fence->error = error;
587 * dma_fence_timestamp - helper to get the completion timestamp of a fence
588 * @fence: fence to get the timestamp from.
590 * After a fence is signaled the timestamp is updated with the signaling time,
594 static inline ktime_t dma_fence_timestamp(struct dma_fence *fence)
596 if (WARN_ON(!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)))
599 while (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags))
602 return fence->timestamp;
613 * dma_fence_wait - sleep until the fence gets signaled
614 * @fence: the fence to wait on
618 * or 0 if the fence was signaled. Other error values may be
621 * Performs a synchronous wait on this fence. It is assumed the caller
622 * directly or indirectly holds a reference to the fence, otherwise the
623 * fence might be freed before return, resulting in undefined behavior.
627 static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
635 ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);
640 void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline);
650 * dma_fence_is_array - check if a fence is from the array subclass
651 * @fence: the fence to test
655 static inline bool dma_fence_is_array(struct dma_fence *fence)
657 return fence->ops == &dma_fence_array_ops;
661 * dma_fence_is_chain - check if a fence is from the chain subclass
662 * @fence: the fence to test
666 static inline bool dma_fence_is_chain(struct dma_fence *fence)
668 return fence->ops == &dma_fence_chain_ops;
672 * dma_fence_is_container - check if a fence is a container for other fences
673 * @fence: the fence to test
675 * Return true if this fence is a container for other fences, false otherwise.
676 * This is important since we can't build up large fence structure or otherwise
679 static inline bool dma_fence_is_container(struct dma_fence *fence)
681 return dma_fence_is_array(fence) || dma_fence_is_chain(fence);