ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_dma_fence.h
1 /*
2  * Copyright (C) 2012-2016 ARM Limited. All rights reserved.
3  * 
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.
6  * 
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.
9  */
10
11 /**
12  * @file mali_dma_fence.h
13  *
14  * Mali interface for Linux dma buf fence objects.
15  */
16
17 #ifndef _MALI_DMA_FENCE_H_
18 #define _MALI_DMA_FENCE_H_
19
20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
21 #include <linux/fence.h>
22 #include <linux/reservation.h>
23 #endif
24
25 struct mali_dma_fence_context;
26
27 /* The mali dma fence context callback function */
28 typedef void (*mali_dma_fence_context_callback_func_t)(void *pp_job_ptr);
29
30 struct mali_dma_fence_waiter {
31         struct fence_cb base;
32         struct mali_dma_fence_context *parent;
33         struct fence *fence;
34 };
35
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;
40         atomic_t count;
41         void *pp_job_ptr; /* the mali pp job pointer */;
42         mali_dma_fence_context_callback_func_t cb_func;
43 };
44
45 /* Create a dma fence
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.
49  */
50 struct fence *mali_dma_fence_new(u32  context, u32 seqno);
51
52 /* Signal and put dma fence
53  * @param fence The dma fence to signal and put
54  */
55 void mali_dma_fence_signal_and_put(struct fence **fence);
56
57 /**
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.
62  */
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,
65                                  void *pp_job_ptr);
66
67 /**
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.
72  */
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);
75
76 /**
77  * Release the dma fence context
78  * @param dma_fence_text The mali dma fence context.
79  */
80 void mali_dma_fence_context_term(struct mali_dma_fence_context *dma_fence_context);
81
82 /**
83  * Decrease the dma fence context atomic count
84  * @param dma_fence_text The mali dma fence context.
85  */
86 void mali_dma_fence_context_dec_count(struct mali_dma_fence_context *dma_fence_context);
87
88 /**
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
93  */
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);
97
98 /**
99  * Wait/wound mutex lock to lock all reservation object.
100  */
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);
103
104 /**
105  * Wait/wound mutex lock to unlock all reservation object.
106  */
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);
109 #endif