2 * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
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.
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.
11 #ifndef __MALI_SCHEDULER_H__
12 #define __MALI_SCHEDULER_H__
15 #include "mali_osk_list.h"
16 #include "mali_scheduler_types.h"
17 #include "mali_session.h"
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. */
26 extern _mali_osk_spinlock_irq_t *mali_scheduler_lock_obj;
28 /* Queue of jobs to be executed on the GP group */
29 extern struct mali_scheduler_job_queue job_queue_gp;
31 /* Queue of PP jobs */
32 extern struct mali_scheduler_job_queue job_queue_pp;
34 extern _mali_osk_atomic_t mali_job_id_autonumber;
35 extern _mali_osk_atomic_t mali_job_cache_order_autonumber;
37 #define MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD() MALI_DEBUG_ASSERT_LOCK_HELD(mali_scheduler_lock_obj);
39 _mali_osk_errcode_t mali_scheduler_initialize(void);
40 void mali_scheduler_terminate(void);
42 MALI_STATIC_INLINE void mali_scheduler_lock(void)
44 _mali_osk_spinlock_irq_lock(mali_scheduler_lock_obj);
45 MALI_DEBUG_PRINT(5, ("Mali scheduler: scheduler lock taken.\n"));
48 MALI_STATIC_INLINE void mali_scheduler_unlock(void)
50 MALI_DEBUG_PRINT(5, ("Mali scheduler: Releasing scheduler lock.\n"));
51 _mali_osk_spinlock_irq_unlock(mali_scheduler_lock_obj);
54 MALI_STATIC_INLINE u32 mali_scheduler_job_gp_count(void)
56 return job_queue_gp.depth;
58 MALI_STATIC_INLINE u32 mali_scheduler_job_gp_big_job_count(void)
60 return job_queue_gp.big_job_num;
63 u32 mali_scheduler_job_physical_head_count(mali_bool gpu_mode_is_secure);
65 mali_bool mali_scheduler_job_next_is_virtual(void);
66 struct mali_pp_job *mali_scheduler_job_pp_next(void);
68 struct mali_gp_job *mali_scheduler_job_gp_get(void);
69 struct mali_pp_job *mali_scheduler_job_pp_physical_peek(void);
70 struct mali_pp_job *mali_scheduler_job_pp_virtual_peek(void);
71 struct mali_pp_job *mali_scheduler_job_pp_physical_get(u32 *sub_job);
72 struct mali_pp_job *mali_scheduler_job_pp_virtual_get(void);
74 MALI_STATIC_INLINE u32 mali_scheduler_get_new_id(void)
76 return _mali_osk_atomic_inc_return(&mali_job_id_autonumber);
79 MALI_STATIC_INLINE u32 mali_scheduler_get_new_cache_order(void)
81 return _mali_osk_atomic_inc_return(&mali_job_cache_order_autonumber);
85 * @brief Used by the Timeline system to queue a GP job.
87 * @note @ref mali_executor_schedule_from_mask() should be called if this
88 * function returns non-zero.
90 * @param job The GP job that is being activated.
92 * @return A scheduling bitmask that can be used to decide if scheduling is
93 * necessary after this call.
95 mali_scheduler_mask mali_scheduler_activate_gp_job(struct mali_gp_job *job);
98 * @brief Used by the Timeline system to queue a PP job.
100 * @note @ref mali_executor_schedule_from_mask() should be called if this
101 * function returns non-zero.
103 * @param job The PP job that is being activated.
105 * @return A scheduling bitmask that can be used to decide if scheduling is
106 * necessary after this call.
108 mali_scheduler_mask mali_scheduler_activate_pp_job(struct mali_pp_job *job);
110 void mali_scheduler_complete_gp_job(struct mali_gp_job *job,
112 mali_bool user_notification,
115 void mali_scheduler_complete_pp_job(struct mali_pp_job *job,
116 u32 num_cores_in_virtual,
117 mali_bool user_notification,
120 void mali_scheduler_abort_session(struct mali_session_data *session);
122 void mali_scheduler_return_pp_job_to_user(struct mali_pp_job *job,
123 u32 num_cores_in_virtual);
125 #if MALI_STATE_TRACKING
126 u32 mali_scheduler_dump_state(char *buf, u32 size);
129 void mali_scheduler_gp_pp_job_queue_print(void);
131 #endif /* __MALI_SCHEDULER_H__ */