1 /* 2 * 3 * (C) COPYRIGHT 2010-2015 ARM Limited. All rights reserved. 4 * 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 8 * of such GNU licence. 9 * 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. 13 * 14 */ 15 16 17 18 /* 19 * Power policy API definitions 20 */ 21 22 #ifndef _KBASE_PM_POLICY_H_ 23 #define _KBASE_PM_POLICY_H_ 24 25 /** 26 * kbase_pm_policy_init - Initialize power policy framework 27 * 28 * @kbdev: The kbase device structure for the device (must be a valid pointer) 29 * 30 * Must be called before calling any other policy function 31 * 32 * Return: 0 if the power policy framework was successfully 33 * initialized, -errno otherwise. 34 */ 35 int kbase_pm_policy_init(struct kbase_device *kbdev); 36 37 /** 38 * kbase_pm_policy_term - Terminate power policy framework 39 * 40 * @kbdev: The kbase device structure for the device (must be a valid pointer) 41 */ 42 void kbase_pm_policy_term(struct kbase_device *kbdev); 43 44 /** 45 * kbase_pm_update_active - Update the active power state of the GPU 46 * 47 * @kbdev: The kbase device structure for the device (must be a valid pointer) 48 * 49 * Calls into the current power policy 50 */ 51 void kbase_pm_update_active(struct kbase_device *kbdev); 52 53 /** 54 * kbase_pm_update_cores - Update the desired core state of the GPU 55 * 56 * @kbdev: The kbase device structure for the device (must be a valid pointer) 57 * 58 * Calls into the current power policy 59 */ 60 void kbase_pm_update_cores(struct kbase_device *kbdev); 61 62 63 enum kbase_pm_cores_ready { 64 KBASE_CORES_NOT_READY = 0, 65 KBASE_NEW_AFFINITY = 1, 66 KBASE_CORES_READY = 2 67 }; 68 69 70 /** 71 * kbase_pm_request_cores_sync - Synchronous variant of kbase_pm_request_cores() 72 * 73 * @kbdev: The kbase device structure for the device 74 * @tiler_required: true if the tiler is required, false otherwise 75 * @shader_cores: A bitmask of shader cores which are necessary for the job 76 * 77 * When this function returns, the @shader_cores will be in the READY state. 78 * 79 * This is safe variant of kbase_pm_check_transitions_sync(): it handles the 80 * work of ensuring the requested cores will remain powered until a matching 81 * call to kbase_pm_unrequest_cores()/kbase_pm_release_cores() (as appropriate) 82 * is made. 83 */ 84 void kbase_pm_request_cores_sync(struct kbase_device *kbdev, 85 bool tiler_required, u64 shader_cores); 86 87 /** 88 * kbase_pm_request_cores - Mark one or more cores as being required 89 * for jobs to be submitted 90 * 91 * @kbdev: The kbase device structure for the device 92 * @tiler_required: true if the tiler is required, false otherwise 93 * @shader_cores: A bitmask of shader cores which are necessary for the job 94 * 95 * This function is called by the job scheduler to mark one or more cores as 96 * being required to submit jobs that are ready to run. 97 * 98 * The cores requested are reference counted and a subsequent call to 99 * kbase_pm_register_inuse_cores() or kbase_pm_unrequest_cores() should be 100 * made to dereference the cores as being 'needed'. 101 * 102 * The active power policy will meet or exceed the requirements of the 103 * requested cores in the system. Any core transitions needed will be begun 104 * immediately, but they might not complete/the cores might not be available 105 * until a Power Management IRQ. 106 * 107 * Return: 0 if the cores were successfully requested, or -errno otherwise. 108 */ 109 void kbase_pm_request_cores(struct kbase_device *kbdev, 110 bool tiler_required, u64 shader_cores); 111 112 /** 113 * kbase_pm_unrequest_cores - Unmark one or more cores as being required for 114 * jobs to be submitted. 115 * 116 * @kbdev: The kbase device structure for the device 117 * @tiler_required: true if the tiler is required, false otherwise 118 * @shader_cores: A bitmask of shader cores (as given to 119 * kbase_pm_request_cores() ) 120 * 121 * This function undoes the effect of kbase_pm_request_cores(). It should be 122 * used when a job is not going to be submitted to the hardware (e.g. the job is 123 * cancelled before it is enqueued). 124 * 125 * The active power policy will meet or exceed the requirements of the 126 * requested cores in the system. Any core transitions needed will be begun 127 * immediately, but they might not complete until a Power Management IRQ. 128 * 129 * The policy may use this as an indication that it can power down cores. 130 */ 131 void kbase_pm_unrequest_cores(struct kbase_device *kbdev, 132 bool tiler_required, u64 shader_cores); 133 134 /** 135 * kbase_pm_register_inuse_cores - Register a set of cores as in use by a job 136 * 137 * @kbdev: The kbase device structure for the device 138 * @tiler_required: true if the tiler is required, false otherwise 139 * @shader_cores: A bitmask of shader cores (as given to 140 * kbase_pm_request_cores() ) 141 * 142 * This function should be called after kbase_pm_request_cores() when the job 143 * is about to be submitted to the hardware. It will check that the necessary 144 * cores are available and if so update the 'needed' and 'inuse' bitmasks to 145 * reflect that the job is now committed to being run. 146 * 147 * If the necessary cores are not currently available then the function will 148 * return %KBASE_CORES_NOT_READY and have no effect. 149 * 150 * Return: %KBASE_CORES_NOT_READY if the cores are not immediately ready, 151 * 152 * %KBASE_NEW_AFFINITY if the affinity requested is not allowed, 153 * 154 * %KBASE_CORES_READY if the cores requested are already available 155 */ 156 enum kbase_pm_cores_ready kbase_pm_register_inuse_cores( 157 struct kbase_device *kbdev, 158 bool tiler_required, 159 u64 shader_cores); 160 161 /** 162 * kbase_pm_release_cores - Release cores after a job has run 163 * 164 * @kbdev: The kbase device structure for the device 165 * @tiler_required: true if the tiler is required, false otherwise 166 * @shader_cores: A bitmask of shader cores (as given to 167 * kbase_pm_register_inuse_cores() ) 168 * 169 * This function should be called when a job has finished running on the 170 * hardware. A call to kbase_pm_register_inuse_cores() must have previously 171 * occurred. The reference counts of the specified cores will be decremented 172 * which may cause the bitmask of 'inuse' cores to be reduced. The power policy 173 * may then turn off any cores which are no longer 'inuse'. 174 */ 175 void kbase_pm_release_cores(struct kbase_device *kbdev, 176 bool tiler_required, u64 shader_cores); 177 178 /** 179 * kbase_pm_request_l2_caches - Request l2 caches 180 * 181 * @kbdev: The kbase device structure for the device (must be a valid pointer) 182 * 183 * Request the use of l2 caches for all core groups, power up, wait and prevent 184 * the power manager from powering down the l2 caches. 185 * 186 * This tells the power management that the caches should be powered up, and 187 * they should remain powered, irrespective of the usage of shader cores. This 188 * does not return until the l2 caches are powered up. 189 * 190 * The caller must call kbase_pm_release_l2_caches() when they are finished 191 * to allow normal power management of the l2 caches to resume. 192 * 193 * This should only be used when power management is active. 194 */ 195 void kbase_pm_request_l2_caches(struct kbase_device *kbdev); 196 197 /** 198 * kbase_pm_request_l2_caches_l2_is_on - Request l2 caches but don't power on 199 * 200 * @kbdev: The kbase device structure for the device (must be a valid pointer) 201 * 202 * Increment the count of l2 users but do not attempt to power on the l2 203 * 204 * It is the callers responsibility to ensure that the l2 is already powered up 205 * and to eventually call kbase_pm_release_l2_caches() 206 */ 207 void kbase_pm_request_l2_caches_l2_is_on(struct kbase_device *kbdev); 208 209 /** 210 * kbase_pm_request_l2_caches - Release l2 caches 211 * 212 * @kbdev: The kbase device structure for the device (must be a valid pointer) 213 * 214 * Release the use of l2 caches for all core groups and allow the power manager 215 * to power them down when necessary. 216 * 217 * This tells the power management that the caches can be powered down if 218 * necessary, with respect to the usage of shader cores. 219 * 220 * The caller must have called kbase_pm_request_l2_caches() prior to a call 221 * to this. 222 * 223 * This should only be used when power management is active. 224 */ 225 void kbase_pm_release_l2_caches(struct kbase_device *kbdev); 226 227 #endif /* _KBASE_PM_POLICY_H_ */ 228