Lines Matching refs:fence

32  * @refcount: refcount for this fence
33 * @ops: dma_fence_ops associated with this fence
34 * @rcu: used for releasing fence with kfree_rcu
37 * @context: execution context this fence belongs to, returned by
39 * @seqno: the sequence number of this fence inside the execution context,
40 * can be compared to decide which fence would be signaled later.
42 * @timestamp: Timestamp when the fence was signaled.
44 * dma_fence_signal, indicates that the fence has completed with an error.
50 * DMA_FENCE_FLAG_SIGNALED_BIT - fence is already signaled
51 * DMA_FENCE_FLAG_TIMESTAMP_BIT - timestamp recorded for fence signaling
54 * implementer of the fence for its own purposes. Can be used in different
55 * ways by different fence implementers, so do not rely on this.
71 * release the fence it is unused. No one should be adding to the
80 * and to read either you *must* hold a reference to the fence,
106 typedef void (*dma_fence_func_t)(struct dma_fence *fence,
111 * @node: used by dma_fence_add_callback() to append this struct to fence::cb_list
123 * struct dma_fence_ops - operations implemented for fence
140 * for each fence, or build a cache of some sort.
144 const char * (*get_driver_name)(struct dma_fence *fence);
149 * Return the name of the context this fence belongs to. This is a
151 * having it to store permanently for each fence, or build a cache of
156 const char * (*get_timeline_name)(struct dma_fence *fence);
161 * Enable software signaling of fence.
163 * For fence implementations that have the capability for hw->hw
168 * dma_fence_wait() or dma_fence_add_callback() path to let the fence
175 * A return value of false indicates the fence already passed,
184 * dma_fence_signal() might result in the final fence reference being
187 * released when the fence is signalled (through e.g. the interrupt
193 bool (*enable_signaling)(struct dma_fence *fence);
198 * Peek whether the fence is signaled, as a fastpath optimization for
200 * callback does not need to make any guarantees beyond that a fence
202 * callback. This callback may return false even if the fence has
210 bool (*signaled)(struct dma_fence *fence);
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
228 signed long (*wait)(struct dma_fence *fence,
234 * Called on destruction of fence to release additional resources.
239 void (*release)(struct dma_fence *fence);
244 * Callback to fill in free-form debug info specific to this fence, like
249 void (*fence_value_str)(struct dma_fence *fence, char *str, int size);
255 * sequence number. Note that the specific fence passed to this function
259 void (*timeline_value_str)(struct dma_fence *fence,
265 * Callback to allow a fence waiter to inform the fence signaler of
267 * would prefer the fence to be signaled by. This is intended to
268 * give feedback to the fence signaler to aid in power management
280 void (*set_deadline)(struct dma_fence *fence, ktime_t deadline);
283 void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
287 void dma_fence_free(struct dma_fence *fence);
288 void dma_fence_describe(struct dma_fence *fence, struct seq_file *seq);
291 * dma_fence_put - decreases refcount of the fence
292 * @fence: fence to reduce refcount of
294 static inline void dma_fence_put(struct dma_fence *fence)
296 if (fence)
297 kref_put(&fence->refcount, dma_fence_release);
301 * dma_fence_get - increases refcount of the fence
302 * @fence: fence to increase refcount of
304 * Returns the same fence, with refcount increased by 1.
306 static inline struct dma_fence *dma_fence_get(struct dma_fence *fence)
308 if (fence)
309 kref_get(&fence->refcount);
310 return fence;
314 * dma_fence_get_rcu - get a fence from a dma_resv_list with
316 * @fence: fence to increase refcount of
318 * Function returns NULL if no refcount could be obtained, or the fence.
320 static inline struct dma_fence *dma_fence_get_rcu(struct dma_fence *fence)
322 if (kref_get_unless_zero(&fence->refcount))
323 return fence;
329 * dma_fence_get_rcu_safe - acquire a reference to an RCU tracked fence
330 * @fencep: pointer to fence to increase refcount of
332 * Function returns NULL if no refcount could be obtained, or the fence.
333 * This function handles acquiring a reference to a fence that may be
335 * so long as the caller is using RCU on the pointer to the fence.
340 * fence is acquired (as shown here).
348 struct dma_fence *fence;
350 fence = rcu_dereference(*fencep);
351 if (!fence)
354 if (!dma_fence_get_rcu(fence))
360 * to the __rcu protected fence pointer so that if that
361 * pointer still matches the current fence, we know we
366 * fence remains valid for the RCU grace period, but it
369 * the right fence, as below.
371 if (fence == rcu_access_pointer(*fencep))
372 return rcu_pointer_handoff(fence);
374 dma_fence_put(fence);
391 int dma_fence_signal(struct dma_fence *fence);
392 int dma_fence_signal_locked(struct dma_fence *fence);
393 int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
394 int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
396 signed long dma_fence_default_wait(struct dma_fence *fence,
398 int dma_fence_add_callback(struct dma_fence *fence,
401 bool dma_fence_remove_callback(struct dma_fence *fence,
403 void dma_fence_enable_sw_signaling(struct dma_fence *fence);
406 * dma_fence_is_signaled_locked - Return an indication if the fence
408 * @fence: the fence to check
410 * Returns true if the fence was already signaled, false if not. Since this
420 dma_fence_is_signaled_locked(struct dma_fence *fence)
422 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
425 if (fence->ops->signaled && fence->ops->signaled(fence)) {
426 dma_fence_signal_locked(fence);
434 * dma_fence_is_signaled - Return an indication if the fence is signaled yet.
435 * @fence: the fence to check
437 * Returns true if the fence was already signaled, false if not. Since this
450 dma_fence_is_signaled(struct dma_fence *fence)
452 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
455 if (fence->ops->signaled && fence->ops->signaled(fence)) {
456 dma_fence_signal(fence);
465 * @f1: the first fence's seqno
466 * @f2: the second fence's seqno from the same context
487 * @f1: the first fence from the same context
488 * @f2: the second fence from the same context
504 * @f1: the first fence from the same context
505 * @f2: the second fence from the same context
507 * Returns true if f1 is chronologically later than f2 or the same fence. Both
518 * dma_fence_later - return the chronologically later fence
519 * @f1: the first fence from the same context
520 * @f2: the second fence from the same context
522 * Returns NULL if both fences are signaled, otherwise the fence that would be
545 * @fence: the dma_fence to query
548 * the fence (to indicate whether the fence was completed due to an error
550 * if the fence has been signaled, dma_fence_get_status_locked() first checks
553 * Returns 0 if the fence has not yet been signaled, 1 if the fence has
555 * if the fence has been completed in err.
557 static inline int dma_fence_get_status_locked(struct dma_fence *fence)
559 if (dma_fence_is_signaled_locked(fence))
560 return fence->error ?: 1;
565 int dma_fence_get_status(struct dma_fence *fence);
568 * dma_fence_set_error - flag an error condition on the fence
569 * @fence: the dma_fence
573 * the fence, to indicate that the fence was completed due to an error
578 static inline void dma_fence_set_error(struct dma_fence *fence,
581 WARN_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags));
584 fence->error = error;
588 * dma_fence_timestamp - helper to get the completion timestamp of a fence
589 * @fence: fence to get the timestamp from.
591 * After a fence is signaled the timestamp is updated with the signaling time,
595 static inline ktime_t dma_fence_timestamp(struct dma_fence *fence)
597 if (WARN_ON(!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)))
600 while (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags))
603 return fence->timestamp;
614 * dma_fence_wait - sleep until the fence gets signaled
615 * @fence: the fence to wait on
619 * or 0 if the fence was signaled. Other error values may be
622 * Performs a synchronous wait on this fence. It is assumed the caller
623 * directly or indirectly holds a reference to the fence, otherwise the
624 * fence might be freed before return, resulting in undefined behavior.
628 static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
636 ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);
641 void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline);
651 * dma_fence_is_array - check if a fence is from the array subclass
652 * @fence: the fence to test
656 static inline bool dma_fence_is_array(struct dma_fence *fence)
658 return fence->ops == &dma_fence_array_ops;
662 * dma_fence_is_chain - check if a fence is from the chain subclass
663 * @fence: the fence to test
667 static inline bool dma_fence_is_chain(struct dma_fence *fence)
669 return fence->ops == &dma_fence_chain_ops;
673 * dma_fence_is_container - check if a fence is a container for other fences
674 * @fence: the fence to test
676 * Return true if this fence is a container for other fences, false otherwise.
677 * This is important since we can't build up large fence structure or otherwise
680 static inline bool dma_fence_is_container(struct dma_fence *fence)
682 return dma_fence_is_array(fence) || dma_fence_is_chain(fence);