Path: blob/21.2-virgl/src/freedreno/vulkan/msm_kgsl.h
4565 views
#ifndef _UAPI_MSM_KGSL_H1#define _UAPI_MSM_KGSL_H23#include <linux/types.h>4#include <linux/ioctl.h>56/*7* The KGSL version has proven not to be very useful in userspace if features8* are cherry picked into other trees out of order so it is frozen as of 3.14.9* It is left here for backwards compatabilty and as a reminder that10* software releases are never linear. Also, I like pie.11*/1213#define KGSL_VERSION_MAJOR 314#define KGSL_VERSION_MINOR 141516/*17* We have traditionally mixed context and issueibcmds / command batch flags18* together into a big flag stew. This worked fine until we started adding a19* lot more command batch flags and we started running out of bits. Turns out20* we have a bit of room in the context type / priority mask that we could use21* for command batches, but that means we need to split out the flags into two22* coherent sets.23*24* If any future definitions are for both context and cmdbatch add both defines25* and link the cmdbatch to the context define as we do below. Otherwise feel26* free to add exclusive bits to either set.27*/2829/* --- context flags --- */30#define KGSL_CONTEXT_SAVE_GMEM 0x0000000131#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x0000000232/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */33#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x0000000434#define KGSL_CONTEXT_CTX_SWITCH 0x0000000835#define KGSL_CONTEXT_PREAMBLE 0x0000001036#define KGSL_CONTEXT_TRASH_STATE 0x0000002037#define KGSL_CONTEXT_PER_CONTEXT_TS 0x0000004038#define KGSL_CONTEXT_USER_GENERATED_TS 0x0000008039/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */40#define KGSL_CONTEXT_END_OF_FRAME 0x0000010041#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x0000020042/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */43#define KGSL_CONTEXT_SYNC 0x0000040044#define KGSL_CONTEXT_PWR_CONSTRAINT 0x0000080045#define KGSL_CONTEXT_PRIORITY_MASK 0x0000F00046#define KGSL_CONTEXT_PRIORITY_SHIFT 1247#define KGSL_CONTEXT_PRIORITY_UNDEF 04849#define KGSL_CONTEXT_IFH_NOP 0x0001000050#define KGSL_CONTEXT_SECURE 0x0002000051#define KGSL_CONTEXT_NO_SNAPSHOT 0x0004000052#define KGSL_CONTEXT_SPARSE 0x000800005354#define KGSL_CONTEXT_PREEMPT_STYLE_MASK 0x0E00000055#define KGSL_CONTEXT_PREEMPT_STYLE_SHIFT 2556#define KGSL_CONTEXT_PREEMPT_STYLE_DEFAULT 0x057#define KGSL_CONTEXT_PREEMPT_STYLE_RINGBUFFER 0x158#define KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN 0x25960#define KGSL_CONTEXT_TYPE_MASK 0x01F0000061#define KGSL_CONTEXT_TYPE_SHIFT 2062#define KGSL_CONTEXT_TYPE_ANY 063#define KGSL_CONTEXT_TYPE_GL 164#define KGSL_CONTEXT_TYPE_CL 265#define KGSL_CONTEXT_TYPE_C2D 366#define KGSL_CONTEXT_TYPE_RS 467#define KGSL_CONTEXT_TYPE_VK 568#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E6970#define KGSL_CONTEXT_INVALIDATE_ON_FAULT 0x100000007172#define KGSL_CONTEXT_INVALID 0xffffffff7374/*75* --- command batch flags ---76* The bits that are linked to a KGSL_CONTEXT equivalent are either legacy77* definitions or bits that are valid for both contexts and cmdbatches. To be78* safe the other 8 bits that are still available in the context field should be79* omitted here in case we need to share - the other bits are available for80* cmdbatch only flags as needed81*/82#define KGSL_CMDBATCH_MEMLIST 0x0000000183#define KGSL_CMDBATCH_MARKER 0x0000000284#define KGSL_CMDBATCH_SUBMIT_IB_LIST KGSL_CONTEXT_SUBMIT_IB_LIST /* 0x004 */85#define KGSL_CMDBATCH_CTX_SWITCH KGSL_CONTEXT_CTX_SWITCH /* 0x008 */86#define KGSL_CMDBATCH_PROFILING 0x0000001087/*88* KGSL_CMDBATCH_PROFILING must also be set for KGSL_CMDBATCH_PROFILING_KTIME89* to take effect, as the latter only affects the time data returned.90*/91#define KGSL_CMDBATCH_PROFILING_KTIME 0x0000002092#define KGSL_CMDBATCH_END_OF_FRAME KGSL_CONTEXT_END_OF_FRAME /* 0x100 */93#define KGSL_CMDBATCH_SYNC KGSL_CONTEXT_SYNC /* 0x400 */94#define KGSL_CMDBATCH_PWR_CONSTRAINT KGSL_CONTEXT_PWR_CONSTRAINT /* 0x800 */95#define KGSL_CMDBATCH_SPARSE 0x1000 /* 0x1000 */9697/*98* Reserve bits [16:19] and bits [28:31] for possible bits shared between99* contexts and command batches. Update this comment as new flags are added.100*/101102/*103* gpu_command_object flags - these flags communicate the type of command or104* memory object being submitted for a GPU command105*/106107/* Flags for GPU command objects */108#define KGSL_CMDLIST_IB 0x00000001U109#define KGSL_CMDLIST_CTXTSWITCH_PREAMBLE 0x00000002U110#define KGSL_CMDLIST_IB_PREAMBLE 0x00000004U111112/* Flags for GPU command memory objects */113#define KGSL_OBJLIST_MEMOBJ 0x00000008U114#define KGSL_OBJLIST_PROFILE 0x00000010U115116/* Flags for GPU command sync points */117#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0118#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1119120/* --- Memory allocation flags --- */121122/* General allocation hints */123#define KGSL_MEMFLAGS_SECURE 0x00000008ULL124#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000U125#define KGSL_MEMFLAGS_GPUWRITEONLY 0x02000000U126#define KGSL_MEMFLAGS_FORCE_32BIT 0x100000000ULL127128/* Flag for binding all the virt range to single phys data */129#define KGSL_SPARSE_BIND_MULTIPLE_TO_PHYS 0x400000000ULL130#define KGSL_SPARSE_BIND 0x1ULL131#define KGSL_SPARSE_UNBIND 0x2ULL132133/* Memory caching hints */134#define KGSL_CACHEMODE_MASK 0x0C000000U135#define KGSL_CACHEMODE_SHIFT 26136137#define KGSL_CACHEMODE_WRITECOMBINE 0138#define KGSL_CACHEMODE_UNCACHED 1139#define KGSL_CACHEMODE_WRITETHROUGH 2140#define KGSL_CACHEMODE_WRITEBACK 3141142#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000ULL143#define KGSL_MEMFLAGS_SPARSE_PHYS 0x20000000ULL144#define KGSL_MEMFLAGS_SPARSE_VIRT 0x40000000ULL145#define KGSL_MEMFLAGS_IOCOHERENT 0x80000000ULL146147/* Memory types for which allocations are made */148#define KGSL_MEMTYPE_MASK 0x0000FF00149#define KGSL_MEMTYPE_SHIFT 8150151#define KGSL_MEMTYPE_OBJECTANY 0152#define KGSL_MEMTYPE_FRAMEBUFFER 1153#define KGSL_MEMTYPE_RENDERBUFFER 2154#define KGSL_MEMTYPE_ARRAYBUFFER 3155#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4156#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5157#define KGSL_MEMTYPE_TEXTURE 6158#define KGSL_MEMTYPE_SURFACE 7159#define KGSL_MEMTYPE_EGL_SURFACE 8160#define KGSL_MEMTYPE_GL 9161#define KGSL_MEMTYPE_CL 10162#define KGSL_MEMTYPE_CL_BUFFER_MAP 11163#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12164#define KGSL_MEMTYPE_CL_IMAGE_MAP 13165#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14166#define KGSL_MEMTYPE_CL_KERNEL_STACK 15167#define KGSL_MEMTYPE_COMMAND 16168#define KGSL_MEMTYPE_2D 17169#define KGSL_MEMTYPE_EGL_IMAGE 18170#define KGSL_MEMTYPE_EGL_SHADOW 19171#define KGSL_MEMTYPE_MULTISAMPLE 20172#define KGSL_MEMTYPE_KERNEL 255173174/*175* Alignment hint, passed as the power of 2 exponent.176* i.e 4k (2^12) would be 12, 64k (2^16)would be 16.177*/178#define KGSL_MEMALIGN_MASK 0x00FF0000179#define KGSL_MEMALIGN_SHIFT 16180181enum kgsl_user_mem_type {182KGSL_USER_MEM_TYPE_PMEM = 0x00000000,183KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,184KGSL_USER_MEM_TYPE_ADDR = 0x00000002,185KGSL_USER_MEM_TYPE_ION = 0x00000003,186/*187* ION type is retained for backwards compatibility but Ion buffers are188* dma-bufs so try to use that naming if we can189*/190KGSL_USER_MEM_TYPE_DMABUF = 0x00000003,191KGSL_USER_MEM_TYPE_MAX = 0x00000007,192};193#define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0194#define KGSL_MEMFLAGS_USERMEM_SHIFT 5195196/*197* Unfortunately, enum kgsl_user_mem_type starts at 0 which does not198* leave a good value for allocated memory. In the flags we use199* 0 to indicate allocated memory and thus need to add 1 to the enum200* values.201*/202#define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT)203204#define KGSL_MEMFLAGS_NOT_USERMEM 0205#define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM)206#define KGSL_MEMFLAGS_USERMEM_ASHMEM \207KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM)208#define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR)209#define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION)210211/* --- generic KGSL flag values --- */212213#define KGSL_FLAGS_NORMALMODE 0x00000000214#define KGSL_FLAGS_SAFEMODE 0x00000001215#define KGSL_FLAGS_INITIALIZED0 0x00000002216#define KGSL_FLAGS_INITIALIZED 0x00000004217#define KGSL_FLAGS_STARTED 0x00000008218#define KGSL_FLAGS_ACTIVE 0x00000010219#define KGSL_FLAGS_RESERVED0 0x00000020220#define KGSL_FLAGS_RESERVED1 0x00000040221#define KGSL_FLAGS_RESERVED2 0x00000080222#define KGSL_FLAGS_SOFT_RESET 0x00000100223#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200224225/* Server Side Sync Timeout in milliseconds */226#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000227228/* UBWC Modes */229#define KGSL_UBWC_NONE 0230#define KGSL_UBWC_1_0 1231#define KGSL_UBWC_2_0 2232#define KGSL_UBWC_3_0 3233234/*235* Reset status values for context236*/237enum kgsl_ctx_reset_stat {238KGSL_CTX_STAT_NO_ERROR = 0x00000000,239KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001,240KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002,241KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003242};243244#define KGSL_CONVERT_TO_MBPS(val) \245(val*1000*1000U)246247/* device id */248enum kgsl_deviceid {249KGSL_DEVICE_3D0 = 0x00000000,250KGSL_DEVICE_MAX251};252253struct kgsl_devinfo {254255unsigned int device_id;256/*257* chip revision id258* coreid:8 majorrev:8 minorrev:8 patch:8259*/260unsigned int chip_id;261unsigned int mmu_enabled;262unsigned long gmem_gpubaseaddr;263/*264* This field contains the adreno revision265* number 200, 205, 220, etc...266*/267unsigned int gpu_id;268size_t gmem_sizebytes;269};270271/*272* struct kgsl_devmemstore - this structure defines the region of memory273* that can be mmap()ed from this driver. The timestamp fields are volatile274* because they are written by the GPU275* @soptimestamp: Start of pipeline timestamp written by GPU before the276* commands in concern are processed277* @sbz: Unused, kept for 8 byte alignment278* @eoptimestamp: End of pipeline timestamp written by GPU after the279* commands in concern are processed280* @sbz2: Unused, kept for 8 byte alignment281* @preempted: Indicates if the context was preempted282* @sbz3: Unused, kept for 8 byte alignment283* @ref_wait_ts: Timestamp on which to generate interrupt, unused now.284* @sbz4: Unused, kept for 8 byte alignment285* @current_context: The current context the GPU is working on286* @sbz5: Unused, kept for 8 byte alignment287*/288struct kgsl_devmemstore {289volatile unsigned int soptimestamp;290unsigned int sbz;291volatile unsigned int eoptimestamp;292unsigned int sbz2;293volatile unsigned int preempted;294unsigned int sbz3;295volatile unsigned int ref_wait_ts;296unsigned int sbz4;297unsigned int current_context;298unsigned int sbz5;299};300301#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \302((ctxt_id)*sizeof(struct kgsl_devmemstore) + \303offsetof(struct kgsl_devmemstore, field))304305/* timestamp id*/306enum kgsl_timestamp_type {307KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */308KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/309KGSL_TIMESTAMP_QUEUED = 0x00000003,310};311312/* property types - used with kgsl_device_getproperty */313#define KGSL_PROP_DEVICE_INFO 0x1314#define KGSL_PROP_DEVICE_SHADOW 0x2315#define KGSL_PROP_DEVICE_POWER 0x3316#define KGSL_PROP_SHMEM 0x4317#define KGSL_PROP_SHMEM_APERTURES 0x5318#define KGSL_PROP_MMU_ENABLE 0x6319#define KGSL_PROP_INTERRUPT_WAITS 0x7320#define KGSL_PROP_VERSION 0x8321#define KGSL_PROP_GPU_RESET_STAT 0x9322#define KGSL_PROP_PWRCTRL 0xE323#define KGSL_PROP_PWR_CONSTRAINT 0x12324#define KGSL_PROP_UCHE_GMEM_VADDR 0x13325#define KGSL_PROP_SP_GENERIC_MEM 0x14326#define KGSL_PROP_UCODE_VERSION 0x15327#define KGSL_PROP_GPMU_VERSION 0x16328#define KGSL_PROP_HIGHEST_BANK_BIT 0x17329#define KGSL_PROP_DEVICE_BITNESS 0x18330#define KGSL_PROP_DEVICE_QDSS_STM 0x19331#define KGSL_PROP_MIN_ACCESS_LENGTH 0x1A332#define KGSL_PROP_UBWC_MODE 0x1B333#define KGSL_PROP_DEVICE_QTIMER 0x20334#define KGSL_PROP_L3_PWR_CONSTRAINT 0x22335#define KGSL_PROP_SECURE_BUFFER_ALIGNMENT 0x23336#define KGSL_PROP_SECURE_CTXT_SUPPORT 0x24337#define KGSL_PROP_SPEED_BIN 0x25338#define KGSL_PROP_GAMING_BIN 0x26339#define KGSL_PROP_CONTEXT_PROPERTY 0x28340341342struct kgsl_shadowprop {343unsigned long gpuaddr;344size_t size;345unsigned int flags; /* contains KGSL_FLAGS_ values */346};347348struct kgsl_qdss_stm_prop {349uint64_t gpuaddr;350uint64_t size;351};352353struct kgsl_qtimer_prop {354uint64_t gpuaddr;355uint64_t size;356};357358struct kgsl_version {359unsigned int drv_major;360unsigned int drv_minor;361unsigned int dev_major;362unsigned int dev_minor;363};364365struct kgsl_sp_generic_mem {366uint64_t local;367uint64_t pvt;368};369370struct kgsl_ucode_version {371unsigned int pfp;372unsigned int pm4;373};374375struct kgsl_gpmu_version {376unsigned int major;377unsigned int minor;378unsigned int features;379};380381struct kgsl_context_property {382__u64 data;383__u32 size;384__u32 type;385__u32 contextid;386};387388struct kgsl_context_property_fault {389__s32 faults;390__u32 timestamp;391};392393/* Context property sub types */394#define KGSL_CONTEXT_PROP_FAULTS 1395396/* Performance counter groups */397398#define KGSL_PERFCOUNTER_GROUP_CP 0x0399#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1400#define KGSL_PERFCOUNTER_GROUP_PC 0x2401#define KGSL_PERFCOUNTER_GROUP_VFD 0x3402#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4403#define KGSL_PERFCOUNTER_GROUP_VPC 0x5404#define KGSL_PERFCOUNTER_GROUP_TSE 0x6405#define KGSL_PERFCOUNTER_GROUP_RAS 0x7406#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8407#define KGSL_PERFCOUNTER_GROUP_TP 0x9408#define KGSL_PERFCOUNTER_GROUP_SP 0xA409#define KGSL_PERFCOUNTER_GROUP_RB 0xB410#define KGSL_PERFCOUNTER_GROUP_PWR 0xC411#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD412#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE413#define KGSL_PERFCOUNTER_GROUP_MH 0xF414#define KGSL_PERFCOUNTER_GROUP_PA_SU 0x10415#define KGSL_PERFCOUNTER_GROUP_SQ 0x11416#define KGSL_PERFCOUNTER_GROUP_SX 0x12417#define KGSL_PERFCOUNTER_GROUP_TCF 0x13418#define KGSL_PERFCOUNTER_GROUP_TCM 0x14419#define KGSL_PERFCOUNTER_GROUP_TCR 0x15420#define KGSL_PERFCOUNTER_GROUP_L2 0x16421#define KGSL_PERFCOUNTER_GROUP_VSC 0x17422#define KGSL_PERFCOUNTER_GROUP_CCU 0x18423#define KGSL_PERFCOUNTER_GROUP_LRZ 0x19424#define KGSL_PERFCOUNTER_GROUP_CMP 0x1A425#define KGSL_PERFCOUNTER_GROUP_ALWAYSON 0x1B426#define KGSL_PERFCOUNTER_GROUP_SP_PWR 0x1C427#define KGSL_PERFCOUNTER_GROUP_TP_PWR 0x1D428#define KGSL_PERFCOUNTER_GROUP_RB_PWR 0x1E429#define KGSL_PERFCOUNTER_GROUP_CCU_PWR 0x1F430#define KGSL_PERFCOUNTER_GROUP_UCHE_PWR 0x20431#define KGSL_PERFCOUNTER_GROUP_CP_PWR 0x21432#define KGSL_PERFCOUNTER_GROUP_GPMU_PWR 0x22433#define KGSL_PERFCOUNTER_GROUP_ALWAYSON_PWR 0x23434#define KGSL_PERFCOUNTER_GROUP_MAX 0x24435436#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF437#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE438439/* structure holds list of ibs */440struct kgsl_ibdesc {441unsigned long gpuaddr;442unsigned long __pad;443size_t sizedwords;444unsigned int ctrl;445};446447/**448* struct kgsl_cmdbatch_profiling_buffer449* @wall_clock_s: Ringbuffer submission time (seconds).450* If KGSL_CMDBATCH_PROFILING_KTIME is set, time is provided451* in kernel clocks, otherwise wall clock time is used.452* @wall_clock_ns: Ringbuffer submission time (nanoseconds).453* If KGSL_CMDBATCH_PROFILING_KTIME is set time is provided454* in kernel clocks, otherwise wall clock time is used.455* @gpu_ticks_queued: GPU ticks at ringbuffer submission456* @gpu_ticks_submitted: GPU ticks when starting cmdbatch execution457* @gpu_ticks_retired: GPU ticks when finishing cmdbatch execution458*459* This structure defines the profiling buffer used to measure cmdbatch460* execution time461*/462struct kgsl_cmdbatch_profiling_buffer {463uint64_t wall_clock_s;464uint64_t wall_clock_ns;465uint64_t gpu_ticks_queued;466uint64_t gpu_ticks_submitted;467uint64_t gpu_ticks_retired;468};469470/* ioctls */471#define KGSL_IOC_TYPE 0x09472473/*474* get misc info about the GPU475* type should be a value from enum kgsl_property_type476* value points to a structure that varies based on type477* sizebytes is sizeof() that structure478* for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo479* this structure contaings hardware versioning info.480* for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop481* this is used to find mmap() offset and sizes for mapping482* struct kgsl_memstore into userspace.483*/484struct kgsl_device_getproperty {485unsigned int type;486void __user *value;487size_t sizebytes;488};489490#define IOCTL_KGSL_DEVICE_GETPROPERTY \491_IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty)492493/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012494*/495496/* block until the GPU has executed past a given timestamp497* timeout is in milliseconds.498*/499struct kgsl_device_waittimestamp {500unsigned int timestamp;501unsigned int timeout;502};503504#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \505_IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp)506507struct kgsl_device_waittimestamp_ctxtid {508unsigned int context_id;509unsigned int timestamp;510unsigned int timeout;511};512513#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \514_IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)515516/* DEPRECATED: issue indirect commands to the GPU.517* drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE518* ibaddr and sizedwords must specify a subset of a buffer created519* with IOCTL_KGSL_SHAREDMEM_FROM_PMEM520* flags may be a mask of KGSL_CONTEXT_ values521* timestamp is a returned counter value which can be passed to522* other ioctls to determine when the commands have been executed by523* the GPU.524*525* This function is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS526* instead527*/528struct kgsl_ringbuffer_issueibcmds {529unsigned int drawctxt_id;530unsigned long ibdesc_addr;531unsigned int numibs;532unsigned int timestamp; /*output param */533unsigned int flags;534};535536#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \537_IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds)538539/* read the most recently executed timestamp value540* type should be a value from enum kgsl_timestamp_type541*/542struct kgsl_cmdstream_readtimestamp {543unsigned int type;544unsigned int timestamp; /*output param */545};546547#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \548_IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)549550#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \551_IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)552553/* free memory when the GPU reaches a given timestamp.554* gpuaddr specify a memory region created by a555* IOCTL_KGSL_SHAREDMEM_FROM_PMEM call556* type should be a value from enum kgsl_timestamp_type557*/558struct kgsl_cmdstream_freememontimestamp {559unsigned long gpuaddr;560unsigned int type;561unsigned int timestamp;562};563564#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \565_IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)566567/*568* Previous versions of this header had incorrectly defined569* IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead570* of a write only ioctl. To ensure binary compatibility, the following571* #define will be used to intercept the incorrect ioctl572*/573574#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \575_IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)576577/* create a draw context, which is used to preserve GPU state.578* The flags field may contain a mask KGSL_CONTEXT_* values579*/580struct kgsl_drawctxt_create {581unsigned int flags;582unsigned int drawctxt_id; /*output param */583};584585#define IOCTL_KGSL_DRAWCTXT_CREATE \586_IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)587588/* destroy a draw context */589struct kgsl_drawctxt_destroy {590unsigned int drawctxt_id;591};592593#define IOCTL_KGSL_DRAWCTXT_DESTROY \594_IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)595596/*597* add a block of pmem, fb, ashmem or user allocated address598* into the GPU address space599*/600struct kgsl_map_user_mem {601int fd;602unsigned long gpuaddr; /*output param */603size_t len;604size_t offset;605unsigned long hostptr; /*input param */606enum kgsl_user_mem_type memtype;607unsigned int flags;608};609610#define IOCTL_KGSL_MAP_USER_MEM \611_IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)612613struct kgsl_cmdstream_readtimestamp_ctxtid {614unsigned int context_id;615unsigned int type;616unsigned int timestamp; /*output param */617};618619#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \620_IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)621622struct kgsl_cmdstream_freememontimestamp_ctxtid {623unsigned int context_id;624unsigned long gpuaddr;625unsigned int type;626unsigned int timestamp;627};628629#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \630_IOW(KGSL_IOC_TYPE, 0x17, \631struct kgsl_cmdstream_freememontimestamp_ctxtid)632633/* add a block of pmem or fb into the GPU address space */634struct kgsl_sharedmem_from_pmem {635int pmem_fd;636unsigned long gpuaddr; /*output param */637unsigned int len;638unsigned int offset;639};640641#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \642_IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem)643644/* remove memory from the GPU's address space */645struct kgsl_sharedmem_free {646unsigned long gpuaddr;647};648649#define IOCTL_KGSL_SHAREDMEM_FREE \650_IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)651652struct kgsl_cff_user_event {653unsigned char cff_opcode;654unsigned int op1;655unsigned int op2;656unsigned int op3;657unsigned int op4;658unsigned int op5;659unsigned int __pad[2];660};661662#define IOCTL_KGSL_CFF_USER_EVENT \663_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event)664665struct kgsl_gmem_desc {666unsigned int x;667unsigned int y;668unsigned int width;669unsigned int height;670unsigned int pitch;671};672673struct kgsl_buffer_desc {674void *hostptr;675unsigned long gpuaddr;676int size;677unsigned int format;678unsigned int pitch;679unsigned int enabled;680};681682struct kgsl_bind_gmem_shadow {683unsigned int drawctxt_id;684struct kgsl_gmem_desc gmem_desc;685unsigned int shadow_x;686unsigned int shadow_y;687struct kgsl_buffer_desc shadow_buffer;688unsigned int buffer_id;689};690691#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \692_IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow)693694/* add a block of memory into the GPU address space */695696/*697* IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012698* use IOCTL_KGSL_GPUMEM_ALLOC instead699*/700701struct kgsl_sharedmem_from_vmalloc {702unsigned long gpuaddr; /*output param */703unsigned int hostptr;704unsigned int flags;705};706707#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \708_IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc)709710/*711* This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which712* supports both directions (flush and invalidate). This code will still713* work, but by definition it will do a flush of the cache which might not be714* what you want to have happen on a buffer following a GPU operation. It is715* safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC716*/717718#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \719_IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free)720721struct kgsl_drawctxt_set_bin_base_offset {722unsigned int drawctxt_id;723unsigned int offset;724};725726#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \727_IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset)728729enum kgsl_cmdwindow_type {730KGSL_CMDWINDOW_MIN = 0x00000000,731KGSL_CMDWINDOW_2D = 0x00000000,732KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */733KGSL_CMDWINDOW_MMU = 0x00000002,734KGSL_CMDWINDOW_ARBITER = 0x000000FF,735KGSL_CMDWINDOW_MAX = 0x000000FF,736};737738/* write to the command window */739struct kgsl_cmdwindow_write {740enum kgsl_cmdwindow_type target;741unsigned int addr;742unsigned int data;743};744745#define IOCTL_KGSL_CMDWINDOW_WRITE \746_IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write)747748struct kgsl_gpumem_alloc {749unsigned long gpuaddr; /* output param */750size_t size;751unsigned int flags;752};753754#define IOCTL_KGSL_GPUMEM_ALLOC \755_IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)756757struct kgsl_cff_syncmem {758unsigned long gpuaddr;759size_t len;760unsigned int __pad[2]; /* For future binary compatibility */761};762763#define IOCTL_KGSL_CFF_SYNCMEM \764_IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem)765766/*767* A timestamp event allows the user space to register an action following an768* expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to769* _IOWR to support fences which need to return a fd for the priv parameter.770*/771772struct kgsl_timestamp_event {773int type; /* Type of event (see list below) */774unsigned int timestamp; /* Timestamp to trigger event on */775unsigned int context_id; /* Context for the timestamp */776void __user *priv; /* Pointer to the event specific blob */777size_t len; /* Size of the event specific blob */778};779780#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \781_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event)782783/* A genlock timestamp event releases an existing lock on timestamp expire */784785#define KGSL_TIMESTAMP_EVENT_GENLOCK 1786787struct kgsl_timestamp_event_genlock {788int handle; /* Handle of the genlock lock to release */789};790791/* A fence timestamp event releases an existing lock on timestamp expire */792793#define KGSL_TIMESTAMP_EVENT_FENCE 2794795struct kgsl_timestamp_event_fence {796int fence_fd; /* Fence to signal */797};798799/*800* Set a property within the kernel. Uses the same structure as801* IOCTL_KGSL_GETPROPERTY802*/803804#define IOCTL_KGSL_SETPROPERTY \805_IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty)806807#define IOCTL_KGSL_TIMESTAMP_EVENT \808_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)809810/**811* struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID812* @id: returned id value for this allocation.813* @flags: mask of KGSL_MEM* values requested and actual flags on return.814* @size: requested size of the allocation and actual size on return.815* @mmapsize: returned size to pass to mmap() which may be larger than 'size'816* @gpuaddr: returned GPU address for the allocation817*818* Allocate memory for access by the GPU. The flags and size fields are echoed819* back by the kernel, so that the caller can know if the request was820* adjusted.821*822* Supported flags:823* KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer824* KGSL_MEMTYPE*: usage hint for debugging aid825* KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel.826* KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU827* address will be 0. Calling mmap() will set the GPU address.828*/829struct kgsl_gpumem_alloc_id {830unsigned int id;831unsigned int flags;832size_t size;833size_t mmapsize;834unsigned long gpuaddr;835/* private: reserved for future use*/836unsigned long __pad[2];837};838839#define IOCTL_KGSL_GPUMEM_ALLOC_ID \840_IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)841842/**843* struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID844* @id: GPU allocation id to free845*846* Free an allocation by id, in case a GPU address has not been assigned or847* is unknown. Freeing an allocation by id with this ioctl or by GPU address848* with IOCTL_KGSL_SHAREDMEM_FREE are equivalent.849*/850struct kgsl_gpumem_free_id {851unsigned int id;852/* private: reserved for future use*/853unsigned int __pad;854};855856#define IOCTL_KGSL_GPUMEM_FREE_ID \857_IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id)858859/**860* struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO861* @gpuaddr: GPU address to query. Also set on return.862* @id: GPU allocation id to query. Also set on return.863* @flags: returned mask of KGSL_MEM* values.864* @size: returned size of the allocation.865* @mmapsize: returned size to pass mmap(), which may be larger than 'size'866* @useraddr: returned address of the userspace mapping for this buffer867*868* This ioctl allows querying of all user visible attributes of an existing869* allocation, by either the GPU address or the id returned by a previous870* call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not871* return all attributes so this ioctl can be used to look them up if needed.872*873*/874struct kgsl_gpumem_get_info {875unsigned long gpuaddr;876unsigned int id;877unsigned int flags;878size_t size;879size_t mmapsize;880unsigned long useraddr;881/* private: reserved for future use*/882unsigned long __pad[4];883};884885#define IOCTL_KGSL_GPUMEM_GET_INFO\886_IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)887888/**889* struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE890* @gpuaddr: GPU address of the buffer to sync.891* @id: id of the buffer to sync. Either gpuaddr or id is sufficient.892* @op: a mask of KGSL_GPUMEM_CACHE_* values893* @offset: offset into the buffer894* @length: number of bytes starting from offset to perform895* the cache operation on896*897* Sync the L2 cache for memory headed to and from the GPU - this replaces898* KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both899* directions900*901*/902struct kgsl_gpumem_sync_cache {903unsigned long gpuaddr;904unsigned int id;905unsigned int op;906size_t offset;907size_t length;908};909910#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0)911#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN912913#define KGSL_GPUMEM_CACHE_INV (1 << 1)914#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV915916#define KGSL_GPUMEM_CACHE_FLUSH \917(KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV)918919/* Flag to ensure backwards compatibility of kgsl_gpumem_sync_cache struct */920#define KGSL_GPUMEM_CACHE_RANGE (1 << 31U)921922#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \923_IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache)924925/**926* struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET927* @groupid: Performance counter group ID928* @countable: Countable to select within the group929* @offset: Return offset of the reserved LO counter930* @offset_hi: Return offset of the reserved HI counter931*932* Get an available performance counter from a specified groupid. The offset933* of the performance counter will be returned after successfully assigning934* the countable to the counter for the specified group. An error will be935* returned and an offset of 0 if the groupid is invalid or there are no936* more counters left. After successfully getting a perfcounter, the user937* must call kgsl_perfcounter_put(groupid, contable) when finished with938* the perfcounter to clear up perfcounter resources.939*940*/941struct kgsl_perfcounter_get {942unsigned int groupid;943unsigned int countable;944unsigned int offset;945unsigned int offset_hi;946/* private: reserved for future use */947unsigned int __pad; /* For future binary compatibility */948};949950#define IOCTL_KGSL_PERFCOUNTER_GET \951_IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get)952953/**954* struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT955* @groupid: Performance counter group ID956* @countable: Countable to release within the group957*958* Put an allocated performance counter to allow others to have access to the959* resource that was previously taken. This is only to be called after960* successfully getting a performance counter from kgsl_perfcounter_get().961*962*/963struct kgsl_perfcounter_put {964unsigned int groupid;965unsigned int countable;966/* private: reserved for future use */967unsigned int __pad[2]; /* For future binary compatibility */968};969970#define IOCTL_KGSL_PERFCOUNTER_PUT \971_IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put)972973/**974* struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY975* @groupid: Performance counter group ID976* @countable: Return active countables array977* @size: Size of active countables array978* @max_counters: Return total number counters for the group ID979*980* Query the available performance counters given a groupid. The array981* *countables is used to return the current active countables in counters.982* The size of the array is passed in so the kernel will only write at most983* size or counter->size for the group id. The total number of available984* counters for the group ID is returned in max_counters.985* If the array or size passed in are invalid, then only the maximum number986* of counters will be returned, no data will be written to *countables.987* If the groupid is invalid an error code will be returned.988*989*/990struct kgsl_perfcounter_query {991unsigned int groupid;992/* Array to return the current countable for up to size counters */993unsigned int __user *countables;994unsigned int count;995unsigned int max_counters;996/* private: reserved for future use */997unsigned int __pad[2]; /* For future binary compatibility */998};9991000#define IOCTL_KGSL_PERFCOUNTER_QUERY \1001_IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query)10021003/**1004* struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY1005* @groupid: Performance counter group IDs1006* @countable: Performance counter countable IDs1007* @value: Return performance counter reads1008* @size: Size of all arrays (groupid/countable pair and return value)1009*1010* Read in the current value of a performance counter given by the groupid1011* and countable.1012*1013*/10141015struct kgsl_perfcounter_read_group {1016unsigned int groupid;1017unsigned int countable;1018unsigned long long value;1019};10201021struct kgsl_perfcounter_read {1022struct kgsl_perfcounter_read_group __user *reads;1023unsigned int count;1024/* private: reserved for future use */1025unsigned int __pad[2]; /* For future binary compatibility */1026};10271028#define IOCTL_KGSL_PERFCOUNTER_READ \1029_IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read)1030/*1031* struct kgsl_gpumem_sync_cache_bulk - argument to1032* IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK1033* @id_list: list of GPU buffer ids of the buffers to sync1034* @count: number of GPU buffer ids in id_list1035* @op: a mask of KGSL_GPUMEM_CACHE_* values1036*1037* Sync the cache for memory headed to and from the GPU. Certain1038* optimizations can be made on the cache operation based on the total1039* size of the working set of memory to be managed.1040*/1041struct kgsl_gpumem_sync_cache_bulk {1042unsigned int __user *id_list;1043unsigned int count;1044unsigned int op;1045/* private: reserved for future use */1046unsigned int __pad[2]; /* For future binary compatibility */1047};10481049#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \1050_IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk)10511052/*1053* struct kgsl_cmd_syncpoint_timestamp1054* @context_id: ID of a KGSL context1055* @timestamp: GPU timestamp1056*1057* This structure defines a syncpoint comprising a context/timestamp pair. A1058* list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define1059* dependencies that must be met before the command can be submitted to the1060* hardware1061*/1062struct kgsl_cmd_syncpoint_timestamp {1063unsigned int context_id;1064unsigned int timestamp;1065};10661067struct kgsl_cmd_syncpoint_fence {1068int fd;1069};10701071/**1072* struct kgsl_cmd_syncpoint - Define a sync point for a command batch1073* @type: type of sync point defined here1074* @priv: Pointer to the type specific buffer1075* @size: Size of the type specific buffer1076*1077* This structure contains pointers defining a specific command sync point.1078* The pointer and size should point to a type appropriate structure.1079*/1080struct kgsl_cmd_syncpoint {1081int type;1082void __user *priv;1083size_t size;1084};10851086/* Flag to indicate that the cmdlist may contain memlists */1087#define KGSL_IBDESC_MEMLIST 0x110881089/* Flag to point out the cmdbatch profiling buffer in the memlist */1090#define KGSL_IBDESC_PROFILING_BUFFER 0x210911092/**1093* struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS1094* @context_id: KGSL context ID that owns the commands1095* @flags:1096* @cmdlist: User pointer to a list of kgsl_ibdesc structures1097* @numcmds: Number of commands listed in cmdlist1098* @synclist: User pointer to a list of kgsl_cmd_syncpoint structures1099* @numsyncs: Number of sync points listed in synclist1100* @timestamp: On entry the a user defined timestamp, on exist the timestamp1101* assigned to the command batch1102*1103* This structure specifies a command to send to the GPU hardware. This is1104* similar to kgsl_issueibcmds expect that it doesn't support the legacy way to1105* submit IB lists and it adds sync points to block the IB until the1106* dependencies are satisified. This entry point is the new and preferred way1107* to submit commands to the GPU. The memory list can be used to specify all1108* memory that is referrenced in the current set of commands.1109*/11101111struct kgsl_submit_commands {1112unsigned int context_id;1113unsigned int flags;1114struct kgsl_ibdesc __user *cmdlist;1115unsigned int numcmds;1116struct kgsl_cmd_syncpoint __user *synclist;1117unsigned int numsyncs;1118unsigned int timestamp;1119/* private: reserved for future use */1120unsigned int __pad[4];1121};11221123#define IOCTL_KGSL_SUBMIT_COMMANDS \1124_IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands)11251126/**1127* struct kgsl_device_constraint - device constraint argument1128* @context_id: KGSL context ID1129* @type: type of constraint i.e pwrlevel/none1130* @data: constraint data1131* @size: size of the constraint data1132*/1133struct kgsl_device_constraint {1134unsigned int type;1135unsigned int context_id;1136void __user *data;1137size_t size;1138};11391140/* Constraint Type*/1141#define KGSL_CONSTRAINT_NONE 01142#define KGSL_CONSTRAINT_PWRLEVEL 111431144/* L3 constraint Type */1145#define KGSL_CONSTRAINT_L3_NONE 21146#define KGSL_CONSTRAINT_L3_PWRLEVEL 311471148/* PWRLEVEL constraint level*/1149/* set to min frequency */1150#define KGSL_CONSTRAINT_PWR_MIN 01151/* set to max frequency */1152#define KGSL_CONSTRAINT_PWR_MAX 111531154struct kgsl_device_constraint_pwrlevel {1155unsigned int level;1156};11571158/**1159* struct kgsl_syncsource_create - Argument to IOCTL_KGSL_SYNCSOURCE_CREATE1160* @id: returned id for the syncsource that was created.1161*1162* This ioctl creates a userspace sync timeline.1163*/11641165struct kgsl_syncsource_create {1166unsigned int id;1167/* private: reserved for future use */1168unsigned int __pad[3];1169};11701171#define IOCTL_KGSL_SYNCSOURCE_CREATE \1172_IOWR(KGSL_IOC_TYPE, 0x40, struct kgsl_syncsource_create)11731174/**1175* struct kgsl_syncsource_destroy - Argument to IOCTL_KGSL_SYNCSOURCE_DESTROY1176* @id: syncsource id to destroy1177*1178* This ioctl creates a userspace sync timeline.1179*/11801181struct kgsl_syncsource_destroy {1182unsigned int id;1183/* private: reserved for future use */1184unsigned int __pad[3];1185};11861187#define IOCTL_KGSL_SYNCSOURCE_DESTROY \1188_IOWR(KGSL_IOC_TYPE, 0x41, struct kgsl_syncsource_destroy)11891190/**1191* struct kgsl_syncsource_create_fence - Argument to1192* IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE1193* @id: syncsource id1194* @fence_fd: returned sync_fence fd1195*1196* Create a fence that may be signaled by userspace by calling1197* IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE. There are no order dependencies between1198* these fences.1199*/1200struct kgsl_syncsource_create_fence {1201unsigned int id;1202int fence_fd;1203/* private: reserved for future use */1204unsigned int __pad[4];1205};12061207/**1208* struct kgsl_syncsource_signal_fence - Argument to1209* IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE1210* @id: syncsource id1211* @fence_fd: sync_fence fd to signal1212*1213* Signal a fence that was created by a IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE1214* call using the same syncsource id. This allows a fence to be shared1215* to other processes but only signaled by the process owning the fd1216* used to create the fence.1217*/1218#define IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE \1219_IOWR(KGSL_IOC_TYPE, 0x42, struct kgsl_syncsource_create_fence)12201221struct kgsl_syncsource_signal_fence {1222unsigned int id;1223int fence_fd;1224/* private: reserved for future use */1225unsigned int __pad[4];1226};12271228#define IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE \1229_IOWR(KGSL_IOC_TYPE, 0x43, struct kgsl_syncsource_signal_fence)12301231/**1232* struct kgsl_cff_sync_gpuobj - Argument to IOCTL_KGSL_CFF_SYNC_GPUOBJ1233* @offset: Offset into the GPU object to sync1234* @length: Number of bytes to sync1235* @id: ID of the GPU object to sync1236*/1237struct kgsl_cff_sync_gpuobj {1238uint64_t offset;1239uint64_t length;1240unsigned int id;1241};12421243#define IOCTL_KGSL_CFF_SYNC_GPUOBJ \1244_IOW(KGSL_IOC_TYPE, 0x44, struct kgsl_cff_sync_gpuobj)12451246/**1247* struct kgsl_gpuobj_alloc - Argument to IOCTL_KGSL_GPUOBJ_ALLOC1248* @size: Size in bytes of the object to allocate1249* @flags: mask of KGSL_MEMFLAG_* bits1250* @va_len: Size in bytes of the virtual region to allocate1251* @mmapsize: Returns the mmap() size of the object1252* @id: Returns the GPU object ID of the new object1253* @metadata_len: Length of the metdata to copy from the user1254* @metadata: Pointer to the user specified metadata to store for the object1255*/1256struct kgsl_gpuobj_alloc {1257uint64_t size;1258uint64_t flags;1259uint64_t va_len;1260uint64_t mmapsize;1261unsigned int id;1262unsigned int metadata_len;1263uint64_t metadata;1264};12651266/* Let the user know that this header supports the gpuobj metadata */1267#define KGSL_GPUOBJ_ALLOC_METADATA_MAX 6412681269#define IOCTL_KGSL_GPUOBJ_ALLOC \1270_IOWR(KGSL_IOC_TYPE, 0x45, struct kgsl_gpuobj_alloc)12711272/**1273* struct kgsl_gpuobj_free - Argument to IOCTL_KGLS_GPUOBJ_FREE1274* @flags: Mask of: KGSL_GUPOBJ_FREE_ON_EVENT1275* @priv: Pointer to the private object if KGSL_GPUOBJ_FREE_ON_EVENT is1276* specified1277* @id: ID of the GPU object to free1278* @type: If KGSL_GPUOBJ_FREE_ON_EVENT is specified, the type of asynchronous1279* event to free on1280* @len: Length of the data passed in priv1281*/1282struct kgsl_gpuobj_free {1283uint64_t flags;1284uint64_t __user priv;1285unsigned int id;1286unsigned int type;1287unsigned int len;1288};12891290#define KGSL_GPUOBJ_FREE_ON_EVENT 112911292#define KGSL_GPU_EVENT_TIMESTAMP 11293#define KGSL_GPU_EVENT_FENCE 212941295/**1296* struct kgsl_gpu_event_timestamp - Specifies a timestamp event to free a GPU1297* object on1298* @context_id: ID of the timestamp event to wait for1299* @timestamp: Timestamp of the timestamp event to wait for1300*/1301struct kgsl_gpu_event_timestamp {1302unsigned int context_id;1303unsigned int timestamp;1304};13051306/**1307* struct kgsl_gpu_event_fence - Specifies a fence ID to to free a GPU object on1308* @fd: File descriptor for the fence1309*/1310struct kgsl_gpu_event_fence {1311int fd;1312};13131314#define IOCTL_KGSL_GPUOBJ_FREE \1315_IOW(KGSL_IOC_TYPE, 0x46, struct kgsl_gpuobj_free)13161317/**1318* struct kgsl_gpuobj_info - argument to IOCTL_KGSL_GPUOBJ_INFO1319* @gpuaddr: GPU address of the object1320* @flags: Current flags for the object1321* @size: Size of the object1322* @va_len: VA size of the object1323* @va_addr: Virtual address of the object (if it is mapped)1324* id - GPU object ID of the object to query1325*/1326struct kgsl_gpuobj_info {1327uint64_t gpuaddr;1328uint64_t flags;1329uint64_t size;1330uint64_t va_len;1331uint64_t va_addr;1332unsigned int id;1333};13341335#define IOCTL_KGSL_GPUOBJ_INFO \1336_IOWR(KGSL_IOC_TYPE, 0x47, struct kgsl_gpuobj_info)13371338/**1339* struct kgsl_gpuobj_import - argument to IOCTL_KGSL_GPUOBJ_IMPORT1340* @priv: Pointer to the private data for the import type1341* @priv_len: Length of the private data1342* @flags: Mask of KGSL_MEMFLAG_ flags1343* @type: Type of the import (KGSL_USER_MEM_TYPE_*)1344* @id: Returns the ID of the new GPU object1345*/1346struct kgsl_gpuobj_import {1347uint64_t __user priv;1348uint64_t priv_len;1349uint64_t flags;1350unsigned int type;1351unsigned int id;1352};13531354/**1355* struct kgsl_gpuobj_import_dma_buf - import a dmabuf object1356* @fd: File descriptor for the dma-buf object1357*/1358struct kgsl_gpuobj_import_dma_buf {1359int fd;1360};13611362/**1363* struct kgsl_gpuobj_import_useraddr - import an object based on a useraddr1364* @virtaddr: Virtual address of the object to import1365*/1366struct kgsl_gpuobj_import_useraddr {1367uint64_t virtaddr;1368};13691370#define IOCTL_KGSL_GPUOBJ_IMPORT \1371_IOWR(KGSL_IOC_TYPE, 0x48, struct kgsl_gpuobj_import)13721373/**1374* struct kgsl_gpuobj_sync_obj - Individual GPU object to sync1375* @offset: Offset within the GPU object to sync1376* @length: Number of bytes to sync1377* @id: ID of the GPU object to sync1378* @op: Cache operation to execute1379*/13801381struct kgsl_gpuobj_sync_obj {1382uint64_t offset;1383uint64_t length;1384unsigned int id;1385unsigned int op;1386};13871388/**1389* struct kgsl_gpuobj_sync - Argument for IOCTL_KGSL_GPUOBJ_SYNC1390* @objs: Pointer to an array of kgsl_gpuobj_sync_obj structs1391* @obj_len: Size of each item in the array1392* @count: Number of items in the array1393*/13941395struct kgsl_gpuobj_sync {1396uint64_t __user objs;1397unsigned int obj_len;1398unsigned int count;1399};14001401#define IOCTL_KGSL_GPUOBJ_SYNC \1402_IOW(KGSL_IOC_TYPE, 0x49, struct kgsl_gpuobj_sync)14031404/**1405* struct kgsl_command_object - GPU command object1406* @offset: GPU address offset of the object1407* @gpuaddr: GPU address of the object1408* @size: Size of the object1409* @flags: Current flags for the object1410* @id - GPU command object ID1411*/1412struct kgsl_command_object {1413uint64_t offset;1414uint64_t gpuaddr;1415uint64_t size;1416unsigned int flags;1417unsigned int id;1418};14191420/**1421* struct kgsl_command_syncpoint - GPU syncpoint object1422* @priv: Pointer to the type specific buffer1423* @size: Size of the type specific buffer1424* @type: type of sync point defined here1425*/1426struct kgsl_command_syncpoint {1427uint64_t __user priv;1428uint64_t size;1429unsigned int type;1430};14311432/**1433* struct kgsl_command_object - Argument for IOCTL_KGSL_GPU_COMMAND1434* @flags: Current flags for the object1435* @cmdlist: List of kgsl_command_objects for submission1436* @cmd_size: Size of kgsl_command_objects structure1437* @numcmds: Number of kgsl_command_objects in command list1438* @objlist: List of kgsl_command_objects for tracking1439* @obj_size: Size of kgsl_command_objects structure1440* @numobjs: Number of kgsl_command_objects in object list1441* @synclist: List of kgsl_command_syncpoints1442* @sync_size: Size of kgsl_command_syncpoint structure1443* @numsyncs: Number of kgsl_command_syncpoints in syncpoint list1444* @context_id: Context ID submittin ghte kgsl_gpu_command1445* @timestamp: Timestamp for the submitted commands1446*/1447struct kgsl_gpu_command {1448uint64_t flags;1449uint64_t __user cmdlist;1450unsigned int cmdsize;1451unsigned int numcmds;1452uint64_t __user objlist;1453unsigned int objsize;1454unsigned int numobjs;1455uint64_t __user synclist;1456unsigned int syncsize;1457unsigned int numsyncs;1458unsigned int context_id;1459unsigned int timestamp;1460};14611462#define IOCTL_KGSL_GPU_COMMAND \1463_IOWR(KGSL_IOC_TYPE, 0x4A, struct kgsl_gpu_command)14641465/**1466* struct kgsl_preemption_counters_query - argument to1467* IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY1468* @counters: Return preemption counters array1469* @size_user: Size allocated by userspace1470* @size_priority_level: Size of preemption counters for each1471* priority level1472* @max_priority_level: Return max number of priority levels1473*1474* Query the available preemption counters. The array counters1475* is used to return preemption counters. The size of the array1476* is passed in so the kernel will only write at most size_user1477* or max available preemption counters. The total number of1478* preemption counters is returned in max_priority_level. If the1479* array or size passed in are invalid, then an error is1480* returned back.1481*/1482struct kgsl_preemption_counters_query {1483uint64_t __user counters;1484unsigned int size_user;1485unsigned int size_priority_level;1486unsigned int max_priority_level;1487};14881489#define IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY \1490_IOWR(KGSL_IOC_TYPE, 0x4B, struct kgsl_preemption_counters_query)14911492/**1493* struct kgsl_gpuobj_set_info - argument for IOCTL_KGSL_GPUOBJ_SET_INFO1494* @flags: Flags to indicate which parameters to change1495* @metadata: If KGSL_GPUOBJ_SET_INFO_METADATA is set, a pointer to the new1496* metadata1497* @id: GPU memory object ID to change1498* @metadata_len: If KGSL_GPUOBJ_SET_INFO_METADATA is set, the length of the1499* new metadata string1500* @type: If KGSL_GPUOBJ_SET_INFO_TYPE is set, the new type of the memory object1501*/15021503#define KGSL_GPUOBJ_SET_INFO_METADATA (1 << 0)1504#define KGSL_GPUOBJ_SET_INFO_TYPE (1 << 1)15051506struct kgsl_gpuobj_set_info {1507uint64_t flags;1508uint64_t metadata;1509unsigned int id;1510unsigned int metadata_len;1511unsigned int type;1512};15131514#define IOCTL_KGSL_GPUOBJ_SET_INFO \1515_IOW(KGSL_IOC_TYPE, 0x4C, struct kgsl_gpuobj_set_info)15161517/**1518* struct kgsl_sparse_phys_alloc - Argument for IOCTL_KGSL_SPARSE_PHYS_ALLOC1519* @size: Size in bytes to back1520* @pagesize: Pagesize alignment required1521* @flags: Flags for this allocation1522* @id: Returned ID for this allocation1523*/1524struct kgsl_sparse_phys_alloc {1525uint64_t size;1526uint64_t pagesize;1527uint64_t flags;1528unsigned int id;1529};15301531#define IOCTL_KGSL_SPARSE_PHYS_ALLOC \1532_IOWR(KGSL_IOC_TYPE, 0x50, struct kgsl_sparse_phys_alloc)15331534/**1535* struct kgsl_sparse_phys_free - Argument for IOCTL_KGSL_SPARSE_PHYS_FREE1536* @id: ID to free1537*/1538struct kgsl_sparse_phys_free {1539unsigned int id;1540};15411542#define IOCTL_KGSL_SPARSE_PHYS_FREE \1543_IOW(KGSL_IOC_TYPE, 0x51, struct kgsl_sparse_phys_free)15441545/**1546* struct kgsl_sparse_virt_alloc - Argument for IOCTL_KGSL_SPARSE_VIRT_ALLOC1547* @size: Size in bytes to reserve1548* @pagesize: Pagesize alignment required1549* @flags: Flags for this allocation1550* @id: Returned ID for this allocation1551* @gpuaddr: Returned GPU address for this allocation1552*/1553struct kgsl_sparse_virt_alloc {1554uint64_t size;1555uint64_t pagesize;1556uint64_t flags;1557uint64_t gpuaddr;1558unsigned int id;1559};15601561#define IOCTL_KGSL_SPARSE_VIRT_ALLOC \1562_IOWR(KGSL_IOC_TYPE, 0x52, struct kgsl_sparse_virt_alloc)15631564/**1565* struct kgsl_sparse_virt_free - Argument for IOCTL_KGSL_SPARSE_VIRT_FREE1566* @id: ID to free1567*/1568struct kgsl_sparse_virt_free {1569unsigned int id;1570};15711572#define IOCTL_KGSL_SPARSE_VIRT_FREE \1573_IOW(KGSL_IOC_TYPE, 0x53, struct kgsl_sparse_virt_free)15741575/**1576* struct kgsl_sparse_binding_object - Argument for kgsl_sparse_bind1577* @virtoffset: Offset into the virtual ID1578* @physoffset: Offset into the physical ID (bind only)1579* @size: Size in bytes to reserve1580* @flags: Flags for this kgsl_sparse_binding_object1581* @id: Physical ID to bind (bind only)1582*/1583struct kgsl_sparse_binding_object {1584uint64_t virtoffset;1585uint64_t physoffset;1586uint64_t size;1587uint64_t flags;1588unsigned int id;1589};15901591/**1592* struct kgsl_sparse_bind - Argument for IOCTL_KGSL_SPARSE_BIND1593* @list: List of kgsl_sparse_bind_objects to bind/unbind1594* @id: Virtual ID to bind/unbind1595* @size: Size of kgsl_sparse_bind_object1596* @count: Number of elements in list1597*1598*/1599struct kgsl_sparse_bind {1600uint64_t __user list;1601unsigned int id;1602unsigned int size;1603unsigned int count;1604};16051606#define IOCTL_KGSL_SPARSE_BIND \1607_IOW(KGSL_IOC_TYPE, 0x54, struct kgsl_sparse_bind)16081609/**1610* struct kgsl_gpu_sparse_command - Argument for1611* IOCTL_KGSL_GPU_SPARSE_COMMAND1612* @flags: Current flags for the object1613* @sparselist: List of kgsl_sparse_binding_object to bind/unbind1614* @synclist: List of kgsl_command_syncpoints1615* @sparsesize: Size of kgsl_sparse_binding_object1616* @numsparse: Number of elements in list1617* @sync_size: Size of kgsl_command_syncpoint structure1618* @numsyncs: Number of kgsl_command_syncpoints in syncpoint list1619* @context_id: Context ID submitting the kgsl_gpu_command1620* @timestamp: Timestamp for the submitted commands1621* @id: Virtual ID to bind/unbind1622*/1623struct kgsl_gpu_sparse_command {1624uint64_t flags;1625uint64_t __user sparselist;1626uint64_t __user synclist;1627unsigned int sparsesize;1628unsigned int numsparse;1629unsigned int syncsize;1630unsigned int numsyncs;1631unsigned int context_id;1632unsigned int timestamp;1633unsigned int id;1634};16351636#define IOCTL_KGSL_GPU_SPARSE_COMMAND \1637_IOWR(KGSL_IOC_TYPE, 0x55, struct kgsl_gpu_sparse_command)16381639#endif /* _UAPI_MSM_KGSL_H */164016411642