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