eb068d40283b25ad994aa1039e74e6e2556fcf17
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard_for_linux / backend / gpu / mali_kbase_jm_internal.h
1 /*
2  *
3  * (C) COPYRIGHT 2011-2015 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  * Job Manager backend-specific low-level APIs.
22  */
23
24 #ifndef _KBASE_JM_HWACCESS_H_
25 #define _KBASE_JM_HWACCESS_H_
26
27 #include <mali_kbase_hw.h>
28 #include <mali_kbase_debug.h>
29 #include <linux/atomic.h>
30
31 #include <backend/gpu/mali_kbase_jm_rb.h>
32
33 /**
34  * kbase_job_submit_nolock() - Submit a job to a certain job-slot
35  * @kbdev:      Device pointer
36  * @katom:      Atom to submit
37  * @js:         Job slot to submit on
38  *
39  * The caller must check kbasep_jm_is_submit_slots_free() != false before
40  * calling this.
41  *
42  * The following locking conditions are made on the caller:
43  * - it must hold the kbasep_js_device_data::runpoool_irq::lock
44  */
45 void kbase_job_submit_nolock(struct kbase_device *kbdev,
46                                         struct kbase_jd_atom *katom, int js);
47
48 /**
49  * kbase_job_done_slot() - Complete the head job on a particular job-slot
50  * @kbdev:              Device pointer
51  * @s:                  Job slot
52  * @completion_code:    Completion code of job reported by GPU
53  * @job_tail:           Job tail address reported by GPU
54  * @end_timestamp:      Timestamp of job completion
55  */
56 void kbase_job_done_slot(struct kbase_device *kbdev, int s, u32 completion_code,
57                                         u64 job_tail, ktime_t *end_timestamp);
58
59 #ifdef CONFIG_GPU_TRACEPOINTS
60 static inline char *kbasep_make_job_slot_string(int js, char *js_string)
61 {
62         sprintf(js_string, "job_slot_%i", js);
63         return js_string;
64 }
65 #endif
66
67 /**
68  * kbase_job_hw_submit() - Submit a job to the GPU
69  * @kbdev:      Device pointer
70  * @katom:      Atom to submit
71  * @js:         Job slot to submit on
72  *
73  * The caller must check kbasep_jm_is_submit_slots_free() != false before
74  * calling this.
75  *
76  * The following locking conditions are made on the caller:
77  * - it must hold the kbasep_js_device_data::runpoool_irq::lock
78  */
79 void kbase_job_hw_submit(struct kbase_device *kbdev,
80                                 struct kbase_jd_atom *katom,
81                                 int js);
82
83 /**
84  * kbasep_job_slot_soft_or_hard_stop_do_action() - Perform a soft or hard stop
85  *                                                 on the specified atom
86  * @kbdev:              Device pointer
87  * @js:                 Job slot to stop on
88  * @action:             The action to perform, either JSn_COMMAND_HARD_STOP or
89  *                      JSn_COMMAND_SOFT_STOP
90  * @core_reqs:          Core requirements of atom to stop
91  * @target_katom:       Atom to stop
92  *
93  * The following locking conditions are made on the caller:
94  * - it must hold the kbasep_js_device_data::runpool_irq::lock
95  */
96 void kbasep_job_slot_soft_or_hard_stop_do_action(struct kbase_device *kbdev,
97                                         int js,
98                                         u32 action,
99                                         u16 core_reqs,
100                                         struct kbase_jd_atom *target_katom);
101
102 /**
103  * kbase_backend_soft_hard_stop_slot() - Soft or hard stop jobs on a given job
104  *                                       slot belonging to a given context.
105  * @kbdev:      Device pointer
106  * @kctx:       Context pointer. May be NULL
107  * @katom:      Specific atom to stop. May be NULL
108  * @js:         Job slot to hard stop
109  * @action:     The action to perform, either JSn_COMMAND_HARD_STOP or
110  *              JSn_COMMAND_SOFT_STOP
111  *
112  * If no context is provided then all jobs on the slot will be soft or hard
113  * stopped.
114  *
115  * If a katom is provided then only that specific atom will be stopped. In this
116  * case the kctx parameter is ignored.
117  *
118  * Jobs that are on the slot but are not yet on the GPU will be unpulled and
119  * returned to the job scheduler.
120  *
121  * Return: true if an atom was stopped, false otherwise
122  */
123 bool kbase_backend_soft_hard_stop_slot(struct kbase_device *kbdev,
124                                         struct kbase_context *kctx,
125                                         int js,
126                                         struct kbase_jd_atom *katom,
127                                         u32 action);
128
129 /**
130  * kbase_job_slot_init - Initialise job slot framework
131  * @kbdev: Device pointer
132  *
133  * Called on driver initialisation
134  *
135  * Return: 0 on success
136  */
137 int kbase_job_slot_init(struct kbase_device *kbdev);
138
139 /**
140  * kbase_job_slot_halt - Halt the job slot framework
141  * @kbdev: Device pointer
142  *
143  * Should prevent any further job slot processing
144  */
145 void kbase_job_slot_halt(struct kbase_device *kbdev);
146
147 /**
148  * kbase_job_slot_term - Terminate job slot framework
149  * @kbdev: Device pointer
150  *
151  * Called on driver termination
152  */
153 void kbase_job_slot_term(struct kbase_device *kbdev);
154
155 #endif /* _KBASE_JM_HWACCESS_H_ */