mali_ukk.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2008-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. /**
  11. * @file mali_ukk.h
  12. * Defines the kernel-side interface of the user-kernel interface
  13. */
  14. #ifndef __MALI_UKK_H__
  15. #define __MALI_UKK_H__
  16. #include "mali_osk.h"
  17. #include "mali_uk_types.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @addtogroup uddapi Unified Device Driver (UDD) APIs
  23. *
  24. * @{
  25. */
  26. /**
  27. * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs
  28. *
  29. * - The _mali_uk functions are an abstraction of the interface to the device
  30. * driver. On certain OSs, this would be implemented via the IOCTL interface.
  31. * On other OSs, it could be via extension of some Device Driver Class, or
  32. * direct function call for Bare metal/RTOSs.
  33. * - It is important to note that:
  34. * - The Device Driver has implemented the _mali_ukk set of functions
  35. * - The Base Driver calls the corresponding set of _mali_uku functions.
  36. * - What requires porting is solely the calling mechanism from User-side to
  37. * Kernel-side, and propagating back the results.
  38. * - Each U/K function is associated with a (group, number) pair from
  39. * \ref _mali_uk_functions to make it possible for a common function in the
  40. * Base Driver and Device Driver to route User/Kernel calls from/to the
  41. * correct _mali_uk function. For example, in an IOCTL system, the IOCTL number
  42. * would be formed based on the group and number assigned to the _mali_uk
  43. * function, as listed in \ref _mali_uk_functions. On the user-side, each
  44. * _mali_uku function would just make an IOCTL with the IOCTL-code being an
  45. * encoded form of the (group, number) pair. On the kernel-side, the Device
  46. * Driver's IOCTL handler decodes the IOCTL-code back into a (group, number)
  47. * pair, and uses this to determine which corresponding _mali_ukk should be
  48. * called.
  49. * - Refer to \ref _mali_uk_functions for more information about this
  50. * (group, number) pairing.
  51. * - In a system where there is no distinction between user and kernel-side,
  52. * the U/K interface may be implemented as:@code
  53. * MALI_STATIC_INLINE _mali_osk_errcode_t _mali_uku_examplefunction( _mali_uk_examplefunction_s *args )
  54. * {
  55. * return mali_ukk_examplefunction( args );
  56. * }
  57. * @endcode
  58. * - Therefore, all U/K calls behave \em as \em though they were direct
  59. * function calls (but the \b implementation \em need \em not be a direct
  60. * function calls)
  61. *
  62. * @note Naming the _mali_uk functions the same on both User and Kernel sides
  63. * on non-RTOS systems causes debugging issues when setting breakpoints. In
  64. * this case, it is not clear which function the breakpoint is put on.
  65. * Therefore the _mali_uk functions in user space are prefixed with \c _mali_uku
  66. * and in kernel space with \c _mali_ukk. The naming for the argument
  67. * structures is unaffected.
  68. *
  69. * - The _mali_uk functions are synchronous.
  70. * - Arguments to the _mali_uk functions are passed in a structure. The only
  71. * parameter passed to the _mali_uk functions is a pointer to this structure.
  72. * This first member of this structure, ctx, is a pointer to a context returned
  73. * by _mali_uku_open(). For example:@code
  74. * typedef struct
  75. * {
  76. * void *ctx;
  77. * u32 number_of_cores;
  78. * } _mali_uk_get_gp_number_of_cores_s;
  79. * @endcode
  80. *
  81. * - Each _mali_uk function has its own argument structure named after the
  82. * function. The argument is distinguished by the _s suffix.
  83. * - The argument types are defined by the base driver and user-kernel
  84. * interface.
  85. * - All _mali_uk functions return a standard \ref _mali_osk_errcode_t.
  86. * - Only arguments of type input or input/output need be initialized before
  87. * calling a _mali_uk function.
  88. * - Arguments of type output and input/output are only valid when the
  89. * _mali_uk function returns \ref _MALI_OSK_ERR_OK.
  90. * - The \c ctx member is always invalid after it has been used by a
  91. * _mali_uk function, except for the context management functions
  92. *
  93. *
  94. * \b Interface \b restrictions
  95. *
  96. * The requirements of the interface mean that an implementation of the
  97. * User-kernel interface may do no 'real' work. For example, the following are
  98. * illegal in the User-kernel implementation:
  99. * - Calling functions necessary for operation on all systems, which would
  100. * not otherwise get called on RTOS systems.
  101. * - For example, a U/K interface that calls multiple _mali_ukk functions
  102. * during one particular U/K call. This could not be achieved by the same code
  103. * which uses direct function calls for the U/K interface.
  104. * - Writing in values to the args members, when otherwise these members would
  105. * not hold a useful value for a direct function call U/K interface.
  106. * - For example, U/K interface implementation that take NULL members in
  107. * their arguments structure from the user side, but those members are
  108. * replaced with non-NULL values in the kernel-side of the U/K interface
  109. * implementation. A scratch area for writing data is one such example. In this
  110. * case, a direct function call U/K interface would segfault, because no code
  111. * would be present to replace the NULL pointer with a meaningful pointer.
  112. * - Note that we discourage the case where the U/K implementation changes
  113. * a NULL argument member to non-NULL, and then the Device Driver code (outside
  114. * of the U/K layer) re-checks this member for NULL, and corrects it when
  115. * necessary. Whilst such code works even on direct function call U/K
  116. * intefaces, it reduces the testing coverage of the Device Driver code. This
  117. * is because we have no way of testing the NULL == value path on an OS
  118. * implementation.
  119. *
  120. * A number of allowable examples exist where U/K interfaces do 'real' work:
  121. * - The 'pointer switching' technique for \ref _mali_ukk_get_system_info
  122. * - In this case, without the pointer switching on direct function call
  123. * U/K interface, the Device Driver code still sees the same thing: a pointer
  124. * to which it can write memory. This is because such a system has no
  125. * distinction between a user and kernel pointer.
  126. * - Writing an OS-specific value into the ukk_private member for
  127. * _mali_ukk_mem_mmap().
  128. * - In this case, this value is passed around by Device Driver code, but
  129. * its actual value is never checked. Device Driver code simply passes it from
  130. * the U/K layer to the OSK layer, where it can be acted upon. In this case,
  131. * \em some OS implementations of the U/K (_mali_ukk_mem_mmap()) and OSK
  132. * (_mali_osk_mem_mapregion_init()) functions will collaborate on the
  133. * meaning of ukk_private member. On other OSs, it may be unused by both
  134. * U/K and OSK layers
  135. * - Therefore, on error inside the U/K interface implementation itself,
  136. * it will be as though the _mali_ukk function itself had failed, and cleaned
  137. * up after itself.
  138. * - Compare this to a direct function call U/K implementation, where all
  139. * error cleanup is handled by the _mali_ukk function itself. The direct
  140. * function call U/K interface implementation is automatically atomic.
  141. *
  142. * The last example highlights a consequence of all U/K interface
  143. * implementations: they must be atomic with respect to the Device Driver code.
  144. * And therefore, should Device Driver code succeed but the U/K implementation
  145. * fail afterwards (but before return to user-space), then the U/K
  146. * implementation must cause appropriate cleanup actions to preserve the
  147. * atomicity of the interface.
  148. *
  149. * @{
  150. */
  151. /** @defgroup _mali_uk_context U/K Context management
  152. *
  153. * These functions allow for initialisation of the user-kernel interface once per process.
  154. *
  155. * Generally the context will store the OS specific object to communicate with the kernel device driver and further
  156. * state information required by the specific implementation. The context is shareable among all threads in the caller process.
  157. *
  158. * On IOCTL systems, this is likely to be a file descriptor as a result of opening the kernel device driver.
  159. *
  160. * On a bare-metal/RTOS system with no distinction between kernel and
  161. * user-space, the U/K interface simply calls the _mali_ukk variant of the
  162. * function by direct function call. In this case, the context returned is the
  163. * mali_session_data from _mali_ukk_open().
  164. *
  165. * The kernel side implementations of the U/K interface expect the first member of the argument structure to
  166. * be the context created by _mali_uku_open(). On some OS implementations, the meaning of this context
  167. * will be different between user-side and kernel-side. In which case, the kernel-side will need to replace this context
  168. * with the kernel-side equivalent, because user-side will not have access to kernel-side data. The context parameter
  169. * in the argument structure therefore has to be of type input/output.
  170. *
  171. * It should be noted that the caller cannot reuse the \c ctx member of U/K
  172. * argument structure after a U/K call, because it may be overwritten. Instead,
  173. * the context handle must always be stored elsewhere, and copied into
  174. * the appropriate U/K argument structure for each user-side call to
  175. * the U/K interface. This is not usually a problem, since U/K argument
  176. * structures are usually placed on the stack.
  177. *
  178. * @{ */
  179. /** @brief Begin a new Mali Device Driver session
  180. *
  181. * This is used to obtain a per-process context handle for all future U/K calls.
  182. *
  183. * @param context pointer to storage to return a (void*)context handle.
  184. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  185. */
  186. _mali_osk_errcode_t _mali_ukk_open( void **context );
  187. /** @brief End a Mali Device Driver session
  188. *
  189. * This should be called when the process no longer requires use of the Mali Device Driver.
  190. *
  191. * The context handle must not be used after it has been closed.
  192. *
  193. * @param context pointer to a stored (void*)context handle.
  194. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  195. */
  196. _mali_osk_errcode_t _mali_ukk_close( void **context );
  197. /** @} */ /* end group _mali_uk_context */
  198. /** @addtogroup _mali_uk_core U/K Core
  199. *
  200. * The core functions provide the following functionality:
  201. * - verify that the user and kernel API are compatible
  202. * - retrieve information about the cores and memory banks in the system
  203. * - wait for the result of jobs started on a core
  204. *
  205. * @{ */
  206. /** @brief Waits for a job notification.
  207. *
  208. * Sleeps until notified or a timeout occurs. Returns information about the notification.
  209. *
  210. * @param args see _mali_uk_wait_for_notification_s in "mali_utgard_uk_types.h"
  211. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  212. */
  213. _mali_osk_errcode_t _mali_ukk_wait_for_notification( _mali_uk_wait_for_notification_s *args );
  214. /** @brief Post a notification to the notification queue of this application.
  215. *
  216. * @param args see _mali_uk_post_notification_s in "mali_utgard_uk_types.h"
  217. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  218. */
  219. _mali_osk_errcode_t _mali_ukk_post_notification( _mali_uk_post_notification_s *args );
  220. /** @brief Verifies if the user and kernel side of this API are compatible.
  221. *
  222. * @param args see _mali_uk_get_api_version_s in "mali_utgard_uk_types.h"
  223. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  224. */
  225. _mali_osk_errcode_t _mali_ukk_get_api_version( _mali_uk_get_api_version_s *args );
  226. /** @brief Get the user space settings applicable for calling process.
  227. *
  228. * @param args see _mali_uk_get_user_settings_s in "mali_utgard_uk_types.h"
  229. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  230. */
  231. _mali_osk_errcode_t _mali_ukk_get_user_settings(_mali_uk_get_user_settings_s *args);
  232. /** @brief Get a user space setting applicable for calling process.
  233. *
  234. * @param args see _mali_uk_get_user_setting_s in "mali_utgard_uk_types.h"
  235. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  236. */
  237. _mali_osk_errcode_t _mali_ukk_get_user_setting(_mali_uk_get_user_setting_s *args);
  238. /* @brief Grant or deny high priority scheduling for this session.
  239. *
  240. * @param args see _mali_uk_request_high_priority_s in "mali_utgard_uk_types.h"
  241. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  242. */
  243. _mali_osk_errcode_t _mali_ukk_request_high_priority(_mali_uk_request_high_priority_s *args);
  244. /** @} */ /* end group _mali_uk_core */
  245. /** @addtogroup _mali_uk_memory U/K Memory
  246. *
  247. * The memory functions provide functionality with and without a Mali-MMU present.
  248. *
  249. * For Mali-MMU based systems, the following functionality is provided:
  250. * - Initialize and terminate MALI virtual address space
  251. * - Allocate/deallocate physical memory to a MALI virtual address range and map into/unmap from the
  252. * current process address space
  253. * - Map/unmap external physical memory into the MALI virtual address range
  254. *
  255. * For Mali-nonMMU based systems:
  256. * - Allocate/deallocate MALI memory
  257. *
  258. * @{ */
  259. /** @brief Map Mali Memory into the current user process
  260. *
  261. * Maps Mali memory into the current user process in a generic way.
  262. *
  263. * This function is to be used for Mali-MMU mode. The function is available in both Mali-MMU and Mali-nonMMU modes,
  264. * but should not be called by a user process in Mali-nonMMU mode.
  265. *
  266. * The implementation and operation of _mali_ukk_mem_mmap() is dependant on whether the driver is built for Mali-MMU
  267. * or Mali-nonMMU:
  268. * - In the nonMMU case, _mali_ukk_mem_mmap() requires a physical address to be specified. For this reason, an OS U/K
  269. * implementation should not allow this to be called from user-space. In any case, nonMMU implementations are
  270. * inherently insecure, and so the overall impact is minimal. Mali-MMU mode should be used if security is desired.
  271. * - In the MMU case, _mali_ukk_mem_mmap() the _mali_uk_mem_mmap_s::phys_addr
  272. * member is used for the \em Mali-virtual address desired for the mapping. The
  273. * implementation of _mali_ukk_mem_mmap() will allocate both the CPU-virtual
  274. * and CPU-physical addresses, and can cope with mapping a contiguous virtual
  275. * address range to a sequence of non-contiguous physical pages. In this case,
  276. * the CPU-physical addresses are not communicated back to the user-side, as
  277. * they are unnecsessary; the \em Mali-virtual address range must be used for
  278. * programming Mali structures.
  279. *
  280. * In the second (MMU) case, _mali_ukk_mem_mmap() handles management of
  281. * CPU-virtual and CPU-physical ranges, but the \em caller must manage the
  282. * \em Mali-virtual address range from the user-side.
  283. *
  284. * @note Mali-virtual address ranges are entirely separate between processes.
  285. * It is not possible for a process to accidentally corrupt another process'
  286. * \em Mali-virtual address space.
  287. *
  288. * @param args see _mali_uk_mem_mmap_s in "mali_utgard_uk_types.h"
  289. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  290. */
  291. _mali_osk_errcode_t _mali_ukk_mem_mmap( _mali_uk_mem_mmap_s *args );
  292. /** @brief Unmap Mali Memory from the current user process
  293. *
  294. * Unmaps Mali memory from the current user process in a generic way. This only operates on Mali memory supplied
  295. * from _mali_ukk_mem_mmap().
  296. *
  297. * @param args see _mali_uk_mem_munmap_s in "mali_utgard_uk_types.h"
  298. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  299. */
  300. _mali_osk_errcode_t _mali_ukk_mem_munmap( _mali_uk_mem_munmap_s *args );
  301. /** @brief Determine the buffer size necessary for an MMU page table dump.
  302. * @param args see _mali_uk_query_mmu_page_table_dump_size_s in mali_utgard_uk_types.h
  303. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  304. */
  305. _mali_osk_errcode_t _mali_ukk_query_mmu_page_table_dump_size( _mali_uk_query_mmu_page_table_dump_size_s *args );
  306. /** @brief Dump MMU Page tables.
  307. * @param args see _mali_uk_dump_mmu_page_table_s in mali_utgard_uk_types.h
  308. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  309. */
  310. _mali_osk_errcode_t _mali_ukk_dump_mmu_page_table( _mali_uk_dump_mmu_page_table_s * args );
  311. /** @brief Write user data to specified Mali memory without causing segfaults.
  312. * @param args see _mali_uk_mem_write_safe_s in mali_utgard_uk_types.h
  313. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  314. */
  315. _mali_osk_errcode_t _mali_ukk_mem_write_safe( _mali_uk_mem_write_safe_s *args );
  316. /** @brief Map a physically contiguous range of memory into Mali
  317. * @param args see _mali_uk_map_external_mem_s in mali_utgard_uk_types.h
  318. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  319. */
  320. _mali_osk_errcode_t _mali_ukk_map_external_mem( _mali_uk_map_external_mem_s *args );
  321. /** @brief Unmap a physically contiguous range of memory from Mali
  322. * @param args see _mali_uk_unmap_external_mem_s in mali_utgard_uk_types.h
  323. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  324. */
  325. _mali_osk_errcode_t _mali_ukk_unmap_external_mem( _mali_uk_unmap_external_mem_s *args );
  326. #if defined(CONFIG_MALI400_UMP)
  327. /** @brief Map UMP memory into Mali
  328. * @param args see _mali_uk_attach_ump_mem_s in mali_utgard_uk_types.h
  329. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  330. */
  331. _mali_osk_errcode_t _mali_ukk_attach_ump_mem( _mali_uk_attach_ump_mem_s *args );
  332. /** @brief Unmap UMP memory from Mali
  333. * @param args see _mali_uk_release_ump_mem_s in mali_utgard_uk_types.h
  334. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  335. */
  336. _mali_osk_errcode_t _mali_ukk_release_ump_mem( _mali_uk_release_ump_mem_s *args );
  337. #endif /* CONFIG_MALI400_UMP */
  338. /** @brief Determine virtual-to-physical mapping of a contiguous memory range
  339. * (optional)
  340. *
  341. * This allows the user-side to do a virtual-to-physical address translation.
  342. * In conjunction with _mali_uku_map_external_mem, this can be used to do
  343. * direct rendering.
  344. *
  345. * This function will only succeed on a virtual range that is mapped into the
  346. * current process, and that is contigious.
  347. *
  348. * If va is not page-aligned, then it is rounded down to the next page
  349. * boundary. The remainer is added to size, such that ((u32)va)+size before
  350. * rounding is equal to ((u32)va)+size after rounding. The rounded modified
  351. * va and size will be written out into args on success.
  352. *
  353. * If the supplied size is zero, or not a multiple of the system's PAGE_SIZE,
  354. * then size will be rounded up to the next multiple of PAGE_SIZE before
  355. * translation occurs. The rounded up size will be written out into args on
  356. * success.
  357. *
  358. * On most OSs, virtual-to-physical address translation is a priveledged
  359. * function. Therefore, the implementer must validate the range supplied, to
  360. * ensure they are not providing arbitrary virtual-to-physical address
  361. * translations. While it is unlikely such a mechanism could be used to
  362. * compromise the security of a system on its own, it is possible it could be
  363. * combined with another small security risk to cause a much larger security
  364. * risk.
  365. *
  366. * @note This is an optional part of the interface, and is only used by certain
  367. * implementations of libEGL. If the platform layer in your libEGL
  368. * implementation does not require Virtual-to-Physical address translation,
  369. * then this function need not be implemented. A stub implementation should not
  370. * be required either, as it would only be removed by the compiler's dead code
  371. * elimination.
  372. *
  373. * @note if implemented, this function is entirely platform-dependant, and does
  374. * not exist in common code.
  375. *
  376. * @param args see _mali_uk_va_to_mali_pa_s in "mali_utgard_uk_types.h"
  377. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  378. */
  379. _mali_osk_errcode_t _mali_ukk_va_to_mali_pa( _mali_uk_va_to_mali_pa_s * args );
  380. /** @} */ /* end group _mali_uk_memory */
  381. /** @addtogroup _mali_uk_pp U/K Fragment Processor
  382. *
  383. * The Fragment Processor (aka PP (Pixel Processor)) functions provide the following functionality:
  384. * - retrieving version of the fragment processors
  385. * - determine number of fragment processors
  386. * - starting a job on a fragment processor
  387. *
  388. * @{ */
  389. /** @brief Issue a request to start a new job on a Fragment Processor.
  390. *
  391. * If the request fails args->status is set to _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE and you can
  392. * try to start the job again.
  393. *
  394. * An existing job could be returned for requeueing if the new job has a higher priority than a previously started job
  395. * which the hardware hasn't actually started processing yet. In this case the new job will be started instead and the
  396. * existing one returned, otherwise the new job is started and the status field args->status is set to
  397. * _MALI_UK_START_JOB_STARTED.
  398. *
  399. * Job completion can be awaited with _mali_ukk_wait_for_notification().
  400. *
  401. * @param ctx user-kernel context (mali_session)
  402. * @param uargs see _mali_uk_pp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data!
  403. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  404. */
  405. _mali_osk_errcode_t _mali_ukk_pp_start_job( void *ctx, _mali_uk_pp_start_job_s *uargs );
  406. /**
  407. * @brief Issue a request to start new jobs on both Vertex Processor and Fragment Processor.
  408. *
  409. * @note Will call into @ref _mali_ukk_pp_start_job and @ref _mali_ukk_gp_start_job.
  410. *
  411. * @param ctx user-kernel context (mali_session)
  412. * @param uargs see _mali_uk_pp_and_gp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data!
  413. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  414. */
  415. _mali_osk_errcode_t _mali_ukk_pp_and_gp_start_job( void *ctx, _mali_uk_pp_and_gp_start_job_s *uargs );
  416. /** @brief Returns the number of Fragment Processors in the system
  417. *
  418. * @param args see _mali_uk_get_pp_number_of_cores_s in "mali_utgard_uk_types.h"
  419. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  420. */
  421. _mali_osk_errcode_t _mali_ukk_get_pp_number_of_cores( _mali_uk_get_pp_number_of_cores_s *args );
  422. /** @brief Returns the version that all Fragment Processor cores are compatible with.
  423. *
  424. * This function may only be called when _mali_ukk_get_pp_number_of_cores() indicated at least one Fragment
  425. * Processor core is available.
  426. *
  427. * @param args see _mali_uk_get_pp_core_version_s in "mali_utgard_uk_types.h"
  428. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  429. */
  430. _mali_osk_errcode_t _mali_ukk_get_pp_core_version( _mali_uk_get_pp_core_version_s *args );
  431. /** @brief Disable Write-back unit(s) on specified job
  432. *
  433. * @param args see _mali_uk_get_pp_core_version_s in "mali_utgard_uk_types.h"
  434. */
  435. void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args);
  436. /** @} */ /* end group _mali_uk_pp */
  437. /** @addtogroup _mali_uk_gp U/K Vertex Processor
  438. *
  439. * The Vertex Processor (aka GP (Geometry Processor)) functions provide the following functionality:
  440. * - retrieving version of the Vertex Processors
  441. * - determine number of Vertex Processors available
  442. * - starting a job on a Vertex Processor
  443. *
  444. * @{ */
  445. /** @brief Issue a request to start a new job on a Vertex Processor.
  446. *
  447. * If the request fails args->status is set to _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE and you can
  448. * try to start the job again.
  449. *
  450. * An existing job could be returned for requeueing if the new job has a higher priority than a previously started job
  451. * which the hardware hasn't actually started processing yet. In this case the new job will be started and the
  452. * existing one returned, otherwise the new job is started and the status field args->status is set to
  453. * _MALI_UK_START_JOB_STARTED.
  454. *
  455. * Job completion can be awaited with _mali_ukk_wait_for_notification().
  456. *
  457. * @param ctx user-kernel context (mali_session)
  458. * @param uargs see _mali_uk_gp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data!
  459. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  460. */
  461. _mali_osk_errcode_t _mali_ukk_gp_start_job( void *ctx, _mali_uk_gp_start_job_s *uargs );
  462. /** @brief Returns the number of Vertex Processors in the system.
  463. *
  464. * @param args see _mali_uk_get_gp_number_of_cores_s in "mali_utgard_uk_types.h"
  465. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  466. */
  467. _mali_osk_errcode_t _mali_ukk_get_gp_number_of_cores( _mali_uk_get_gp_number_of_cores_s *args );
  468. /** @brief Returns the version that all Vertex Processor cores are compatible with.
  469. *
  470. * This function may only be called when _mali_uk_get_gp_number_of_cores() indicated at least one Vertex
  471. * Processor core is available.
  472. *
  473. * @param args see _mali_uk_get_gp_core_version_s in "mali_utgard_uk_types.h"
  474. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  475. */
  476. _mali_osk_errcode_t _mali_ukk_get_gp_core_version( _mali_uk_get_gp_core_version_s *args );
  477. /** @brief Resume or abort suspended Vertex Processor jobs.
  478. *
  479. * After receiving notification that a Vertex Processor job was suspended from
  480. * _mali_ukk_wait_for_notification() you can use this function to resume or abort the job.
  481. *
  482. * @param args see _mali_uk_gp_suspend_response_s in "mali_utgard_uk_types.h"
  483. * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
  484. */
  485. _mali_osk_errcode_t _mali_ukk_gp_suspend_response( _mali_uk_gp_suspend_response_s *args );
  486. /** @} */ /* end group _mali_uk_gp */
  487. #if defined(CONFIG_MALI400_PROFILING)
  488. /** @addtogroup _mali_uk_profiling U/K Timeline profiling module
  489. * @{ */
  490. /** @brief Start recording profiling events.
  491. *
  492. * @param args see _mali_uk_profiling_start_s in "mali_utgard_uk_types.h"
  493. */
  494. _mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args);
  495. /** @brief Add event to profiling buffer.
  496. *
  497. * @param args see _mali_uk_profiling_add_event_s in "mali_utgard_uk_types.h"
  498. */
  499. _mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args);
  500. /** @brief Stop recording profiling events.
  501. *
  502. * @param args see _mali_uk_profiling_stop_s in "mali_utgard_uk_types.h"
  503. */
  504. _mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args);
  505. /** @brief Retrieve a recorded profiling event.
  506. *
  507. * @param args see _mali_uk_profiling_get_event_s in "mali_utgard_uk_types.h"
  508. */
  509. _mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args);
  510. /** @brief Clear recorded profiling events.
  511. *
  512. * @param args see _mali_uk_profiling_clear_s in "mali_utgard_uk_types.h"
  513. */
  514. _mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args);
  515. /** @} */ /* end group _mali_uk_profiling */
  516. #endif
  517. /** @addtogroup _mali_uk_vsync U/K VSYNC reporting module
  518. * @{ */
  519. /** @brief Report events related to vsync.
  520. *
  521. * @note Events should be reported when starting to wait for vsync and when the
  522. * waiting is finished. This information can then be used in kernel space to
  523. * complement the GPU utilization metric.
  524. *
  525. * @param args see _mali_uk_vsync_event_report_s in "mali_utgard_uk_types.h"
  526. */
  527. _mali_osk_errcode_t _mali_ukk_vsync_event_report(_mali_uk_vsync_event_report_s *args);
  528. /** @} */ /* end group _mali_uk_vsync */
  529. /** @addtogroup _mali_sw_counters_report U/K Software counter reporting
  530. * @{ */
  531. /** @brief Report software counters.
  532. *
  533. * @param args see _mali_uk_sw_counters_report_s in "mali_uk_types.h"
  534. */
  535. _mali_osk_errcode_t _mali_ukk_sw_counters_report(_mali_uk_sw_counters_report_s *args);
  536. /** @} */ /* end group _mali_sw_counters_report */
  537. /** @} */ /* end group u_k_api */
  538. /** @} */ /* end group uddapi */
  539. u32 _mali_ukk_report_memory_usage(void);
  540. u32 _mali_ukk_utilization_gp_pp(void);
  541. u32 _mali_ukk_utilization_gp(void);
  542. u32 _mali_ukk_utilization_pp(void);
  543. #ifdef __cplusplus
  544. }
  545. #endif
  546. #endif /* __MALI_UKK_H__ */