Lines Matching full:chain

3  * fence-chain: chain fences together in a timeline
10 #include <linux/dma-fence-chain.h>
16 * @chain: chain node to get the previous node from
19 * chain node.
21 static struct dma_fence *dma_fence_chain_get_prev(struct dma_fence_chain *chain) in dma_fence_chain_get_prev() argument
26 prev = dma_fence_get_rcu_safe(&chain->prev); in dma_fence_chain_get_prev()
32 * dma_fence_chain_walk - chain walking function
33 * @fence: current chain node
35 * Walk the chain to the next node. Returns the next fence or NULL if we are at
36 * the end of the chain. Garbage collects chain nodes which are already
41 struct dma_fence_chain *chain, *prev_chain; in dma_fence_chain_walk() local
44 chain = to_dma_fence_chain(fence); in dma_fence_chain_walk()
45 if (!chain) { in dma_fence_chain_walk()
50 while ((prev = dma_fence_chain_get_prev(chain))) { in dma_fence_chain_walk()
65 tmp = unrcu_pointer(cmpxchg(&chain->prev, RCU_INITIALIZER(prev), in dma_fence_chain_walk()
80 * dma_fence_chain_find_seqno - find fence chain node by seqno
81 * @pfence: pointer to the chain node where to start
84 * Advance the fence pointer to the chain node which will signal this sequence
87 * Returns EINVAL if the fence is not a chain node or the sequence number has
92 struct dma_fence_chain *chain; in dma_fence_chain_find_seqno() local
97 chain = to_dma_fence_chain(*pfence); in dma_fence_chain_find_seqno()
98 if (!chain || chain->base.seqno < seqno) in dma_fence_chain_find_seqno()
101 dma_fence_chain_for_each(*pfence, &chain->base) { in dma_fence_chain_find_seqno()
102 if ((*pfence)->context != chain->base.context || in dma_fence_chain_find_seqno()
106 dma_fence_put(&chain->base); in dma_fence_chain_find_seqno()
124 struct dma_fence_chain *chain; in dma_fence_chain_irq_work() local
126 chain = container_of(work, typeof(*chain), work); in dma_fence_chain_irq_work()
129 if (!dma_fence_chain_enable_signaling(&chain->base)) in dma_fence_chain_irq_work()
131 dma_fence_signal(&chain->base); in dma_fence_chain_irq_work()
132 dma_fence_put(&chain->base); in dma_fence_chain_irq_work()
137 struct dma_fence_chain *chain; in dma_fence_chain_cb() local
139 chain = container_of(cb, typeof(*chain), cb); in dma_fence_chain_cb()
140 init_irq_work(&chain->work, dma_fence_chain_irq_work); in dma_fence_chain_cb()
141 irq_work_queue(&chain->work); in dma_fence_chain_cb()
180 struct dma_fence_chain *chain = to_dma_fence_chain(fence); in dma_fence_chain_release() local
183 /* Manually unlink the chain as much as possible to avoid recursion in dma_fence_chain_release()
186 while ((prev = rcu_dereference_protected(chain->prev, true))) { in dma_fence_chain_release()
199 chain->prev = prev_chain->prev; in dma_fence_chain_release()
205 dma_fence_put(chain->fence); in dma_fence_chain_release()
232 * dma_fence_chain_init - initialize a fence chain
233 * @chain: the chain node to initialize
236 * @seqno: the sequence number to use for the fence chain
238 * Initialize a new chain node and either start a new chain or add the node to
239 * the existing chain of the previous fence.
241 void dma_fence_chain_init(struct dma_fence_chain *chain, in dma_fence_chain_init() argument
249 spin_lock_init(&chain->lock); in dma_fence_chain_init()
250 rcu_assign_pointer(chain->prev, prev); in dma_fence_chain_init()
251 chain->fence = fence; in dma_fence_chain_init()
252 chain->prev_seqno = 0; in dma_fence_chain_init()
254 /* Try to reuse the context of the previous chain node. */ in dma_fence_chain_init()
257 chain->prev_seqno = prev->seqno; in dma_fence_chain_init()
265 dma_fence_init(&chain->base, &dma_fence_chain_ops, in dma_fence_chain_init()
266 &chain->lock, context, seqno); in dma_fence_chain_init()