@@ -144,37 +144,38 @@ const struct dma_fence_ops dma_fence_array_ops = {
144
144
EXPORT_SYMBOL (dma_fence_array_ops );
145
145
146
146
/**
147
- * dma_fence_array_create - Create a custom fence array
147
+ * dma_fence_array_alloc - Allocate a custom fence array
148
+ * @num_fences: [in] number of fences to add in the array
149
+ *
150
+ * Return dma fence array on success, NULL on failure
151
+ */
152
+ struct dma_fence_array * dma_fence_array_alloc (int num_fences )
153
+ {
154
+ struct dma_fence_array * array ;
155
+
156
+ return kzalloc (struct_size (array , callbacks , num_fences ), GFP_KERNEL );
157
+ }
158
+ EXPORT_SYMBOL (dma_fence_array_alloc );
159
+
160
+ /**
161
+ * dma_fence_array_init - Init a custom fence array
162
+ * @array: [in] dma fence array to arm
148
163
* @num_fences: [in] number of fences to add in the array
149
164
* @fences: [in] array containing the fences
150
165
* @context: [in] fence context to use
151
166
* @seqno: [in] sequence number to use
152
167
* @signal_on_any: [in] signal on any fence in the array
153
168
*
154
- * Allocate a dma_fence_array object and initialize the base fence with
155
- * dma_fence_init().
156
- * In case of error it returns NULL.
157
- *
158
- * The caller should allocate the fences array with num_fences size
159
- * and fill it with the fences it wants to add to the object. Ownership of this
160
- * array is taken and dma_fence_put() is used on each fence on release.
161
- *
162
- * If @signal_on_any is true the fence array signals if any fence in the array
163
- * signals, otherwise it signals when all fences in the array signal.
169
+ * Implementation of @dma_fence_array_create without allocation. Useful to init
170
+ * a preallocated dma fence array in the path of reclaim or dma fence signaling.
164
171
*/
165
- struct dma_fence_array * dma_fence_array_create ( int num_fences ,
166
- struct dma_fence * * fences ,
167
- u64 context , unsigned seqno ,
168
- bool signal_on_any )
172
+ void dma_fence_array_init ( struct dma_fence_array * array ,
173
+ int num_fences , struct dma_fence * * fences ,
174
+ u64 context , unsigned seqno ,
175
+ bool signal_on_any )
169
176
{
170
- struct dma_fence_array * array ;
171
-
172
177
WARN_ON (!num_fences || !fences );
173
178
174
- array = kzalloc (struct_size (array , callbacks , num_fences ), GFP_KERNEL );
175
- if (!array )
176
- return NULL ;
177
-
178
179
array -> num_fences = num_fences ;
179
180
180
181
spin_lock_init (& array -> lock );
@@ -200,6 +201,41 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
200
201
*/
201
202
while (num_fences -- )
202
203
WARN_ON (dma_fence_is_container (fences [num_fences ]));
204
+ }
205
+ EXPORT_SYMBOL (dma_fence_array_init );
206
+
207
+ /**
208
+ * dma_fence_array_create - Create a custom fence array
209
+ * @num_fences: [in] number of fences to add in the array
210
+ * @fences: [in] array containing the fences
211
+ * @context: [in] fence context to use
212
+ * @seqno: [in] sequence number to use
213
+ * @signal_on_any: [in] signal on any fence in the array
214
+ *
215
+ * Allocate a dma_fence_array object and initialize the base fence with
216
+ * dma_fence_init().
217
+ * In case of error it returns NULL.
218
+ *
219
+ * The caller should allocate the fences array with num_fences size
220
+ * and fill it with the fences it wants to add to the object. Ownership of this
221
+ * array is taken and dma_fence_put() is used on each fence on release.
222
+ *
223
+ * If @signal_on_any is true the fence array signals if any fence in the array
224
+ * signals, otherwise it signals when all fences in the array signal.
225
+ */
226
+ struct dma_fence_array * dma_fence_array_create (int num_fences ,
227
+ struct dma_fence * * fences ,
228
+ u64 context , unsigned seqno ,
229
+ bool signal_on_any )
230
+ {
231
+ struct dma_fence_array * array ;
232
+
233
+ array = dma_fence_array_alloc (num_fences );
234
+ if (!array )
235
+ return NULL ;
236
+
237
+ dma_fence_array_init (array , num_fences , fences ,
238
+ context , seqno , signal_on_any );
203
239
204
240
return array ;
205
241
}
0 commit comments