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