// SPDX-License-Identifier: GPL-2.0-only /* * dma-fence-array: aggregate fences to be waited together * * Copyright (C) 2016 Collabora Ltd * Copyright (C) 2016 Advanced Micro Devices, Inc. * Authors: * Gustavo Padovan <[email protected]> * Christian König <[email protected]> */ #include <linux/export.h> #include <linux/slab.h> #include <linux/dma-fence-array.h> #define PENDING_ERROR … static const char *dma_fence_array_get_driver_name(struct dma_fence *fence) { … } static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence) { … } static void dma_fence_array_set_pending_error(struct dma_fence_array *array, int error) { … } static void dma_fence_array_clear_pending_error(struct dma_fence_array *array) { … } static void irq_dma_fence_array_work(struct irq_work *wrk) { … } static void dma_fence_array_cb_func(struct dma_fence *f, struct dma_fence_cb *cb) { … } static bool dma_fence_array_enable_signaling(struct dma_fence *fence) { … } static bool dma_fence_array_signaled(struct dma_fence *fence) { … } static void dma_fence_array_release(struct dma_fence *fence) { … } static void dma_fence_array_set_deadline(struct dma_fence *fence, ktime_t deadline) { … } const struct dma_fence_ops dma_fence_array_ops = …; EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); struct dma_fence *dma_fence_array_first(struct dma_fence *head) { … } EXPORT_SYMBOL(…); struct dma_fence *dma_fence_array_next(struct dma_fence *head, unsigned int index) { … } EXPORT_SYMBOL(…);