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