rk312x, mali_400_driver :
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / common / mali_scheduler.h
1 /*
2  * Copyright (C) 2012-2014 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_SCHEDULER_H__
12 #define __MALI_SCHEDULER_H__
13
14 #include "mali_osk.h"
15 #include "mali_osk_list.h"
16 #include "mali_scheduler_types.h"
17 #include "mali_session.h"
18
19 struct mali_scheduler_job_queue {
20         _MALI_OSK_LIST_HEAD(normal_pri); /* Queued jobs with normal priority */
21         _MALI_OSK_LIST_HEAD(high_pri);   /* Queued jobs with high priority */
22         u32 depth;                       /* Depth of combined queues. */
23 };
24
25 extern _mali_osk_spinlock_irq_t *mali_scheduler_lock_obj;
26
27 /* Queue of jobs to be executed on the GP group */
28 extern struct mali_scheduler_job_queue job_queue_gp;
29
30 /* Queue of PP jobs */
31 extern struct mali_scheduler_job_queue job_queue_pp;
32
33 extern _mali_osk_atomic_t mali_job_id_autonumber;
34 extern _mali_osk_atomic_t mali_job_cache_order_autonumber;
35
36 #define MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD() MALI_DEBUG_ASSERT_LOCK_HELD(mali_scheduler_lock_obj);
37
38 _mali_osk_errcode_t mali_scheduler_initialize(void);
39 void mali_scheduler_terminate(void);
40
41 MALI_STATIC_INLINE void mali_scheduler_lock(void)
42 {
43         _mali_osk_spinlock_irq_lock(mali_scheduler_lock_obj);
44         MALI_DEBUG_PRINT(5, ("Mali scheduler: scheduler lock taken.\n"));
45 }
46
47 MALI_STATIC_INLINE void mali_scheduler_unlock(void)
48 {
49         MALI_DEBUG_PRINT(5, ("Mali scheduler: Releasing scheduler lock.\n"));
50         _mali_osk_spinlock_irq_unlock(mali_scheduler_lock_obj);
51 }
52
53 MALI_STATIC_INLINE u32 mali_scheduler_job_gp_count(void)
54 {
55         return job_queue_gp.depth;
56 }
57
58 u32 mali_scheduler_job_physical_head_count(void);
59
60 mali_bool mali_scheduler_job_next_is_virtual(void);
61
62 struct mali_gp_job *mali_scheduler_job_gp_get(void);
63 struct mali_pp_job *mali_scheduler_job_pp_physical_peek(void);
64 struct mali_pp_job *mali_scheduler_job_pp_virtual_peek(void);
65 struct mali_pp_job *mali_scheduler_job_pp_physical_get(u32 *sub_job);
66 struct mali_pp_job *mali_scheduler_job_pp_virtual_get(void);
67
68 MALI_STATIC_INLINE u32 mali_scheduler_get_new_id(void)
69 {
70         return _mali_osk_atomic_inc_return(&mali_job_id_autonumber);
71 }
72
73 MALI_STATIC_INLINE u32 mali_scheduler_get_new_cache_order(void)
74 {
75         return _mali_osk_atomic_inc_return(&mali_job_cache_order_autonumber);
76 }
77
78 /**
79  * @brief Used by the Timeline system to queue a GP job.
80  *
81  * @note @ref mali_executor_schedule_from_mask() should be called if this
82  * function returns non-zero.
83  *
84  * @param job The GP job that is being activated.
85  *
86  * @return A scheduling bitmask that can be used to decide if scheduling is
87  * necessary after this call.
88  */
89 mali_scheduler_mask mali_scheduler_activate_gp_job(struct mali_gp_job *job);
90
91 /**
92  * @brief Used by the Timeline system to queue a PP job.
93  *
94  * @note @ref mali_executor_schedule_from_mask() should be called if this
95  * function returns non-zero.
96  *
97  * @param job The PP job that is being activated.
98  *
99  * @return A scheduling bitmask that can be used to decide if scheduling is
100  * necessary after this call.
101  */
102 mali_scheduler_mask mali_scheduler_activate_pp_job(struct mali_pp_job *job);
103
104 void mali_scheduler_complete_gp_job(struct mali_gp_job *job,
105                                     mali_bool success,
106                                     mali_bool user_notification,
107                                     mali_bool dequeued);
108
109 void mali_scheduler_complete_pp_job(struct mali_pp_job *job,
110                                     u32 num_cores_in_virtual,
111                                     mali_bool user_notification,
112                                     mali_bool dequeued);
113
114 void mali_scheduler_abort_session(struct mali_session_data *session);
115
116 #if MALI_STATE_TRACKING
117 u32 mali_scheduler_dump_state(char *buf, u32 size);
118 #endif
119
120 #endif /* __MALI_SCHEDULER_H__ */