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