/drivers/gpu/mali/mali/common/mali_group.h

https://bitbucket.org/ndreys/linux-sunxi · C++ Header · 146 lines · 62 code · 22 blank · 62 comment · 0 complexity · e0b2a6abe092e31bd81187698903478d MD5 · raw file

  1. /*
  2. * Copyright (C) 2011-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. #ifndef __MALI_GROUP_H__
  11. #define __MALI_GROUP_H__
  12. #include "linux/jiffies.h"
  13. #include "mali_osk.h"
  14. #include "mali_cluster.h"
  15. #include "mali_mmu.h"
  16. #include "mali_gp.h"
  17. #include "mali_pp.h"
  18. #include "mali_session.h"
  19. /* max runtime [ms] for a core job - used by timeout timers */
  20. #define MAX_RUNTIME 5000
  21. /** @brief A mali group object represents a MMU and a PP and/or a GP core.
  22. *
  23. */
  24. #define MALI_MAX_NUMBER_OF_GROUPS 9
  25. struct mali_group;
  26. enum mali_group_event_t
  27. {
  28. GROUP_EVENT_PP_JOB_COMPLETED, /**< PP job completed successfully */
  29. GROUP_EVENT_PP_JOB_FAILED, /**< PP job completed with failure */
  30. GROUP_EVENT_PP_JOB_TIMED_OUT, /**< PP job reached max runtime */
  31. GROUP_EVENT_GP_JOB_COMPLETED, /**< GP job completed successfully */
  32. GROUP_EVENT_GP_JOB_FAILED, /**< GP job completed with failure */
  33. GROUP_EVENT_GP_JOB_TIMED_OUT, /**< GP job reached max runtime */
  34. GROUP_EVENT_GP_OOM, /**< GP job ran out of heap memory */
  35. GROUP_EVENT_MMU_PAGE_FAULT, /**< MMU page fault */
  36. };
  37. enum mali_group_core_state
  38. {
  39. MALI_GROUP_CORE_STATE_IDLE,
  40. MALI_GROUP_CORE_STATE_WORKING,
  41. MALI_GROUP_CORE_STATE_OOM
  42. };
  43. /** @brief Create a new Mali group object
  44. *
  45. * @param cluster Pointer to the cluster to which the group is connected.
  46. * @param mmu Pointer to the MMU that defines this group
  47. * @return A pointer to a new group object
  48. */
  49. struct mali_group *mali_group_create(struct mali_cluster *cluster, struct mali_mmu_core *mmu);
  50. void mali_group_add_gp_core(struct mali_group *group, struct mali_gp_core* gp_core);
  51. void mali_group_add_pp_core(struct mali_group *group, struct mali_pp_core* pp_core);
  52. void mali_group_delete(struct mali_group *group);
  53. /** @brief Reset group
  54. *
  55. * This function will reset the entire group, including all the cores present in the group.
  56. *
  57. * @param group Pointer to the group to reset
  58. */
  59. void mali_group_reset(struct mali_group *group);
  60. /** @brief Get pointer to GP core object
  61. */
  62. struct mali_gp_core* mali_group_get_gp_core(struct mali_group *group);
  63. /** @brief Get pointer to PP core object
  64. */
  65. struct mali_pp_core* mali_group_get_pp_core(struct mali_group *group);
  66. /** @brief Lock group object
  67. *
  68. * Most group functions will lock the group object themselves. The expection is
  69. * the group_bottom_half which requires the group to be locked on entry.
  70. *
  71. * @param group Pointer to group to lock
  72. */
  73. void mali_group_lock(struct mali_group *group);
  74. /** @brief Unlock group object
  75. *
  76. * @param group Pointer to group to unlock
  77. */
  78. void mali_group_unlock(struct mali_group *group);
  79. #ifdef DEBUG
  80. void mali_group_assert_locked(struct mali_group *group);
  81. #define MALI_ASSERT_GROUP_LOCKED(group) mali_group_assert_locked(group)
  82. #else
  83. #define MALI_ASSERT_GROUP_LOCKED(group)
  84. #endif
  85. /** @brief Start GP job
  86. */
  87. _mali_osk_errcode_t mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job);
  88. /** @brief Start fragment of PP job
  89. */
  90. _mali_osk_errcode_t mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job, u32 sub_job);
  91. /** @brief Resume GP job that suspended waiting for more heap memory
  92. */
  93. void mali_group_resume_gp_with_new_heap(struct mali_group *group, u32 job_id, u32 start_addr, u32 end_addr);
  94. /** @brief Abort GP job
  95. *
  96. * Used to abort suspended OOM jobs when user space failed to allocte more memory.
  97. */
  98. void mali_group_abort_gp_job(struct mali_group *group, u32 job_id);
  99. /** @brief Abort all GP jobs from \a session
  100. *
  101. * Used on session close when terminating all running and queued jobs from \a session.
  102. */
  103. void mali_group_abort_session(struct mali_group *group, struct mali_session_data *session);
  104. enum mali_group_core_state mali_group_gp_state(struct mali_group *group);
  105. enum mali_group_core_state mali_group_pp_state(struct mali_group *group);
  106. /** @brief The common group bottom half interrupt handler
  107. *
  108. * This is only called from the GP and PP bottom halves.
  109. *
  110. * The action taken is dictated by the \a event.
  111. *
  112. * @param event The event code
  113. */
  114. void mali_group_bottom_half(struct mali_group *group, enum mali_group_event_t event);
  115. struct mali_mmu_core *mali_group_get_mmu(struct mali_group *group);
  116. struct mali_session_data *mali_group_get_session(struct mali_group *group);
  117. void mali_group_remove_session_if_unused(struct mali_group *group, struct mali_session_data *session_data);
  118. void mali_group_power_on(void);
  119. void mali_group_power_off(void);
  120. mali_bool mali_group_power_is_on(struct mali_group *group);
  121. struct mali_group *mali_group_get_glob_group(u32 index);
  122. u32 mali_group_get_glob_num_groups(void);
  123. u32 mali_group_dump_state(struct mali_group *group, char *buf, u32 size);
  124. #endif /* __MALI_GROUP_H__ */