MALI: rockchip: upgrade midgard DDK to r14p0-01rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_kbase_jm.h
1 /*
2  *
3  * (C) COPYRIGHT 2014, 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  * Job manager common APIs
21  */
22
23 #ifndef _KBASE_JM_H_
24 #define _KBASE_JM_H_
25
26 /**
27  * kbase_jm_kick() - Indicate that there are jobs ready to run.
28  * @kbdev:      Device pointer
29  * @js_mask:    Mask of the job slots that can be pulled from.
30  *
31  * Caller must hold the hwaccess_lock and schedule_sem semaphore
32  *
33  * Return: Mask of the job slots that can still be submitted to.
34  */
35 u32 kbase_jm_kick(struct kbase_device *kbdev, u32 js_mask);
36
37 /**
38  * kbase_jm_kick_all() - Indicate that there are jobs ready to run on all job
39  *                       slots.
40  * @kbdev:      Device pointer
41  *
42  * Caller must hold the hwaccess_lock and schedule_sem semaphore
43  *
44  * Return: Mask of the job slots that can still be submitted to.
45  */
46 static inline u32 kbase_jm_kick_all(struct kbase_device *kbdev)
47 {
48         return kbase_jm_kick(kbdev, (1 << kbdev->gpu_props.num_job_slots) - 1);
49 }
50
51 /**
52  * kbase_jm_try_kick - Attempt to call kbase_jm_kick
53  * @kbdev:   Device pointer
54  * @js_mask: Mask of the job slots that can be pulled from
55  * Context: Caller must hold hwaccess_lock
56  *
57  * If schedule_sem can be immediately obtained then this function will call
58  * kbase_jm_kick() otherwise it will do nothing.
59  */
60 void kbase_jm_try_kick(struct kbase_device *kbdev, u32 js_mask);
61
62 /**
63  * kbase_jm_try_kick_all() - Attempt to call kbase_jm_kick_all
64  * @kbdev:  Device pointer
65  * Context: Caller must hold hwaccess_lock
66  *
67  * If schedule_sem can be immediately obtained then this function will call
68  * kbase_jm_kick_all() otherwise it will do nothing.
69  */
70 void kbase_jm_try_kick_all(struct kbase_device *kbdev);
71
72 /**
73  * kbase_jm_idle_ctx() - Mark a context as idle.
74  * @kbdev:      Device pointer
75  * @kctx:       Context to mark as idle
76  *
77  * No more atoms will be pulled from this context until it is marked as active
78  * by kbase_js_use_ctx().
79  *
80  * The context should have no atoms currently pulled from it
81  * (kctx->atoms_pulled == 0).
82  *
83  * Caller must hold the hwaccess_lock
84  */
85 void kbase_jm_idle_ctx(struct kbase_device *kbdev, struct kbase_context *kctx);
86
87 /**
88  * kbase_jm_return_atom_to_js() - Return an atom to the job scheduler that has
89  *                                been soft-stopped or will fail due to a
90  *                                dependency
91  * @kbdev:      Device pointer
92  * @katom:      Atom that has been stopped or will be failed
93  *
94  * Return: Atom that has now been unblocked and can now be run, or NULL if none
95  */
96 struct kbase_jd_atom *kbase_jm_return_atom_to_js(struct kbase_device *kbdev,
97                         struct kbase_jd_atom *katom);
98
99 /**
100  * kbase_jm_complete() - Complete an atom
101  * @kbdev:              Device pointer
102  * @katom:              Atom that has completed
103  * @end_timestamp:      Timestamp of atom completion
104  *
105  * Return: Atom that has now been unblocked and can now be run, or NULL if none
106  */
107 struct kbase_jd_atom *kbase_jm_complete(struct kbase_device *kbdev,
108                 struct kbase_jd_atom *katom, ktime_t *end_timestamp);
109
110 #endif /* _KBASE_JM_H_ */