2 * Copyright (C) 2012-2016 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 * @file mali_dma_fence.h
14 * Mali interface for Linux dma buf fence objects.
17 #ifndef _MALI_DMA_FENCE_H_
18 #define _MALI_DMA_FENCE_H_
20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
21 #include <linux/fence.h>
22 #include <linux/reservation.h>
25 struct mali_dma_fence_context;
27 /* The mali dma fence context callback function */
28 typedef void (*mali_dma_fence_context_callback_func_t)(void *pp_job_ptr);
30 struct mali_dma_fence_waiter {
32 struct mali_dma_fence_context *parent;
36 struct mali_dma_fence_context {
37 struct work_struct work_handle;
38 struct mali_dma_fence_waiter **mali_dma_fence_waiters;
39 u32 num_dma_fence_waiter;
41 void *pp_job_ptr; /* the mali pp job pointer */;
42 mali_dma_fence_context_callback_func_t cb_func;
46 * @param context The execution context this fence is run on
47 * @param seqno A linearly increasing sequence number for this context
48 * @return the new dma fence if success, or NULL on failure.
50 struct fence *mali_dma_fence_new(u32 context, u32 seqno);
52 /* Signal and put dma fence
53 * @param fence The dma fence to signal and put
55 void mali_dma_fence_signal_and_put(struct fence **fence);
58 * Initialize a mali dma fence context for pp job.
59 * @param dma_fence_context The mali dma fence context to initialize.
60 * @param cb_func The dma fence context callback function to call when all dma fence release.
61 * @param pp_job_ptr The pp_job to call function with.
63 void mali_dma_fence_context_init(struct mali_dma_fence_context *dma_fence_context,
64 mali_dma_fence_context_callback_func_t cb_func,
68 * Add new mali dma fence waiter into mali dma fence context
69 * @param dma_fence_context The mali dma fence context
70 * @param dma_reservation_object the reservation object to create new mali dma fence waiters
71 * @return _MALI_OSK_ERR_OK if success, or not.
73 _mali_osk_errcode_t mali_dma_fence_context_add_waiters(struct mali_dma_fence_context *dma_fence_context,
74 struct reservation_object *dma_reservation_object);
77 * Release the dma fence context
78 * @param dma_fence_text The mali dma fence context.
80 void mali_dma_fence_context_term(struct mali_dma_fence_context *dma_fence_context);
83 * Decrease the dma fence context atomic count
84 * @param dma_fence_text The mali dma fence context.
86 void mali_dma_fence_context_dec_count(struct mali_dma_fence_context *dma_fence_context);
89 * Get all reservation object
90 * @param dma_reservation_object The reservation object to add into the reservation object list
91 * @param dma_reservation_object_list The reservation object list to store all reservation object
92 * @param num_dma_reservation_object The number of all reservation object
94 void mali_dma_fence_add_reservation_object_list(struct reservation_object *dma_reservation_object,
95 struct reservation_object **dma_reservation_object_list,
96 u32 *num_dma_reservation_object);
99 * Wait/wound mutex lock to lock all reservation object.
101 int mali_dma_fence_lock_reservation_object_list(struct reservation_object **dma_reservation_object_list,
102 u32 num_dma_reservation_object, struct ww_acquire_ctx *ww_actx);
105 * Wait/wound mutex lock to unlock all reservation object.
107 void mali_dma_fence_unlock_reservation_object_list(struct reservation_object **dma_reservation_object_list,
108 u32 num_dma_reservation_object, struct ww_acquire_ctx *ww_actx);