History

dma-buf: Add dma_fence_array_for_each (v2)

Add a helper to iterate over all fences in a dma_fence_array object. v2 (Jason Ekstrand) - Return NULL from dma_fence_array_first if head == NULL. This matches the iterator behavior of dma_fence_chain_for_each in that it iterates zero times if head == NULL. - Return NULL from dma_fence_array_next if index > array->num_fences.

Christian König committed 4 years ago

Commit caaf2ae1 parent 7344bad2 files · +44 −0Browse files

Showing the changes to include (1 of 2 files). Show all

Unified · Split

include/linux/dma-fence-array.h+17−0
@@ -61,6 +61,19 @@ to_dma_fence_array(struct dma_fence *fence) · 60 unmodified lines
61 return container_of(fence, struct dma_fence_array, base);61 return container_of(fence, struct dma_fence_array, base);
62}62}
63 63
64/**
65 * dma_fence_array_for_each - iterate over all fences in array
66 * @fence: current fence
67 * @index: index into the array
68 * @head: potential dma_fence_array object
69 *
70 * Test if @array is a dma_fence_array object and if yes iterate over all fences
71 * in the array. If not just iterate over the fence in @array itself.
72 */
73#define dma_fence_array_for_each(fence, index, head) \
74 for (index = 0, fence = dma_fence_array_first(head); fence; \
75 ++(index), fence = dma_fence_array_next(head, index))
76
64struct dma_fence_array *dma_fence_array_create(int num_fences,77struct dma_fence_array *dma_fence_array_create(int num_fences,
65 struct dma_fence **fences,78 struct dma_fence **fences,
66 u64 context, unsigned seqno,79 u64 context, unsigned seqno,
@@ -68,4 +81,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, · 1 unmodified line
68 81
69bool dma_fence_match_context(struct dma_fence *fence, u64 context);82bool dma_fence_match_context(struct dma_fence *fence, u64 context);
70 83
84struct dma_fence *dma_fence_array_first(struct dma_fence *head);
85struct dma_fence *dma_fence_array_next(struct dma_fence *head,
86 unsigned int index);
87
71#endif /* __LINUX_DMA_FENCE_ARRAY_H */88#endif /* __LINUX_DMA_FENCE_ARRAY_H */