Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /* |
2 | * This confidential and proprietary software may be used only as | |
3 | * authorised by a licensing agreement from ARM Limited | |
db9a41fa | 4 | * (C) COPYRIGHT 2008-2015 ARM Limited |
6fa3eb70 S |
5 | * ALL RIGHTS RESERVED |
6 | * The entire notice above must be reproduced on all authorised | |
7 | * copies and copies may only be made to the extent permitted | |
8 | * by a licensing agreement from ARM Limited. | |
9 | */ | |
10 | ||
11 | #ifndef __MALI_SESSION_H__ | |
12 | #define __MALI_SESSION_H__ | |
13 | ||
14 | #include "mali_mmu_page_directory.h" | |
6fa3eb70 S |
15 | #include "mali_osk.h" |
16 | #include "mali_osk_list.h" | |
db9a41fa S |
17 | #include "mali_memory_types.h" |
18 | #include "mali_memory_manager.h" | |
6fa3eb70 S |
19 | |
20 | struct mali_timeline_system; | |
21 | struct mali_soft_system; | |
22 | ||
23 | /* Number of frame builder job lists per session. */ | |
24 | #define MALI_PP_JOB_FB_LOOKUP_LIST_SIZE 16 | |
25 | #define MALI_PP_JOB_FB_LOOKUP_LIST_MASK (MALI_PP_JOB_FB_LOOKUP_LIST_SIZE - 1) | |
26 | ||
27 | struct mali_session_data { | |
db9a41fa | 28 | _mali_osk_notification_queue_t *ioctl_queue; |
6fa3eb70 S |
29 | |
30 | _mali_osk_mutex_t *memory_lock; /**< Lock protecting the vm manipulation */ | |
db9a41fa | 31 | #if 0 |
6fa3eb70 | 32 | _mali_osk_list_t memory_head; /**< Track all the memory allocated in this session, for freeing on abnormal termination */ |
db9a41fa | 33 | #endif |
6fa3eb70 S |
34 | struct mali_page_directory *page_directory; /**< MMU page directory for this session */ |
35 | ||
36 | _MALI_OSK_LIST_HEAD(link); /**< Link for list of all sessions */ | |
37 | _MALI_OSK_LIST_HEAD(pp_job_list); /**< List of all PP jobs on this session */ | |
38 | ||
db9a41fa | 39 | #if defined(CONFIG_MALI_DVFS) |
6fa3eb70 S |
40 | _mali_osk_atomic_t number_of_window_jobs; /**< Record the window jobs completed on this session in a period */ |
41 | #endif | |
42 | ||
43 | _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. */ | |
44 | ||
45 | struct mali_soft_job_system *soft_job_system; /**< Soft job system for this session. */ | |
46 | struct mali_timeline_system *timeline_system; /**< Timeline system for this session. */ | |
47 | ||
48 | mali_bool is_aborting; /**< MALI_TRUE if the session is aborting, MALI_FALSE if not. */ | |
49 | mali_bool use_high_priority_job_queue; /**< If MALI_TRUE, jobs added from this session will use the high priority job queues. */ | |
db9a41fa S |
50 | u32 pid; |
51 | char *comm; | |
52 | atomic_t mali_mem_array[MALI_MEM_TYPE_MAX]; /**< The array to record mem types' usage for this session. */ | |
53 | atomic_t mali_mem_allocated_pages; /** The current allocated mali memory pages, which include mali os memory and mali dedicated memory.*/ | |
54 | size_t max_mali_mem_allocated_size; /**< The past max mali memory allocated size, which include mali os memory and mali dedicated memory. */ | |
55 | /* Added for new memroy system */ | |
56 | struct mali_allocation_manager allocation_mgr; | |
6fa3eb70 S |
57 | }; |
58 | ||
59 | _mali_osk_errcode_t mali_session_initialize(void); | |
60 | void mali_session_terminate(void); | |
61 | ||
62 | /* List of all sessions. Actual list head in mali_kernel_core.c */ | |
63 | extern _mali_osk_list_t mali_sessions; | |
64 | /* Lock to protect modification and access to the mali_sessions list */ | |
65 | extern _mali_osk_spinlock_irq_t *mali_sessions_lock; | |
66 | ||
67 | MALI_STATIC_INLINE void mali_session_lock(void) | |
68 | { | |
69 | _mali_osk_spinlock_irq_lock(mali_sessions_lock); | |
70 | } | |
71 | ||
72 | MALI_STATIC_INLINE void mali_session_unlock(void) | |
73 | { | |
74 | _mali_osk_spinlock_irq_unlock(mali_sessions_lock); | |
75 | } | |
76 | ||
77 | void mali_session_add(struct mali_session_data *session); | |
78 | void mali_session_remove(struct mali_session_data *session); | |
79 | u32 mali_session_get_count(void); | |
80 | ||
81 | #define MALI_SESSION_FOREACH(session, tmp, link) \ | |
82 | _MALI_OSK_LIST_FOREACHENTRY(session, tmp, &mali_sessions, struct mali_session_data, link) | |
83 | ||
84 | MALI_STATIC_INLINE struct mali_page_directory *mali_session_get_page_directory(struct mali_session_data *session) | |
85 | { | |
86 | return session->page_directory; | |
87 | } | |
88 | ||
db9a41fa S |
89 | MALI_STATIC_INLINE void mali_session_memory_lock(struct mali_session_data *session) |
90 | { | |
91 | MALI_DEBUG_ASSERT_POINTER(session); | |
92 | _mali_osk_mutex_wait(session->memory_lock); | |
93 | } | |
94 | ||
95 | MALI_STATIC_INLINE void mali_session_memory_unlock(struct mali_session_data *session) | |
96 | { | |
97 | MALI_DEBUG_ASSERT_POINTER(session); | |
98 | _mali_osk_mutex_signal(session->memory_lock); | |
99 | } | |
100 | ||
6fa3eb70 S |
101 | MALI_STATIC_INLINE void mali_session_send_notification(struct mali_session_data *session, _mali_osk_notification_t *object) |
102 | { | |
103 | _mali_osk_notification_queue_send(session->ioctl_queue, object); | |
104 | } | |
105 | ||
db9a41fa S |
106 | #if defined(CONFIG_MALI_DVFS) |
107 | ||
108 | MALI_STATIC_INLINE void mali_session_inc_num_window_jobs(struct mali_session_data *session) | |
109 | { | |
110 | MALI_DEBUG_ASSERT_POINTER(session); | |
111 | _mali_osk_atomic_inc(&session->number_of_window_jobs); | |
112 | } | |
113 | ||
6fa3eb70 S |
114 | /* |
115 | * Get the max completed window jobs from all active session, | |
116 | * which will be used in window render frame per sec calculate | |
117 | */ | |
6fa3eb70 | 118 | u32 mali_session_max_window_num(void); |
db9a41fa | 119 | |
6fa3eb70 S |
120 | #endif |
121 | ||
db9a41fa S |
122 | void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx); |
123 | ||
6fa3eb70 | 124 | #endif /* __MALI_SESSION_H__ */ |