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