[PATCH] dma-buf: add dma_fence_chain_for_each_unwrap helper v2

Chris Wilson chris at chris-wilson.co.uk
Wed Jul 31 09:34:25 UTC 2019


Quoting Christian König (2019-07-31 10:22:17)
> Add another for_each helper to iterate over all the fences in a chain
> with unwrapping each chain node.
> 
> v2: fix typos, simplify and rename the new helper
> 
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
>  static bool dma_fence_chain_signaled(struct dma_fence *fence)
>  {
> -       dma_fence_chain_for_each(fence, fence) {
> -               struct dma_fence_chain *chain = to_dma_fence_chain(fence);
> -               struct dma_fence *f = chain ? chain->fence : fence;
> +       struct dma_fence *f;
>  
> +       dma_fence_chain_for_each_fence(f, fence, fence) {

for_each_fence(fence, fence, fence) :)

No bright ideas, I did look at how consistent it would be to call the
arguments chain, maybe head? But then for_each_fence(f, head, head), so
not much of improvement.

> +/**
> + * dma_fence_chain_for_each_fences - iterate over all unwrapped fences in chain
One last typo, dma_fence_chain_for_each_fence.

> + * @fence: the unwrapped fence
> + * @iter: current fence
> + * @head: starting point
> + *
> + * Iterate over all fences in the chain with unwrapping. We keep a reference to
> + * the current chain node while inside the loop which must be dropped when breaking
> + * out.
> + */
> +#define dma_fence_chain_for_each_fence(fence, iter, head)      \
> +       for (iter = dma_fence_get(head);                        \
> +            (fence = dma_fence_chain_unwrap(iter));            \
> +            iter = dma_fence_chain_walk(iter))

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the dri-devel mailing list