diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2017-03-17 12:34:49 -0400 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2017-03-17 14:21:36 -0400 |
commit | d5b72a2123dfaf9416b1a1177b4be041f8a8b6d4 (patch) | |
tree | 13688abc1a544a75f611e0e8256c528762ddc518 /drivers/dma-buf | |
parent | bb7d78568814a31a11fa14f1479a9fe51f1582ad (diff) |
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: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1489768492-25190-1-git-send-email-p.zabel@pengutronix.de
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r-- | drivers/dma-buf/dma-fence-array.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c index 67eb7c8fb88c..0350829ba62e 100644 --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c | |||
@@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, | |||
144 | return array; | 144 | return array; |
145 | } | 145 | } |
146 | EXPORT_SYMBOL(dma_fence_array_create); | 146 | EXPORT_SYMBOL(dma_fence_array_create); |
147 | |||
148 | /** | ||
149 | * dma_fence_match_context - Check if all fences are from the given context | ||
150 | * @fence: [in] fence or fence array | ||
151 | * @context: [in] fence context to check all fences against | ||
152 | * | ||
153 | * Checks the provided fence or, for a fence array, all fences in the array | ||
154 | * against the given context. Returns false if any fence is from a different | ||
155 | * context. | ||
156 | */ | ||
157 | bool dma_fence_match_context(struct dma_fence *fence, u64 context) | ||
158 | { | ||
159 | struct dma_fence_array *array = to_dma_fence_array(fence); | ||
160 | unsigned i; | ||
161 | |||
162 | if (!dma_fence_is_array(fence)) | ||
163 | return fence->context == context; | ||
164 | |||
165 | for (i = 0; i < array->num_fences; i++) { | ||
166 | if (array->fences[i]->context != context) | ||
167 | return false; | ||
168 | } | ||
169 | |||
170 | return true; | ||
171 | } | ||
172 | EXPORT_SYMBOL(dma_fence_match_context); | ||