signal: Fix sending signals with siginfo
[cris-mirror.git] / include / linux / dma-fence-array.h
blob332a5420243c44f1b9e8c4d5bbf20d64637b1950
1 /*
2 * fence-array: aggregates fence to be waited together
4 * Copyright (C) 2016 Collabora Ltd
5 * Copyright (C) 2016 Advanced Micro Devices, Inc.
6 * Authors:
7 * Gustavo Padovan <gustavo@padovan.org>
8 * Christian König <christian.koenig@amd.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
20 #ifndef __LINUX_DMA_FENCE_ARRAY_H
21 #define __LINUX_DMA_FENCE_ARRAY_H
23 #include <linux/dma-fence.h>
25 /**
26 * struct dma_fence_array_cb - callback helper for fence array
27 * @cb: fence callback structure for signaling
28 * @array: reference to the parent fence array object
30 struct dma_fence_array_cb {
31 struct dma_fence_cb cb;
32 struct dma_fence_array *array;
35 /**
36 * struct dma_fence_array - fence to represent an array of fences
37 * @base: fence base class
38 * @lock: spinlock for fence handling
39 * @num_fences: number of fences in the array
40 * @num_pending: fences in the array still pending
41 * @fences: array of the fences
43 struct dma_fence_array {
44 struct dma_fence base;
46 spinlock_t lock;
47 unsigned num_fences;
48 atomic_t num_pending;
49 struct dma_fence **fences;
52 extern const struct dma_fence_ops dma_fence_array_ops;
54 /**
55 * dma_fence_is_array - check if a fence is from the array subsclass
56 * @fence: fence to test
58 * Return true if it is a dma_fence_array and false otherwise.
60 static inline bool dma_fence_is_array(struct dma_fence *fence)
62 return fence->ops == &dma_fence_array_ops;
65 /**
66 * to_dma_fence_array - cast a fence to a dma_fence_array
67 * @fence: fence to cast to a dma_fence_array
69 * Returns NULL if the fence is not a dma_fence_array,
70 * or the dma_fence_array otherwise.
72 static inline struct dma_fence_array *
73 to_dma_fence_array(struct dma_fence *fence)
75 if (fence->ops != &dma_fence_array_ops)
76 return NULL;
78 return container_of(fence, struct dma_fence_array, base);
81 struct dma_fence_array *dma_fence_array_create(int num_fences,
82 struct dma_fence **fences,
83 u64 context, unsigned seqno,
84 bool signal_on_any);
86 bool dma_fence_match_context(struct dma_fence *fence, u64 context);
88 #endif /* __LINUX_DMA_FENCE_ARRAY_H */