mali_kbase_pm_policy.h 8.2 KB

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