rk3288 gpu : update GPU driver r4p0_eac version
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_kbase_js_affinity.h
1 /*
2  *
3  * (C) COPYRIGHT ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 /**
21  * @file mali_kbase_js_affinity.h
22  * Affinity Manager internal APIs.
23  */
24
25 #ifndef _KBASE_JS_AFFINITY_H_
26 #define _KBASE_JS_AFFINITY_H_
27
28 /**
29  * @addtogroup base_api
30  * @{
31  */
32
33 /**
34  * @addtogroup base_kbase_api
35  * @{
36  */
37
38 /**
39  * @addtogroup kbase_js_affinity Affinity Manager internal APIs.
40  * @{
41  *
42  */
43
44 /**
45  * @brief Decide whether it is possible to submit a job to a particular job slot in the current status
46  *
47  * Will check if submitting to the given job slot is allowed in the current
48  * status.  For example using job slot 2 while in soft-stoppable state and only
49  * having 1 coregroup is not allowed by the policy. This function should be
50  * called prior to submitting a job to a slot to make sure policy rules are not
51  * violated.
52  *
53  * The following locking conditions are made on the caller:
54  * - it must hold kbasep_js_device_data::runpool_irq::lock
55  *
56  * @param kbdev The kbase device structure of the device
57  * @param js    Job slot number to check for allowance
58  */
59 mali_bool kbase_js_can_run_job_on_slot_no_lock(kbase_device *kbdev, int js);
60
61 /**
62  * @brief Compute affinity for a given job.
63  *
64  * Currently assumes an all-on/all-off power management policy.
65  * Also assumes there is at least one core with tiler available.
66  *
67  * Returns MALI_TRUE if a valid affinity was chosen, MALI_FALSE if
68  * no cores were available.
69  *
70  * @param[out] affinity       Affinity bitmap computed
71  * @param kbdev The kbase device structure of the device
72  * @param katom Job chain of which affinity is going to be found
73  * @param js    Slot the job chain is being submitted
74
75  */
76 mali_bool kbase_js_choose_affinity(u64 * const affinity, kbase_device *kbdev, kbase_jd_atom *katom, int js);
77
78 /**
79  * @brief Determine whether a proposed \a affinity on job slot \a js would
80  * cause a violation of affinity restrictions.
81  *
82  * The following locks must be held by the caller:
83  * - kbasep_js_device_data::runpool_irq::lock
84  */
85 mali_bool kbase_js_affinity_would_violate(kbase_device *kbdev, int js, u64 affinity);
86
87 /**
88  * @brief Affinity tracking: retain cores used by a slot
89  *
90  * The following locks must be held by the caller:
91  * - kbasep_js_device_data::runpool_irq::lock
92  */
93 void kbase_js_affinity_retain_slot_cores(kbase_device *kbdev, int js, u64 affinity);
94
95 /**
96  * @brief Affinity tracking: release cores used by a slot
97  *
98  * Cores \b must be released as soon as a job is dequeued from a slot's 'submit
99  * slots', and before another job is submitted to those slots. Otherwise, the
100  * refcount could exceed the maximum number submittable to a slot,
101  * BASE_JM_SUBMIT_SLOTS.
102  *
103  * The following locks must be held by the caller:
104  * - kbasep_js_device_data::runpool_irq::lock
105  */
106 void kbase_js_affinity_release_slot_cores(kbase_device *kbdev, int js, u64 affinity);
107
108 /**
109  * @brief Register a slot as blocking atoms due to affinity violations
110  *
111  * Once a slot has been registered, we must check after every atom completion
112  * (including those on different slots) to see if the slot can be
113  * unblocked. This is done by calling
114  * kbase_js_affinity_submit_to_blocked_slots(), which will also deregister the
115  * slot if it no long blocks atoms due to affinity violations.
116  *
117  * The following locks must be held by the caller:
118  * - kbasep_js_device_data::runpool_irq::lock
119  */
120 void kbase_js_affinity_slot_blocked_an_atom(kbase_device *kbdev, int js);
121
122 /**
123  * @brief Submit to job slots that have registered that an atom was blocked on
124  * the slot previously due to affinity violations.
125  *
126  * This submits to all slots registered by
127  * kbase_js_affinity_slot_blocked_an_atom(). If submission succeeded, then the
128  * slot is deregistered as having blocked atoms due to affinity
129  * violations. Otherwise it stays registered, and the next atom to complete
130  * must attempt to submit to the blocked slots again.
131  *
132  * This must only be called whilst the GPU is powered - for example, when
133  * kbdev->jsdata.nr_user_contexts_running > 0.
134  *
135  * The following locking conditions are made on the caller:
136  * - it must hold kbasep_js_device_data::runpool_mutex
137  * - it must hold kbasep_js_device_data::runpool_irq::lock
138  */
139 void kbase_js_affinity_submit_to_blocked_slots(kbase_device *kbdev);
140
141 /**
142  * @brief Output to the Trace log the current tracked affinities on all slots
143  */
144 #if KBASE_TRACE_ENABLE != 0
145 void kbase_js_debug_log_current_affinities(kbase_device *kbdev);
146 #else                           /*  KBASE_TRACE_ENABLE != 0 */
147 static INLINE void kbase_js_debug_log_current_affinities(kbase_device *kbdev)
148 {
149 }
150 #endif                          /*  KBASE_TRACE_ENABLE != 0 */
151
152           /** @} *//* end group kbase_js_affinity */
153           /** @} *//* end group base_kbase_api */
154           /** @} *//* end group base_api */
155
156
157 #endif                          /* _KBASE_JS_AFFINITY_H_ */