msm_kgsl.h 44 KB

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