1 /* 2 * Copyright (C) 2010-2017 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_uk_types.h 13 * Defines the types and constants used in the user-kernel interface 14 */ 15 16 #ifndef __MALI_UTGARD_UK_TYPES_H__ 17 #define __MALI_UTGARD_UK_TYPES_H__ 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /* Iteration functions depend on these values being consecutive. */ 24 #define MALI_UK_TIMELINE_GP 0 25 #define MALI_UK_TIMELINE_PP 1 26 #define MALI_UK_TIMELINE_SOFT 2 27 #define MALI_UK_TIMELINE_MAX 3 28 29 #define MALI_UK_BIG_VARYING_SIZE (1024*1024*2) 30 31 typedef struct { 32 u32 points[MALI_UK_TIMELINE_MAX]; 33 s32 sync_fd; 34 } _mali_uk_fence_t; 35 36 /** 37 * @addtogroup uddapi Unified Device Driver (UDD) APIs 38 * 39 * @{ 40 */ 41 42 /** 43 * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs 44 * 45 * @{ 46 */ 47 48 /** @defgroup _mali_uk_core U/K Core 49 * @{ */ 50 51 /** Definition of subsystem numbers, to assist in creating a unique identifier 52 * for each U/K call. 53 * 54 * @see _mali_uk_functions */ 55 typedef enum { 56 _MALI_UK_CORE_SUBSYSTEM, /**< Core Group of U/K calls */ 57 _MALI_UK_MEMORY_SUBSYSTEM, /**< Memory Group of U/K calls */ 58 _MALI_UK_PP_SUBSYSTEM, /**< Fragment Processor Group of U/K calls */ 59 _MALI_UK_GP_SUBSYSTEM, /**< Vertex Processor Group of U/K calls */ 60 _MALI_UK_PROFILING_SUBSYSTEM, /**< Profiling Group of U/K calls */ 61 _MALI_UK_VSYNC_SUBSYSTEM, /**< VSYNC Group of U/K calls */ 62 } _mali_uk_subsystem_t; 63 64 /** Within a function group each function has its unique sequence number 65 * to assist in creating a unique identifier for each U/K call. 66 * 67 * An ordered pair of numbers selected from 68 * ( \ref _mali_uk_subsystem_t,\ref _mali_uk_functions) will uniquely identify the 69 * U/K call across all groups of functions, and all functions. */ 70 typedef enum { 71 /** Core functions */ 72 73 _MALI_UK_OPEN = 0, /**< _mali_ukk_open() */ 74 _MALI_UK_CLOSE, /**< _mali_ukk_close() */ 75 _MALI_UK_WAIT_FOR_NOTIFICATION, /**< _mali_ukk_wait_for_notification() */ 76 _MALI_UK_GET_API_VERSION, /**< _mali_ukk_get_api_version() */ 77 _MALI_UK_POST_NOTIFICATION, /**< _mali_ukk_post_notification() */ 78 _MALI_UK_GET_USER_SETTING, /**< _mali_ukk_get_user_setting() *//**< [out] */ 79 _MALI_UK_GET_USER_SETTINGS, /**< _mali_ukk_get_user_settings() *//**< [out] */ 80 _MALI_UK_REQUEST_HIGH_PRIORITY, /**< _mali_ukk_request_high_priority() */ 81 _MALI_UK_TIMELINE_GET_LATEST_POINT, /**< _mali_ukk_timeline_get_latest_point() */ 82 _MALI_UK_TIMELINE_WAIT, /**< _mali_ukk_timeline_wait() */ 83 _MALI_UK_TIMELINE_CREATE_SYNC_FENCE, /**< _mali_ukk_timeline_create_sync_fence() */ 84 _MALI_UK_SOFT_JOB_START, /**< _mali_ukk_soft_job_start() */ 85 _MALI_UK_SOFT_JOB_SIGNAL, /**< _mali_ukk_soft_job_signal() */ 86 _MALI_UK_PENDING_SUBMIT, /**< _mali_ukk_pending_submit() */ 87 88 _MALI_GET_RK_KO_VERSION, /* rk_ext */ 89 _MALI_UK_GET_MALI_VERSION_IN_RK30, 90 91 /** Memory functions */ 92 93 _MALI_UK_ALLOC_MEM = 0, /**< _mali_ukk_alloc_mem() */ 94 _MALI_UK_FREE_MEM, /**< _mali_ukk_free_mem() */ 95 _MALI_UK_BIND_MEM, /**< _mali_ukk_mem_bind() */ 96 _MALI_UK_UNBIND_MEM, /**< _mali_ukk_mem_unbind() */ 97 _MALI_UK_COW_MEM, /**< _mali_ukk_mem_cow() */ 98 _MALI_UK_COW_MODIFY_RANGE, /**< _mali_ukk_mem_cow_modify_range() */ 99 _MALI_UK_RESIZE_MEM, /**<._mali_ukk_mem_resize() */ 100 _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, /**< _mali_ukk_mem_get_mmu_page_table_dump_size() */ 101 _MALI_UK_DUMP_MMU_PAGE_TABLE, /**< _mali_ukk_mem_dump_mmu_page_table() */ 102 _MALI_UK_DMA_BUF_GET_SIZE, /**< _mali_ukk_dma_buf_get_size() */ 103 _MALI_UK_MEM_WRITE_SAFE, /**< _mali_uku_mem_write_safe() */ 104 105 /** Common functions for each core */ 106 107 _MALI_UK_START_JOB = 0, /**< Start a Fragment/Vertex Processor Job on a core */ 108 _MALI_UK_GET_NUMBER_OF_CORES, /**< Get the number of Fragment/Vertex Processor cores */ 109 _MALI_UK_GET_CORE_VERSION, /**< Get the Fragment/Vertex Processor version compatible with all cores */ 110 111 /** Fragment Processor Functions */ 112 113 _MALI_UK_PP_START_JOB = _MALI_UK_START_JOB, /**< _mali_ukk_pp_start_job() */ 114 _MALI_UK_GET_PP_NUMBER_OF_CORES = _MALI_UK_GET_NUMBER_OF_CORES, /**< _mali_ukk_get_pp_number_of_cores() */ 115 _MALI_UK_GET_PP_CORE_VERSION = _MALI_UK_GET_CORE_VERSION, /**< _mali_ukk_get_pp_core_version() */ 116 _MALI_UK_PP_DISABLE_WB, /**< _mali_ukk_pp_job_disable_wb() */ 117 _MALI_UK_PP_AND_GP_START_JOB, /**< _mali_ukk_pp_and_gp_start_job() */ 118 119 /** Vertex Processor Functions */ 120 121 _MALI_UK_GP_START_JOB = _MALI_UK_START_JOB, /**< _mali_ukk_gp_start_job() */ 122 _MALI_UK_GET_GP_NUMBER_OF_CORES = _MALI_UK_GET_NUMBER_OF_CORES, /**< _mali_ukk_get_gp_number_of_cores() */ 123 _MALI_UK_GET_GP_CORE_VERSION = _MALI_UK_GET_CORE_VERSION, /**< _mali_ukk_get_gp_core_version() */ 124 _MALI_UK_GP_SUSPEND_RESPONSE, /**< _mali_ukk_gp_suspend_response() */ 125 126 /** Profiling functions */ 127 128 _MALI_UK_PROFILING_ADD_EVENT = 0, /**< __mali_uku_profiling_add_event() */ 129 _MALI_UK_PROFILING_REPORT_SW_COUNTERS,/**< __mali_uku_profiling_report_sw_counters() */ 130 _MALI_UK_PROFILING_MEMORY_USAGE_GET, /**< __mali_uku_profiling_memory_usage_get() */ 131 _MALI_UK_PROFILING_STREAM_FD_GET, /** < __mali_uku_profiling_stream_fd_get() */ 132 _MALI_UK_PROFILING_CONTROL_SET, /** < __mali_uku_profiling_control_set() */ 133 134 /** VSYNC reporting fuctions */ 135 _MALI_UK_VSYNC_EVENT_REPORT = 0, /**< _mali_ukk_vsync_event_report() */ 136 } _mali_uk_functions; 137 138 /** @defgroup _mali_uk_getsysteminfo U/K Get System Info 139 * @{ */ 140 141 /** 142 * Type definition for the core version number. 143 * Used when returning the version number read from a core 144 * 145 * Its format is that of the 32-bit Version register for a particular core. 146 * Refer to the "Mali200 and MaliGP2 3D Graphics Processor Technical Reference 147 * Manual", ARM DDI 0415C, for more information. 148 */ 149 typedef u32 _mali_core_version; 150 151 /** @} */ /* end group _mali_uk_core */ 152 153 154 /** @defgroup _mali_uk_gp U/K Vertex Processor 155 * @{ */ 156 157 /** @defgroup _mali_uk_gp_suspend_response_s Vertex Processor Suspend Response 158 * @{ */ 159 160 /** @brief Arguments for _mali_ukk_gp_suspend_response() 161 * 162 * When _mali_wait_for_notification() receives notification that a 163 * Vertex Processor job was suspended, you need to send a response to indicate 164 * what needs to happen with this job. You can either abort or resume the job. 165 * 166 * - set @c code to indicate response code. This is either @c _MALIGP_JOB_ABORT or 167 * @c _MALIGP_JOB_RESUME_WITH_NEW_HEAP to indicate you will provide a new heap 168 * for the job that will resolve the out of memory condition for the job. 169 * - copy the @c cookie value from the @c _mali_uk_gp_job_suspended_s notification; 170 * this is an identifier for the suspended job 171 * - set @c arguments[0] and @c arguments[1] to zero if you abort the job. If 172 * you resume it, @c argument[0] should specify the Mali start address for the new 173 * heap and @c argument[1] the Mali end address of the heap. 174 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 175 * 176 */ 177 typedef enum _maligp_job_suspended_response_code { 178 _MALIGP_JOB_ABORT, /**< Abort the Vertex Processor job */ 179 _MALIGP_JOB_RESUME_WITH_NEW_HEAP /**< Resume the Vertex Processor job with a new heap */ 180 } _maligp_job_suspended_response_code; 181 182 typedef struct { 183 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 184 u32 cookie; /**< [in] cookie from the _mali_uk_gp_job_suspended_s notification */ 185 _maligp_job_suspended_response_code code; /**< [in] abort or resume response code, see \ref _maligp_job_suspended_response_code */ 186 u32 arguments[2]; /**< [in] 0 when aborting a job. When resuming a job, the Mali start and end address for a new heap to resume the job with */ 187 } _mali_uk_gp_suspend_response_s; 188 189 /** @} */ /* end group _mali_uk_gp_suspend_response_s */ 190 191 /** @defgroup _mali_uk_gpstartjob_s Vertex Processor Start Job 192 * @{ */ 193 194 /** @brief Status indicating the result of the execution of a Vertex or Fragment processor job */ 195 typedef enum { 196 _MALI_UK_JOB_STATUS_END_SUCCESS = 1 << (16 + 0), 197 _MALI_UK_JOB_STATUS_END_OOM = 1 << (16 + 1), 198 _MALI_UK_JOB_STATUS_END_ABORT = 1 << (16 + 2), 199 _MALI_UK_JOB_STATUS_END_TIMEOUT_SW = 1 << (16 + 3), 200 _MALI_UK_JOB_STATUS_END_HANG = 1 << (16 + 4), 201 _MALI_UK_JOB_STATUS_END_SEG_FAULT = 1 << (16 + 5), 202 _MALI_UK_JOB_STATUS_END_ILLEGAL_JOB = 1 << (16 + 6), 203 _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR = 1 << (16 + 7), 204 _MALI_UK_JOB_STATUS_END_SHUTDOWN = 1 << (16 + 8), 205 _MALI_UK_JOB_STATUS_END_SYSTEM_UNUSABLE = 1 << (16 + 9) 206 } _mali_uk_job_status; 207 208 #define MALIGP2_NUM_REGS_FRAME (6) 209 210 /** @brief Arguments for _mali_ukk_gp_start_job() 211 * 212 * To start a Vertex Processor job 213 * - associate the request with a reference to a @c mali_gp_job_info by setting 214 * user_job_ptr to the address of the @c mali_gp_job_info of the job. 215 * - set @c priority to the priority of the @c mali_gp_job_info 216 * - specify a timeout for the job by setting @c watchdog_msecs to the number of 217 * milliseconds the job is allowed to run. Specifying a value of 0 selects the 218 * default timeout in use by the device driver. 219 * - copy the frame registers from the @c mali_gp_job_info into @c frame_registers. 220 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero 221 * for a non-instrumented build. For an instrumented build you can use up 222 * to two performance counters. Set the corresponding bit in @c perf_counter_flag 223 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify 224 * the source of what needs to get counted (e.g. number of vertex loader 225 * cache hits). For source id values, see ARM DDI0415A, Table 3-60. 226 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 227 * 228 * When @c _mali_ukk_gp_start_job() returns @c _MALI_OSK_ERR_OK, status contains the 229 * result of the request (see \ref _mali_uk_start_job_status). If the job could 230 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be 231 * tried again. 232 * 233 * After the job has started, @c _mali_wait_for_notification() will be notified 234 * that the job finished or got suspended. It may get suspended due to 235 * resource shortage. If it finished (see _mali_ukk_wait_for_notification()) 236 * the notification will contain a @c _mali_uk_gp_job_finished_s result. If 237 * it got suspended the notification will contain a @c _mali_uk_gp_job_suspended_s 238 * result. 239 * 240 * The @c _mali_uk_gp_job_finished_s contains the job status (see \ref _mali_uk_job_status), 241 * the number of milliseconds the job took to render, and values of core registers 242 * when the job finished (irq status, performance counters, renderer list 243 * address). A job has finished succesfully when its status is 244 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering 245 * the job, or software detected the job is taking more than watchdog_msecs to 246 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG. 247 * If the hardware detected a bus error while accessing memory associated with the 248 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT. 249 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to 250 * stop the job but the job didn't start on the hardware yet, e.g. when the 251 * driver shutdown. 252 * 253 * In case the job got suspended, @c _mali_uk_gp_job_suspended_s contains 254 * the @c user_job_ptr identifier used to start the job with, the @c reason 255 * why the job stalled (see \ref _maligp_job_suspended_reason) and a @c cookie 256 * to identify the core on which the job stalled. This @c cookie will be needed 257 * when responding to this nofication by means of _mali_ukk_gp_suspend_response(). 258 * (see _mali_ukk_gp_suspend_response()). The response is either to abort or 259 * resume the job. If the job got suspended due to an out of memory condition 260 * you may be able to resolve this by providing more memory and resuming the job. 261 * 262 */ 263 typedef struct { 264 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 265 u64 user_job_ptr; /**< [in] identifier for the job in user space, a @c mali_gp_job_info* */ 266 u32 priority; /**< [in] job priority. A lower number means higher priority */ 267 u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< [in] core specific registers associated with this job */ 268 u32 perf_counter_flag; /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */ 269 u32 perf_counter_src0; /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */ 270 u32 perf_counter_src1; /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */ 271 u32 frame_builder_id; /**< [in] id of the originating frame builder */ 272 u32 flush_id; /**< [in] flush id within the originating frame builder */ 273 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */ 274 u64 timeline_point_ptr; /**< [in,out] pointer to u32: location where point on gp timeline for this job will be written */ 275 u32 varying_memsize; /** < [in] size of varying memory to use deffer bind*/ 276 u32 deferred_mem_num; 277 u64 deferred_mem_list; /** < [in] memory hanlde list of varying buffer to use deffer bind */ 278 } _mali_uk_gp_start_job_s; 279 280 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */ 281 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE (1<<1) /**< Enable performance counter SRC1 for a job */ 282 #define _MALI_PERFORMANCE_COUNTER_FLAG_HEATMAP_ENABLE (1<<2) /**< Enable per tile (aka heatmap) generation with for a job (using the enabled counter sources) */ 283 284 /** @} */ /* end group _mali_uk_gpstartjob_s */ 285 286 typedef struct { 287 u64 user_job_ptr; /**< [out] identifier for the job in user space */ 288 _mali_uk_job_status status; /**< [out] status of finished job */ 289 u32 heap_current_addr; /**< [out] value of the GP PLB PL heap start address register */ 290 u32 perf_counter0; /**< [out] value of performance counter 0 (see ARM DDI0415A) */ 291 u32 perf_counter1; /**< [out] value of performance counter 1 (see ARM DDI0415A) */ 292 u32 pending_big_job_num; 293 } _mali_uk_gp_job_finished_s; 294 295 typedef struct { 296 u64 user_job_ptr; /**< [out] identifier for the job in user space */ 297 u32 cookie; /**< [out] identifier for the core in kernel space on which the job stalled */ 298 } _mali_uk_gp_job_suspended_s; 299 300 /** @} */ /* end group _mali_uk_gp */ 301 302 303 /** @defgroup _mali_uk_pp U/K Fragment Processor 304 * @{ */ 305 306 #define _MALI_PP_MAX_SUB_JOBS 8 307 308 #define _MALI_PP_MAX_FRAME_REGISTERS ((0x058/4)+1) 309 310 #define _MALI_PP_MAX_WB_REGISTERS ((0x02C/4)+1) 311 312 #define _MALI_DLBU_MAX_REGISTERS 4 313 314 /** Flag for _mali_uk_pp_start_job_s */ 315 #define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0) 316 #define _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE (1<<1) 317 #define _MALI_PP_JOB_FLAG_PROTECTED (1<<2) 318 319 /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job 320 * @{ */ 321 322 /** @brief Arguments for _mali_ukk_pp_start_job() 323 * 324 * To start a Fragment Processor job 325 * - associate the request with a reference to a mali_pp_job by setting 326 * @c user_job_ptr to the address of the @c mali_pp_job of the job. 327 * - set @c priority to the priority of the mali_pp_job 328 * - specify a timeout for the job by setting @c watchdog_msecs to the number of 329 * milliseconds the job is allowed to run. Specifying a value of 0 selects the 330 * default timeout in use by the device driver. 331 * - copy the frame registers from the @c mali_pp_job into @c frame_registers. 332 * For MALI200 you also need to copy the write back 0,1 and 2 registers. 333 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero 334 * for a non-instrumented build. For an instrumented build you can use up 335 * to two performance counters. Set the corresponding bit in @c perf_counter_flag 336 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify 337 * the source of what needs to get counted (e.g. number of vertex loader 338 * cache hits). For source id values, see ARM DDI0415A, Table 3-60. 339 * - pass in the user-kernel context in @c ctx that was returned from _mali_ukk_open() 340 * 341 * When _mali_ukk_pp_start_job() returns @c _MALI_OSK_ERR_OK, @c status contains the 342 * result of the request (see \ref _mali_uk_start_job_status). If the job could 343 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be 344 * tried again. 345 * 346 * After the job has started, _mali_wait_for_notification() will be notified 347 * when the job finished. The notification will contain a 348 * @c _mali_uk_pp_job_finished_s result. It contains the @c user_job_ptr 349 * identifier used to start the job with, the job @c status (see \ref _mali_uk_job_status), 350 * the number of milliseconds the job took to render, and values of core registers 351 * when the job finished (irq status, performance counters, renderer list 352 * address). A job has finished succesfully when its status is 353 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering 354 * the job, or software detected the job is taking more than @c watchdog_msecs to 355 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG. 356 * If the hardware detected a bus error while accessing memory associated with the 357 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT. 358 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to 359 * stop the job but the job didn't start on the hardware yet, e.g. when the 360 * driver shutdown. 361 * 362 */ 363 typedef struct { 364 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 365 u64 user_job_ptr; /**< [in] identifier for the job in user space */ 366 u32 priority; /**< [in] job priority. A lower number means higher priority */ 367 u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS]; /**< [in] core specific registers associated with first sub job, see ARM DDI0415A */ 368 u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_FRAME registers for sub job 1-7 */ 369 u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_STACK registers for sub job 1-7 */ 370 u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS]; 371 u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS]; 372 u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS]; 373 u32 dlbu_registers[_MALI_DLBU_MAX_REGISTERS]; /**< [in] Dynamic load balancing unit registers */ 374 u32 num_cores; /**< [in] Number of cores to set up (valid range: 1-8(M450) or 4(M400)) */ 375 u32 perf_counter_flag; /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */ 376 u32 perf_counter_src0; /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */ 377 u32 perf_counter_src1; /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */ 378 u32 frame_builder_id; /**< [in] id of the originating frame builder */ 379 u32 flush_id; /**< [in] flush id within the originating frame builder */ 380 u32 flags; /**< [in] See _MALI_PP_JOB_FLAG_* for a list of avaiable flags */ 381 u32 tilesx; /**< [in] number of tiles in the x direction (needed for heatmap generation */ 382 u32 tilesy; /**< [in] number of tiles in y direction (needed for reading the heatmap memory) */ 383 u32 heatmap_mem; /**< [in] memory address to store counter values per tile (aka heatmap) */ 384 u32 num_memory_cookies; /**< [in] number of memory cookies attached to job */ 385 u64 memory_cookies; /**< [in] pointer to array of u32 memory cookies attached to job */ 386 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */ 387 u64 timeline_point_ptr; /**< [in,out] pointer to location of u32 where point on pp timeline for this job will be written */ 388 } _mali_uk_pp_start_job_s; 389 390 typedef struct { 391 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 392 u64 gp_args; /**< [in,out] GP uk arguments (see _mali_uk_gp_start_job_s) */ 393 u64 pp_args; /**< [in,out] PP uk arguments (see _mali_uk_pp_start_job_s) */ 394 } _mali_uk_pp_and_gp_start_job_s; 395 396 /** @} */ /* end group _mali_uk_ppstartjob_s */ 397 398 typedef struct { 399 u64 user_job_ptr; /**< [out] identifier for the job in user space */ 400 _mali_uk_job_status status; /**< [out] status of finished job */ 401 u32 perf_counter0[_MALI_PP_MAX_SUB_JOBS]; /**< [out] value of perfomance counter 0 (see ARM DDI0415A), one for each sub job */ 402 u32 perf_counter1[_MALI_PP_MAX_SUB_JOBS]; /**< [out] value of perfomance counter 1 (see ARM DDI0415A), one for each sub job */ 403 u32 perf_counter_src0; 404 u32 perf_counter_src1; 405 } _mali_uk_pp_job_finished_s; 406 407 typedef struct { 408 u32 number_of_enabled_cores; /**< [out] the new number of enabled cores */ 409 } _mali_uk_pp_num_cores_changed_s; 410 411 412 413 /** 414 * Flags to indicate write-back units 415 */ 416 typedef enum { 417 _MALI_UK_PP_JOB_WB0 = 1, 418 _MALI_UK_PP_JOB_WB1 = 2, 419 _MALI_UK_PP_JOB_WB2 = 4, 420 } _mali_uk_pp_job_wbx_flag; 421 422 typedef struct { 423 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 424 u32 fb_id; /**< [in] Frame builder ID of job to disable WB units for */ 425 u32 wb0_memory; 426 u32 wb1_memory; 427 u32 wb2_memory; 428 } _mali_uk_pp_disable_wb_s; 429 430 431 /** @} */ /* end group _mali_uk_pp */ 432 433 /** @defgroup _mali_uk_soft_job U/K Soft Job 434 * @{ */ 435 436 typedef struct { 437 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 438 u64 user_job; /**< [in] identifier for the job in user space */ 439 u64 job_id_ptr; /**< [in,out] pointer to location of u32 where job id will be written */ 440 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */ 441 u32 point; /**< [out] point on soft timeline for this job */ 442 u32 type; /**< [in] type of soft job */ 443 } _mali_uk_soft_job_start_s; 444 445 typedef struct { 446 u64 user_job; /**< [out] identifier for the job in user space */ 447 } _mali_uk_soft_job_activated_s; 448 449 typedef struct { 450 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 451 u32 job_id; /**< [in] id for soft job */ 452 } _mali_uk_soft_job_signal_s; 453 454 /** @} */ /* end group _mali_uk_soft_job */ 455 456 typedef struct { 457 u32 counter_id; 458 u32 key; 459 int enable; 460 } _mali_uk_annotate_profiling_mem_counter_s; 461 462 typedef struct { 463 u32 sampling_rate; 464 int enable; 465 } _mali_uk_annotate_profiling_enable_s; 466 467 468 /** @addtogroup _mali_uk_core U/K Core 469 * @{ */ 470 471 /** @defgroup _mali_uk_waitfornotification_s Wait For Notification 472 * @{ */ 473 474 /** @brief Notification type encodings 475 * 476 * Each Notification type is an ordered pair of (subsystem,id), and is unique. 477 * 478 * The encoding of subsystem,id into a 32-bit word is: 479 * encoding = (( subsystem << _MALI_NOTIFICATION_SUBSYSTEM_SHIFT ) & _MALI_NOTIFICATION_SUBSYSTEM_MASK) 480 * | (( id << _MALI_NOTIFICATION_ID_SHIFT ) & _MALI_NOTIFICATION_ID_MASK) 481 * 482 * @see _mali_uk_wait_for_notification_s 483 */ 484 typedef enum { 485 /** core notifications */ 486 487 _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x20, 488 _MALI_NOTIFICATION_APPLICATION_QUIT = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x40, 489 _MALI_NOTIFICATION_SETTINGS_CHANGED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x80, 490 _MALI_NOTIFICATION_SOFT_ACTIVATED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x100, 491 492 /** Fragment Processor notifications */ 493 494 _MALI_NOTIFICATION_PP_FINISHED = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x10, 495 _MALI_NOTIFICATION_PP_NUM_CORE_CHANGE = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x20, 496 497 /** Vertex Processor notifications */ 498 499 _MALI_NOTIFICATION_GP_FINISHED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x10, 500 _MALI_NOTIFICATION_GP_STALLED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x20, 501 502 /** Profiling notifications */ 503 _MALI_NOTIFICATION_ANNOTATE_PROFILING_MEM_COUNTER = (_MALI_UK_PROFILING_SUBSYSTEM << 16) | 0x10, 504 _MALI_NOTIFICATION_ANNOTATE_PROFILING_ENABLE = (_MALI_UK_PROFILING_SUBSYSTEM << 16) | 0x20, 505 } _mali_uk_notification_type; 506 507 /** to assist in splitting up 32-bit notification value in subsystem and id value */ 508 #define _MALI_NOTIFICATION_SUBSYSTEM_MASK 0xFFFF0000 509 #define _MALI_NOTIFICATION_SUBSYSTEM_SHIFT 16 510 #define _MALI_NOTIFICATION_ID_MASK 0x0000FFFF 511 #define _MALI_NOTIFICATION_ID_SHIFT 0 512 513 514 /** @brief Enumeration of possible settings which match mali_setting_t in user space 515 * 516 * 517 */ 518 typedef enum { 519 _MALI_UK_USER_SETTING_SW_EVENTS_ENABLE = 0, 520 _MALI_UK_USER_SETTING_COLORBUFFER_CAPTURE_ENABLED, 521 _MALI_UK_USER_SETTING_DEPTHBUFFER_CAPTURE_ENABLED, 522 _MALI_UK_USER_SETTING_STENCILBUFFER_CAPTURE_ENABLED, 523 _MALI_UK_USER_SETTING_PER_TILE_COUNTERS_CAPTURE_ENABLED, 524 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_COMPOSITOR, 525 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_WINDOW, 526 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_OTHER, 527 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_N_FRAMES, 528 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_RESIZE_FACTOR, 529 _MALI_UK_USER_SETTING_SW_COUNTER_ENABLED, 530 _MALI_UK_USER_SETTING_MAX, 531 } _mali_uk_user_setting_t; 532 533 /* See mali_user_settings_db.c */ 534 extern const char *_mali_uk_user_setting_descriptions[]; 535 #define _MALI_UK_USER_SETTING_DESCRIPTIONS \ 536 { \ 537 "sw_events_enable", \ 538 "colorbuffer_capture_enable", \ 539 "depthbuffer_capture_enable", \ 540 "stencilbuffer_capture_enable", \ 541 "per_tile_counters_enable", \ 542 "buffer_capture_compositor", \ 543 "buffer_capture_window", \ 544 "buffer_capture_other", \ 545 "buffer_capture_n_frames", \ 546 "buffer_capture_resize_factor", \ 547 "sw_counters_enable", \ 548 }; 549 550 /** @brief struct to hold the value to a particular setting as seen in the kernel space 551 */ 552 typedef struct { 553 _mali_uk_user_setting_t setting; 554 u32 value; 555 } _mali_uk_settings_changed_s; 556 557 /** @brief Arguments for _mali_ukk_wait_for_notification() 558 * 559 * On successful return from _mali_ukk_wait_for_notification(), the members of 560 * this structure will indicate the reason for notification. 561 * 562 * Specifically, the source of the notification can be identified by the 563 * subsystem and id fields of the mali_uk_notification_type in the code.type 564 * member. The type member is encoded in a way to divide up the types into a 565 * subsystem field, and a per-subsystem ID field. See 566 * _mali_uk_notification_type for more information. 567 * 568 * Interpreting the data union member depends on the notification type: 569 * 570 * - type == _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS 571 * - The kernel side is shutting down. No further 572 * _mali_uk_wait_for_notification() calls should be made. 573 * - In this case, the value of the data union member is undefined. 574 * - This is used to indicate to the user space client that it should close 575 * the connection to the Mali Device Driver. 576 * - type == _MALI_NOTIFICATION_PP_FINISHED 577 * - The notification data is of type _mali_uk_pp_job_finished_s. It contains the user_job_ptr 578 * identifier used to start the job with, the job status, the number of milliseconds the job took to render, 579 * and values of core registers when the job finished (irq status, performance counters, renderer list 580 * address). 581 * - A job has finished succesfully when its status member is _MALI_UK_JOB_STATUS_FINISHED. 582 * - If the hardware detected a timeout while rendering the job, or software detected the job is 583 * taking more than watchdog_msecs (see _mali_ukk_pp_start_job()) to complete, the status member will 584 * indicate _MALI_UK_JOB_STATUS_HANG. 585 * - If the hardware detected a bus error while accessing memory associated with the job, status will 586 * indicate _MALI_UK_JOB_STATUS_SEG_FAULT. 587 * - Status will indicate MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to stop the job but the job 588 * didn't start the hardware yet, e.g. when the driver closes. 589 * - type == _MALI_NOTIFICATION_GP_FINISHED 590 * - The notification data is of type _mali_uk_gp_job_finished_s. The notification is similar to that of 591 * type == _MALI_NOTIFICATION_PP_FINISHED, except that several other GP core register values are returned. 592 * The status values have the same meaning for type == _MALI_NOTIFICATION_PP_FINISHED. 593 * - type == _MALI_NOTIFICATION_GP_STALLED 594 * - The nofication data is of type _mali_uk_gp_job_suspended_s. It contains the user_job_ptr 595 * identifier used to start the job with, the reason why the job stalled and a cookie to identify the core on 596 * which the job stalled. 597 * - The reason member of gp_job_suspended is set to _MALIGP_JOB_SUSPENDED_OUT_OF_MEMORY 598 * when the polygon list builder unit has run out of memory. 599 */ 600 typedef struct { 601 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 602 _mali_uk_notification_type type; /**< [out] Type of notification available */ 603 union { 604 _mali_uk_gp_job_suspended_s gp_job_suspended;/**< [out] Notification data for _MALI_NOTIFICATION_GP_STALLED notification type */ 605 _mali_uk_gp_job_finished_s gp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_GP_FINISHED notification type */ 606 _mali_uk_pp_job_finished_s pp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_PP_FINISHED notification type */ 607 _mali_uk_settings_changed_s setting_changed;/**< [out] Notification data for _MALI_NOTIFICAATION_SETTINGS_CHANGED notification type */ 608 _mali_uk_soft_job_activated_s soft_job_activated; /**< [out] Notification data for _MALI_NOTIFICATION_SOFT_ACTIVATED notification type */ 609 _mali_uk_annotate_profiling_mem_counter_s profiling_mem_counter; 610 _mali_uk_annotate_profiling_enable_s profiling_enable; 611 } data; 612 } _mali_uk_wait_for_notification_s; 613 614 /** @brief Arguments for _mali_ukk_post_notification() 615 * 616 * Posts the specified notification to the notification queue for this application. 617 * This is used to send a quit message to the callback thread. 618 */ 619 typedef struct { 620 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 621 _mali_uk_notification_type type; /**< [in] Type of notification to post */ 622 } _mali_uk_post_notification_s; 623 624 /** @} */ /* end group _mali_uk_waitfornotification_s */ 625 626 /** @defgroup _mali_uk_getapiversion_s Get API Version 627 * @{ */ 628 629 /** helpers for Device Driver API version handling */ 630 631 /** @brief Encode a version ID from a 16-bit input 632 * 633 * @note the input is assumed to be 16 bits. It must not exceed 16 bits. */ 634 #define _MAKE_VERSION_ID(x) (((x) << 16UL) | (x)) 635 636 /** @brief Check whether a 32-bit value is likely to be Device Driver API 637 * version ID. */ 638 #define _IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF)) 639 640 /** @brief Decode a 16-bit version number from a 32-bit Device Driver API version 641 * ID */ 642 #define _GET_VERSION(x) (((x) >> 16UL) & 0xFFFF) 643 644 /** @brief Determine whether two 32-bit encoded version IDs match */ 645 #define _IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y)))) 646 /** 647 * RK MALI version code 648 */ 649 #define _MALI_RK_LIBS_VERSION 1 650 651 /** 652 * API version define. 653 * Indicates the version of the kernel API 654 * The version is a 16bit integer incremented on each API change. 655 * The 16bit integer is stored twice in a 32bit integer 656 * For example, for version 1 the value would be 0x00010001 657 */ 658 #define _MALI_API_VERSION 900 659 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION) 660 661 /** 662 * The API version is a 16-bit integer stored in both the lower and upper 16-bits 663 * of a 32-bit value. The 16-bit API version value is incremented on each API 664 * change. Version 1 would be 0x00010001. Used in _mali_uk_get_api_version_s. 665 */ 666 typedef u32 _mali_uk_api_version; 667 668 /** @brief Arguments for _mali_uk_get_api_version() 669 * 670 * The user-side interface version must be written into the version member, 671 * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of 672 * the kernel-side interface. 673 * 674 * On successful return, the version member will be the API version of the 675 * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version 676 * of the API. 677 * 678 * The compatible member must be checked to see if the version of the user-side 679 * interface is compatible with the kernel-side interface, since future versions 680 * of the interface may be backwards compatible. 681 */ 682 typedef struct { 683 u32 ctx; /**< [in,out] user-kernel context (trashed on output) */ 684 _mali_uk_api_version version; /**< [in,out] API version of user-side interface. */ 685 int compatible; /**< [out] @c 1 when @version is compatible, @c 0 otherwise */ 686 } _mali_uk_get_api_version_s; 687 688 /** @brief Arguments for _mali_uk_get_api_version_v2() 689 * 690 * The user-side interface version must be written into the version member, 691 * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of 692 * the kernel-side interface. 693 * 694 * On successful return, the version member will be the API version of the 695 * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version 696 * of the API. 697 * 698 * The compatible member must be checked to see if the version of the user-side 699 * interface is compatible with the kernel-side interface, since future versions 700 * of the interface may be backwards compatible. 701 */ 702 typedef struct { 703 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 704 _mali_uk_api_version version; /**< [in,out] API version of user-side interface. */ 705 int compatible; /**< [out] @c 1 when @version is compatible, @c 0 otherwise */ 706 } _mali_uk_get_api_version_v2_s; 707 708 typedef struct 709 { 710 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 711 _mali_uk_api_version version; /**< [in,out] API version of user-side interface. */ 712 } _mali_uk_get_mali_version_in_rk30_s; 713 714 /* rk_ext : rk_ko_ver_t. */ 715 typedef struct { 716 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 717 _mali_uk_api_version version; /**< [in,out] API version of user-side interface. */ 718 } _mali_rk_ko_version_s; 719 /** @} */ /* end group _mali_uk_getapiversion_s */ 720 721 /** @defgroup _mali_uk_get_user_settings_s Get user space settings */ 722 723 /** @brief struct to keep the matching values of the user space settings within certain context 724 * 725 * Each member of the settings array corresponds to a matching setting in the user space and its value is the value 726 * of that particular setting. 727 * 728 * All settings are given reference to the context pointed to by the ctx pointer. 729 * 730 */ 731 typedef struct { 732 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 733 u32 settings[_MALI_UK_USER_SETTING_MAX]; /**< [out] The values for all settings */ 734 } _mali_uk_get_user_settings_s; 735 736 /** @brief struct to hold the value of a particular setting from the user space within a given context 737 */ 738 typedef struct { 739 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 740 _mali_uk_user_setting_t setting; /**< [in] setting to get */ 741 u32 value; /**< [out] value of setting */ 742 } _mali_uk_get_user_setting_s; 743 744 /** @brief Arguments for _mali_ukk_request_high_priority() */ 745 typedef struct { 746 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 747 } _mali_uk_request_high_priority_s; 748 749 /** @brief Arguments for _mali_ukk_pending_submit() */ 750 typedef struct { 751 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 752 } _mali_uk_pending_submit_s; 753 754 /** @} */ /* end group _mali_uk_core */ 755 756 757 /** @defgroup _mali_uk_memory U/K Memory 758 * @{ */ 759 760 #define _MALI_MEMORY_ALLOCATE_RESIZEABLE (1<<4) /* BUFFER can trim dow/grow*/ 761 #define _MALI_MEMORY_ALLOCATE_NO_BIND_GPU (1<<5) /*Not map to GPU when allocate, must call bind later*/ 762 #define _MALI_MEMORY_ALLOCATE_SWAPPABLE (1<<6) /* Allocate swappale memory. */ 763 #define _MALI_MEMORY_ALLOCATE_DEFER_BIND (1<<7) /*Not map to GPU when allocate, must call bind later*/ 764 #define _MALI_MEMORY_ALLOCATE_SECURE (1<<8) /* Allocate secure memory. */ 765 766 767 typedef struct { 768 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 769 u32 gpu_vaddr; /**< [in] GPU virtual address */ 770 u32 vsize; /**< [in] vitrual size of the allocation */ 771 u32 psize; /**< [in] physical size of the allocation */ 772 u32 flags; 773 u64 backend_handle; /**< [out] backend handle */ 774 s32 secure_shared_fd; /** < [in] the mem handle for secure mem */ 775 } _mali_uk_alloc_mem_s; 776 777 778 typedef struct { 779 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 780 u32 gpu_vaddr; /**< [in] use as handle to free allocation */ 781 u32 free_pages_nr; /** < [out] record the number of free pages */ 782 } _mali_uk_free_mem_s; 783 784 785 #define _MALI_MEMORY_BIND_BACKEND_UMP (1<<8) 786 #define _MALI_MEMORY_BIND_BACKEND_DMA_BUF (1<<9) 787 #define _MALI_MEMORY_BIND_BACKEND_MALI_MEMORY (1<<10) 788 #define _MALI_MEMORY_BIND_BACKEND_EXTERNAL_MEMORY (1<<11) 789 #define _MALI_MEMORY_BIND_BACKEND_EXT_COW (1<<12) 790 #define _MALI_MEMORY_BIND_BACKEND_HAVE_ALLOCATION (1<<13) 791 792 793 #define _MALI_MEMORY_BIND_BACKEND_MASK (_MALI_MEMORY_BIND_BACKEND_UMP| \ 794 _MALI_MEMORY_BIND_BACKEND_DMA_BUF |\ 795 _MALI_MEMORY_BIND_BACKEND_MALI_MEMORY |\ 796 _MALI_MEMORY_BIND_BACKEND_EXTERNAL_MEMORY |\ 797 _MALI_MEMORY_BIND_BACKEND_EXT_COW |\ 798 _MALI_MEMORY_BIND_BACKEND_HAVE_ALLOCATION) 799 800 801 #define _MALI_MEMORY_GPU_READ_ALLOCATE (1<<16) 802 803 804 typedef struct { 805 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 806 u32 vaddr; /**< [in] mali address to map the physical memory to */ 807 u32 size; /**< [in] size */ 808 u32 flags; /**< [in] see_MALI_MEMORY_BIND_BACKEND_* */ 809 u32 padding; /** padding for 32/64 struct alignment */ 810 union { 811 struct { 812 u32 secure_id; /**< [in] secure id */ 813 u32 rights; /**< [in] rights necessary for accessing memory */ 814 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */ 815 } bind_ump; 816 struct { 817 u32 mem_fd; /**< [in] Memory descriptor */ 818 u32 rights; /**< [in] rights necessary for accessing memory */ 819 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */ 820 } bind_dma_buf; 821 struct { 822 u32 phys_addr; /**< [in] physical address */ 823 u32 rights; /**< [in] rights necessary for accessing memory */ 824 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */ 825 } bind_ext_memory; 826 } mem_union; 827 } _mali_uk_bind_mem_s; 828 829 typedef struct { 830 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 831 u32 flags; /**< [in] see_MALI_MEMORY_BIND_BACKEND_* */ 832 u32 vaddr; /**< [in] identifier for mapped memory object in kernel space */ 833 } _mali_uk_unbind_mem_s; 834 835 typedef struct { 836 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 837 u32 target_handle; /**< [in] handle of allocation need to do COW */ 838 u32 target_offset; /**< [in] offset in target allocation to do COW(for support COW a memory allocated from memory_bank, PAGE_SIZE align)*/ 839 u32 target_size; /**< [in] size of target allocation to do COW (for support memory bank, PAGE_SIZE align)(in byte) */ 840 u32 range_start; /**< [in] re allocate range start offset, offset from the start of allocation (PAGE_SIZE align)*/ 841 u32 range_size; /**< [in] re allocate size (PAGE_SIZE align)*/ 842 u32 vaddr; /**< [in] mali address for the new allocaiton */ 843 u32 backend_handle; /**< [out] backend handle */ 844 u32 flags; 845 } _mali_uk_cow_mem_s; 846 847 typedef struct { 848 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 849 u32 range_start; /**< [in] re allocate range start offset, offset from the start of allocation */ 850 u32 size; /**< [in] re allocate size*/ 851 u32 vaddr; /**< [in] mali address for the new allocaiton */ 852 s32 change_pages_nr; /**< [out] record the page number change for cow operation */ 853 } _mali_uk_cow_modify_range_s; 854 855 856 typedef struct { 857 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 858 u32 mem_fd; /**< [in] Memory descriptor */ 859 u32 size; /**< [out] size */ 860 } _mali_uk_dma_buf_get_size_s; 861 862 /** Flag for _mali_uk_map_external_mem_s, _mali_uk_attach_ump_mem_s and _mali_uk_attach_dma_buf_s */ 863 #define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0) 864 865 866 typedef struct { 867 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 868 u64 vaddr; /* the buffer to do resize*/ 869 u32 psize; /* wanted physical size of this memory */ 870 } _mali_uk_mem_resize_s; 871 872 /** 873 * @brief Arguments for _mali_uk[uk]_mem_write_safe() 874 */ 875 typedef struct { 876 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 877 u64 src; /**< [in] Pointer to source data */ 878 u64 dest; /**< [in] Destination Mali buffer */ 879 u32 size; /**< [in,out] Number of bytes to write/copy on input, number of bytes actually written/copied on output */ 880 } _mali_uk_mem_write_safe_s; 881 882 typedef struct { 883 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 884 u32 size; /**< [out] size of MMU page table information (registers + page tables) */ 885 } _mali_uk_query_mmu_page_table_dump_size_s; 886 887 typedef struct { 888 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 889 u32 size; /**< [in] size of buffer to receive mmu page table information */ 890 u64 buffer; /**< [in,out] buffer to receive mmu page table information */ 891 u32 register_writes_size; /**< [out] size of MMU register dump */ 892 u64 register_writes; /**< [out] pointer within buffer where MMU register dump is stored */ 893 u32 page_table_dump_size; /**< [out] size of MMU page table dump */ 894 u64 page_table_dump; /**< [out] pointer within buffer where MMU page table dump is stored */ 895 } _mali_uk_dump_mmu_page_table_s; 896 897 /** @} */ /* end group _mali_uk_memory */ 898 899 900 /** @addtogroup _mali_uk_pp U/K Fragment Processor 901 * @{ */ 902 903 /** @brief Arguments for _mali_ukk_get_pp_number_of_cores() 904 * 905 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 906 * - Upon successful return from _mali_ukk_get_pp_number_of_cores(), @c number_of_cores 907 * will contain the number of Fragment Processor cores in the system. 908 */ 909 typedef struct { 910 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 911 u32 number_of_total_cores; /**< [out] Total number of Fragment Processor cores in the system */ 912 u32 number_of_enabled_cores; /**< [out] Number of enabled Fragment Processor cores */ 913 } _mali_uk_get_pp_number_of_cores_s; 914 915 /** @brief Arguments for _mali_ukk_get_pp_core_version() 916 * 917 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 918 * - Upon successful return from _mali_ukk_get_pp_core_version(), @c version contains 919 * the version that all Fragment Processor cores are compatible with. 920 */ 921 typedef struct { 922 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 923 _mali_core_version version; /**< [out] version returned from core, see \ref _mali_core_version */ 924 u32 padding; 925 } _mali_uk_get_pp_core_version_s; 926 927 /** @} */ /* end group _mali_uk_pp */ 928 929 930 /** @addtogroup _mali_uk_gp U/K Vertex Processor 931 * @{ */ 932 933 /** @brief Arguments for _mali_ukk_get_gp_number_of_cores() 934 * 935 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 936 * - Upon successful return from _mali_ukk_get_gp_number_of_cores(), @c number_of_cores 937 * will contain the number of Vertex Processor cores in the system. 938 */ 939 typedef struct { 940 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 941 u32 number_of_cores; /**< [out] number of Vertex Processor cores in the system */ 942 } _mali_uk_get_gp_number_of_cores_s; 943 944 /** @brief Arguments for _mali_ukk_get_gp_core_version() 945 * 946 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open() 947 * - Upon successful return from _mali_ukk_get_gp_core_version(), @c version contains 948 * the version that all Vertex Processor cores are compatible with. 949 */ 950 typedef struct { 951 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 952 _mali_core_version version; /**< [out] version returned from core, see \ref _mali_core_version */ 953 } _mali_uk_get_gp_core_version_s; 954 955 /** @} */ /* end group _mali_uk_gp */ 956 957 typedef struct { 958 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 959 u32 event_id; /**< [in] event id to register (see enum mali_profiling_events for values) */ 960 u32 data[5]; /**< [in] event specific data */ 961 } _mali_uk_profiling_add_event_s; 962 963 typedef struct { 964 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 965 u32 memory_usage; /**< [out] total memory usage */ 966 u32 vaddr; /**< [in] mali address for the cow allocaiton */ 967 s32 change_pages_nr; /**< [out] record the page number change for cow operation */ 968 } _mali_uk_profiling_memory_usage_get_s; 969 970 971 /** @addtogroup _mali_uk_memory U/K Memory 972 * @{ */ 973 974 /** @brief Arguments to _mali_ukk_mem_mmap() 975 * 976 * Use of the phys_addr member depends on whether the driver is compiled for 977 * Mali-MMU or nonMMU: 978 * - in the nonMMU case, this is the physical address of the memory as seen by 979 * the CPU (which may be a constant offset from that used by Mali) 980 * - in the MMU case, this is the Mali Virtual base address of the memory to 981 * allocate, and the particular physical pages used to back the memory are 982 * entirely determined by _mali_ukk_mem_mmap(). The details of the physical pages 983 * are not reported to user-space for security reasons. 984 * 985 * The cookie member must be stored for use later when freeing the memory by 986 * calling _mali_ukk_mem_munmap(). In the Mali-MMU case, the cookie is secure. 987 * 988 * The ukk_private word must be set to zero when calling from user-space. On 989 * Kernel-side, the OS implementation of the U/K interface can use it to 990 * communicate data to the OS implementation of the OSK layer. In particular, 991 * _mali_ukk_get_big_block() directly calls _mali_ukk_mem_mmap directly, and 992 * will communicate its own ukk_private word through the ukk_private member 993 * here. The common code itself will not inspect or modify the ukk_private 994 * word, and so it may be safely used for whatever purposes necessary to 995 * integrate Mali Memory handling into the OS. 996 * 997 * The uku_private member is currently reserved for use by the user-side 998 * implementation of the U/K interface. Its value must be zero. 999 */ 1000 typedef struct { 1001 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1002 void *mapping; /**< [out] Returns user-space virtual address for the mapping */ 1003 u32 size; /**< [in] Size of the requested mapping */ 1004 u32 phys_addr; /**< [in] Physical address - could be offset, depending on caller+callee convention */ 1005 mali_bool writeable; 1006 } _mali_uk_mem_mmap_s; 1007 1008 /** @brief Arguments to _mali_ukk_mem_munmap() 1009 * 1010 * The cookie and mapping members must be that returned from the same previous 1011 * call to _mali_ukk_mem_mmap(). The size member must correspond to cookie 1012 * and mapping - that is, it must be the value originally supplied to a call to 1013 * _mali_ukk_mem_mmap that returned the values of mapping and cookie. 1014 * 1015 * An error will be returned if an attempt is made to unmap only part of the 1016 * originally obtained range, or to unmap more than was originally obtained. 1017 */ 1018 typedef struct { 1019 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1020 void *mapping; /**< [in] The mapping returned from mmap call */ 1021 u32 size; /**< [in] The size passed to mmap call */ 1022 } _mali_uk_mem_munmap_s; 1023 /** @} */ /* end group _mali_uk_memory */ 1024 1025 /** @defgroup _mali_uk_vsync U/K VSYNC Wait Reporting Module 1026 * @{ */ 1027 1028 /** @brief VSYNC events 1029 * 1030 * These events are reported when DDK starts to wait for vsync and when the 1031 * vsync has occured and the DDK can continue on the next frame. 1032 */ 1033 typedef enum _mali_uk_vsync_event { 1034 _MALI_UK_VSYNC_EVENT_BEGIN_WAIT = 0, 1035 _MALI_UK_VSYNC_EVENT_END_WAIT 1036 } _mali_uk_vsync_event; 1037 1038 /** @brief Arguments to _mali_ukk_vsync_event() 1039 * 1040 */ 1041 typedef struct { 1042 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1043 _mali_uk_vsync_event event; /**< [in] VSYNCH event type */ 1044 } _mali_uk_vsync_event_report_s; 1045 1046 /** @} */ /* end group _mali_uk_vsync */ 1047 1048 /** @defgroup _mali_uk_sw_counters_report U/K Software Counter Reporting 1049 * @{ */ 1050 1051 /** @brief Software counter values 1052 * 1053 * Values recorded for each of the software counters during a single renderpass. 1054 */ 1055 typedef struct { 1056 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1057 u64 counters; /**< [in] The array of u32 counter values */ 1058 u32 num_counters; /**< [in] The number of elements in counters array */ 1059 } _mali_uk_sw_counters_report_s; 1060 1061 /** @} */ /* end group _mali_uk_sw_counters_report */ 1062 1063 /** @defgroup _mali_uk_timeline U/K Mali Timeline 1064 * @{ */ 1065 1066 typedef struct { 1067 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1068 u32 timeline; /**< [in] timeline id */ 1069 u32 point; /**< [out] latest point on timeline */ 1070 } _mali_uk_timeline_get_latest_point_s; 1071 1072 typedef struct { 1073 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1074 _mali_uk_fence_t fence; /**< [in] fence */ 1075 u32 timeout; /**< [in] timeout (0 for no wait, -1 for blocking) */ 1076 u32 status; /**< [out] status of fence (1 if signaled, 0 if timeout) */ 1077 } _mali_uk_timeline_wait_s; 1078 1079 typedef struct { 1080 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1081 _mali_uk_fence_t fence; /**< [in] mali fence to create linux sync fence from */ 1082 s32 sync_fd; /**< [out] file descriptor for new linux sync fence */ 1083 } _mali_uk_timeline_create_sync_fence_s; 1084 1085 /** @} */ /* end group _mali_uk_timeline */ 1086 1087 /** @} */ /* end group u_k_api */ 1088 1089 /** @} */ /* end group uddapi */ 1090 1091 typedef struct { 1092 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1093 s32 stream_fd; /**< [in] The profiling kernel base stream fd handle */ 1094 } _mali_uk_profiling_stream_fd_get_s; 1095 1096 typedef struct { 1097 u64 ctx; /**< [in,out] user-kernel context (trashed on output) */ 1098 u64 control_packet_data; /**< [in] the control packet data for control settings */ 1099 u32 control_packet_size; /**< [in] The control packet size */ 1100 u64 response_packet_data; /** < [out] The response packet data */ 1101 u32 response_packet_size; /** < [in,out] The response packet data */ 1102 } _mali_uk_profiling_control_set_s; 1103 1104 #ifdef __cplusplus 1105 } 1106 #endif 1107 1108 #endif /* __MALI_UTGARD_UK_TYPES_H__ */ 1109