MALI: utgard: upgrade DDK to r6p1-01rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / common / mali_pp_job.h
1 /*
2  * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
3  * 
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  * 
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 #ifndef __MALI_PP_JOB_H__
12 #define __MALI_PP_JOB_H__
13
14 #include "mali_osk.h"
15 #include "mali_osk_list.h"
16 #include "mali_uk_types.h"
17 #include "mali_session.h"
18 #include "mali_kernel_common.h"
19 #include "regs/mali_200_regs.h"
20 #include "mali_kernel_core.h"
21 #include "mali_dlbu.h"
22 #include "mali_timeline.h"
23 #include "mali_scheduler.h"
24 #include "mali_executor.h"
25 #if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
26 #include "linux/mali_memory_dma_buf.h"
27 #endif
28
29 typedef enum pp_job_status {
30         MALI_NO_SWAP_IN,
31         MALI_SWAP_IN_FAIL,
32         MALI_SWAP_IN_SUCC,
33 } pp_job_status;
34
35 /**
36  * This structure represents a PP job, including all sub jobs.
37  *
38  * The PP job object itself is not protected by any single lock,
39  * but relies on other locks instead (scheduler, executor and timeline lock).
40  * Think of the job object as moving between these sub systems through-out
41  * its lifetime. Different part of the PP job struct is used by different
42  * subsystems. Accessor functions ensure that correct lock is taken.
43  * Do NOT access any data members directly from outside this module!
44  */
45 struct mali_pp_job {
46         /*
47          * These members are typically only set at creation,
48          * and only read later on.
49          * They do not require any lock protection.
50          */
51         _mali_uk_pp_start_job_s uargs;                     /**< Arguments from user space */
52         struct mali_session_data *session;                 /**< Session which submitted this job */
53         u32 pid;                                           /**< Process ID of submitting process */
54         u32 tid;                                           /**< Thread ID of submitting thread */
55         u32 id;                                            /**< Identifier for this job in kernel space (sequential numbering) */
56         u32 cache_order;                                   /**< Cache order used for L2 cache flushing (sequential numbering) */
57         struct mali_timeline_tracker tracker;              /**< Timeline tracker for this job */
58         _mali_osk_notification_t *finished_notification;   /**< Notification sent back to userspace on job complete */
59         u32 perf_counter_per_sub_job_count;                /**< Number of values in the two arrays which is != MALI_HW_CORE_NO_COUNTER */
60         u32 perf_counter_per_sub_job_src0[_MALI_PP_MAX_SUB_JOBS]; /**< Per sub job counters src0 */
61         u32 perf_counter_per_sub_job_src1[_MALI_PP_MAX_SUB_JOBS]; /**< Per sub job counters src1 */
62         u32 sub_jobs_num;                                  /**< Number of subjobs; set to 1 for Mali-450 if DLBU is used, otherwise equals number of PP cores */
63
64         pp_job_status swap_status;                         /**< Used to track each PP job swap status, if fail, we need to drop them in scheduler part */
65         mali_bool user_notification;                       /**< When we deferred delete PP job, we need to judge if we need to send job finish notification to user space */
66         u32 num_pp_cores_in_virtual;                       /**< How many PP cores we have when job finished */
67
68         /*
69          * These members are used by both scheduler and executor.
70          * They are "protected" by atomic operations.
71          */
72         _mali_osk_atomic_t sub_jobs_completed;                            /**< Number of completed sub-jobs in this superjob */
73         _mali_osk_atomic_t sub_job_errors;                                /**< Bitfield with errors (errors for each single sub-job is or'ed together) */
74
75         /*
76          * These members are used by scheduler, but only when no one else
77          * knows about this job object but the working function.
78          * No lock is thus needed for these.
79          */
80         u32 *memory_cookies;                               /**< Memory cookies attached to job */
81
82         /*
83          * These members are used by the scheduler,
84          * protected by scheduler lock
85          */
86         _mali_osk_list_t list;                             /**< Used to link jobs together in the scheduler queue */
87         _mali_osk_list_t session_fb_lookup_list;           /**< Used to link jobs together from the same frame builder in the session */
88         u32 sub_jobs_started;                              /**< Total number of sub-jobs started (always started in ascending order) */
89
90         /*
91          * Set by executor/group on job completion, read by scheduler when
92          * returning job to user. Hold executor lock when setting,
93          * no lock needed when reading
94          */
95         u32 perf_counter_value0[_MALI_PP_MAX_SUB_JOBS];    /**< Value of performance counter 0 (to be returned to user space), one for each sub job */
96         u32 perf_counter_value1[_MALI_PP_MAX_SUB_JOBS];    /**< Value of performance counter 1 (to be returned to user space), one for each sub job */
97 };
98
99 void mali_pp_job_initialize(void);
100 void mali_pp_job_terminate(void);
101
102 struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id);
103 void mali_pp_job_delete(struct mali_pp_job *job);
104
105 u32 mali_pp_job_get_perf_counter_src0(struct mali_pp_job *job, u32 sub_job);
106 u32 mali_pp_job_get_perf_counter_src1(struct mali_pp_job *job, u32 sub_job);
107
108 void mali_pp_job_set_pp_counter_global_src0(u32 counter);
109 void mali_pp_job_set_pp_counter_global_src1(u32 counter);
110 void mali_pp_job_set_pp_counter_sub_job_src0(u32 sub_job, u32 counter);
111 void mali_pp_job_set_pp_counter_sub_job_src1(u32 sub_job, u32 counter);
112
113 u32 mali_pp_job_get_pp_counter_global_src0(void);
114 u32 mali_pp_job_get_pp_counter_global_src1(void);
115 u32 mali_pp_job_get_pp_counter_sub_job_src0(u32 sub_job);
116 u32 mali_pp_job_get_pp_counter_sub_job_src1(u32 sub_job);
117
118 MALI_STATIC_INLINE u32 mali_pp_job_get_id(struct mali_pp_job *job)
119 {
120         MALI_DEBUG_ASSERT_POINTER(job);
121         return (NULL == job) ? 0 : job->id;
122 }
123
124 MALI_STATIC_INLINE void mali_pp_job_set_cache_order(struct mali_pp_job *job,
125                 u32 cache_order)
126 {
127         MALI_DEBUG_ASSERT_POINTER(job);
128         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
129         job->cache_order = cache_order;
130 }
131
132 MALI_STATIC_INLINE u32 mali_pp_job_get_cache_order(struct mali_pp_job *job)
133 {
134         MALI_DEBUG_ASSERT_POINTER(job);
135         return (NULL == job) ? 0 : job->cache_order;
136 }
137
138 MALI_STATIC_INLINE u64 mali_pp_job_get_user_id(struct mali_pp_job *job)
139 {
140         MALI_DEBUG_ASSERT_POINTER(job);
141         return job->uargs.user_job_ptr;
142 }
143
144 MALI_STATIC_INLINE u32 mali_pp_job_get_frame_builder_id(struct mali_pp_job *job)
145 {
146         MALI_DEBUG_ASSERT_POINTER(job);
147         return job->uargs.frame_builder_id;
148 }
149
150 MALI_STATIC_INLINE u32 mali_pp_job_get_flush_id(struct mali_pp_job *job)
151 {
152         MALI_DEBUG_ASSERT_POINTER(job);
153         return job->uargs.flush_id;
154 }
155
156 MALI_STATIC_INLINE u32 mali_pp_job_get_pid(struct mali_pp_job *job)
157 {
158         MALI_DEBUG_ASSERT_POINTER(job);
159         return job->pid;
160 }
161
162 MALI_STATIC_INLINE u32 mali_pp_job_get_tid(struct mali_pp_job *job)
163 {
164         MALI_DEBUG_ASSERT_POINTER(job);
165         return job->tid;
166 }
167
168 MALI_STATIC_INLINE u32 *mali_pp_job_get_frame_registers(struct mali_pp_job *job)
169 {
170         MALI_DEBUG_ASSERT_POINTER(job);
171         return job->uargs.frame_registers;
172 }
173
174 MALI_STATIC_INLINE u32 *mali_pp_job_get_dlbu_registers(struct mali_pp_job *job)
175 {
176         MALI_DEBUG_ASSERT_POINTER(job);
177         return job->uargs.dlbu_registers;
178 }
179
180 MALI_STATIC_INLINE mali_bool mali_pp_job_is_virtual(struct mali_pp_job *job)
181 {
182 #if (defined(CONFIG_MALI450) || defined(CONFIG_MALI470))
183         MALI_DEBUG_ASSERT_POINTER(job);
184         return (0 == job->uargs.num_cores) ? MALI_TRUE : MALI_FALSE;
185 #else
186         return MALI_FALSE;
187 #endif
188 }
189
190 MALI_STATIC_INLINE u32 mali_pp_job_get_addr_frame(struct mali_pp_job *job, u32 sub_job)
191 {
192         MALI_DEBUG_ASSERT_POINTER(job);
193
194         if (mali_pp_job_is_virtual(job)) {
195                 return MALI_DLBU_VIRT_ADDR;
196         } else if (0 == sub_job) {
197                 return job->uargs.frame_registers[MALI200_REG_ADDR_FRAME / sizeof(u32)];
198         } else if (sub_job < _MALI_PP_MAX_SUB_JOBS) {
199                 return job->uargs.frame_registers_addr_frame[sub_job - 1];
200         }
201
202         return 0;
203 }
204
205 MALI_STATIC_INLINE u32 mali_pp_job_get_addr_stack(struct mali_pp_job *job, u32 sub_job)
206 {
207         MALI_DEBUG_ASSERT_POINTER(job);
208
209         if (0 == sub_job) {
210                 return job->uargs.frame_registers[MALI200_REG_ADDR_STACK / sizeof(u32)];
211         } else if (sub_job < _MALI_PP_MAX_SUB_JOBS) {
212                 return job->uargs.frame_registers_addr_stack[sub_job - 1];
213         }
214
215         return 0;
216 }
217
218 void mali_pp_job_list_add(struct mali_pp_job *job, _mali_osk_list_t *list);
219
220 MALI_STATIC_INLINE void mali_pp_job_list_addtail(struct mali_pp_job *job,
221                 _mali_osk_list_t *list)
222 {
223         _mali_osk_list_addtail(&job->list, list);
224 }
225
226 MALI_STATIC_INLINE void mali_pp_job_list_move(struct mali_pp_job *job,
227                 _mali_osk_list_t *list)
228 {
229         MALI_DEBUG_ASSERT_POINTER(job);
230         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
231         MALI_DEBUG_ASSERT(!_mali_osk_list_empty(&job->list));
232         _mali_osk_list_move(&job->list, list);
233 }
234
235 MALI_STATIC_INLINE void mali_pp_job_list_remove(struct mali_pp_job *job)
236 {
237         MALI_DEBUG_ASSERT_POINTER(job);
238         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
239         _mali_osk_list_delinit(&job->list);
240 }
241
242 MALI_STATIC_INLINE u32 *mali_pp_job_get_wb0_registers(struct mali_pp_job *job)
243 {
244         MALI_DEBUG_ASSERT_POINTER(job);
245         return job->uargs.wb0_registers;
246 }
247
248 MALI_STATIC_INLINE u32 *mali_pp_job_get_wb1_registers(struct mali_pp_job *job)
249 {
250         MALI_DEBUG_ASSERT_POINTER(job);
251         return job->uargs.wb1_registers;
252 }
253
254 MALI_STATIC_INLINE u32 *mali_pp_job_get_wb2_registers(struct mali_pp_job *job)
255 {
256         MALI_DEBUG_ASSERT_POINTER(job);
257         return job->uargs.wb2_registers;
258 }
259
260 MALI_STATIC_INLINE u32 mali_pp_job_get_wb0_source_addr(struct mali_pp_job *job)
261 {
262         MALI_DEBUG_ASSERT_POINTER(job);
263         return job->uargs.wb0_registers[MALI200_REG_ADDR_WB_SOURCE_ADDR / sizeof(u32)];
264 }
265
266 MALI_STATIC_INLINE u32 mali_pp_job_get_wb1_source_addr(struct mali_pp_job *job)
267 {
268         MALI_DEBUG_ASSERT_POINTER(job);
269         return job->uargs.wb1_registers[MALI200_REG_ADDR_WB_SOURCE_ADDR / sizeof(u32)];
270 }
271
272 MALI_STATIC_INLINE u32 mali_pp_job_get_wb2_source_addr(struct mali_pp_job *job)
273 {
274         MALI_DEBUG_ASSERT_POINTER(job);
275         return job->uargs.wb2_registers[MALI200_REG_ADDR_WB_SOURCE_ADDR / sizeof(u32)];
276 }
277
278 MALI_STATIC_INLINE void mali_pp_job_disable_wb0(struct mali_pp_job *job)
279 {
280         MALI_DEBUG_ASSERT_POINTER(job);
281         job->uargs.wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
282 }
283
284 MALI_STATIC_INLINE void mali_pp_job_disable_wb1(struct mali_pp_job *job)
285 {
286         MALI_DEBUG_ASSERT_POINTER(job);
287         job->uargs.wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
288 }
289
290 MALI_STATIC_INLINE void mali_pp_job_disable_wb2(struct mali_pp_job *job)
291 {
292         MALI_DEBUG_ASSERT_POINTER(job);
293         job->uargs.wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
294 }
295
296 MALI_STATIC_INLINE mali_bool mali_pp_job_all_writeback_unit_disabled(struct mali_pp_job *job)
297 {
298         MALI_DEBUG_ASSERT_POINTER(job);
299
300         if (job->uargs.wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] ||
301             job->uargs.wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] ||
302             job->uargs.wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT]
303            ) {
304                 /* At least one output unit active */
305                 return MALI_FALSE;
306         }
307
308         /* All outputs are disabled - we can abort the job */
309         return MALI_TRUE;
310 }
311
312 MALI_STATIC_INLINE void mali_pp_job_fb_lookup_add(struct mali_pp_job *job)
313 {
314         u32 fb_lookup_id;
315
316         MALI_DEBUG_ASSERT_POINTER(job);
317         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
318
319         fb_lookup_id = MALI_PP_JOB_FB_LOOKUP_LIST_MASK & job->uargs.frame_builder_id;
320
321         MALI_DEBUG_ASSERT(MALI_PP_JOB_FB_LOOKUP_LIST_SIZE > fb_lookup_id);
322
323         _mali_osk_list_addtail(&job->session_fb_lookup_list,
324                                &job->session->pp_job_fb_lookup_list[fb_lookup_id]);
325 }
326
327 MALI_STATIC_INLINE void mali_pp_job_fb_lookup_remove(struct mali_pp_job *job)
328 {
329         MALI_DEBUG_ASSERT_POINTER(job);
330         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
331         _mali_osk_list_delinit(&job->session_fb_lookup_list);
332 }
333
334 MALI_STATIC_INLINE struct mali_session_data *mali_pp_job_get_session(struct mali_pp_job *job)
335 {
336         MALI_DEBUG_ASSERT_POINTER(job);
337         return job->session;
338 }
339
340 MALI_STATIC_INLINE mali_bool mali_pp_job_has_started_sub_jobs(struct mali_pp_job *job)
341 {
342         MALI_DEBUG_ASSERT_POINTER(job);
343         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
344         return (0 < job->sub_jobs_started) ? MALI_TRUE : MALI_FALSE;
345 }
346
347 MALI_STATIC_INLINE mali_bool mali_pp_job_has_unstarted_sub_jobs(struct mali_pp_job *job)
348 {
349         MALI_DEBUG_ASSERT_POINTER(job);
350         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
351         return (job->sub_jobs_started < job->sub_jobs_num) ? MALI_TRUE : MALI_FALSE;
352 }
353
354 /* Function used when we are terminating a session with jobs. Return TRUE if it has a rendering job.
355    Makes sure that no new subjobs are started. */
356 MALI_STATIC_INLINE void mali_pp_job_mark_unstarted_failed(struct mali_pp_job *job)
357 {
358         u32 jobs_remaining;
359         u32 i;
360
361         MALI_DEBUG_ASSERT_POINTER(job);
362         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
363
364         jobs_remaining = job->sub_jobs_num - job->sub_jobs_started;
365         job->sub_jobs_started += jobs_remaining;
366
367         /* Not the most optimal way, but this is only used in error cases */
368         for (i = 0; i < jobs_remaining; i++) {
369                 _mali_osk_atomic_inc(&job->sub_jobs_completed);
370                 _mali_osk_atomic_inc(&job->sub_job_errors);
371         }
372 }
373
374 MALI_STATIC_INLINE mali_bool mali_pp_job_is_complete(struct mali_pp_job *job)
375 {
376         MALI_DEBUG_ASSERT_POINTER(job);
377         return (job->sub_jobs_num ==
378                 _mali_osk_atomic_read(&job->sub_jobs_completed)) ?
379                MALI_TRUE : MALI_FALSE;
380 }
381
382 MALI_STATIC_INLINE u32 mali_pp_job_get_first_unstarted_sub_job(struct mali_pp_job *job)
383 {
384         MALI_DEBUG_ASSERT_POINTER(job);
385         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
386         return job->sub_jobs_started;
387 }
388
389 MALI_STATIC_INLINE u32 mali_pp_job_get_sub_job_count(struct mali_pp_job *job)
390 {
391         MALI_DEBUG_ASSERT_POINTER(job);
392         return job->sub_jobs_num;
393 }
394
395 MALI_STATIC_INLINE u32 mali_pp_job_unstarted_sub_job_count(struct mali_pp_job *job)
396 {
397         MALI_DEBUG_ASSERT_POINTER(job);
398         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
399         MALI_DEBUG_ASSERT(job->sub_jobs_num >= job->sub_jobs_started);
400         return (job->sub_jobs_num - job->sub_jobs_started);
401 }
402
403 MALI_STATIC_INLINE u32 mali_pp_job_num_memory_cookies(struct mali_pp_job *job)
404 {
405         MALI_DEBUG_ASSERT_POINTER(job);
406         return job->uargs.num_memory_cookies;
407 }
408
409 MALI_STATIC_INLINE u32 mali_pp_job_get_memory_cookie(
410         struct mali_pp_job *job, u32 index)
411 {
412         MALI_DEBUG_ASSERT_POINTER(job);
413         MALI_DEBUG_ASSERT(index < job->uargs.num_memory_cookies);
414         MALI_DEBUG_ASSERT_POINTER(job->memory_cookies);
415         return job->memory_cookies[index];
416 }
417
418 MALI_STATIC_INLINE mali_bool mali_pp_job_needs_dma_buf_mapping(struct mali_pp_job *job)
419 {
420         MALI_DEBUG_ASSERT_POINTER(job);
421
422         if (0 < job->uargs.num_memory_cookies) {
423                 return MALI_TRUE;
424         }
425
426         return MALI_FALSE;
427 }
428
429 MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_started(struct mali_pp_job *job, u32 sub_job)
430 {
431         MALI_DEBUG_ASSERT_POINTER(job);
432         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
433
434         /* Assert that we are marking the "first unstarted sub job" as started */
435         MALI_DEBUG_ASSERT(job->sub_jobs_started == sub_job);
436
437         job->sub_jobs_started++;
438 }
439
440 MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_completed(struct mali_pp_job *job, mali_bool success)
441 {
442         MALI_DEBUG_ASSERT_POINTER(job);
443
444         _mali_osk_atomic_inc(&job->sub_jobs_completed);
445         if (MALI_FALSE == success) {
446                 _mali_osk_atomic_inc(&job->sub_job_errors);
447         }
448 }
449
450 MALI_STATIC_INLINE mali_bool mali_pp_job_was_success(struct mali_pp_job *job)
451 {
452         MALI_DEBUG_ASSERT_POINTER(job);
453         if (0 == _mali_osk_atomic_read(&job->sub_job_errors)) {
454                 return MALI_TRUE;
455         }
456         return MALI_FALSE;
457 }
458
459 MALI_STATIC_INLINE mali_bool mali_pp_job_use_no_notification(
460         struct mali_pp_job *job)
461 {
462         MALI_DEBUG_ASSERT_POINTER(job);
463         return (job->uargs.flags & _MALI_PP_JOB_FLAG_NO_NOTIFICATION) ?
464                MALI_TRUE : MALI_FALSE;
465 }
466
467 MALI_STATIC_INLINE mali_bool mali_pp_job_is_pilot_job(struct mali_pp_job *job)
468 {
469         /*
470          * A pilot job is currently identified as jobs which
471          * require no callback notification.
472          */
473         return mali_pp_job_use_no_notification(job);
474 }
475
476 MALI_STATIC_INLINE _mali_osk_notification_t *
477 mali_pp_job_get_finished_notification(struct mali_pp_job *job)
478 {
479         _mali_osk_notification_t *notification;
480
481         MALI_DEBUG_ASSERT_POINTER(job);
482         MALI_DEBUG_ASSERT_POINTER(job->finished_notification);
483
484         notification = job->finished_notification;
485         job->finished_notification = NULL;
486
487         return notification;
488 }
489
490 MALI_STATIC_INLINE mali_bool mali_pp_job_is_window_surface(
491         struct mali_pp_job *job)
492 {
493         MALI_DEBUG_ASSERT_POINTER(job);
494         return (job->uargs.flags & _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE)
495                ? MALI_TRUE : MALI_FALSE;
496 }
497
498 MALI_STATIC_INLINE mali_bool mali_pp_job_is_protected_job(struct mali_pp_job *job)
499 {
500         MALI_DEBUG_ASSERT_POINTER(job);
501         return (job->uargs.flags & _MALI_PP_JOB_FLAG_PROTECTED)
502                ? MALI_TRUE : MALI_FALSE;
503 }
504
505 MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_flag(struct mali_pp_job *job)
506 {
507         MALI_DEBUG_ASSERT_POINTER(job);
508         return job->uargs.perf_counter_flag;
509 }
510
511 MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_value0(struct mali_pp_job *job, u32 sub_job)
512 {
513         MALI_DEBUG_ASSERT_POINTER(job);
514         return job->perf_counter_value0[sub_job];
515 }
516
517 MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_value1(struct mali_pp_job *job, u32 sub_job)
518 {
519         MALI_DEBUG_ASSERT_POINTER(job);
520         return job->perf_counter_value1[sub_job];
521 }
522
523 MALI_STATIC_INLINE void mali_pp_job_set_perf_counter_value0(struct mali_pp_job *job, u32 sub_job, u32 value)
524 {
525         MALI_DEBUG_ASSERT_POINTER(job);
526         MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
527         job->perf_counter_value0[sub_job] = value;
528 }
529
530 MALI_STATIC_INLINE void mali_pp_job_set_perf_counter_value1(struct mali_pp_job *job, u32 sub_job, u32 value)
531 {
532         MALI_DEBUG_ASSERT_POINTER(job);
533         MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
534         job->perf_counter_value1[sub_job] = value;
535 }
536
537 MALI_STATIC_INLINE _mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job)
538 {
539         MALI_DEBUG_ASSERT_POINTER(job);
540         if (mali_pp_job_is_virtual(job) && job->sub_jobs_num != 1) {
541                 return _MALI_OSK_ERR_FAULT;
542         }
543         return _MALI_OSK_ERR_OK;
544 }
545
546 /**
547  * Returns MALI_TRUE if this job has more than two sub jobs and all sub jobs are unstarted.
548  *
549  * @param job Job to check.
550  * @return MALI_TRUE if job has more than two sub jobs and all sub jobs are unstarted, MALI_FALSE if not.
551  */
552 MALI_STATIC_INLINE mali_bool mali_pp_job_is_large_and_unstarted(struct mali_pp_job *job)
553 {
554         MALI_DEBUG_ASSERT_POINTER(job);
555         MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD();
556         MALI_DEBUG_ASSERT(!mali_pp_job_is_virtual(job));
557
558         return (0 == job->sub_jobs_started && 2 < job->sub_jobs_num);
559 }
560
561 /**
562  * Get PP job's Timeline tracker.
563  *
564  * @param job PP job.
565  * @return Pointer to Timeline tracker for the job.
566  */
567 MALI_STATIC_INLINE struct mali_timeline_tracker *mali_pp_job_get_tracker(struct mali_pp_job *job)
568 {
569         MALI_DEBUG_ASSERT_POINTER(job);
570         return &(job->tracker);
571 }
572
573 MALI_STATIC_INLINE u32 *mali_pp_job_get_timeline_point_ptr(
574         struct mali_pp_job *job)
575 {
576         MALI_DEBUG_ASSERT_POINTER(job);
577         return (u32 __user *)(uintptr_t)job->uargs.timeline_point_ptr;
578 }
579
580
581 #endif /* __MALI_PP_JOB_H__ */