3 * (C) COPYRIGHT ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
19 * @file mali_kbase_pm_ca.h
20 * Base kernel core availability APIs
23 #ifndef _KBASE_PM_CA_H_
24 #define _KBASE_PM_CA_H_
26 typedef enum kbase_pm_ca_policy_id {
27 KBASE_PM_CA_POLICY_ID_FIXED = 1,
28 KBASE_PM_CA_POLICY_ID_RANDOM
29 } kbase_pm_ca_policy_id;
31 typedef u32 kbase_pm_ca_policy_flags;
33 /** Core availability policy structure.
35 * Each core availability policy exposes a (static) instance of this structure which contains function pointers to the
38 typedef struct kbase_pm_ca_policy {
39 /** The name of this policy */
42 /** Function called when the policy is selected
44 * This should initialize the kbdev->pm.ca_policy_data structure. It should not attempt
45 * to make any changes to hardware state.
47 * It is undefined what state the cores are in when the function is called.
49 * @param kbdev The kbase device structure for the device (must be a valid pointer)
51 void (*init) (struct kbase_device *kbdev);
53 /** Function called when the policy is unselected.
55 * @param kbdev The kbase device structure for the device (must be a valid pointer)
57 void (*term) (struct kbase_device *kbdev);
59 /** Function called to get the current shader core availability mask
61 * When a change in core availability is occuring, the policy must set kbdev->pm.ca_in_transition
62 * to MALI_TRUE. This is to indicate that reporting changes in power state cannot be optimized out,
63 * even if kbdev->pm.desired_shader_state remains unchanged. This must be done by any functions
64 * internal to the Core Availability Policy that change the return value of
65 * kbase_pm_ca_policy::get_core_mask.
67 * @param kbdev The kbase device structure for the device (must be a valid pointer)
69 * @return The current core availability mask */
70 u64 (*get_core_mask) (struct kbase_device *kbdev);
72 /** Function called to update the current core status
74 * If none of the cores in core group 0 are ready or transitioning, then the policy must
75 * ensure that the next call to get_core_mask does not return 0 for all cores in core group
76 * 0. It is an error to disable core group 0 through the core availability policy.
78 * When a change in core availability has finished, the policy must set kbdev->pm.ca_in_transition
79 * to MALI_FALSE. This is to indicate that changes in power state can once again be optimized out
80 * when kbdev->pm.desired_shader_state is unchanged.
82 * @param kbdev The kbase device structure for the device (must be a valid pointer)
83 * @param cores_ready The mask of cores currently powered and ready to run jobs
84 * @param cores_transitioning The mask of cores currently transitioning power state */
85 void (*update_core_status) (struct kbase_device *kbdev, u64 cores_ready, u64 cores_transitioning);
87 /** Field indicating flags for this policy */
88 kbase_pm_ca_policy_flags flags;
90 /** Field indicating an ID for this policy. This is not necessarily the
91 * same as its index in the list returned by kbase_pm_list_policies().
92 * It is used purely for debugging. */
93 kbase_pm_ca_policy_id id;
96 /** Initialize core availability framework
98 * Must be called before calling any other core availability function
100 * @param kbdev The kbase device structure for the device (must be a valid pointer)
102 * @return MALI_ERROR_NONE if the core availability framework was successfully initialized.
104 mali_error kbase_pm_ca_init(struct kbase_device *kbdev);
106 /** Terminate core availability framework
108 * @param kbdev The kbase device structure for the device (must be a valid pointer)
110 void kbase_pm_ca_term(struct kbase_device *kbdev);
112 /** Return mask of currently available shaders cores
113 * Calls into the core availability policy
115 * @param kbdev The kbase device structure for the device (must be a valid pointer)
117 * @return The bit mask of available cores
119 u64 kbase_pm_ca_get_core_mask(struct kbase_device *kbdev);
121 /** Update core availability policy with current core power status
122 * Calls into the core availability policy
124 * @param kbdev The kbase device structure for the device (must be a valid pointer)
125 * @param cores_ready The bit mask of cores ready for job submission
126 * @param cores_transitioning The bit mask of cores that are transitioning power state
128 void kbase_pm_ca_update_core_status(struct kbase_device *kbdev, u64 cores_ready, u64 cores_transitioning);
130 /** Enable override for instrumentation
132 * This overrides the output of the core availability policy, ensuring that all cores are available
134 * @param kbdev The kbase device structure for the device (must be a valid pointer)
136 void kbase_pm_ca_instr_enable(struct kbase_device *kbdev);
138 /** Disable override for instrumentation
140 * This disables any previously enabled override, and resumes normal policy functionality
142 * @param kbdev The kbase device structure for the device (must be a valid pointer)
144 void kbase_pm_ca_instr_disable(struct kbase_device *kbdev);
146 /** Get the current policy.
147 * Returns the policy that is currently active.
149 * @param kbdev The kbase device structure for the device (must be a valid pointer)
151 * @return The current policy
153 const kbase_pm_ca_policy *kbase_pm_ca_get_policy(struct kbase_device *kbdev);
155 /** Change the policy to the one specified.
157 * @param kbdev The kbase device structure for the device (must be a valid pointer)
158 * @param policy The policy to change to (valid pointer returned from @ref kbase_pm_ca_list_policies)
160 void kbase_pm_ca_set_policy(struct kbase_device *kbdev, const kbase_pm_ca_policy *policy);
162 /** Retrieve a static list of the available policies.
163 * @param[out] policies An array pointer to take the list of policies. This may be NULL.
164 * The contents of this array must not be modified.
166 * @return The number of policies
168 int kbase_pm_ca_list_policies(const kbase_pm_ca_policy * const **policies);
170 #endif /* _KBASE_PM_CA_H_ */