2 * Copyright (C) 2012 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.
12 #include "mali_osk_list.h"
13 #include "mali_session.h"
15 _MALI_OSK_LIST_HEAD(mali_sessions);
16 static u32 mali_session_count = 0;
18 _mali_osk_spinlock_irq_t *mali_sessions_lock;
20 _mali_osk_errcode_t mali_session_initialize(void)
22 _MALI_OSK_INIT_LIST_HEAD(&mali_sessions);
24 mali_sessions_lock = _mali_osk_spinlock_irq_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SESSIONS);
26 if (NULL == mali_sessions_lock) return _MALI_OSK_ERR_NOMEM;
28 return _MALI_OSK_ERR_OK;
31 void mali_session_terminate(void)
33 _mali_osk_spinlock_irq_term(mali_sessions_lock);
36 void mali_session_add(struct mali_session_data *session)
39 _mali_osk_list_add(&session->link, &mali_sessions);
41 mali_session_unlock();
44 void mali_session_remove(struct mali_session_data *session)
47 _mali_osk_list_delinit(&session->link);
49 mali_session_unlock();
52 u32 mali_session_get_count(void)
54 return mali_session_count;
58 * Get the max completed window jobs from all active session,
59 * which will be used in window render frame per sec calculate
61 #if defined(CONFIG_MALI400_POWER_PERFORMANCE_POLICY)
62 u32 mali_session_max_window_num(void)
64 struct mali_session_data *session, *tmp;
65 u32 max_window_num = 0;
70 MALI_SESSION_FOREACH(session, tmp, link) {
71 tmp_number = _mali_osk_atomic_xchg(&session->number_of_window_jobs, 0);
72 if (max_window_num < tmp_number) {
73 max_window_num = tmp_number;
77 mali_session_unlock();
79 return max_window_num;