3 * (C) COPYRIGHT ARM Limited. All rights reserved.
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
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.
21 * @file mali_kbase_js_affinity.h
22 * Affinity Manager internal APIs.
25 #ifndef _KBASE_JS_AFFINITY_H_
26 #define _KBASE_JS_AFFINITY_H_
29 * @addtogroup base_api
34 * @addtogroup base_kbase_api
39 * @addtogroup kbase_js_affinity Affinity Manager internal APIs.
45 * @brief Decide whether it is possible to submit a job to a particular job slot in the current status
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
53 * The following locking conditions are made on the caller:
54 * - it must hold kbasep_js_device_data::runpool_irq::lock
56 * @param kbdev The kbase device structure of the device
57 * @param js Job slot number to check for allowance
59 mali_bool kbase_js_can_run_job_on_slot_no_lock(kbase_device *kbdev, int js);
62 * @brief Compute affinity for a given job.
64 * Currently assumes an all-on/all-off power management policy.
65 * Also assumes there is at least one core with tiler available.
67 * Returns MALI_TRUE if a valid affinity was chosen, MALI_FALSE if
68 * no cores were available.
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
76 mali_bool kbase_js_choose_affinity(u64 * const affinity, kbase_device *kbdev, kbase_jd_atom *katom, int js);
79 * @brief Determine whether a proposed \a affinity on job slot \a js would
80 * cause a violation of affinity restrictions.
82 * The following locks must be held by the caller:
83 * - kbasep_js_device_data::runpool_irq::lock
85 mali_bool kbase_js_affinity_would_violate(kbase_device *kbdev, int js, u64 affinity);
88 * @brief Affinity tracking: retain cores used by a slot
90 * The following locks must be held by the caller:
91 * - kbasep_js_device_data::runpool_irq::lock
93 void kbase_js_affinity_retain_slot_cores(kbase_device *kbdev, int js, u64 affinity);
96 * @brief Affinity tracking: release cores used by a slot
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.
103 * The following locks must be held by the caller:
104 * - kbasep_js_device_data::runpool_irq::lock
106 void kbase_js_affinity_release_slot_cores(kbase_device *kbdev, int js, u64 affinity);
109 * @brief Register a slot as blocking atoms due to affinity violations
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.
117 * The following locks must be held by the caller:
118 * - kbasep_js_device_data::runpool_irq::lock
120 void kbase_js_affinity_slot_blocked_an_atom(kbase_device *kbdev, int js);
123 * @brief Submit to job slots that have registered that an atom was blocked on
124 * the slot previously due to affinity violations.
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.
132 * This must only be called whilst the GPU is powered - for example, when
133 * kbdev->jsdata.nr_user_contexts_running > 0.
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
139 void kbase_js_affinity_submit_to_blocked_slots(kbase_device *kbdev);
142 * @brief Output to the Trace log the current tracked affinities on all slots
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)
150 #endif /* KBASE_TRACE_ENABLE != 0 */
152 /** @} *//* end group kbase_js_affinity */
153 /** @} *//* end group base_kbase_api */
154 /** @} *//* end group base_api */
157 #endif /* _KBASE_JS_AFFINITY_H_ */