staticvoid dma_fence_array_set_pending_error(struct dma_fence_array *array, int error)
{ /* * Propagate the first error reported by any of our fences, but only * before we ourselves are signaled.
*/ if (error)
cmpxchg(&array->base.error, PENDING_ERROR, error);
}
staticvoid dma_fence_array_clear_pending_error(struct dma_fence_array *array)
{ /* Clear the error flag if not actually set. */
cmpxchg(&array->base.error, PENDING_ERROR, 0);
}
for (i = 0; i < array->num_fences; ++i) {
cb[i].array = array; /* * As we may report that the fence is signaled before all * callbacks are complete, we need to take an additional * reference count on the array so that we do not free it too * early. The core fence handling will only hold the reference * until we signal the array as complete (but that is now * insufficient).
*/
dma_fence_get(&array->base); if (dma_fence_add_callback(array->fences[i], &cb[i].cb,
dma_fence_array_cb_func)) { int error = array->fences[i]->error;
/* * We need to read num_pending before checking the enable_signal bit * to avoid racing with the enable_signaling() implementation, which * might decrement the counter, and cause a partial check. * atomic_read_acquire() pairs with atomic_dec_and_test() in * dma_fence_array_enable_signaling() * * The !--num_pending check is here to account for the any_signaled case * if we race with enable_signaling(), that means the !num_pending check * in the is_signalling_enabled branch might be outdated (num_pending * might have been decremented), but that's fine. The user will get the * right value when testing again later.
*/
num_pending = atomic_read_acquire(&array->num_pending); if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &array->base.flags)) { if (num_pending <= 0) goto signal; returnfalse;
}
for (i = 0; i < array->num_fences; ++i) { if (dma_fence_is_signaled(array->fences[i]) && !--num_pending) goto signal;
} returnfalse;
/** * dma_fence_array_alloc - Allocate a custom fence array * @num_fences: [in] number of fences to add in the array * * Return dma fence array on success, NULL on failure
*/ struct dma_fence_array *dma_fence_array_alloc(int num_fences)
{ struct dma_fence_array *array;
/** * dma_fence_array_init - Init a custom fence array * @array: [in] dma fence array to arm * @num_fences: [in] number of fences to add in the array * @fences: [in] array containing the fences * @context: [in] fence context to use * @seqno: [in] sequence number to use * @signal_on_any: [in] signal on any fence in the array * * Implementation of @dma_fence_array_create without allocation. Useful to init * a preallocated dma fence array in the path of reclaim or dma fence signaling.
*/ void dma_fence_array_init(struct dma_fence_array *array, int num_fences, struct dma_fence **fences,
u64 context, unsigned seqno, bool signal_on_any)
{
WARN_ON(!num_fences || !fences);
/* * dma_fence_array objects should never contain any other fence * containers or otherwise we run into recursion and potential kernel * stack overflow on operations on the dma_fence_array. * * The correct way of handling this is to flatten out the array by the * caller instead. * * Enforce this here by checking that we don't create a dma_fence_array * with any container inside.
*/ while (num_fences--)
WARN_ON(dma_fence_is_container(fences[num_fences]));
}
EXPORT_SYMBOL(dma_fence_array_init);
/** * dma_fence_array_create - Create a custom fence array * @num_fences: [in] number of fences to add in the array * @fences: [in] array containing the fences * @context: [in] fence context to use * @seqno: [in] sequence number to use * @signal_on_any: [in] signal on any fence in the array * * Allocate a dma_fence_array object and initialize the base fence with * dma_fence_init(). * In case of error it returns NULL. * * The caller should allocate the fences array with num_fences size * and fill it with the fences it wants to add to the object. Ownership of this * array is taken and dma_fence_put() is used on each fence on release. * * If @signal_on_any is true the fence array signals if any fence in the array * signals, otherwise it signals when all fences in the array signal.
*/ struct dma_fence_array *dma_fence_array_create(int num_fences, struct dma_fence **fences,
u64 context, unsigned seqno, bool signal_on_any)
{ struct dma_fence_array *array;
array = dma_fence_array_alloc(num_fences); if (!array) return NULL;
/** * 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) returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.