tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / common / mali_session.h
1 /*
2  * Copyright (C) 2010-2012 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_SESSION_H__
12 #define __MALI_SESSION_H__
13
14 #include "mali_mmu_page_directory.h"
15 #include "mali_kernel_descriptor_mapping.h"
16 #include "mali_osk.h"
17 #include "mali_osk_list.h"
18
19 struct mali_timeline_system;
20 struct mali_soft_system;
21
22 /* Number of frame builder job lists per session. */
23 #define MALI_PP_JOB_FB_LOOKUP_LIST_SIZE 16
24 #define MALI_PP_JOB_FB_LOOKUP_LIST_MASK (MALI_PP_JOB_FB_LOOKUP_LIST_SIZE - 1)
25
26 struct mali_session_data {
27         _mali_osk_notification_queue_t * ioctl_queue;
28
29         _mali_osk_mutex_t *memory_lock; /**< Lock protecting the vm manipulation */
30         mali_descriptor_mapping * descriptor_mapping; /**< Mapping between userspace descriptors and our pointers */
31         _mali_osk_list_t memory_head; /**< Track all the memory allocated in this session, for freeing on abnormal termination */
32
33         struct mali_page_directory *page_directory; /**< MMU page directory for this session */
34
35         _MALI_OSK_LIST_HEAD(link); /**< Link for list of all sessions */
36         _MALI_OSK_LIST_HEAD(pp_job_list); /**< List of all PP jobs on this session */
37
38 #if defined(CONFIG_MALI400_POWER_PERFORMANCE_POLICY)
39         _mali_osk_atomic_t number_of_window_jobs; /**< Record the window jobs completed on this session in a period */
40 #endif
41
42         _mali_osk_list_t pp_job_fb_lookup_list[MALI_PP_JOB_FB_LOOKUP_LIST_SIZE]; /**< List of PP job lists per frame builder id.  Used to link jobs from same frame builder. */
43
44         struct mali_soft_job_system *soft_job_system; /**< Soft job system for this session. */
45         struct mali_timeline_system *timeline_system; /**< Timeline system for this session. */
46
47         mali_bool is_aborting; /**< MALI_TRUE if the session is aborting, MALI_FALSE if not. */
48         mali_bool use_high_priority_job_queue; /**< If MALI_TRUE, jobs added from this session will use the high priority job queues. */
49 };
50
51 _mali_osk_errcode_t mali_session_initialize(void);
52 void mali_session_terminate(void);
53
54 /* List of all sessions. Actual list head in mali_kernel_core.c */
55 extern _mali_osk_list_t mali_sessions;
56 /* Lock to protect modification and access to the mali_sessions list */
57 extern _mali_osk_spinlock_irq_t *mali_sessions_lock;
58
59 MALI_STATIC_INLINE void mali_session_lock(void)
60 {
61         _mali_osk_spinlock_irq_lock(mali_sessions_lock);
62 }
63
64 MALI_STATIC_INLINE void mali_session_unlock(void)
65 {
66         _mali_osk_spinlock_irq_unlock(mali_sessions_lock);
67 }
68
69 void mali_session_add(struct mali_session_data *session);
70 void mali_session_remove(struct mali_session_data *session);
71 u32 mali_session_get_count(void);
72
73 #define MALI_SESSION_FOREACH(session, tmp, link) \
74         _MALI_OSK_LIST_FOREACHENTRY(session, tmp, &mali_sessions, struct mali_session_data, link)
75
76 MALI_STATIC_INLINE struct mali_page_directory *mali_session_get_page_directory(struct mali_session_data *session)
77 {
78         return session->page_directory;
79 }
80
81 MALI_STATIC_INLINE void mali_session_send_notification(struct mali_session_data *session, _mali_osk_notification_t *object)
82 {
83         _mali_osk_notification_queue_send(session->ioctl_queue, object);
84 }
85
86 /*
87  * Get the max completed window jobs from all active session,
88  * which will be used in  window render frame per sec calculate
89  */
90 #if defined(CONFIG_MALI400_POWER_PERFORMANCE_POLICY)
91 u32 mali_session_max_window_num(void);
92 #endif
93
94 #endif /* __MALI_SESSION_H__ */