1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef _MSM_KGSL_H 7 #define _MSM_KGSL_H 8 9 #include <linux/types.h> 10 #include <linux/ioctl.h> 11 12 /* 13 * The KGSL version has proven not to be very useful in userspace if features 14 * are cherry picked into other trees out of order so it is frozen as of 3.14. 15 * It is left here for backwards compatabilty and as a reminder that 16 * software releases are never linear. Also, I like pie. 17 */ 18 19 #define KGSL_VERSION_MAJOR 3 20 #define KGSL_VERSION_MINOR 14 21 22 /* 23 * We have traditionally mixed context and issueibcmds / command batch flags 24 * together into a big flag stew. This worked fine until we started adding a 25 * lot more command batch flags and we started running out of bits. Turns out 26 * we have a bit of room in the context type / priority mask that we could use 27 * for command batches, but that means we need to split out the flags into two 28 * coherent sets. 29 * 30 * If any future definitions are for both context and cmdbatch add both defines 31 * and link the cmdbatch to the context define as we do below. Otherwise feel 32 * free to add exclusive bits to either set. 33 */ 34 35 /* --- context flags --- */ 36 #define KGSL_CONTEXT_SAVE_GMEM 0x00000001 37 #define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002 38 /* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ 39 #define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004 40 #define KGSL_CONTEXT_CTX_SWITCH 0x00000008 41 #define KGSL_CONTEXT_PREAMBLE 0x00000010 42 #define KGSL_CONTEXT_TRASH_STATE 0x00000020 43 #define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040 44 #define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080 45 /* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ 46 #define KGSL_CONTEXT_END_OF_FRAME 0x00000100 47 #define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200 48 /* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ 49 #define KGSL_CONTEXT_SYNC 0x00000400 50 #define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800 51 #define KGSL_CONTEXT_PRIORITY_MASK 0x0000F000 52 #define KGSL_CONTEXT_PRIORITY_SHIFT 12 53 #define KGSL_CONTEXT_PRIORITY_UNDEF 0 54 55 #define KGSL_CONTEXT_IFH_NOP 0x00010000 56 #define KGSL_CONTEXT_SECURE 0x00020000 57 #define KGSL_CONTEXT_NO_SNAPSHOT 0x00040000 58 #define KGSL_CONTEXT_SPARSE 0x00080000 59 60 #define KGSL_CONTEXT_PREEMPT_STYLE_MASK 0x0E000000 61 #define KGSL_CONTEXT_PREEMPT_STYLE_SHIFT 25 62 #define KGSL_CONTEXT_PREEMPT_STYLE_DEFAULT 0x0 63 #define KGSL_CONTEXT_PREEMPT_STYLE_RINGBUFFER 0x1 64 #define KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN 0x2 65 66 #define KGSL_CONTEXT_TYPE_MASK 0x01F00000 67 #define KGSL_CONTEXT_TYPE_SHIFT 20 68 #define KGSL_CONTEXT_TYPE_ANY 0 69 #define KGSL_CONTEXT_TYPE_GL 1 70 #define KGSL_CONTEXT_TYPE_CL 2 71 #define KGSL_CONTEXT_TYPE_C2D 3 72 #define KGSL_CONTEXT_TYPE_RS 4 73 #define KGSL_CONTEXT_TYPE_VK 5 74 #define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E 75 76 #define KGSL_CONTEXT_INVALIDATE_ON_FAULT 0x10000000 77 78 #define KGSL_CONTEXT_INVALID 0xffffffff 79 80 /* 81 * --- command batch flags --- 82 * The bits that are linked to a KGSL_CONTEXT equivalent are either legacy 83 * definitions or bits that are valid for both contexts and cmdbatches. To be 84 * safe the other 8 bits that are still available in the context field should be 85 * omitted here in case we need to share - the other bits are available for 86 * cmdbatch only flags as needed 87 */ 88 #define KGSL_CMDBATCH_MEMLIST 0x00000001 89 #define KGSL_CMDBATCH_MARKER 0x00000002 90 #define KGSL_CMDBATCH_SUBMIT_IB_LIST KGSL_CONTEXT_SUBMIT_IB_LIST /* 0x004 */ 91 #define KGSL_CMDBATCH_CTX_SWITCH KGSL_CONTEXT_CTX_SWITCH /* 0x008 */ 92 #define KGSL_CMDBATCH_PROFILING 0x00000010 93 /* 94 * KGSL_CMDBATCH_PROFILING must also be set for KGSL_CMDBATCH_PROFILING_KTIME 95 * to take effect, as the latter only affects the time data returned. 96 */ 97 #define KGSL_CMDBATCH_PROFILING_KTIME 0x00000020 98 #define KGSL_CMDBATCH_END_OF_FRAME KGSL_CONTEXT_END_OF_FRAME /* 0x100 */ 99 #define KGSL_CMDBATCH_SYNC KGSL_CONTEXT_SYNC /* 0x400 */ 100 #define KGSL_CMDBATCH_PWR_CONSTRAINT KGSL_CONTEXT_PWR_CONSTRAINT /* 0x800 */ 101 #define KGSL_CMDBATCH_SPARSE 0x1000 /* 0x1000 */ 102 103 /* 104 * Reserve bits [16:19] and bits [28:31] for possible bits shared between 105 * contexts and command batches. Update this comment as new flags are added. 106 */ 107 108 /* 109 * gpu_command_object flags - these flags communicate the type of command or 110 * memory object being submitted for a GPU command 111 */ 112 113 /* Flags for GPU command objects */ 114 #define KGSL_CMDLIST_IB 0x00000001U 115 #define KGSL_CMDLIST_CTXTSWITCH_PREAMBLE 0x00000002U 116 #define KGSL_CMDLIST_IB_PREAMBLE 0x00000004U 117 118 /* Flags for GPU command memory objects */ 119 #define KGSL_OBJLIST_MEMOBJ 0x00000008U 120 #define KGSL_OBJLIST_PROFILE 0x00000010U 121 122 /* Flags for GPU command sync points */ 123 #define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0 124 #define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1 125 #define KGSL_CMD_SYNCPOINT_TYPE_TIMELINE 2 126 127 /* --- Memory allocation flags --- */ 128 129 /* General allocation hints */ 130 #define KGSL_MEMFLAGS_SECURE 0x00000008ULL 131 #define KGSL_MEMFLAGS_GPUREADONLY 0x01000000U 132 #define KGSL_MEMFLAGS_GPUWRITEONLY 0x02000000U 133 #define KGSL_MEMFLAGS_FORCE_32BIT 0x100000000ULL 134 135 /* Flag for binding all the virt range to single phys data */ 136 #define KGSL_SPARSE_BIND_MULTIPLE_TO_PHYS 0x400000000ULL 137 #define KGSL_SPARSE_BIND 0x1ULL 138 #define KGSL_SPARSE_UNBIND 0x2ULL 139 140 /* Memory caching hints */ 141 #define KGSL_CACHEMODE_MASK 0x0C000000U 142 #define KGSL_CACHEMODE_SHIFT 26 143 144 #define KGSL_CACHEMODE_WRITECOMBINE 0 145 #define KGSL_CACHEMODE_UNCACHED 1 146 #define KGSL_CACHEMODE_WRITETHROUGH 2 147 #define KGSL_CACHEMODE_WRITEBACK 3 148 149 #define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000ULL 150 #define KGSL_MEMFLAGS_SPARSE_PHYS 0x20000000ULL 151 #define KGSL_MEMFLAGS_SPARSE_VIRT 0x40000000ULL 152 #define KGSL_MEMFLAGS_IOCOHERENT 0x80000000ULL 153 154 /* Memory types for which allocations are made */ 155 #define KGSL_MEMTYPE_MASK 0x0000FF00 156 #define KGSL_MEMTYPE_SHIFT 8 157 158 #define KGSL_MEMTYPE_OBJECTANY 0 159 #define KGSL_MEMTYPE_FRAMEBUFFER 1 160 #define KGSL_MEMTYPE_RENDERBUFFER 2 161 #define KGSL_MEMTYPE_ARRAYBUFFER 3 162 #define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4 163 #define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5 164 #define KGSL_MEMTYPE_TEXTURE 6 165 #define KGSL_MEMTYPE_SURFACE 7 166 #define KGSL_MEMTYPE_EGL_SURFACE 8 167 #define KGSL_MEMTYPE_GL 9 168 #define KGSL_MEMTYPE_CL 10 169 #define KGSL_MEMTYPE_CL_BUFFER_MAP 11 170 #define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12 171 #define KGSL_MEMTYPE_CL_IMAGE_MAP 13 172 #define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14 173 #define KGSL_MEMTYPE_CL_KERNEL_STACK 15 174 #define KGSL_MEMTYPE_COMMAND 16 175 #define KGSL_MEMTYPE_2D 17 176 #define KGSL_MEMTYPE_EGL_IMAGE 18 177 #define KGSL_MEMTYPE_EGL_SHADOW 19 178 #define KGSL_MEMTYPE_MULTISAMPLE 20 179 #define KGSL_MEMTYPE_KERNEL 255 180 181 /* 182 * Alignment hint, passed as the power of 2 exponent. 183 * i.e 4k (2^12) would be 12, 64k (2^16)would be 16. 184 */ 185 #define KGSL_MEMALIGN_MASK 0x00FF0000 186 #define KGSL_MEMALIGN_SHIFT 16 187 188 enum kgsl_user_mem_type { 189 KGSL_USER_MEM_TYPE_PMEM = 0x00000000, 190 KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001, 191 KGSL_USER_MEM_TYPE_ADDR = 0x00000002, 192 KGSL_USER_MEM_TYPE_ION = 0x00000003, 193 /* 194 * ION type is retained for backwards compatibility but Ion buffers are 195 * dma-bufs so try to use that naming if we can 196 */ 197 KGSL_USER_MEM_TYPE_DMABUF = 0x00000003, 198 KGSL_USER_MEM_TYPE_MAX = 0x00000007, 199 }; 200 #define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0 201 #define KGSL_MEMFLAGS_USERMEM_SHIFT 5 202 203 /* 204 * Unfortunately, enum kgsl_user_mem_type starts at 0 which does not 205 * leave a good value for allocated memory. In the flags we use 206 * 0 to indicate allocated memory and thus need to add 1 to the enum 207 * values. 208 */ 209 #define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT) 210 211 #define KGSL_MEMFLAGS_NOT_USERMEM 0 212 #define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM) 213 #define KGSL_MEMFLAGS_USERMEM_ASHMEM \ 214 KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM) 215 #define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR) 216 #define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION) 217 218 /* --- generic KGSL flag values --- */ 219 220 #define KGSL_FLAGS_NORMALMODE 0x00000000 221 #define KGSL_FLAGS_SAFEMODE 0x00000001 222 #define KGSL_FLAGS_INITIALIZED0 0x00000002 223 #define KGSL_FLAGS_INITIALIZED 0x00000004 224 #define KGSL_FLAGS_STARTED 0x00000008 225 #define KGSL_FLAGS_ACTIVE 0x00000010 226 #define KGSL_FLAGS_RESERVED0 0x00000020 227 #define KGSL_FLAGS_RESERVED1 0x00000040 228 #define KGSL_FLAGS_RESERVED2 0x00000080 229 #define KGSL_FLAGS_SOFT_RESET 0x00000100 230 #define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200 231 232 /* Server Side Sync Timeout in milliseconds */ 233 #define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000 234 235 /* UBWC Modes */ 236 #define KGSL_UBWC_NONE 0 237 #define KGSL_UBWC_1_0 1 238 #define KGSL_UBWC_2_0 2 239 #define KGSL_UBWC_3_0 3 240 #define KGSL_UBWC_4_0 4 241 242 /* 243 * Reset status values for context 244 */ 245 enum kgsl_ctx_reset_stat { 246 KGSL_CTX_STAT_NO_ERROR = 0x00000000, 247 KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001, 248 KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002, 249 KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003 250 }; 251 252 #define KGSL_CONVERT_TO_MBPS(val) \ 253 (val*1000*1000U) 254 255 struct kgsl_devinfo { 256 257 unsigned int device_id; 258 /* 259 * chip revision id 260 * coreid:8 majorrev:8 minorrev:8 patch:8 261 */ 262 unsigned int chip_id; 263 unsigned int mmu_enabled; 264 unsigned long gmem_gpubaseaddr; 265 /* 266 * This field contains the adreno revision 267 * number 200, 205, 220, etc... 268 */ 269 unsigned int gpu_id; 270 size_t gmem_sizebytes; 271 }; 272 273 /* 274 * struct kgsl_devmemstore - this structure defines the region of memory 275 * that can be mmap()ed from this driver. The timestamp fields are __volatile__ 276 * because they are written by the GPU 277 * @soptimestamp: Start of pipeline timestamp written by GPU before the 278 * commands in concern are processed 279 * @sbz: Unused, kept for 8 byte alignment 280 * @eoptimestamp: End of pipeline timestamp written by GPU after the 281 * commands in concern are processed 282 * @sbz2: Unused, kept for 8 byte alignment 283 * @preempted: Indicates if the context was preempted 284 * @sbz3: Unused, kept for 8 byte alignment 285 * @ref_wait_ts: Timestamp on which to generate interrupt, unused now. 286 * @sbz4: Unused, kept for 8 byte alignment 287 * @current_context: The current context the GPU is working on 288 * @sbz5: Unused, kept for 8 byte alignment 289 */ 290 struct kgsl_devmemstore { 291 __volatile__ unsigned int soptimestamp; 292 unsigned int sbz; 293 __volatile__ unsigned int eoptimestamp; 294 unsigned int sbz2; 295 __volatile__ unsigned int preempted; 296 unsigned int sbz3; 297 __volatile__ unsigned int ref_wait_ts; 298 unsigned int sbz4; 299 unsigned int current_context; 300 unsigned int sbz5; 301 }; 302 303 #define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \ 304 ((ctxt_id)*sizeof(struct kgsl_devmemstore) + \ 305 offsetof(struct kgsl_devmemstore, field)) 306 307 /* timestamp id*/ 308 enum kgsl_timestamp_type { 309 KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */ 310 KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/ 311 KGSL_TIMESTAMP_QUEUED = 0x00000003, 312 }; 313 314 /* property types - used with kgsl_device_getproperty */ 315 #define KGSL_PROP_DEVICE_INFO 0x1 316 #define KGSL_PROP_DEVICE_SHADOW 0x2 317 #define KGSL_PROP_DEVICE_POWER 0x3 318 #define KGSL_PROP_SHMEM 0x4 319 #define KGSL_PROP_SHMEM_APERTURES 0x5 320 #define KGSL_PROP_MMU_ENABLE 0x6 321 #define KGSL_PROP_INTERRUPT_WAITS 0x7 322 #define KGSL_PROP_VERSION 0x8 323 #define KGSL_PROP_GPU_RESET_STAT 0x9 324 #define KGSL_PROP_PWRCTRL 0xE 325 #define KGSL_PROP_PWR_CONSTRAINT 0x12 326 #define KGSL_PROP_UCHE_GMEM_VADDR 0x13 327 #define KGSL_PROP_SP_GENERIC_MEM 0x14 328 #define KGSL_PROP_UCODE_VERSION 0x15 329 #define KGSL_PROP_GPMU_VERSION 0x16 330 #define KGSL_PROP_HIGHEST_BANK_BIT 0x17 331 #define KGSL_PROP_DEVICE_BITNESS 0x18 332 #define KGSL_PROP_DEVICE_QDSS_STM 0x19 333 #define KGSL_PROP_MIN_ACCESS_LENGTH 0x1A 334 #define KGSL_PROP_UBWC_MODE 0x1B 335 #define KGSL_PROP_DEVICE_QTIMER 0x20 336 #define KGSL_PROP_L3_PWR_CONSTRAINT 0x22 337 #define KGSL_PROP_SECURE_BUFFER_ALIGNMENT 0x23 338 #define KGSL_PROP_SECURE_CTXT_SUPPORT 0x24 339 #define KGSL_PROP_SPEED_BIN 0x25 340 #define KGSL_PROP_GAMING_BIN 0x26 341 #define KGSL_PROP_QUERY_CAPABILITIES 0x27 342 #define KGSL_PROP_CONTEXT_PROPERTY 0x28 343 344 /* 345 * kgsl_capabilties_properties returns a list of supported properties. 346 * If the user passes 0 for 'count' the kernel will set it to the number of 347 * supported properties. The list is expected to be 'count * sizeof(uint32_t)' 348 * bytes long. The kernel will return the actual number of entries copied into 349 * list via 'count'. 350 */ 351 struct kgsl_capabilities_properties { 352 __u64 list; 353 __u32 count; 354 }; 355 356 /* 357 * KGSL_QUERY_CAPS_PROPERTIES returns a list of the valid properties in the 358 * kernel. The subtype data should be struct kgsl_capabilities_properties 359 */ 360 #define KGSL_QUERY_CAPS_PROPERTIES 1 361 362 /* 363 * kgsl_capabilities allows the user to query kernel capabiilties. The 'data' 364 * type should be set appropriately for the querytype (see above). Pass 0 to 365 * 'size' and the kernel will set it to the expected size of 'data' that is 366 * appropriate for querytype (in bytes). 367 */ 368 struct kgsl_capabilities { 369 __u64 data; 370 __u64 size; 371 __u32 querytype; 372 }; 373 374 struct kgsl_shadowprop { 375 unsigned long gpuaddr; 376 size_t size; 377 unsigned int flags; /* contains KGSL_FLAGS_ values */ 378 }; 379 380 struct kgsl_qdss_stm_prop { 381 uint64_t gpuaddr; 382 uint64_t size; 383 }; 384 385 struct kgsl_qtimer_prop { 386 uint64_t gpuaddr; 387 uint64_t size; 388 }; 389 390 struct kgsl_version { 391 unsigned int drv_major; 392 unsigned int drv_minor; 393 unsigned int dev_major; 394 unsigned int dev_minor; 395 }; 396 397 struct kgsl_sp_generic_mem { 398 uint64_t local; 399 uint64_t pvt; 400 }; 401 402 struct kgsl_ucode_version { 403 unsigned int pfp; 404 unsigned int pm4; 405 }; 406 407 struct kgsl_gpmu_version { 408 unsigned int major; 409 unsigned int minor; 410 unsigned int features; 411 }; 412 413 struct kgsl_context_property { 414 __u64 data; 415 __u32 size; 416 __u32 type; 417 __u32 contextid; 418 }; 419 420 struct kgsl_context_property_fault { 421 __s32 faults; 422 __u32 timestamp; 423 }; 424 425 /* Context property sub types */ 426 #define KGSL_CONTEXT_PROP_FAULTS 1 427 428 /* Performance counter groups */ 429 430 #define KGSL_PERFCOUNTER_GROUP_CP 0x0 431 #define KGSL_PERFCOUNTER_GROUP_RBBM 0x1 432 #define KGSL_PERFCOUNTER_GROUP_PC 0x2 433 #define KGSL_PERFCOUNTER_GROUP_VFD 0x3 434 #define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4 435 #define KGSL_PERFCOUNTER_GROUP_VPC 0x5 436 #define KGSL_PERFCOUNTER_GROUP_TSE 0x6 437 #define KGSL_PERFCOUNTER_GROUP_RAS 0x7 438 #define KGSL_PERFCOUNTER_GROUP_UCHE 0x8 439 #define KGSL_PERFCOUNTER_GROUP_TP 0x9 440 #define KGSL_PERFCOUNTER_GROUP_SP 0xA 441 #define KGSL_PERFCOUNTER_GROUP_RB 0xB 442 #define KGSL_PERFCOUNTER_GROUP_PWR 0xC 443 #define KGSL_PERFCOUNTER_GROUP_VBIF 0xD 444 #define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE 445 #define KGSL_PERFCOUNTER_GROUP_MH 0xF 446 #define KGSL_PERFCOUNTER_GROUP_PA_SU 0x10 447 #define KGSL_PERFCOUNTER_GROUP_SQ 0x11 448 #define KGSL_PERFCOUNTER_GROUP_SX 0x12 449 #define KGSL_PERFCOUNTER_GROUP_TCF 0x13 450 #define KGSL_PERFCOUNTER_GROUP_TCM 0x14 451 #define KGSL_PERFCOUNTER_GROUP_TCR 0x15 452 #define KGSL_PERFCOUNTER_GROUP_L2 0x16 453 #define KGSL_PERFCOUNTER_GROUP_VSC 0x17 454 #define KGSL_PERFCOUNTER_GROUP_CCU 0x18 455 #define KGSL_PERFCOUNTER_GROUP_LRZ 0x19 456 #define KGSL_PERFCOUNTER_GROUP_CMP 0x1A 457 #define KGSL_PERFCOUNTER_GROUP_ALWAYSON 0x1B 458 #define KGSL_PERFCOUNTER_GROUP_SP_PWR 0x1C 459 #define KGSL_PERFCOUNTER_GROUP_TP_PWR 0x1D 460 #define KGSL_PERFCOUNTER_GROUP_RB_PWR 0x1E 461 #define KGSL_PERFCOUNTER_GROUP_CCU_PWR 0x1F 462 #define KGSL_PERFCOUNTER_GROUP_UCHE_PWR 0x20 463 #define KGSL_PERFCOUNTER_GROUP_CP_PWR 0x21 464 #define KGSL_PERFCOUNTER_GROUP_GPMU_PWR 0x22 465 #define KGSL_PERFCOUNTER_GROUP_ALWAYSON_PWR 0x23 466 #define KGSL_PERFCOUNTER_GROUP_GLC 0x24 467 #define KGSL_PERFCOUNTER_GROUP_FCHE 0x25 468 #define KGSL_PERFCOUNTER_GROUP_MHUB 0x26 469 #define KGSL_PERFCOUNTER_GROUP_MAX 0x27 470 471 #define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF 472 #define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE 473 474 /* structure holds list of ibs */ 475 struct kgsl_ibdesc { 476 unsigned long gpuaddr; 477 unsigned long __pad; 478 size_t sizedwords; 479 unsigned int ctrl; 480 }; 481 482 /** 483 * struct kgsl_cmdbatch_profiling_buffer 484 * @wall_clock_s: Ringbuffer submission time (seconds). 485 * If KGSL_CMDBATCH_PROFILING_KTIME is set, time is provided 486 * in kernel clocks, otherwise wall clock time is used. 487 * @wall_clock_ns: Ringbuffer submission time (nanoseconds). 488 * If KGSL_CMDBATCH_PROFILING_KTIME is set time is provided 489 * in kernel clocks, otherwise wall clock time is used. 490 * @gpu_ticks_queued: GPU ticks at ringbuffer submission 491 * @gpu_ticks_submitted: GPU ticks when starting cmdbatch execution 492 * @gpu_ticks_retired: GPU ticks when finishing cmdbatch execution 493 * 494 * This structure defines the profiling buffer used to measure cmdbatch 495 * execution time 496 */ 497 struct kgsl_cmdbatch_profiling_buffer { 498 uint64_t wall_clock_s; 499 uint64_t wall_clock_ns; 500 uint64_t gpu_ticks_queued; 501 uint64_t gpu_ticks_submitted; 502 uint64_t gpu_ticks_retired; 503 }; 504 505 /* ioctls */ 506 #define KGSL_IOC_TYPE 0x09 507 508 /* 509 * get misc info about the GPU 510 * type should be a value from enum kgsl_property_type 511 * value points to a structure that varies based on type 512 * sizebytes is sizeof() that structure 513 * for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo 514 * this structure contaings hardware versioning info. 515 * for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop 516 * this is used to find mmap() offset and sizes for mapping 517 * struct kgsl_memstore into userspace. 518 */ 519 struct kgsl_device_getproperty { 520 unsigned int type; 521 void *value; 522 size_t sizebytes; 523 }; 524 525 #define IOCTL_KGSL_DEVICE_GETPROPERTY \ 526 _IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty) 527 528 /* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012 529 */ 530 531 /* block until the GPU has executed past a given timestamp 532 * timeout is in milliseconds. 533 */ 534 struct kgsl_device_waittimestamp { 535 unsigned int timestamp; 536 unsigned int timeout; 537 }; 538 539 #define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \ 540 _IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp) 541 542 struct kgsl_device_waittimestamp_ctxtid { 543 unsigned int context_id; 544 unsigned int timestamp; 545 unsigned int timeout; 546 }; 547 548 #define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \ 549 _IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid) 550 551 /* DEPRECATED: issue indirect commands to the GPU. 552 * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE 553 * ibaddr and sizedwords must specify a subset of a buffer created 554 * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM 555 * flags may be a mask of KGSL_CONTEXT_ values 556 * timestamp is a returned counter value which can be passed to 557 * other ioctls to determine when the commands have been executed by 558 * the GPU. 559 * 560 * This function is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS 561 * instead 562 */ 563 struct kgsl_ringbuffer_issueibcmds { 564 unsigned int drawctxt_id; 565 unsigned long ibdesc_addr; 566 unsigned int numibs; 567 unsigned int timestamp; /*output param */ 568 unsigned int flags; 569 }; 570 571 #define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \ 572 _IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds) 573 574 /* read the most recently executed timestamp value 575 * type should be a value from enum kgsl_timestamp_type 576 */ 577 struct kgsl_cmdstream_readtimestamp { 578 unsigned int type; 579 unsigned int timestamp; /*output param */ 580 }; 581 582 #define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \ 583 _IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) 584 585 #define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \ 586 _IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) 587 588 /* free memory when the GPU reaches a given timestamp. 589 * gpuaddr specify a memory region created by a 590 * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call 591 * type should be a value from enum kgsl_timestamp_type 592 */ 593 struct kgsl_cmdstream_freememontimestamp { 594 unsigned long gpuaddr; 595 unsigned int type; 596 unsigned int timestamp; 597 }; 598 599 #define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \ 600 _IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) 601 602 /* 603 * Previous versions of this header had incorrectly defined 604 * IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead 605 * of a write only ioctl. To ensure binary compatibility, the following 606 * #define will be used to intercept the incorrect ioctl 607 */ 608 609 #define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \ 610 _IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) 611 612 /* create a draw context, which is used to preserve GPU state. 613 * The flags field may contain a mask KGSL_CONTEXT_* values 614 */ 615 struct kgsl_drawctxt_create { 616 unsigned int flags; 617 unsigned int drawctxt_id; /*output param */ 618 }; 619 620 #define IOCTL_KGSL_DRAWCTXT_CREATE \ 621 _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create) 622 623 /* destroy a draw context */ 624 struct kgsl_drawctxt_destroy { 625 unsigned int drawctxt_id; 626 }; 627 628 #define IOCTL_KGSL_DRAWCTXT_DESTROY \ 629 _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy) 630 631 /* 632 * add a block of pmem, fb, ashmem or user allocated address 633 * into the GPU address space 634 */ 635 struct kgsl_map_user_mem { 636 int fd; 637 unsigned long gpuaddr; /*output param */ 638 size_t len; 639 size_t offset; 640 unsigned long hostptr; /*input param */ 641 enum kgsl_user_mem_type memtype; 642 unsigned int flags; 643 }; 644 645 #define IOCTL_KGSL_MAP_USER_MEM \ 646 _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem) 647 648 struct kgsl_cmdstream_readtimestamp_ctxtid { 649 unsigned int context_id; 650 unsigned int type; 651 unsigned int timestamp; /*output param */ 652 }; 653 654 #define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \ 655 _IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid) 656 657 struct kgsl_cmdstream_freememontimestamp_ctxtid { 658 unsigned int context_id; 659 unsigned long gpuaddr; 660 unsigned int type; 661 unsigned int timestamp; 662 }; 663 664 #define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \ 665 _IOW(KGSL_IOC_TYPE, 0x17, \ 666 struct kgsl_cmdstream_freememontimestamp_ctxtid) 667 668 /* add a block of pmem or fb into the GPU address space */ 669 struct kgsl_sharedmem_from_pmem { 670 int pmem_fd; 671 unsigned long gpuaddr; /*output param */ 672 unsigned int len; 673 unsigned int offset; 674 }; 675 676 #define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \ 677 _IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem) 678 679 /* remove memory from the GPU's address space */ 680 struct kgsl_sharedmem_free { 681 unsigned long gpuaddr; 682 }; 683 684 #define IOCTL_KGSL_SHAREDMEM_FREE \ 685 _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free) 686 687 struct kgsl_cff_user_event { 688 unsigned char cff_opcode; 689 unsigned int op1; 690 unsigned int op2; 691 unsigned int op3; 692 unsigned int op4; 693 unsigned int op5; 694 unsigned int __pad[2]; 695 }; 696 697 #define IOCTL_KGSL_CFF_USER_EVENT \ 698 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event) 699 700 struct kgsl_gmem_desc { 701 unsigned int x; 702 unsigned int y; 703 unsigned int width; 704 unsigned int height; 705 unsigned int pitch; 706 }; 707 708 struct kgsl_buffer_desc { 709 void *hostptr; 710 unsigned long gpuaddr; 711 int size; 712 unsigned int format; 713 unsigned int pitch; 714 unsigned int enabled; 715 }; 716 717 struct kgsl_bind_gmem_shadow { 718 unsigned int drawctxt_id; 719 struct kgsl_gmem_desc gmem_desc; 720 unsigned int shadow_x; 721 unsigned int shadow_y; 722 struct kgsl_buffer_desc shadow_buffer; 723 unsigned int buffer_id; 724 }; 725 726 #define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \ 727 _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow) 728 729 /* add a block of memory into the GPU address space */ 730 731 /* 732 * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012 733 * use IOCTL_KGSL_GPUMEM_ALLOC instead 734 */ 735 736 struct kgsl_sharedmem_from_vmalloc { 737 unsigned long gpuaddr; /*output param */ 738 unsigned int hostptr; 739 unsigned int flags; 740 }; 741 742 #define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \ 743 _IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc) 744 745 /* 746 * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which 747 * supports both directions (flush and invalidate). This code will still 748 * work, but by definition it will do a flush of the cache which might not be 749 * what you want to have happen on a buffer following a GPU operation. It is 750 * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC 751 */ 752 753 #define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \ 754 _IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free) 755 756 struct kgsl_drawctxt_set_bin_base_offset { 757 unsigned int drawctxt_id; 758 unsigned int offset; 759 }; 760 761 #define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \ 762 _IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset) 763 764 enum kgsl_cmdwindow_type { 765 KGSL_CMDWINDOW_MIN = 0x00000000, 766 KGSL_CMDWINDOW_2D = 0x00000000, 767 KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */ 768 KGSL_CMDWINDOW_MMU = 0x00000002, 769 KGSL_CMDWINDOW_ARBITER = 0x000000FF, 770 KGSL_CMDWINDOW_MAX = 0x000000FF, 771 }; 772 773 /* write to the command window */ 774 struct kgsl_cmdwindow_write { 775 enum kgsl_cmdwindow_type target; 776 unsigned int addr; 777 unsigned int data; 778 }; 779 780 #define IOCTL_KGSL_CMDWINDOW_WRITE \ 781 _IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write) 782 783 struct kgsl_gpumem_alloc { 784 unsigned long gpuaddr; /* output param */ 785 size_t size; 786 unsigned int flags; 787 }; 788 789 #define IOCTL_KGSL_GPUMEM_ALLOC \ 790 _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc) 791 792 struct kgsl_cff_syncmem { 793 unsigned long gpuaddr; 794 size_t len; 795 unsigned int __pad[2]; /* For future binary compatibility */ 796 }; 797 798 #define IOCTL_KGSL_CFF_SYNCMEM \ 799 _IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem) 800 801 /* 802 * A timestamp event allows the user space to register an action following an 803 * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to 804 * _IOWR to support fences which need to return a fd for the priv parameter. 805 */ 806 807 struct kgsl_timestamp_event { 808 int type; /* Type of event (see list below) */ 809 unsigned int timestamp; /* Timestamp to trigger event on */ 810 unsigned int context_id; /* Context for the timestamp */ 811 void *priv; /* Pointer to the event specific blob */ 812 size_t len; /* Size of the event specific blob */ 813 }; 814 815 #define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \ 816 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event) 817 818 /* A genlock timestamp event releases an existing lock on timestamp expire */ 819 820 #define KGSL_TIMESTAMP_EVENT_GENLOCK 1 821 822 struct kgsl_timestamp_event_genlock { 823 int handle; /* Handle of the genlock lock to release */ 824 }; 825 826 /* A fence timestamp event releases an existing lock on timestamp expire */ 827 828 #define KGSL_TIMESTAMP_EVENT_FENCE 2 829 830 struct kgsl_timestamp_event_fence { 831 int fence_fd; /* Fence to signal */ 832 }; 833 834 /* 835 * Set a property within the kernel. Uses the same structure as 836 * IOCTL_KGSL_GETPROPERTY 837 */ 838 839 #define IOCTL_KGSL_SETPROPERTY \ 840 _IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty) 841 842 #define IOCTL_KGSL_TIMESTAMP_EVENT \ 843 _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event) 844 845 /** 846 * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID 847 * @id: returned id value for this allocation. 848 * @flags: mask of KGSL_MEM* values requested and actual flags on return. 849 * @size: requested size of the allocation and actual size on return. 850 * @mmapsize: returned size to pass to mmap() which may be larger than 'size' 851 * @gpuaddr: returned GPU address for the allocation 852 * 853 * Allocate memory for access by the GPU. The flags and size fields are echoed 854 * back by the kernel, so that the caller can know if the request was 855 * adjusted. 856 * 857 * Supported flags: 858 * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer 859 * KGSL_MEMTYPE*: usage hint for debugging aid 860 * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel. 861 * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU 862 * address will be 0. Calling mmap() will set the GPU address. 863 */ 864 struct kgsl_gpumem_alloc_id { 865 unsigned int id; 866 unsigned int flags; 867 size_t size; 868 size_t mmapsize; 869 unsigned long gpuaddr; 870 /* private: reserved for future use*/ 871 unsigned long __pad[2]; 872 }; 873 874 #define IOCTL_KGSL_GPUMEM_ALLOC_ID \ 875 _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id) 876 877 /** 878 * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID 879 * @id: GPU allocation id to free 880 * 881 * Free an allocation by id, in case a GPU address has not been assigned or 882 * is unknown. Freeing an allocation by id with this ioctl or by GPU address 883 * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent. 884 */ 885 struct kgsl_gpumem_free_id { 886 unsigned int id; 887 /* private: reserved for future use*/ 888 unsigned int __pad; 889 }; 890 891 #define IOCTL_KGSL_GPUMEM_FREE_ID \ 892 _IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id) 893 894 /** 895 * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO 896 * @gpuaddr: GPU address to query. Also set on return. 897 * @id: GPU allocation id to query. Also set on return. 898 * @flags: returned mask of KGSL_MEM* values. 899 * @size: returned size of the allocation. 900 * @mmapsize: returned size to pass mmap(), which may be larger than 'size' 901 * @useraddr: returned address of the userspace mapping for this buffer 902 * 903 * This ioctl allows querying of all user visible attributes of an existing 904 * allocation, by either the GPU address or the id returned by a previous 905 * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not 906 * return all attributes so this ioctl can be used to look them up if needed. 907 * 908 */ 909 struct kgsl_gpumem_get_info { 910 unsigned long gpuaddr; 911 unsigned int id; 912 unsigned int flags; 913 size_t size; 914 size_t mmapsize; 915 unsigned long useraddr; 916 /* private: reserved for future use*/ 917 unsigned long __pad[4]; 918 }; 919 920 #define IOCTL_KGSL_GPUMEM_GET_INFO\ 921 _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info) 922 923 /** 924 * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE 925 * @gpuaddr: GPU address of the buffer to sync. 926 * @id: id of the buffer to sync. Either gpuaddr or id is sufficient. 927 * @op: a mask of KGSL_GPUMEM_CACHE_* values 928 * @offset: offset into the buffer 929 * @length: number of bytes starting from offset to perform 930 * the cache operation on 931 * 932 * Sync the L2 cache for memory headed to and from the GPU - this replaces 933 * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both 934 * directions 935 * 936 */ 937 struct kgsl_gpumem_sync_cache { 938 unsigned long gpuaddr; 939 unsigned int id; 940 unsigned int op; 941 size_t offset; 942 size_t length; 943 }; 944 945 #define KGSL_GPUMEM_CACHE_CLEAN (1 << 0) 946 #define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN 947 948 #define KGSL_GPUMEM_CACHE_INV (1 << 1) 949 #define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV 950 951 #define KGSL_GPUMEM_CACHE_FLUSH \ 952 (KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV) 953 954 /* Flag to ensure backwards compatibility of kgsl_gpumem_sync_cache struct */ 955 #define KGSL_GPUMEM_CACHE_RANGE (1 << 31U) 956 957 #define IOCTL_KGSL_GPUMEM_SYNC_CACHE \ 958 _IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache) 959 960 /** 961 * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET 962 * @groupid: Performance counter group ID 963 * @countable: Countable to select within the group 964 * @offset: Return offset of the reserved LO counter 965 * @offset_hi: Return offset of the reserved HI counter 966 * 967 * Get an available performance counter from a specified groupid. The offset 968 * of the performance counter will be returned after successfully assigning 969 * the countable to the counter for the specified group. An error will be 970 * returned and an offset of 0 if the groupid is invalid or there are no 971 * more counters left. After successfully getting a perfcounter, the user 972 * must call kgsl_perfcounter_put(groupid, contable) when finished with 973 * the perfcounter to clear up perfcounter resources. 974 * 975 */ 976 struct kgsl_perfcounter_get { 977 unsigned int groupid; 978 unsigned int countable; 979 unsigned int offset; 980 unsigned int offset_hi; 981 /* private: reserved for future use */ 982 unsigned int __pad; /* For future binary compatibility */ 983 }; 984 985 #define IOCTL_KGSL_PERFCOUNTER_GET \ 986 _IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get) 987 988 /** 989 * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT 990 * @groupid: Performance counter group ID 991 * @countable: Countable to release within the group 992 * 993 * Put an allocated performance counter to allow others to have access to the 994 * resource that was previously taken. This is only to be called after 995 * successfully getting a performance counter from kgsl_perfcounter_get(). 996 * 997 */ 998 struct kgsl_perfcounter_put { 999 unsigned int groupid; 1000 unsigned int countable; 1001 /* private: reserved for future use */ 1002 unsigned int __pad[2]; /* For future binary compatibility */ 1003 }; 1004 1005 #define IOCTL_KGSL_PERFCOUNTER_PUT \ 1006 _IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put) 1007 1008 /** 1009 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY 1010 * @groupid: Performance counter group ID 1011 * @countable: Return active countables array 1012 * @size: Size of active countables array 1013 * @max_counters: Return total number counters for the group ID 1014 * 1015 * Query the available performance counters given a groupid. The array 1016 * *countables is used to return the current active countables in counters. 1017 * The size of the array is passed in so the kernel will only write at most 1018 * size or counter->size for the group id. The total number of available 1019 * counters for the group ID is returned in max_counters. 1020 * If the array or size passed in are invalid, then only the maximum number 1021 * of counters will be returned, no data will be written to *countables. 1022 * If the groupid is invalid an error code will be returned. 1023 * 1024 */ 1025 struct kgsl_perfcounter_query { 1026 unsigned int groupid; 1027 /* Array to return the current countable for up to size counters */ 1028 unsigned int *countables; 1029 unsigned int count; 1030 unsigned int max_counters; 1031 /* private: reserved for future use */ 1032 unsigned int __pad[2]; /* For future binary compatibility */ 1033 }; 1034 1035 #define IOCTL_KGSL_PERFCOUNTER_QUERY \ 1036 _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query) 1037 1038 /** 1039 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY 1040 * @groupid: Performance counter group IDs 1041 * @countable: Performance counter countable IDs 1042 * @value: Return performance counter reads 1043 * @size: Size of all arrays (groupid/countable pair and return value) 1044 * 1045 * Read in the current value of a performance counter given by the groupid 1046 * and countable. 1047 * 1048 */ 1049 1050 struct kgsl_perfcounter_read_group { 1051 unsigned int groupid; 1052 unsigned int countable; 1053 unsigned long long value; 1054 }; 1055 1056 struct kgsl_perfcounter_read { 1057 struct kgsl_perfcounter_read_group *reads; 1058 unsigned int count; 1059 /* private: reserved for future use */ 1060 unsigned int __pad[2]; /* For future binary compatibility */ 1061 }; 1062 1063 #define IOCTL_KGSL_PERFCOUNTER_READ \ 1064 _IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read) 1065 /* 1066 * struct kgsl_gpumem_sync_cache_bulk - argument to 1067 * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK 1068 * @id_list: list of GPU buffer ids of the buffers to sync 1069 * @count: number of GPU buffer ids in id_list 1070 * @op: a mask of KGSL_GPUMEM_CACHE_* values 1071 * 1072 * Sync the cache for memory headed to and from the GPU. Certain 1073 * optimizations can be made on the cache operation based on the total 1074 * size of the working set of memory to be managed. 1075 */ 1076 struct kgsl_gpumem_sync_cache_bulk { 1077 unsigned int *id_list; 1078 unsigned int count; 1079 unsigned int op; 1080 /* private: reserved for future use */ 1081 unsigned int __pad[2]; /* For future binary compatibility */ 1082 }; 1083 1084 #define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \ 1085 _IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk) 1086 1087 /* 1088 * struct kgsl_cmd_syncpoint_timestamp 1089 * @context_id: ID of a KGSL context 1090 * @timestamp: GPU timestamp 1091 * 1092 * This structure defines a syncpoint comprising a context/timestamp pair. A 1093 * list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define 1094 * dependencies that must be met before the command can be submitted to the 1095 * hardware 1096 */ 1097 struct kgsl_cmd_syncpoint_timestamp { 1098 unsigned int context_id; 1099 unsigned int timestamp; 1100 }; 1101 1102 struct kgsl_cmd_syncpoint_fence { 1103 int fd; 1104 }; 1105 1106 /* 1107 * struct kgsl_cmd_syncpoint_timeline 1108 * @timelines: Address of an array of &struct kgsl_timeline_val 1109 * @count: Number of entries in @timelines 1110 * @timelines_size: Size of each entry in @timelines 1111 * 1112 * Define a syncpoint for a number of timelines. This syncpoint will 1113 * be satisfied when all of the specified timelines are signaled. 1114 */ 1115 struct kgsl_cmd_syncpoint_timeline { 1116 __u64 timelines; 1117 __u32 count; 1118 __u32 timelines_size; 1119 }; 1120 1121 /** 1122 * struct kgsl_cmd_syncpoint - Define a sync point for a command batch 1123 * @type: type of sync point defined here 1124 * @priv: Pointer to the type specific buffer 1125 * @size: Size of the type specific buffer 1126 * 1127 * This structure contains pointers defining a specific command sync point. 1128 * The pointer and size should point to a type appropriate structure. 1129 */ 1130 struct kgsl_cmd_syncpoint { 1131 int type; 1132 void *priv; 1133 size_t size; 1134 }; 1135 1136 /* Flag to indicate that the cmdlist may contain memlists */ 1137 #define KGSL_IBDESC_MEMLIST 0x1 1138 1139 /* Flag to point out the cmdbatch profiling buffer in the memlist */ 1140 #define KGSL_IBDESC_PROFILING_BUFFER 0x2 1141 1142 /** 1143 * struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS 1144 * @context_id: KGSL context ID that owns the commands 1145 * @flags: 1146 * @cmdlist: User pointer to a list of kgsl_ibdesc structures 1147 * @numcmds: Number of commands listed in cmdlist 1148 * @synclist: User pointer to a list of kgsl_cmd_syncpoint structures 1149 * @numsyncs: Number of sync points listed in synclist 1150 * @timestamp: On entry the a user defined timestamp, on exist the timestamp 1151 * assigned to the command batch 1152 * 1153 * This structure specifies a command to send to the GPU hardware. This is 1154 * similar to kgsl_issueibcmds expect that it doesn't support the legacy way to 1155 * submit IB lists and it adds sync points to block the IB until the 1156 * dependencies are satisified. This entry point is the new and preferred way 1157 * to submit commands to the GPU. The memory list can be used to specify all 1158 * memory that is referrenced in the current set of commands. 1159 */ 1160 1161 struct kgsl_submit_commands { 1162 unsigned int context_id; 1163 unsigned int flags; 1164 struct kgsl_ibdesc *cmdlist; 1165 unsigned int numcmds; 1166 struct kgsl_cmd_syncpoint *synclist; 1167 unsigned int numsyncs; 1168 unsigned int timestamp; 1169 /* private: reserved for future use */ 1170 unsigned int __pad[4]; 1171 }; 1172 1173 #define IOCTL_KGSL_SUBMIT_COMMANDS \ 1174 _IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands) 1175 1176 /** 1177 * struct kgsl_device_constraint - device constraint argument 1178 * @context_id: KGSL context ID 1179 * @type: type of constraint i.e pwrlevel/none 1180 * @data: constraint data 1181 * @size: size of the constraint data 1182 */ 1183 struct kgsl_device_constraint { 1184 unsigned int type; 1185 unsigned int context_id; 1186 void *data; 1187 size_t size; 1188 }; 1189 1190 /* Constraint Type*/ 1191 #define KGSL_CONSTRAINT_NONE 0 1192 #define KGSL_CONSTRAINT_PWRLEVEL 1 1193 1194 /* L3 constraint Type */ 1195 #define KGSL_CONSTRAINT_L3_NONE 2 1196 #define KGSL_CONSTRAINT_L3_PWRLEVEL 3 1197 1198 /* PWRLEVEL constraint level*/ 1199 /* set to min frequency */ 1200 #define KGSL_CONSTRAINT_PWR_MIN 0 1201 /* set to max frequency */ 1202 #define KGSL_CONSTRAINT_PWR_MAX 1 1203 1204 struct kgsl_device_constraint_pwrlevel { 1205 unsigned int level; 1206 }; 1207 1208 /** 1209 * struct kgsl_syncsource_create - Argument to IOCTL_KGSL_SYNCSOURCE_CREATE 1210 * @id: returned id for the syncsource that was created. 1211 * 1212 * This ioctl creates a userspace sync timeline. 1213 */ 1214 1215 struct kgsl_syncsource_create { 1216 unsigned int id; 1217 /* private: reserved for future use */ 1218 unsigned int __pad[3]; 1219 }; 1220 1221 #define IOCTL_KGSL_SYNCSOURCE_CREATE \ 1222 _IOWR(KGSL_IOC_TYPE, 0x40, struct kgsl_syncsource_create) 1223 1224 /** 1225 * struct kgsl_syncsource_destroy - Argument to IOCTL_KGSL_SYNCSOURCE_DESTROY 1226 * @id: syncsource id to destroy 1227 * 1228 * This ioctl creates a userspace sync timeline. 1229 */ 1230 1231 struct kgsl_syncsource_destroy { 1232 unsigned int id; 1233 /* private: reserved for future use */ 1234 unsigned int __pad[3]; 1235 }; 1236 1237 #define IOCTL_KGSL_SYNCSOURCE_DESTROY \ 1238 _IOWR(KGSL_IOC_TYPE, 0x41, struct kgsl_syncsource_destroy) 1239 1240 /** 1241 * struct kgsl_syncsource_create_fence - Argument to 1242 * IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE 1243 * @id: syncsource id 1244 * @fence_fd: returned sync_fence fd 1245 * 1246 * Create a fence that may be signaled by userspace by calling 1247 * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE. There are no order dependencies between 1248 * these fences. 1249 */ 1250 struct kgsl_syncsource_create_fence { 1251 unsigned int id; 1252 int fence_fd; 1253 /* private: reserved for future use */ 1254 unsigned int __pad[4]; 1255 }; 1256 1257 /** 1258 * struct kgsl_syncsource_signal_fence - Argument to 1259 * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE 1260 * @id: syncsource id 1261 * @fence_fd: sync_fence fd to signal 1262 * 1263 * Signal a fence that was created by a IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE 1264 * call using the same syncsource id. This allows a fence to be shared 1265 * to other processes but only signaled by the process owning the fd 1266 * used to create the fence. 1267 */ 1268 #define IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE \ 1269 _IOWR(KGSL_IOC_TYPE, 0x42, struct kgsl_syncsource_create_fence) 1270 1271 struct kgsl_syncsource_signal_fence { 1272 unsigned int id; 1273 int fence_fd; 1274 /* private: reserved for future use */ 1275 unsigned int __pad[4]; 1276 }; 1277 1278 #define IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE \ 1279 _IOWR(KGSL_IOC_TYPE, 0x43, struct kgsl_syncsource_signal_fence) 1280 1281 /** 1282 * struct kgsl_cff_sync_gpuobj - Argument to IOCTL_KGSL_CFF_SYNC_GPUOBJ 1283 * @offset: Offset into the GPU object to sync 1284 * @length: Number of bytes to sync 1285 * @id: ID of the GPU object to sync 1286 */ 1287 struct kgsl_cff_sync_gpuobj { 1288 uint64_t offset; 1289 uint64_t length; 1290 unsigned int id; 1291 }; 1292 1293 #define IOCTL_KGSL_CFF_SYNC_GPUOBJ \ 1294 _IOW(KGSL_IOC_TYPE, 0x44, struct kgsl_cff_sync_gpuobj) 1295 1296 /** 1297 * struct kgsl_gpuobj_alloc - Argument to IOCTL_KGSL_GPUOBJ_ALLOC 1298 * @size: Size in bytes of the object to allocate 1299 * @flags: mask of KGSL_MEMFLAG_* bits 1300 * @va_len: Size in bytes of the virtual region to allocate 1301 * @mmapsize: Returns the mmap() size of the object 1302 * @id: Returns the GPU object ID of the new object 1303 * @metadata_len: Length of the metdata to copy from the user 1304 * @metadata: Pointer to the user specified metadata to store for the object 1305 */ 1306 struct kgsl_gpuobj_alloc { 1307 uint64_t size; 1308 uint64_t flags; 1309 uint64_t va_len; 1310 uint64_t mmapsize; 1311 unsigned int id; 1312 unsigned int metadata_len; 1313 uint64_t metadata; 1314 }; 1315 1316 /* Let the user know that this header supports the gpuobj metadata */ 1317 #define KGSL_GPUOBJ_ALLOC_METADATA_MAX 64 1318 1319 #define IOCTL_KGSL_GPUOBJ_ALLOC \ 1320 _IOWR(KGSL_IOC_TYPE, 0x45, struct kgsl_gpuobj_alloc) 1321 1322 /** 1323 * struct kgsl_gpuobj_free - Argument to IOCTL_KGLS_GPUOBJ_FREE 1324 * @flags: Mask of: KGSL_GUPOBJ_FREE_ON_EVENT 1325 * @priv: Pointer to the private object if KGSL_GPUOBJ_FREE_ON_EVENT is 1326 * specified 1327 * @id: ID of the GPU object to free 1328 * @type: If KGSL_GPUOBJ_FREE_ON_EVENT is specified, the type of asynchronous 1329 * event to free on 1330 * @len: Length of the data passed in priv 1331 */ 1332 struct kgsl_gpuobj_free { 1333 uint64_t flags; 1334 uint64_t priv; 1335 unsigned int id; 1336 unsigned int type; 1337 unsigned int len; 1338 }; 1339 1340 #define KGSL_GPUOBJ_FREE_ON_EVENT 1 1341 1342 #define KGSL_GPU_EVENT_TIMESTAMP 1 1343 #define KGSL_GPU_EVENT_FENCE 2 1344 1345 /** 1346 * struct kgsl_gpu_event_timestamp - Specifies a timestamp event to free a GPU 1347 * object on 1348 * @context_id: ID of the timestamp event to wait for 1349 * @timestamp: Timestamp of the timestamp event to wait for 1350 */ 1351 struct kgsl_gpu_event_timestamp { 1352 unsigned int context_id; 1353 unsigned int timestamp; 1354 }; 1355 1356 /** 1357 * struct kgsl_gpu_event_fence - Specifies a fence ID to to free a GPU object on 1358 * @fd: File descriptor for the fence 1359 */ 1360 struct kgsl_gpu_event_fence { 1361 int fd; 1362 }; 1363 1364 #define IOCTL_KGSL_GPUOBJ_FREE \ 1365 _IOW(KGSL_IOC_TYPE, 0x46, struct kgsl_gpuobj_free) 1366 1367 /** 1368 * struct kgsl_gpuobj_info - argument to IOCTL_KGSL_GPUOBJ_INFO 1369 * @gpuaddr: GPU address of the object 1370 * @flags: Current flags for the object 1371 * @size: Size of the object 1372 * @va_len: VA size of the object 1373 * @va_addr: Virtual address of the object (if it is mapped) 1374 * id - GPU object ID of the object to query 1375 */ 1376 struct kgsl_gpuobj_info { 1377 uint64_t gpuaddr; 1378 uint64_t flags; 1379 uint64_t size; 1380 uint64_t va_len; 1381 uint64_t va_addr; 1382 unsigned int id; 1383 }; 1384 1385 #define IOCTL_KGSL_GPUOBJ_INFO \ 1386 _IOWR(KGSL_IOC_TYPE, 0x47, struct kgsl_gpuobj_info) 1387 1388 /** 1389 * struct kgsl_gpuobj_import - argument to IOCTL_KGSL_GPUOBJ_IMPORT 1390 * @priv: Pointer to the private data for the import type 1391 * @priv_len: Length of the private data 1392 * @flags: Mask of KGSL_MEMFLAG_ flags 1393 * @type: Type of the import (KGSL_USER_MEM_TYPE_*) 1394 * @id: Returns the ID of the new GPU object 1395 */ 1396 struct kgsl_gpuobj_import { 1397 uint64_t priv; 1398 uint64_t priv_len; 1399 uint64_t flags; 1400 unsigned int type; 1401 unsigned int id; 1402 }; 1403 1404 /** 1405 * struct kgsl_gpuobj_import_dma_buf - import a dmabuf object 1406 * @fd: File descriptor for the dma-buf object 1407 */ 1408 struct kgsl_gpuobj_import_dma_buf { 1409 int fd; 1410 }; 1411 1412 /** 1413 * struct kgsl_gpuobj_import_useraddr - import an object based on a useraddr 1414 * @virtaddr: Virtual address of the object to import 1415 */ 1416 struct kgsl_gpuobj_import_useraddr { 1417 uint64_t virtaddr; 1418 }; 1419 1420 #define IOCTL_KGSL_GPUOBJ_IMPORT \ 1421 _IOWR(KGSL_IOC_TYPE, 0x48, struct kgsl_gpuobj_import) 1422 1423 /** 1424 * struct kgsl_gpuobj_sync_obj - Individual GPU object to sync 1425 * @offset: Offset within the GPU object to sync 1426 * @length: Number of bytes to sync 1427 * @id: ID of the GPU object to sync 1428 * @op: Cache operation to execute 1429 */ 1430 1431 struct kgsl_gpuobj_sync_obj { 1432 uint64_t offset; 1433 uint64_t length; 1434 unsigned int id; 1435 unsigned int op; 1436 }; 1437 1438 /** 1439 * struct kgsl_gpuobj_sync - Argument for IOCTL_KGSL_GPUOBJ_SYNC 1440 * @objs: Pointer to an array of kgsl_gpuobj_sync_obj structs 1441 * @obj_len: Size of each item in the array 1442 * @count: Number of items in the array 1443 */ 1444 1445 struct kgsl_gpuobj_sync { 1446 uint64_t objs; 1447 unsigned int obj_len; 1448 unsigned int count; 1449 }; 1450 1451 #define IOCTL_KGSL_GPUOBJ_SYNC \ 1452 _IOW(KGSL_IOC_TYPE, 0x49, struct kgsl_gpuobj_sync) 1453 1454 /** 1455 * struct kgsl_command_object - GPU command object 1456 * @offset: GPU address offset of the object 1457 * @gpuaddr: GPU address of the object 1458 * @size: Size of the object 1459 * @flags: Current flags for the object 1460 * @id - GPU command object ID 1461 */ 1462 struct kgsl_command_object { 1463 uint64_t offset; 1464 uint64_t gpuaddr; 1465 uint64_t size; 1466 unsigned int flags; 1467 unsigned int id; 1468 }; 1469 1470 /** 1471 * struct kgsl_command_syncpoint - GPU syncpoint object 1472 * @priv: Pointer to the type specific buffer 1473 * @size: Size of the type specific buffer 1474 * @type: type of sync point defined here 1475 */ 1476 struct kgsl_command_syncpoint { 1477 uint64_t priv; 1478 uint64_t size; 1479 unsigned int type; 1480 }; 1481 1482 /** 1483 * struct kgsl_command_object - Argument for IOCTL_KGSL_GPU_COMMAND 1484 * @flags: Current flags for the object 1485 * @cmdlist: List of kgsl_command_objects for submission 1486 * @cmd_size: Size of kgsl_command_objects structure 1487 * @numcmds: Number of kgsl_command_objects in command list 1488 * @objlist: List of kgsl_command_objects for tracking 1489 * @obj_size: Size of kgsl_command_objects structure 1490 * @numobjs: Number of kgsl_command_objects in object list 1491 * @synclist: List of kgsl_command_syncpoints 1492 * @sync_size: Size of kgsl_command_syncpoint structure 1493 * @numsyncs: Number of kgsl_command_syncpoints in syncpoint list 1494 * @context_id: Context ID submittin ghte kgsl_gpu_command 1495 * @timestamp: Timestamp for the submitted commands 1496 */ 1497 struct kgsl_gpu_command { 1498 uint64_t flags; 1499 uint64_t cmdlist; 1500 unsigned int cmdsize; 1501 unsigned int numcmds; 1502 uint64_t objlist; 1503 unsigned int objsize; 1504 unsigned int numobjs; 1505 uint64_t synclist; 1506 unsigned int syncsize; 1507 unsigned int numsyncs; 1508 unsigned int context_id; 1509 unsigned int timestamp; 1510 }; 1511 1512 #define IOCTL_KGSL_GPU_COMMAND \ 1513 _IOWR(KGSL_IOC_TYPE, 0x4A, struct kgsl_gpu_command) 1514 1515 /** 1516 * struct kgsl_preemption_counters_query - argument to 1517 * IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY 1518 * @counters: Return preemption counters array 1519 * @size_user: Size allocated by userspace 1520 * @size_priority_level: Size of preemption counters for each 1521 * priority level 1522 * @max_priority_level: Return max number of priority levels 1523 * 1524 * Query the available preemption counters. The array counters 1525 * is used to return preemption counters. The size of the array 1526 * is passed in so the kernel will only write at most size_user 1527 * or max available preemption counters. The total number of 1528 * preemption counters is returned in max_priority_level. If the 1529 * array or size passed in are invalid, then an error is 1530 * returned back. 1531 */ 1532 struct kgsl_preemption_counters_query { 1533 uint64_t counters; 1534 unsigned int size_user; 1535 unsigned int size_priority_level; 1536 unsigned int max_priority_level; 1537 }; 1538 1539 #define IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY \ 1540 _IOWR(KGSL_IOC_TYPE, 0x4B, struct kgsl_preemption_counters_query) 1541 1542 /** 1543 * struct kgsl_gpuobj_set_info - argument for IOCTL_KGSL_GPUOBJ_SET_INFO 1544 * @flags: Flags to indicate which parameters to change 1545 * @metadata: If KGSL_GPUOBJ_SET_INFO_METADATA is set, a pointer to the new 1546 * metadata 1547 * @id: GPU memory object ID to change 1548 * @metadata_len: If KGSL_GPUOBJ_SET_INFO_METADATA is set, the length of the 1549 * new metadata string 1550 * @type: If KGSL_GPUOBJ_SET_INFO_TYPE is set, the new type of the memory object 1551 */ 1552 1553 #define KGSL_GPUOBJ_SET_INFO_METADATA (1 << 0) 1554 #define KGSL_GPUOBJ_SET_INFO_TYPE (1 << 1) 1555 1556 struct kgsl_gpuobj_set_info { 1557 uint64_t flags; 1558 uint64_t metadata; 1559 unsigned int id; 1560 unsigned int metadata_len; 1561 unsigned int type; 1562 }; 1563 1564 #define IOCTL_KGSL_GPUOBJ_SET_INFO \ 1565 _IOW(KGSL_IOC_TYPE, 0x4C, struct kgsl_gpuobj_set_info) 1566 1567 /** 1568 * struct kgsl_sparse_phys_alloc - Argument for IOCTL_KGSL_SPARSE_PHYS_ALLOC 1569 * @size: Size in bytes to back 1570 * @pagesize: Pagesize alignment required 1571 * @flags: Flags for this allocation 1572 * @id: Returned ID for this allocation 1573 */ 1574 struct kgsl_sparse_phys_alloc { 1575 uint64_t size; 1576 uint64_t pagesize; 1577 uint64_t flags; 1578 unsigned int id; 1579 }; 1580 1581 #define IOCTL_KGSL_SPARSE_PHYS_ALLOC \ 1582 _IOWR(KGSL_IOC_TYPE, 0x50, struct kgsl_sparse_phys_alloc) 1583 1584 /** 1585 * struct kgsl_sparse_phys_free - Argument for IOCTL_KGSL_SPARSE_PHYS_FREE 1586 * @id: ID to free 1587 */ 1588 struct kgsl_sparse_phys_free { 1589 unsigned int id; 1590 }; 1591 1592 #define IOCTL_KGSL_SPARSE_PHYS_FREE \ 1593 _IOW(KGSL_IOC_TYPE, 0x51, struct kgsl_sparse_phys_free) 1594 1595 /** 1596 * struct kgsl_sparse_virt_alloc - Argument for IOCTL_KGSL_SPARSE_VIRT_ALLOC 1597 * @size: Size in bytes to reserve 1598 * @pagesize: Pagesize alignment required 1599 * @flags: Flags for this allocation 1600 * @id: Returned ID for this allocation 1601 * @gpuaddr: Returned GPU address for this allocation 1602 */ 1603 struct kgsl_sparse_virt_alloc { 1604 uint64_t size; 1605 uint64_t pagesize; 1606 uint64_t flags; 1607 uint64_t gpuaddr; 1608 unsigned int id; 1609 }; 1610 1611 #define IOCTL_KGSL_SPARSE_VIRT_ALLOC \ 1612 _IOWR(KGSL_IOC_TYPE, 0x52, struct kgsl_sparse_virt_alloc) 1613 1614 /** 1615 * struct kgsl_sparse_virt_free - Argument for IOCTL_KGSL_SPARSE_VIRT_FREE 1616 * @id: ID to free 1617 */ 1618 struct kgsl_sparse_virt_free { 1619 unsigned int id; 1620 }; 1621 1622 #define IOCTL_KGSL_SPARSE_VIRT_FREE \ 1623 _IOW(KGSL_IOC_TYPE, 0x53, struct kgsl_sparse_virt_free) 1624 1625 /** 1626 * struct kgsl_sparse_binding_object - Argument for kgsl_sparse_bind 1627 * @virtoffset: Offset into the virtual ID 1628 * @physoffset: Offset into the physical ID (bind only) 1629 * @size: Size in bytes to reserve 1630 * @flags: Flags for this kgsl_sparse_binding_object 1631 * @id: Physical ID to bind (bind only) 1632 */ 1633 struct kgsl_sparse_binding_object { 1634 uint64_t virtoffset; 1635 uint64_t physoffset; 1636 uint64_t size; 1637 uint64_t flags; 1638 unsigned int id; 1639 }; 1640 1641 /** 1642 * struct kgsl_sparse_bind - Argument for IOCTL_KGSL_SPARSE_BIND 1643 * @list: List of kgsl_sparse_bind_objects to bind/unbind 1644 * @id: Virtual ID to bind/unbind 1645 * @size: Size of kgsl_sparse_bind_object 1646 * @count: Number of elements in list 1647 * 1648 */ 1649 struct kgsl_sparse_bind { 1650 uint64_t list; 1651 unsigned int id; 1652 unsigned int size; 1653 unsigned int count; 1654 }; 1655 1656 #define IOCTL_KGSL_SPARSE_BIND \ 1657 _IOW(KGSL_IOC_TYPE, 0x54, struct kgsl_sparse_bind) 1658 1659 /** 1660 * struct kgsl_gpu_sparse_command - Argument for 1661 * IOCTL_KGSL_GPU_SPARSE_COMMAND 1662 * @flags: Current flags for the object 1663 * @sparselist: List of kgsl_sparse_binding_object to bind/unbind 1664 * @synclist: List of kgsl_command_syncpoints 1665 * @sparsesize: Size of kgsl_sparse_binding_object 1666 * @numsparse: Number of elements in list 1667 * @sync_size: Size of kgsl_command_syncpoint structure 1668 * @numsyncs: Number of kgsl_command_syncpoints in syncpoint list 1669 * @context_id: Context ID submitting the kgsl_gpu_command 1670 * @timestamp: Timestamp for the submitted commands 1671 * @id: Virtual ID to bind/unbind 1672 */ 1673 struct kgsl_gpu_sparse_command { 1674 uint64_t flags; 1675 uint64_t sparselist; 1676 uint64_t synclist; 1677 unsigned int sparsesize; 1678 unsigned int numsparse; 1679 unsigned int syncsize; 1680 unsigned int numsyncs; 1681 unsigned int context_id; 1682 unsigned int timestamp; 1683 unsigned int id; 1684 }; 1685 1686 #define IOCTL_KGSL_GPU_SPARSE_COMMAND \ 1687 _IOWR(KGSL_IOC_TYPE, 0x55, struct kgsl_gpu_sparse_command) 1688 1689 #define KGSL_GPU_AUX_COMMAND_TIMELINE (1 << 1) 1690 /* Reuse the same flag that GPU COMMAND uses */ 1691 #define KGSL_GPU_AUX_COMMAND_SYNC KGSL_CMDBATCH_SYNC 1692 1693 /** 1694 * struct kgsl_aux_command_generic - Container for an AUX command 1695 * @priv: Pointer to the type specific buffer 1696 * @size: Size of the type specific buffer 1697 * @type: type of sync point defined here 1698 * 1699 * Describes a generic container for GPU aux commands. @priv is a user pointer 1700 * to the command struct matching @type of size @size. 1701 */ 1702 struct kgsl_gpu_aux_command_generic { 1703 __u64 priv; 1704 __u64 size; 1705 __u32 type; 1706 /* private: Padding for 64 bit compatibility */ 1707 __u32 padding; 1708 }; 1709 1710 /** 1711 * struct kgsl_gpu_aux_command - Argument for IOCTL_KGSL_GPU_AUX_COMMAND 1712 * @flags: flags for the object 1713 * @cmdlist: List of &struct kgsl_gpu_aux_command_generic objects 1714 * @cmd_size: Size of each entry in @cmdlist 1715 * @numcmds: Number of entries in @cmdlist 1716 * @synclist: List of &struct kgsl_command_syncpoint objects 1717 * @syncsize: Size of each entry in @synclist 1718 * @numsyncs: Number of entries in @synclist 1719 * @context_id: ID of the context submtting the aux command 1720 * @timestamp: Timestamp for the command submission 1721 * 1722 * Describe a GPU auxiliary command. Auxiliary commands are tasks that are not 1723 * performed on hardware but can be queued like normal GPU commands. Like GPU 1724 * commands AUX commands are assigned a timestamp and processed in order in the 1725 * queue. They can also have standard sync objects attached. The only 1726 * difference is that AUX commands usually perform some sort of administrative 1727 * task in the CPU and are retired in the dispatcher. 1728 * 1729 * For bind operations flags must have one of the KGSL_GPU_AUX_COMMAND_* flags 1730 * set. If sync objects are attached KGSL_GPU_AUX_COMMAND_SYNC must be set. 1731 * @cmdlist points to an array of &struct kgsl_gpu_aux_command_generic structs 1732 * which in turn will have a pointer to a specific command type. 1733 * @numcmds is the number of commands in the list and @cmdsize is the size 1734 * of each entity in @cmdlist. 1735 * 1736 * If KGSL_GPU_AUX_COMMAND_SYNC is specified @synclist will point to an array of 1737 * &struct kgsl_command_syncpoint items in the same fashion as a GPU hardware 1738 * command. @numsyncs and @syncsize describe the list. 1739 * 1740 * @context_id is the context that is submitting the command and @timestamp 1741 * contains the timestamp for the operation. 1742 */ 1743 struct kgsl_gpu_aux_command { 1744 __u64 flags; 1745 __u64 cmdlist; 1746 __u32 cmdsize; 1747 __u32 numcmds; 1748 __u64 synclist; 1749 __u32 syncsize; 1750 __u32 numsyncs; 1751 __u32 context_id; 1752 __u32 timestamp; 1753 }; 1754 1755 #define IOCTL_KGSL_GPU_AUX_COMMAND \ 1756 _IOWR(KGSL_IOC_TYPE, 0x57, struct kgsl_gpu_aux_command) 1757 1758 /** 1759 * struct kgsl_timeline_create - Argument for IOCTL_KGSL_TIMELINE_CREATE 1760 * @seqno: Initial sequence number for the timeline 1761 * @id: Timeline identifier [out] 1762 * 1763 * Create a new semaphore timeline and return the identifier in @id. 1764 * The identifier is global for the device and can be used to 1765 * identify the timeline in all subsequent commands. 1766 */ 1767 struct kgsl_timeline_create { 1768 __u64 seqno; 1769 __u32 id; 1770 /* private: padding for 64 bit compatibility */ 1771 __u32 padding; 1772 }; 1773 1774 #define IOCTL_KGSL_TIMELINE_CREATE \ 1775 _IOWR(KGSL_IOC_TYPE, 0x58, struct kgsl_timeline_create) 1776 1777 /** 1778 * struct kgsl_timeline_val - A container to store a timeline/sequence number 1779 * pair. 1780 * @seqno: Sequence number to signal/query 1781 * @timeline: The timeline identifier to signal/query 1782 * 1783 * A container to store a timeline/seqno pair used by the query and signal 1784 * ioctls. 1785 */ 1786 struct kgsl_timeline_val { 1787 __u64 seqno; 1788 __u32 timeline; 1789 /* private: padding for 64 bit compatibility */ 1790 __u32 padding; 1791 }; 1792 1793 #define KGSL_TIMELINE_WAIT_ALL 1 1794 #define KGSL_TIMELINE_WAIT_ANY 2 1795 1796 /** 1797 * struct kgsl_timeline_wait - Argument for IOCTL_KGSL_TIMELINE_WAIT 1798 * @tv_sec: Number of seconds to wait for the signal 1799 * @tv_nsec: Number of nanoseconds to wait for the signal 1800 * @timelines: Address of an array of &struct kgsl_timeline_val entries 1801 * @count: Number of entries in @timeline 1802 * @timelines_size: Size of each entry in @timelines 1803 * @flags: One of KGSL_TIMELINE_WAIT_ALL or KGSL_TIMELINE_WAIT_ANY 1804 * 1805 * Wait for the timelines listed in @timelines to be signaled. If @flags is 1806 * equal to KGSL_TIMELINE_WAIT_ALL then wait for all timelines or if 1807 * KGSL_TIMELINE_WAIT_ANY is specified then wait for any of the timelines to 1808 * signal. @tv_sec and @tv_nsec indicates the number of seconds and nanoseconds 1809 * that the process should be blocked waiting for the signal. 1810 */ 1811 struct kgsl_timeline_wait { 1812 __s64 tv_sec; 1813 __s64 tv_nsec; 1814 __u64 timelines; 1815 __u32 count; 1816 __u32 timelines_size; 1817 __u32 flags; 1818 /* private: padding for 64 bit compatibility */ 1819 __u32 padding; 1820 }; 1821 1822 #define IOCTL_KGSL_TIMELINE_WAIT \ 1823 _IOW(KGSL_IOC_TYPE, 0x59, struct kgsl_timeline_wait) 1824 1825 #define IOCTL_KGSL_TIMELINE_QUERY \ 1826 _IOWR(KGSL_IOC_TYPE, 0x5A, struct kgsl_timeline_val) 1827 1828 /** 1829 * struct kgsl_timeline_signal - argument for IOCTL_KGSL_TIMELINE_SIGNAL 1830 * @timelines: Address of an array of &struct kgsl_timeline_val entries 1831 * @count: Number of entries in @timelines 1832 * @timelines_size: Size of each entry in @timelines 1833 * 1834 * Signal an array of timelines of type @struct kgsl_timeline_val. 1835 */ 1836 struct kgsl_timeline_signal { 1837 __u64 timelines; 1838 __u32 count; 1839 __u32 timelines_size; 1840 }; 1841 1842 #define IOCTL_KGSL_TIMELINE_SIGNAL \ 1843 _IOW(KGSL_IOC_TYPE, 0x5B, struct kgsl_timeline_signal) 1844 1845 /** 1846 * struct kgsl_timeline_fence_get - argument for IOCTL_KGSL_TIMELINE_FENCE_GET 1847 * @seqno: Sequence number for the fence 1848 * @timeline: Timeline to create the fence on 1849 * @handle: Contains the fence fd for a successful operation [out] 1850 * 1851 * Create a sync file descriptor for the seqnum on the timeline and return it in 1852 * @handle. Can be polled and queried just like any other sync file descriptor 1853 */ 1854 struct kgsl_timeline_fence_get { 1855 __u64 seqno; 1856 __u32 timeline; 1857 int handle; 1858 }; 1859 1860 #define IOCTL_KGSL_TIMELINE_FENCE_GET \ 1861 _IOWR(KGSL_IOC_TYPE, 0x5C, struct kgsl_timeline_fence_get) 1862 /** 1863 * IOCTL_KGSL_TIMELINE_DESTROY takes a u32 identifier for the timeline to 1864 * destroy 1865 */ 1866 #define IOCTL_KGSL_TIMELINE_DESTROY _IOW(KGSL_IOC_TYPE, 0x5D, __u32) 1867 1868 /** 1869 * struct kgsl_gpu_aux_command_timeline - An aux command for timeline signals 1870 * @timelines: An array of &struct kgsl_timeline_val elements 1871 * @count: The number of entries in @timelines 1872 * @timelines_size: The size of each element in @timelines 1873 * 1874 * An aux command for timeline signals that can be pointed to by 1875 * &struct kgsl_aux_command_generic when the type is 1876 * KGSL_GPU_AUX_COMMAND_TIMELINE. 1877 */ 1878 struct kgsl_gpu_aux_command_timeline { 1879 __u64 timelines; 1880 __u32 count; 1881 __u32 timelines_size; 1882 }; 1883 1884 #endif /* _MSM_KGSL_H */ 1885