mali_session.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2012-2013 ARM Limited
  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. #include "mali_osk.h"
  11. #include "mali_osk_list.h"
  12. #include "mali_session.h"
  13. _MALI_OSK_LIST_HEAD(mali_sessions);
  14. static u32 mali_session_count = 0;
  15. _mali_osk_spinlock_irq_t *mali_sessions_lock;
  16. _mali_osk_errcode_t mali_session_initialize(void)
  17. {
  18. _MALI_OSK_INIT_LIST_HEAD(&mali_sessions);
  19. mali_sessions_lock = _mali_osk_spinlock_irq_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SESSIONS);
  20. if (NULL == mali_sessions_lock) return _MALI_OSK_ERR_NOMEM;
  21. return _MALI_OSK_ERR_OK;
  22. }
  23. void mali_session_terminate(void)
  24. {
  25. _mali_osk_spinlock_irq_term(mali_sessions_lock);
  26. }
  27. void mali_session_add(struct mali_session_data *session)
  28. {
  29. mali_session_lock();
  30. _mali_osk_list_add(&session->link, &mali_sessions);
  31. mali_session_count++;
  32. mali_session_unlock();
  33. }
  34. void mali_session_remove(struct mali_session_data *session)
  35. {
  36. mali_session_lock();
  37. _mali_osk_list_delinit(&session->link);
  38. mali_session_count--;
  39. mali_session_unlock();
  40. }
  41. u32 mali_session_get_count(void)
  42. {
  43. return mali_session_count;
  44. }
  45. /*
  46. * Get the max completed window jobs from all active session,
  47. * which will be used in window render frame per sec calculate
  48. */
  49. #if defined(CONFIG_MALI400_POWER_PERFORMANCE_POLICY)
  50. u32 mali_session_max_window_num(void)
  51. {
  52. struct mali_session_data *session, *tmp;
  53. u32 max_window_num = 0;
  54. u32 tmp_number = 0;
  55. mali_session_lock();
  56. MALI_SESSION_FOREACH(session, tmp, link) {
  57. tmp_number = _mali_osk_atomic_xchg(&session->number_of_window_jobs, 0);
  58. if (max_window_num < tmp_number) {
  59. max_window_num = tmp_number;
  60. }
  61. }
  62. mali_session_unlock();
  63. return max_window_num;
  64. }
  65. #endif