summaryrefslogtreecommitdiff
path: root/drivers/gpu/arm/utgard/common/mali_scheduler.h
blob: f24cf42b8a794d818923fecdb0671f9fc6dd14b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
 * 
 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
 * 
 * A copy of the licence is included with the program, and can also be obtained from Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef __MALI_SCHEDULER_H__
#define __MALI_SCHEDULER_H__

#include "mali_osk.h"
#include "mali_osk_list.h"
#include "mali_scheduler_types.h"
#include "mali_session.h"

struct mali_scheduler_job_queue {
	_MALI_OSK_LIST_HEAD(normal_pri); /* Queued jobs with normal priority */
	_MALI_OSK_LIST_HEAD(high_pri);   /* Queued jobs with high priority */
	u32 depth;                       /* Depth of combined queues. */
	u32 big_job_num;
};

extern _mali_osk_spinlock_irq_t *mali_scheduler_lock_obj;

/* Queue of jobs to be executed on the GP group */
extern struct mali_scheduler_job_queue job_queue_gp;

/* Queue of PP jobs */
extern struct mali_scheduler_job_queue job_queue_pp;

extern _mali_osk_atomic_t mali_job_id_autonumber;
extern _mali_osk_atomic_t mali_job_cache_order_autonumber;

#define MALI_DEBUG_ASSERT_SCHEDULER_LOCK_HELD() MALI_DEBUG_ASSERT_LOCK_HELD(mali_scheduler_lock_obj);

_mali_osk_errcode_t mali_scheduler_initialize(void);
void mali_scheduler_terminate(void);

MALI_STATIC_INLINE void mali_scheduler_lock(void)
{
	_mali_osk_spinlock_irq_lock(mali_scheduler_lock_obj);
	MALI_DEBUG_PRINT(5, ("Mali scheduler: scheduler lock taken.\n"));
}

MALI_STATIC_INLINE void mali_scheduler_unlock(void)
{
	MALI_DEBUG_PRINT(5, ("Mali scheduler: Releasing scheduler lock.\n"));
	_mali_osk_spinlock_irq_unlock(mali_scheduler_lock_obj);
}

MALI_STATIC_INLINE u32 mali_scheduler_job_gp_count(void)
{
	return job_queue_gp.depth;
}
MALI_STATIC_INLINE u32 mali_scheduler_job_gp_big_job_count(void)
{
	return job_queue_gp.big_job_num;
}

u32 mali_scheduler_job_physical_head_count(void);

mali_bool mali_scheduler_job_next_is_virtual(void);

struct mali_gp_job *mali_scheduler_job_gp_get(void);
struct mali_pp_job *mali_scheduler_job_pp_physical_peek(void);
struct mali_pp_job *mali_scheduler_job_pp_virtual_peek(void);
struct mali_pp_job *mali_scheduler_job_pp_physical_get(u32 *sub_job);
struct mali_pp_job *mali_scheduler_job_pp_virtual_get(void);

MALI_STATIC_INLINE u32 mali_scheduler_get_new_id(void)
{
	return _mali_osk_atomic_inc_return(&mali_job_id_autonumber);
}

MALI_STATIC_INLINE u32 mali_scheduler_get_new_cache_order(void)
{
	return _mali_osk_atomic_inc_return(&mali_job_cache_order_autonumber);
}

/**
 * @brief Used by the Timeline system to queue a GP job.
 *
 * @note @ref mali_executor_schedule_from_mask() should be called if this
 * function returns non-zero.
 *
 * @param job The GP job that is being activated.
 *
 * @return A scheduling bitmask that can be used to decide if scheduling is
 * necessary after this call.
 */
mali_scheduler_mask mali_scheduler_activate_gp_job(struct mali_gp_job *job);

/**
 * @brief Used by the Timeline system to queue a PP job.
 *
 * @note @ref mali_executor_schedule_from_mask() should be called if this
 * function returns non-zero.
 *
 * @param job The PP job that is being activated.
 *
 * @return A scheduling bitmask that can be used to decide if scheduling is
 * necessary after this call.
 */
mali_scheduler_mask mali_scheduler_activate_pp_job(struct mali_pp_job *job);

void mali_scheduler_complete_gp_job(struct mali_gp_job *job,
				    mali_bool success,
				    mali_bool user_notification,
				    mali_bool dequeued);

void mali_scheduler_complete_pp_job(struct mali_pp_job *job,
				    u32 num_cores_in_virtual,
				    mali_bool user_notification,
				    mali_bool dequeued);

void mali_scheduler_abort_session(struct mali_session_data *session);

void mali_scheduler_return_pp_job_to_user(struct mali_pp_job *job,
		u32 num_cores_in_virtual);

#if MALI_STATE_TRACKING
u32 mali_scheduler_dump_state(char *buf, u32 size);
#endif

void mali_scheduler_gp_pp_job_queue_print(void);

#endif /* __MALI_SCHEDULER_H__ */