Merge tag 'v4.4-rc3'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / backend / gpu / mali_kbase_js_affinity.h
1 /*
2  *
3  * (C) COPYRIGHT 2011-2015 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 #ifdef CONFIG_MALI_DEBUG_SHADER_SPLIT_FS
29 /* Import the external affinity mask variables */
30 extern u64 mali_js0_affinity_mask;
31 extern u64 mali_js1_affinity_mask;
32 extern u64 mali_js2_affinity_mask;
33 #endif /* CONFIG_MALI_DEBUG_SHADER_SPLIT_FS */
34
35
36 /**
37  * @addtogroup base_api
38  * @{
39  */
40
41 /**
42  * @addtogroup base_kbase_api
43  * @{
44  */
45
46 /**
47  * @addtogroup kbase_js_affinity Affinity Manager internal APIs.
48  * @{
49  *
50  */
51
52 /**
53  * @brief Decide whether it is possible to submit a job to a particular job slot
54  * in the current status
55  *
56  * Will check if submitting to the given job slot is allowed in the current
57  * status.  For example using job slot 2 while in soft-stoppable state and only
58  * having 1 coregroup is not allowed by the policy. This function should be
59  * called prior to submitting a job to a slot to make sure policy rules are not
60  * violated.
61  *
62  * The following locking conditions are made on the caller:
63  * - it must hold kbasep_js_device_data::runpool_irq::lock
64  *
65  * @param kbdev The kbase device structure of the device
66  * @param js    Job slot number to check for allowance
67  */
68 bool kbase_js_can_run_job_on_slot_no_lock(struct kbase_device *kbdev,
69                                                                         int js);
70
71 /**
72  * @brief Compute affinity for a given job.
73  *
74  * Currently assumes an all-on/all-off power management policy.
75  * Also assumes there is at least one core with tiler available.
76  *
77  * Returns true if a valid affinity was chosen, false if
78  * no cores were available.
79  *
80  * @param[out] affinity       Affinity bitmap computed
81  * @param kbdev The kbase device structure of the device
82  * @param katom Job chain of which affinity is going to be found
83  * @param js    Slot the job chain is being submitted
84  */
85 bool kbase_js_choose_affinity(u64 * const affinity,
86                                         struct kbase_device *kbdev,
87                                         struct kbase_jd_atom *katom,
88                                         int js);
89
90 /**
91  * @brief Determine whether a proposed \a affinity on job slot \a js would
92  * cause a violation of affinity restrictions.
93  *
94  * The following locks must be held by the caller:
95  * - kbasep_js_device_data::runpool_irq::lock
96  */
97 bool kbase_js_affinity_would_violate(struct kbase_device *kbdev, int js,
98                                                                 u64 affinity);
99
100 /**
101  * @brief Affinity tracking: retain cores used by a slot
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_retain_slot_cores(struct kbase_device *kbdev, int js,
107                                                                 u64 affinity);
108
109 /**
110  * @brief Affinity tracking: release cores used by a slot
111  *
112  * Cores \b must be released as soon as a job is dequeued from a slot's 'submit
113  * slots', and before another job is submitted to those slots. Otherwise, the
114  * refcount could exceed the maximum number submittable to a slot,
115  * BASE_JM_SUBMIT_SLOTS.
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_release_slot_cores(struct kbase_device *kbdev, int js,
121                                                                 u64 affinity);
122
123 /**
124  * @brief Output to the Trace log the current tracked affinities on all slots
125  */
126 #if KBASE_TRACE_ENABLE
127 void kbase_js_debug_log_current_affinities(struct kbase_device *kbdev);
128 #else                           /*  KBASE_TRACE_ENABLE  */
129 static inline void
130 kbase_js_debug_log_current_affinities(struct kbase_device *kbdev)
131 {
132 }
133 #endif                          /*  KBASE_TRACE_ENABLE  */
134
135           /** @} *//* end group kbase_js_affinity */
136           /** @} *//* end group base_kbase_api */
137           /** @} *//* end group base_api */
138
139
140 #endif                          /* _KBASE_JS_AFFINITY_H_ */