1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3 *
4 * (C) COPYRIGHT 2013-2014, 2016, 2019-2021 ARM Limited. All rights reserved.
5 *
6 * This program is free software and is provided to you under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation, and any use by you of this program is subject to the terms
9 * of such GNU license.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you can access it online at
18 * http://www.gnu.org/licenses/gpl-2.0.html.
19 *
20 */
21
22 /*
23 * Job manager common APIs
24 */
25
26 #ifndef _KBASE_JM_H_
27 #define _KBASE_JM_H_
28
29 #if !MALI_USE_CSF
30 /**
31 * kbase_jm_kick() - Indicate that there are jobs ready to run.
32 * @kbdev: Device pointer
33 * @js_mask: Mask of the job slots that can be pulled from.
34 *
35 * Caller must hold the hwaccess_lock and schedule_sem semaphore
36 *
37 * Return: Mask of the job slots that can still be submitted to.
38 */
39 u32 kbase_jm_kick(struct kbase_device *kbdev, u32 js_mask);
40
41 /**
42 * kbase_jm_kick_all() - Indicate that there are jobs ready to run on all job
43 * slots.
44 * @kbdev: Device pointer
45 *
46 * Caller must hold the hwaccess_lock and schedule_sem semaphore
47 *
48 * Return: Mask of the job slots that can still be submitted to.
49 */
kbase_jm_kick_all(struct kbase_device *kbdev)50 static inline u32 kbase_jm_kick_all(struct kbase_device *kbdev)
51 {
52 return kbase_jm_kick(kbdev, (1 << kbdev->gpu_props.num_job_slots) - 1);
53 }
54
55 /**
56 * kbase_jm_try_kick - Attempt to call kbase_jm_kick
57 * @kbdev: Device pointer
58 * @js_mask: Mask of the job slots that can be pulled from
59 * Context: Caller must hold hwaccess_lock
60 *
61 * If schedule_sem can be immediately obtained then this function will call
62 * kbase_jm_kick() otherwise it will do nothing.
63 */
64 void kbase_jm_try_kick(struct kbase_device *kbdev, u32 js_mask);
65
66 /**
67 * kbase_jm_try_kick_all() - Attempt to call kbase_jm_kick_all
68 * @kbdev: Device pointer
69 * Context: Caller must hold hwaccess_lock
70 *
71 * If schedule_sem can be immediately obtained then this function will call
72 * kbase_jm_kick_all() otherwise it will do nothing.
73 */
74 void kbase_jm_try_kick_all(struct kbase_device *kbdev);
75 #endif /* !MALI_USE_CSF */
76
77 #if !MALI_USE_CSF
78 /**
79 * kbase_jm_idle_ctx() - Mark a context as idle.
80 * @kbdev: Device pointer
81 * @kctx: Context to mark as idle
82 *
83 * No more atoms will be pulled from this context until it is marked as active
84 * by kbase_js_use_ctx().
85 *
86 * The context should have no atoms currently pulled from it
87 * (kbase_jsctx_atoms_pulled(kctx) == 0).
88 *
89 * Caller must hold the hwaccess_lock
90 */
91 void kbase_jm_idle_ctx(struct kbase_device *kbdev, struct kbase_context *kctx);
92
93 /**
94 * kbase_jm_return_atom_to_js() - Return an atom to the job scheduler that has
95 * been soft-stopped or will fail due to a
96 * dependency
97 * @kbdev: Device pointer
98 * @katom: Atom that has been stopped or will be failed
99 *
100 * Return: Atom that has now been unblocked and can now be run, or NULL if none
101 */
102 struct kbase_jd_atom *kbase_jm_return_atom_to_js(struct kbase_device *kbdev,
103 struct kbase_jd_atom *katom);
104
105 /**
106 * kbase_jm_complete() - Complete an atom
107 * @kbdev: Device pointer
108 * @katom: Atom that has completed
109 * @end_timestamp: Timestamp of atom completion
110 *
111 * Return: Atom that has now been unblocked and can now be run, or NULL if none
112 */
113 struct kbase_jd_atom *kbase_jm_complete(struct kbase_device *kbdev,
114 struct kbase_jd_atom *katom, ktime_t *end_timestamp);
115 #endif /* !MALI_USE_CSF */
116
117 #endif /* _KBASE_JM_H_ */
118