Commit d5b72a21 authored by Philipp Zabel's avatar Philipp Zabel Committed by Sumit Semwal

dma-fence: add dma_fence_match_context helper

Add a helper to check if all fences in a fence array are from a given
context. For convenience, the function can also handle being given a
non-array fence.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: default avatarGustavo Padovan <gustavo.padovan@collabora.com>
Acked-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1489768492-25190-1-git-send-email-p.zabel@pengutronix.de
parent bb7d7856
...@@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, ...@@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
return array; return array;
} }
EXPORT_SYMBOL(dma_fence_array_create); EXPORT_SYMBOL(dma_fence_array_create);
/**
* dma_fence_match_context - Check if all fences are from the given context
* @fence: [in] fence or fence array
* @context: [in] fence context to check all fences against
*
* Checks the provided fence or, for a fence array, all fences in the array
* against the given context. Returns false if any fence is from a different
* context.
*/
bool dma_fence_match_context(struct dma_fence *fence, u64 context)
{
struct dma_fence_array *array = to_dma_fence_array(fence);
unsigned i;
if (!dma_fence_is_array(fence))
return fence->context == context;
for (i = 0; i < array->num_fences; i++) {
if (array->fences[i]->context != context)
return false;
}
return true;
}
EXPORT_SYMBOL(dma_fence_match_context);
...@@ -83,4 +83,6 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, ...@@ -83,4 +83,6 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
u64 context, unsigned seqno, u64 context, unsigned seqno,
bool signal_on_any); bool signal_on_any);
bool dma_fence_match_context(struct dma_fence *fence, u64 context);
#endif /* __LINUX_DMA_FENCE_ARRAY_H */ #endif /* __LINUX_DMA_FENCE_ARRAY_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment