summaryrefslogtreecommitdiff
path: root/mali-midgard-16.0/backend/gpu/mali_kbase_js_affinity.h
blob: 35d9781ae092c60c9bae4d8a4320e883ded0ea8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 *
 * (C) COPYRIGHT 2011-2016 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU licence.
 *
 * A copy of the licence is included with the program, and can also be obtained
 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 */





/*
 * Affinity Manager internal APIs.
 */

#ifndef _KBASE_JS_AFFINITY_H_
#define _KBASE_JS_AFFINITY_H_

/**
 * kbase_js_can_run_job_on_slot_no_lock - Decide whether it is possible to
 * submit a job to a particular job slot in the current status
 *
 * @kbdev: The kbase device structure of the device
 * @js:    Job slot number to check for allowance
 *
 * Will check if submitting to the given job slot is allowed in the current
 * status.  For example using job slot 2 while in soft-stoppable state and only
 * having 1 coregroup is not allowed by the policy. This function should be
 * called prior to submitting a job to a slot to make sure policy rules are not
 * violated.
 *
 * The following locking conditions are made on the caller
 * - it must hold hwaccess_lock
 */
bool kbase_js_can_run_job_on_slot_no_lock(struct kbase_device *kbdev, int js);

/**
 * kbase_js_choose_affinity - Compute affinity for a given job.
 *
 * @affinity: Affinity bitmap computed
 * @kbdev:    The kbase device structure of the device
 * @katom:    Job chain of which affinity is going to be found
 * @js:       Slot the job chain is being submitted
 *
 * Currently assumes an all-on/all-off power management policy.
 * Also assumes there is at least one core with tiler available.
 *
 * Returns true if a valid affinity was chosen, false if
 * no cores were available.
 */
bool kbase_js_choose_affinity(u64 * const affinity,
					struct kbase_device *kbdev,
					struct kbase_jd_atom *katom,
					int js);

/**
 * kbase_js_affinity_would_violate - Determine whether a proposed affinity on
 * job slot @js would cause a violation of affinity restrictions.
 *
 * @kbdev:    Kbase device structure
 * @js:       The job slot to test
 * @affinity: The affinity mask to test
 *
 * The following locks must be held by the caller
 * - hwaccess_lock
 *
 * Return: true if the affinity would violate the restrictions
 */
bool kbase_js_affinity_would_violate(struct kbase_device *kbdev, int js,
								u64 affinity);

/**
 * kbase_js_affinity_retain_slot_cores - Affinity tracking: retain cores used by
 *                                       a slot
 *
 * @kbdev:    Kbase device structure
 * @js:       The job slot retaining the cores
 * @affinity: The cores to retain
 *
 * The following locks must be held by the caller
 * - hwaccess_lock
 */
void kbase_js_affinity_retain_slot_cores(struct kbase_device *kbdev, int js,
								u64 affinity);

/**
 * kbase_js_affinity_release_slot_cores - Affinity tracking: release cores used
 *                                        by a slot
 *
 * @kbdev:    Kbase device structure
 * @js:       Job slot
 * @affinity: Bit mask of core to be released
 *
 * Cores must be released as soon as a job is dequeued from a slot's 'submit
 * slots', and before another job is submitted to those slots. Otherwise, the
 * refcount could exceed the maximum number submittable to a slot,
 * %BASE_JM_SUBMIT_SLOTS.
 *
 * The following locks must be held by the caller
 * - hwaccess_lock
 */
void kbase_js_affinity_release_slot_cores(struct kbase_device *kbdev, int js,
								u64 affinity);

/**
 * kbase_js_debug_log_current_affinities - log the current affinities
 *
 * @kbdev:  Kbase device structure
 *
 * Output to the Trace log the current tracked affinities on all slots
 */
#if KBASE_TRACE_ENABLE
void kbase_js_debug_log_current_affinities(struct kbase_device *kbdev);
#else				/*  KBASE_TRACE_ENABLE  */
static inline void
kbase_js_debug_log_current_affinities(struct kbase_device *kbdev)
{
}
#endif				/*  KBASE_TRACE_ENABLE  */

#endif				/* _KBASE_JS_AFFINITY_H_ */