1
0

amdgpu_drm.h 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  1. /* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-
  2. *
  3. * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
  4. * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
  5. * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. * Copyright 2014 Advanced Micro Devices, Inc.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Authors:
  27. * Kevin E. Martin <martin@valinux.com>
  28. * Gareth Hughes <gareth@valinux.com>
  29. * Keith Whitwell <keith@tungstengraphics.com>
  30. */
  31. #ifndef __AMDGPU_DRM_H__
  32. #define __AMDGPU_DRM_H__
  33. #include "drm.h"
  34. #if defined(__cplusplus)
  35. extern "C" {
  36. #endif
  37. #define DRM_AMDGPU_GEM_CREATE 0x00
  38. #define DRM_AMDGPU_GEM_MMAP 0x01
  39. #define DRM_AMDGPU_CTX 0x02
  40. #define DRM_AMDGPU_BO_LIST 0x03
  41. #define DRM_AMDGPU_CS 0x04
  42. #define DRM_AMDGPU_INFO 0x05
  43. #define DRM_AMDGPU_GEM_METADATA 0x06
  44. #define DRM_AMDGPU_GEM_WAIT_IDLE 0x07
  45. #define DRM_AMDGPU_GEM_VA 0x08
  46. #define DRM_AMDGPU_WAIT_CS 0x09
  47. #define DRM_AMDGPU_GEM_OP 0x10
  48. #define DRM_AMDGPU_GEM_USERPTR 0x11
  49. #define DRM_AMDGPU_WAIT_FENCES 0x12
  50. #define DRM_AMDGPU_VM 0x13
  51. #define DRM_AMDGPU_FENCE_TO_HANDLE 0x14
  52. #define DRM_AMDGPU_SCHED 0x15
  53. #define DRM_AMDGPU_USERQ 0x16
  54. #define DRM_AMDGPU_USERQ_SIGNAL 0x17
  55. #define DRM_AMDGPU_USERQ_WAIT 0x18
  56. #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  57. #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
  58. #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
  59. #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
  60. #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
  61. #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
  62. #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
  63. #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
  64. #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
  65. #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
  66. #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
  67. #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
  68. #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
  69. #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
  70. #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
  71. #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
  72. #define DRM_IOCTL_AMDGPU_USERQ DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ, union drm_amdgpu_userq)
  73. #define DRM_IOCTL_AMDGPU_USERQ_SIGNAL DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal)
  74. #define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait)
  75. /**
  76. * DOC: memory domains
  77. *
  78. * %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible.
  79. * Memory in this pool could be swapped out to disk if there is pressure.
  80. *
  81. * %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the
  82. * GPU's virtual address space via gart. Gart memory linearizes non-contiguous
  83. * pages of system memory, allows GPU access system memory in a linearized
  84. * fashion.
  85. *
  86. * %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory
  87. * carved out by the BIOS.
  88. *
  89. * %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data
  90. * across shader threads.
  91. *
  92. * %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the
  93. * execution of all the waves on a device.
  94. *
  95. * %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines
  96. * for appending data.
  97. *
  98. * %AMDGPU_GEM_DOMAIN_DOORBELL Doorbell. It is an MMIO region for
  99. * signalling user mode queues.
  100. */
  101. #define AMDGPU_GEM_DOMAIN_CPU 0x1
  102. #define AMDGPU_GEM_DOMAIN_GTT 0x2
  103. #define AMDGPU_GEM_DOMAIN_VRAM 0x4
  104. #define AMDGPU_GEM_DOMAIN_GDS 0x8
  105. #define AMDGPU_GEM_DOMAIN_GWS 0x10
  106. #define AMDGPU_GEM_DOMAIN_OA 0x20
  107. #define AMDGPU_GEM_DOMAIN_DOORBELL 0x40
  108. #define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \
  109. AMDGPU_GEM_DOMAIN_GTT | \
  110. AMDGPU_GEM_DOMAIN_VRAM | \
  111. AMDGPU_GEM_DOMAIN_GDS | \
  112. AMDGPU_GEM_DOMAIN_GWS | \
  113. AMDGPU_GEM_DOMAIN_OA | \
  114. AMDGPU_GEM_DOMAIN_DOORBELL)
  115. /* Flag that CPU access will be required for the case of VRAM domain */
  116. #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
  117. /* Flag that CPU access will not work, this VRAM domain is invisible */
  118. #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
  119. /* Flag that USWC attributes should be used for GTT */
  120. #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
  121. /* Flag that the memory should be in VRAM and cleared */
  122. #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
  123. /* Flag that allocating the BO should use linear VRAM */
  124. #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
  125. /* Flag that BO is always valid in this VM */
  126. #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
  127. /* Flag that BO sharing will be explicitly synchronized */
  128. #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)
  129. /* Flag that indicates allocating MQD gart on GFX9, where the mtype
  130. * for the second page onward should be set to NC. It should never
  131. * be used by user space applications.
  132. */
  133. #define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)
  134. /* Flag that BO may contain sensitive data that must be wiped before
  135. * releasing the memory
  136. */
  137. #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)
  138. /* Flag that BO will be encrypted and that the TMZ bit should be
  139. * set in the PTEs when mapping this buffer via GPUVM or
  140. * accessing it with various hw blocks
  141. */
  142. #define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)
  143. /* Flag that BO will be used only in preemptible context, which does
  144. * not require GTT memory accounting
  145. */
  146. #define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)
  147. /* Flag that BO can be discarded under memory pressure without keeping the
  148. * content.
  149. */
  150. #define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)
  151. /* Flag that BO is shared coherently between multiple devices or CPU threads.
  152. * May depend on GPU instructions to flush caches to system scope explicitly.
  153. *
  154. * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
  155. * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
  156. */
  157. #define AMDGPU_GEM_CREATE_COHERENT (1 << 13)
  158. /* Flag that BO should not be cached by GPU. Coherent without having to flush
  159. * GPU caches explicitly
  160. *
  161. * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
  162. * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
  163. */
  164. #define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)
  165. /* Flag that BO should be coherent across devices when using device-level
  166. * atomics. May depend on GPU instructions to flush caches to device scope
  167. * explicitly, promoting them to system scope automatically.
  168. *
  169. * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
  170. * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
  171. */
  172. #define AMDGPU_GEM_CREATE_EXT_COHERENT (1 << 15)
  173. struct drm_amdgpu_gem_create_in {
  174. /** the requested memory size */
  175. __u64 bo_size;
  176. /** physical start_addr alignment in bytes for some HW requirements */
  177. __u64 alignment;
  178. /** the requested memory domains */
  179. __u64 domains;
  180. /** allocation flags */
  181. __u64 domain_flags;
  182. };
  183. struct drm_amdgpu_gem_create_out {
  184. /** returned GEM object handle */
  185. __u32 handle;
  186. __u32 _pad;
  187. };
  188. union drm_amdgpu_gem_create {
  189. struct drm_amdgpu_gem_create_in in;
  190. struct drm_amdgpu_gem_create_out out;
  191. };
  192. /** Opcode to create new residency list. */
  193. #define AMDGPU_BO_LIST_OP_CREATE 0
  194. /** Opcode to destroy previously created residency list */
  195. #define AMDGPU_BO_LIST_OP_DESTROY 1
  196. /** Opcode to update resource information in the list */
  197. #define AMDGPU_BO_LIST_OP_UPDATE 2
  198. struct drm_amdgpu_bo_list_in {
  199. /** Type of operation */
  200. __u32 operation;
  201. /** Handle of list or 0 if we want to create one */
  202. __u32 list_handle;
  203. /** Number of BOs in list */
  204. __u32 bo_number;
  205. /** Size of each element describing BO */
  206. __u32 bo_info_size;
  207. /** Pointer to array describing BOs */
  208. __u64 bo_info_ptr;
  209. };
  210. struct drm_amdgpu_bo_list_entry {
  211. /** Handle of BO */
  212. __u32 bo_handle;
  213. /** New (if specified) BO priority to be used during migration */
  214. __u32 bo_priority;
  215. };
  216. struct drm_amdgpu_bo_list_out {
  217. /** Handle of resource list */
  218. __u32 list_handle;
  219. __u32 _pad;
  220. };
  221. union drm_amdgpu_bo_list {
  222. struct drm_amdgpu_bo_list_in in;
  223. struct drm_amdgpu_bo_list_out out;
  224. };
  225. /* context related */
  226. #define AMDGPU_CTX_OP_ALLOC_CTX 1
  227. #define AMDGPU_CTX_OP_FREE_CTX 2
  228. #define AMDGPU_CTX_OP_QUERY_STATE 3
  229. #define AMDGPU_CTX_OP_QUERY_STATE2 4
  230. #define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5
  231. #define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6
  232. /* GPU reset status */
  233. #define AMDGPU_CTX_NO_RESET 0
  234. /* this the context caused it */
  235. #define AMDGPU_CTX_GUILTY_RESET 1
  236. /* some other context caused it */
  237. #define AMDGPU_CTX_INNOCENT_RESET 2
  238. /* unknown cause */
  239. #define AMDGPU_CTX_UNKNOWN_RESET 3
  240. /* indicate gpu reset occurred after ctx created */
  241. #define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)
  242. /* indicate vram lost occurred after ctx created */
  243. #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
  244. /* indicate some job from this context once cause gpu hang */
  245. #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)
  246. /* indicate some errors are detected by RAS */
  247. #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)
  248. #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)
  249. /* indicate that the reset hasn't completed yet */
  250. #define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
  251. /* Context priority level */
  252. #define AMDGPU_CTX_PRIORITY_UNSET -2048
  253. #define AMDGPU_CTX_PRIORITY_VERY_LOW -1023
  254. #define AMDGPU_CTX_PRIORITY_LOW -512
  255. #define AMDGPU_CTX_PRIORITY_NORMAL 0
  256. /*
  257. * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
  258. * CAP_SYS_NICE or DRM_MASTER
  259. */
  260. #define AMDGPU_CTX_PRIORITY_HIGH 512
  261. #define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
  262. /* select a stable profiling pstate for perfmon tools */
  263. #define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf
  264. #define AMDGPU_CTX_STABLE_PSTATE_NONE 0
  265. #define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1
  266. #define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2
  267. #define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3
  268. #define AMDGPU_CTX_STABLE_PSTATE_PEAK 4
  269. struct drm_amdgpu_ctx_in {
  270. /** AMDGPU_CTX_OP_* */
  271. __u32 op;
  272. /** Flags */
  273. __u32 flags;
  274. __u32 ctx_id;
  275. /** AMDGPU_CTX_PRIORITY_* */
  276. __s32 priority;
  277. };
  278. union drm_amdgpu_ctx_out {
  279. struct {
  280. __u32 ctx_id;
  281. __u32 _pad;
  282. } alloc;
  283. struct {
  284. /** For future use, no flags defined so far */
  285. __u64 flags;
  286. /** Number of resets caused by this context so far. */
  287. __u32 hangs;
  288. /** Reset status since the last call of the ioctl. */
  289. __u32 reset_status;
  290. } state;
  291. struct {
  292. __u32 flags;
  293. __u32 _pad;
  294. } pstate;
  295. };
  296. union drm_amdgpu_ctx {
  297. struct drm_amdgpu_ctx_in in;
  298. union drm_amdgpu_ctx_out out;
  299. };
  300. /* user queue IOCTL operations */
  301. #define AMDGPU_USERQ_OP_CREATE 1
  302. #define AMDGPU_USERQ_OP_FREE 2
  303. /* queue priority levels */
  304. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK 0x3
  305. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_SHIFT 0
  306. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_LOW 0
  307. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_LOW 1
  308. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_HIGH 2
  309. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH 3 /* admin only */
  310. /* for queues that need access to protected content */
  311. #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE (1 << 2)
  312. /*
  313. * This structure is a container to pass input configuration
  314. * info for all supported userqueue related operations.
  315. * For operation AMDGPU_USERQ_OP_CREATE: user is expected
  316. * to set all fields, excep the parameter 'queue_id'.
  317. * For operation AMDGPU_USERQ_OP_FREE: the only input parameter expected
  318. * to be set is 'queue_id', eveything else is ignored.
  319. */
  320. struct drm_amdgpu_userq_in {
  321. /** AMDGPU_USERQ_OP_* */
  322. __u32 op;
  323. /** Queue id passed for operation USERQ_OP_FREE */
  324. __u32 queue_id;
  325. /** the target GPU engine to execute workload (AMDGPU_HW_IP_*) */
  326. __u32 ip_type;
  327. /**
  328. * @doorbell_handle: the handle of doorbell GEM object
  329. * associated to this userqueue client.
  330. */
  331. __u32 doorbell_handle;
  332. /**
  333. * @doorbell_offset: 32-bit offset of the doorbell in the doorbell bo.
  334. * Kernel will generate absolute doorbell offset using doorbell_handle
  335. * and doorbell_offset in the doorbell bo.
  336. */
  337. __u32 doorbell_offset;
  338. /**
  339. * @flags: flags used for queue parameters
  340. */
  341. __u32 flags;
  342. /**
  343. * @queue_va: Virtual address of the GPU memory which holds the queue
  344. * object. The queue holds the workload packets.
  345. */
  346. __u64 queue_va;
  347. /**
  348. * @queue_size: Size of the queue in bytes, this needs to be 256-byte
  349. * aligned.
  350. */
  351. __u64 queue_size;
  352. /**
  353. * @rptr_va : Virtual address of the GPU memory which holds the ring RPTR.
  354. * This object must be at least 8 byte in size and aligned to 8-byte offset.
  355. */
  356. __u64 rptr_va;
  357. /**
  358. * @wptr_va : Virtual address of the GPU memory which holds the ring WPTR.
  359. * This object must be at least 8 byte in size and aligned to 8-byte offset.
  360. *
  361. * Queue, RPTR and WPTR can come from the same object, as long as the size
  362. * and alignment related requirements are met.
  363. */
  364. __u64 wptr_va;
  365. /**
  366. * @mqd: MQD (memory queue descriptor) is a set of parameters which allow
  367. * the GPU to uniquely define and identify a usermode queue.
  368. *
  369. * MQD data can be of different size for different GPU IP/engine and
  370. * their respective versions/revisions, so this points to a __u64 *
  371. * which holds IP specific MQD of this usermode queue.
  372. */
  373. __u64 mqd;
  374. /**
  375. * @size: size of MQD data in bytes, it must match the MQD structure
  376. * size of the respective engine/revision defined in UAPI for ex, for
  377. * gfx11 workloads, size = sizeof(drm_amdgpu_userq_mqd_gfx11).
  378. */
  379. __u64 mqd_size;
  380. };
  381. /* The structure to carry output of userqueue ops */
  382. struct drm_amdgpu_userq_out {
  383. /**
  384. * For operation AMDGPU_USERQ_OP_CREATE: This field contains a unique
  385. * queue ID to represent the newly created userqueue in the system, otherwise
  386. * it should be ignored.
  387. */
  388. __u32 queue_id;
  389. __u32 _pad;
  390. };
  391. union drm_amdgpu_userq {
  392. struct drm_amdgpu_userq_in in;
  393. struct drm_amdgpu_userq_out out;
  394. };
  395. /* GFX V11 IP specific MQD parameters */
  396. struct drm_amdgpu_userq_mqd_gfx11 {
  397. /**
  398. * @shadow_va: Virtual address of the GPU memory to hold the shadow buffer.
  399. * Use AMDGPU_INFO_IOCTL to find the exact size of the object.
  400. */
  401. __u64 shadow_va;
  402. /**
  403. * @csa_va: Virtual address of the GPU memory to hold the CSA buffer.
  404. * Use AMDGPU_INFO_IOCTL to find the exact size of the object.
  405. */
  406. __u64 csa_va;
  407. };
  408. /* GFX V11 SDMA IP specific MQD parameters */
  409. struct drm_amdgpu_userq_mqd_sdma_gfx11 {
  410. /**
  411. * @csa_va: Virtual address of the GPU memory to hold the CSA buffer.
  412. * This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL
  413. * to get the size.
  414. */
  415. __u64 csa_va;
  416. };
  417. /* GFX V11 Compute IP specific MQD parameters */
  418. struct drm_amdgpu_userq_mqd_compute_gfx11 {
  419. /**
  420. * @eop_va: Virtual address of the GPU memory to hold the EOP buffer.
  421. * This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL
  422. * to get the size.
  423. */
  424. __u64 eop_va;
  425. };
  426. /* userq signal/wait ioctl */
  427. struct drm_amdgpu_userq_signal {
  428. /**
  429. * @queue_id: Queue handle used by the userq fence creation function
  430. * to retrieve the WPTR.
  431. */
  432. __u32 queue_id;
  433. __u32 pad;
  434. /**
  435. * @syncobj_handles: The list of syncobj handles submitted by the user queue
  436. * job to be signaled.
  437. */
  438. __u64 syncobj_handles;
  439. /**
  440. * @num_syncobj_handles: A count that represents the number of syncobj handles in
  441. * @syncobj_handles.
  442. */
  443. __u64 num_syncobj_handles;
  444. /**
  445. * @bo_read_handles: The list of BO handles that the submitted user queue job
  446. * is using for read only. This will update BO fences in the kernel.
  447. */
  448. __u64 bo_read_handles;
  449. /**
  450. * @bo_write_handles: The list of BO handles that the submitted user queue job
  451. * is using for write only. This will update BO fences in the kernel.
  452. */
  453. __u64 bo_write_handles;
  454. /**
  455. * @num_bo_read_handles: A count that represents the number of read BO handles in
  456. * @bo_read_handles.
  457. */
  458. __u32 num_bo_read_handles;
  459. /**
  460. * @num_bo_write_handles: A count that represents the number of write BO handles in
  461. * @bo_write_handles.
  462. */
  463. __u32 num_bo_write_handles;
  464. };
  465. struct drm_amdgpu_userq_fence_info {
  466. /**
  467. * @va: A gpu address allocated for each queue which stores the
  468. * read pointer (RPTR) value.
  469. */
  470. __u64 va;
  471. /**
  472. * @value: A 64 bit value represents the write pointer (WPTR) of the
  473. * queue commands which compared with the RPTR value to signal the
  474. * fences.
  475. */
  476. __u64 value;
  477. };
  478. struct drm_amdgpu_userq_wait {
  479. /**
  480. * @waitq_id: Queue handle used by the userq wait IOCTL to retrieve the
  481. * wait queue and maintain the fence driver references in it.
  482. */
  483. __u32 waitq_id;
  484. __u32 pad;
  485. /**
  486. * @syncobj_handles: The list of syncobj handles submitted by the user queue
  487. * job to get the va/value pairs.
  488. */
  489. __u64 syncobj_handles;
  490. /**
  491. * @syncobj_timeline_handles: The list of timeline syncobj handles submitted by
  492. * the user queue job to get the va/value pairs at given @syncobj_timeline_points.
  493. */
  494. __u64 syncobj_timeline_handles;
  495. /**
  496. * @syncobj_timeline_points: The list of timeline syncobj points submitted by the
  497. * user queue job for the corresponding @syncobj_timeline_handles.
  498. */
  499. __u64 syncobj_timeline_points;
  500. /**
  501. * @bo_read_handles: The list of read BO handles submitted by the user queue
  502. * job to get the va/value pairs.
  503. */
  504. __u64 bo_read_handles;
  505. /**
  506. * @bo_write_handles: The list of write BO handles submitted by the user queue
  507. * job to get the va/value pairs.
  508. */
  509. __u64 bo_write_handles;
  510. /**
  511. * @num_syncobj_timeline_handles: A count that represents the number of timeline
  512. * syncobj handles in @syncobj_timeline_handles.
  513. */
  514. __u16 num_syncobj_timeline_handles;
  515. /**
  516. * @num_fences: This field can be used both as input and output. As input it defines
  517. * the maximum number of fences that can be returned and as output it will specify
  518. * how many fences were actually returned from the ioctl.
  519. */
  520. __u16 num_fences;
  521. /**
  522. * @num_syncobj_handles: A count that represents the number of syncobj handles in
  523. * @syncobj_handles.
  524. */
  525. __u32 num_syncobj_handles;
  526. /**
  527. * @num_bo_read_handles: A count that represents the number of read BO handles in
  528. * @bo_read_handles.
  529. */
  530. __u32 num_bo_read_handles;
  531. /**
  532. * @num_bo_write_handles: A count that represents the number of write BO handles in
  533. * @bo_write_handles.
  534. */
  535. __u32 num_bo_write_handles;
  536. /**
  537. * @out_fences: The field is a return value from the ioctl containing the list of
  538. * address/value pairs to wait for.
  539. */
  540. __u64 out_fences;
  541. };
  542. /* vm ioctl */
  543. #define AMDGPU_VM_OP_RESERVE_VMID 1
  544. #define AMDGPU_VM_OP_UNRESERVE_VMID 2
  545. struct drm_amdgpu_vm_in {
  546. /** AMDGPU_VM_OP_* */
  547. __u32 op;
  548. __u32 flags;
  549. };
  550. struct drm_amdgpu_vm_out {
  551. /** For future use, no flags defined so far */
  552. __u64 flags;
  553. };
  554. union drm_amdgpu_vm {
  555. struct drm_amdgpu_vm_in in;
  556. struct drm_amdgpu_vm_out out;
  557. };
  558. /* sched ioctl */
  559. #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1
  560. #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2
  561. struct drm_amdgpu_sched_in {
  562. /* AMDGPU_SCHED_OP_* */
  563. __u32 op;
  564. __u32 fd;
  565. /** AMDGPU_CTX_PRIORITY_* */
  566. __s32 priority;
  567. __u32 ctx_id;
  568. };
  569. union drm_amdgpu_sched {
  570. struct drm_amdgpu_sched_in in;
  571. };
  572. /*
  573. * This is not a reliable API and you should expect it to fail for any
  574. * number of reasons and have fallback path that do not use userptr to
  575. * perform any operation.
  576. */
  577. #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
  578. #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
  579. #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
  580. #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
  581. struct drm_amdgpu_gem_userptr {
  582. __u64 addr;
  583. __u64 size;
  584. /* AMDGPU_GEM_USERPTR_* */
  585. __u32 flags;
  586. /* Resulting GEM handle */
  587. __u32 handle;
  588. };
  589. /* SI-CI-VI: */
  590. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  591. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  592. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  593. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  594. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  595. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  596. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  597. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  598. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  599. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  600. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  601. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  602. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  603. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  604. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  605. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  606. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  607. /* GFX9 - GFX11: */
  608. #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0
  609. #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f
  610. #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5
  611. #define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF
  612. #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29
  613. #define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF
  614. #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43
  615. #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1
  616. #define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44
  617. #define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1
  618. #define AMDGPU_TILING_SCANOUT_SHIFT 63
  619. #define AMDGPU_TILING_SCANOUT_MASK 0x1
  620. /* GFX12 and later: */
  621. #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT 0
  622. #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK 0x7
  623. /* These are DCC recompression setting for memory management: */
  624. #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT 3
  625. #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 /* 0:64B, 1:128B, 2:256B */
  626. #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT 5
  627. #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK 0x7 /* CB_COLOR0_INFO.NUMBER_TYPE */
  628. #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT 8
  629. #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK 0x3f /* [0:4]:CB_COLOR0_INFO.FORMAT, [5]:MM */
  630. /* Set/Get helpers for tiling flags. */
  631. #define AMDGPU_TILING_SET(field, value) \
  632. (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  633. #define AMDGPU_TILING_GET(value, field) \
  634. (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  635. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  636. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  637. /** The same structure is shared for input/output */
  638. struct drm_amdgpu_gem_metadata {
  639. /** GEM Object handle */
  640. __u32 handle;
  641. /** Do we want get or set metadata */
  642. __u32 op;
  643. struct {
  644. /** For future use, no flags defined so far */
  645. __u64 flags;
  646. /** family specific tiling info */
  647. __u64 tiling_info;
  648. __u32 data_size_bytes;
  649. __u32 data[64];
  650. } data;
  651. };
  652. struct drm_amdgpu_gem_mmap_in {
  653. /** the GEM object handle */
  654. __u32 handle;
  655. __u32 _pad;
  656. };
  657. struct drm_amdgpu_gem_mmap_out {
  658. /** mmap offset from the vma offset manager */
  659. __u64 addr_ptr;
  660. };
  661. union drm_amdgpu_gem_mmap {
  662. struct drm_amdgpu_gem_mmap_in in;
  663. struct drm_amdgpu_gem_mmap_out out;
  664. };
  665. struct drm_amdgpu_gem_wait_idle_in {
  666. /** GEM object handle */
  667. __u32 handle;
  668. /** For future use, no flags defined so far */
  669. __u32 flags;
  670. /** Absolute timeout to wait */
  671. __u64 timeout;
  672. };
  673. struct drm_amdgpu_gem_wait_idle_out {
  674. /** BO status: 0 - BO is idle, 1 - BO is busy */
  675. __u32 status;
  676. /** Returned current memory domain */
  677. __u32 domain;
  678. };
  679. union drm_amdgpu_gem_wait_idle {
  680. struct drm_amdgpu_gem_wait_idle_in in;
  681. struct drm_amdgpu_gem_wait_idle_out out;
  682. };
  683. struct drm_amdgpu_wait_cs_in {
  684. /* Command submission handle
  685. * handle equals 0 means none to wait for
  686. * handle equals ~0ull means wait for the latest sequence number
  687. */
  688. __u64 handle;
  689. /** Absolute timeout to wait */
  690. __u64 timeout;
  691. __u32 ip_type;
  692. __u32 ip_instance;
  693. __u32 ring;
  694. __u32 ctx_id;
  695. };
  696. struct drm_amdgpu_wait_cs_out {
  697. /** CS status: 0 - CS completed, 1 - CS still busy */
  698. __u64 status;
  699. };
  700. union drm_amdgpu_wait_cs {
  701. struct drm_amdgpu_wait_cs_in in;
  702. struct drm_amdgpu_wait_cs_out out;
  703. };
  704. struct drm_amdgpu_fence {
  705. __u32 ctx_id;
  706. __u32 ip_type;
  707. __u32 ip_instance;
  708. __u32 ring;
  709. __u64 seq_no;
  710. };
  711. struct drm_amdgpu_wait_fences_in {
  712. /** This points to uint64_t * which points to fences */
  713. __u64 fences;
  714. __u32 fence_count;
  715. __u32 wait_all;
  716. __u64 timeout_ns;
  717. };
  718. struct drm_amdgpu_wait_fences_out {
  719. __u32 status;
  720. __u32 first_signaled;
  721. };
  722. union drm_amdgpu_wait_fences {
  723. struct drm_amdgpu_wait_fences_in in;
  724. struct drm_amdgpu_wait_fences_out out;
  725. };
  726. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  727. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  728. /* Sets or returns a value associated with a buffer. */
  729. struct drm_amdgpu_gem_op {
  730. /** GEM object handle */
  731. __u32 handle;
  732. /** AMDGPU_GEM_OP_* */
  733. __u32 op;
  734. /** Input or return value */
  735. __u64 value;
  736. };
  737. #define AMDGPU_VA_OP_MAP 1
  738. #define AMDGPU_VA_OP_UNMAP 2
  739. #define AMDGPU_VA_OP_CLEAR 3
  740. #define AMDGPU_VA_OP_REPLACE 4
  741. /* Delay the page table update till the next CS */
  742. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  743. /* Mapping flags */
  744. /* readable mapping */
  745. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  746. /* writable mapping */
  747. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  748. /* executable mapping, new for VI */
  749. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  750. /* partially resident texture */
  751. #define AMDGPU_VM_PAGE_PRT (1 << 4)
  752. /* MTYPE flags use bit 5 to 8 */
  753. #define AMDGPU_VM_MTYPE_MASK (0xf << 5)
  754. /* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */
  755. #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
  756. /* Use Non Coherent MTYPE instead of default MTYPE */
  757. #define AMDGPU_VM_MTYPE_NC (1 << 5)
  758. /* Use Write Combine MTYPE instead of default MTYPE */
  759. #define AMDGPU_VM_MTYPE_WC (2 << 5)
  760. /* Use Cache Coherent MTYPE instead of default MTYPE */
  761. #define AMDGPU_VM_MTYPE_CC (3 << 5)
  762. /* Use UnCached MTYPE instead of default MTYPE */
  763. #define AMDGPU_VM_MTYPE_UC (4 << 5)
  764. /* Use Read Write MTYPE instead of default MTYPE */
  765. #define AMDGPU_VM_MTYPE_RW (5 << 5)
  766. /* don't allocate MALL */
  767. #define AMDGPU_VM_PAGE_NOALLOC (1 << 9)
  768. struct drm_amdgpu_gem_va {
  769. /** GEM object handle */
  770. __u32 handle;
  771. __u32 _pad;
  772. /** AMDGPU_VA_OP_* */
  773. __u32 operation;
  774. /** AMDGPU_VM_PAGE_* */
  775. __u32 flags;
  776. /** va address to assign . Must be correctly aligned.*/
  777. __u64 va_address;
  778. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  779. __u64 offset_in_bo;
  780. /** Specify mapping size. Must be correctly aligned. */
  781. __u64 map_size;
  782. /**
  783. * vm_timeline_point is a sequence number used to add new timeline point.
  784. */
  785. __u64 vm_timeline_point;
  786. /**
  787. * The vm page table update fence is installed in given vm_timeline_syncobj_out
  788. * at vm_timeline_point.
  789. */
  790. __u32 vm_timeline_syncobj_out;
  791. /** the number of syncobj handles in @input_fence_syncobj_handles */
  792. __u32 num_syncobj_handles;
  793. /** Array of sync object handle to wait for given input fences */
  794. __u64 input_fence_syncobj_handles;
  795. };
  796. #define AMDGPU_HW_IP_GFX 0
  797. #define AMDGPU_HW_IP_COMPUTE 1
  798. #define AMDGPU_HW_IP_DMA 2
  799. #define AMDGPU_HW_IP_UVD 3
  800. #define AMDGPU_HW_IP_VCE 4
  801. #define AMDGPU_HW_IP_UVD_ENC 5
  802. #define AMDGPU_HW_IP_VCN_DEC 6
  803. /*
  804. * From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support
  805. * both encoding and decoding jobs.
  806. */
  807. #define AMDGPU_HW_IP_VCN_ENC 7
  808. #define AMDGPU_HW_IP_VCN_JPEG 8
  809. #define AMDGPU_HW_IP_VPE 9
  810. #define AMDGPU_HW_IP_NUM 10
  811. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  812. #define AMDGPU_CHUNK_ID_IB 0x01
  813. #define AMDGPU_CHUNK_ID_FENCE 0x02
  814. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  815. #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04
  816. #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05
  817. #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06
  818. #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
  819. #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08
  820. #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09
  821. #define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a
  822. struct drm_amdgpu_cs_chunk {
  823. __u32 chunk_id;
  824. __u32 length_dw;
  825. __u64 chunk_data;
  826. };
  827. struct drm_amdgpu_cs_in {
  828. /** Rendering context id */
  829. __u32 ctx_id;
  830. /** Handle of resource list associated with CS */
  831. __u32 bo_list_handle;
  832. __u32 num_chunks;
  833. __u32 flags;
  834. /** this points to __u64 * which point to cs chunks */
  835. __u64 chunks;
  836. };
  837. struct drm_amdgpu_cs_out {
  838. __u64 handle;
  839. };
  840. union drm_amdgpu_cs {
  841. struct drm_amdgpu_cs_in in;
  842. struct drm_amdgpu_cs_out out;
  843. };
  844. /* Specify flags to be used for IB */
  845. /* This IB should be submitted to CE */
  846. #define AMDGPU_IB_FLAG_CE (1<<0)
  847. /* Preamble flag, which means the IB could be dropped if no context switch */
  848. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  849. /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
  850. #define AMDGPU_IB_FLAG_PREEMPT (1<<2)
  851. /* The IB fence should do the L2 writeback but not invalidate any shader
  852. * caches (L2/vL1/sL1/I$). */
  853. #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
  854. /* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.
  855. * This will reset wave ID counters for the IB.
  856. */
  857. #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
  858. /* Flag the IB as secure (TMZ)
  859. */
  860. #define AMDGPU_IB_FLAGS_SECURE (1 << 5)
  861. /* Tell KMD to flush and invalidate caches
  862. */
  863. #define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)
  864. struct drm_amdgpu_cs_chunk_ib {
  865. __u32 _pad;
  866. /** AMDGPU_IB_FLAG_* */
  867. __u32 flags;
  868. /** Virtual address to begin IB execution */
  869. __u64 va_start;
  870. /** Size of submission */
  871. __u32 ib_bytes;
  872. /** HW IP to submit to */
  873. __u32 ip_type;
  874. /** HW IP index of the same type to submit to */
  875. __u32 ip_instance;
  876. /** Ring index to submit to */
  877. __u32 ring;
  878. };
  879. struct drm_amdgpu_cs_chunk_dep {
  880. __u32 ip_type;
  881. __u32 ip_instance;
  882. __u32 ring;
  883. __u32 ctx_id;
  884. __u64 handle;
  885. };
  886. struct drm_amdgpu_cs_chunk_fence {
  887. __u32 handle;
  888. __u32 offset;
  889. };
  890. struct drm_amdgpu_cs_chunk_sem {
  891. __u32 handle;
  892. };
  893. struct drm_amdgpu_cs_chunk_syncobj {
  894. __u32 handle;
  895. __u32 flags;
  896. __u64 point;
  897. };
  898. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0
  899. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1
  900. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
  901. union drm_amdgpu_fence_to_handle {
  902. struct {
  903. struct drm_amdgpu_fence fence;
  904. __u32 what;
  905. __u32 pad;
  906. } in;
  907. struct {
  908. __u32 handle;
  909. } out;
  910. };
  911. struct drm_amdgpu_cs_chunk_data {
  912. union {
  913. struct drm_amdgpu_cs_chunk_ib ib_data;
  914. struct drm_amdgpu_cs_chunk_fence fence_data;
  915. };
  916. };
  917. #define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x1
  918. struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
  919. __u64 shadow_va;
  920. __u64 csa_va;
  921. __u64 gds_va;
  922. __u64 flags;
  923. };
  924. /*
  925. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  926. *
  927. */
  928. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  929. #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
  930. #define AMDGPU_IDS_FLAGS_TMZ 0x4
  931. #define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
  932. /*
  933. * Query h/w info: Flag identifying VF/PF/PT mode
  934. *
  935. */
  936. #define AMDGPU_IDS_FLAGS_MODE_MASK 0x300
  937. #define AMDGPU_IDS_FLAGS_MODE_SHIFT 0x8
  938. #define AMDGPU_IDS_FLAGS_MODE_PF 0x0
  939. #define AMDGPU_IDS_FLAGS_MODE_VF 0x1
  940. #define AMDGPU_IDS_FLAGS_MODE_PT 0x2
  941. /* indicate if acceleration can be working */
  942. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  943. /* get the crtc_id from the mode object id? */
  944. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  945. /* query hw IP info */
  946. #define AMDGPU_INFO_HW_IP_INFO 0x02
  947. /* query hw IP instance count for the specified type */
  948. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  949. /* timestamp for GL_ARB_timer_query */
  950. #define AMDGPU_INFO_TIMESTAMP 0x05
  951. /* Query the firmware version */
  952. #define AMDGPU_INFO_FW_VERSION 0x0e
  953. /* Subquery id: Query VCE firmware version */
  954. #define AMDGPU_INFO_FW_VCE 0x1
  955. /* Subquery id: Query UVD firmware version */
  956. #define AMDGPU_INFO_FW_UVD 0x2
  957. /* Subquery id: Query GMC firmware version */
  958. #define AMDGPU_INFO_FW_GMC 0x03
  959. /* Subquery id: Query GFX ME firmware version */
  960. #define AMDGPU_INFO_FW_GFX_ME 0x04
  961. /* Subquery id: Query GFX PFP firmware version */
  962. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  963. /* Subquery id: Query GFX CE firmware version */
  964. #define AMDGPU_INFO_FW_GFX_CE 0x06
  965. /* Subquery id: Query GFX RLC firmware version */
  966. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  967. /* Subquery id: Query GFX MEC firmware version */
  968. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  969. /* Subquery id: Query SMC firmware version */
  970. #define AMDGPU_INFO_FW_SMC 0x0a
  971. /* Subquery id: Query SDMA firmware version */
  972. #define AMDGPU_INFO_FW_SDMA 0x0b
  973. /* Subquery id: Query PSP SOS firmware version */
  974. #define AMDGPU_INFO_FW_SOS 0x0c
  975. /* Subquery id: Query PSP ASD firmware version */
  976. #define AMDGPU_INFO_FW_ASD 0x0d
  977. /* Subquery id: Query VCN firmware version */
  978. #define AMDGPU_INFO_FW_VCN 0x0e
  979. /* Subquery id: Query GFX RLC SRLC firmware version */
  980. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
  981. /* Subquery id: Query GFX RLC SRLG firmware version */
  982. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
  983. /* Subquery id: Query GFX RLC SRLS firmware version */
  984. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
  985. /* Subquery id: Query DMCU firmware version */
  986. #define AMDGPU_INFO_FW_DMCU 0x12
  987. #define AMDGPU_INFO_FW_TA 0x13
  988. /* Subquery id: Query DMCUB firmware version */
  989. #define AMDGPU_INFO_FW_DMCUB 0x14
  990. /* Subquery id: Query TOC firmware version */
  991. #define AMDGPU_INFO_FW_TOC 0x15
  992. /* Subquery id: Query CAP firmware version */
  993. #define AMDGPU_INFO_FW_CAP 0x16
  994. /* Subquery id: Query GFX RLCP firmware version */
  995. #define AMDGPU_INFO_FW_GFX_RLCP 0x17
  996. /* Subquery id: Query GFX RLCV firmware version */
  997. #define AMDGPU_INFO_FW_GFX_RLCV 0x18
  998. /* Subquery id: Query MES_KIQ firmware version */
  999. #define AMDGPU_INFO_FW_MES_KIQ 0x19
  1000. /* Subquery id: Query MES firmware version */
  1001. #define AMDGPU_INFO_FW_MES 0x1a
  1002. /* Subquery id: Query IMU firmware version */
  1003. #define AMDGPU_INFO_FW_IMU 0x1b
  1004. /* Subquery id: Query VPE firmware version */
  1005. #define AMDGPU_INFO_FW_VPE 0x1c
  1006. /* number of bytes moved for TTM migration */
  1007. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  1008. /* the used VRAM size */
  1009. #define AMDGPU_INFO_VRAM_USAGE 0x10
  1010. /* the used GTT size */
  1011. #define AMDGPU_INFO_GTT_USAGE 0x11
  1012. /* Information about GDS, etc. resource configuration */
  1013. #define AMDGPU_INFO_GDS_CONFIG 0x13
  1014. /* Query information about VRAM and GTT domains */
  1015. #define AMDGPU_INFO_VRAM_GTT 0x14
  1016. /* Query information about register in MMR address space*/
  1017. #define AMDGPU_INFO_READ_MMR_REG 0x15
  1018. /* Query information about device: rev id, family, etc. */
  1019. #define AMDGPU_INFO_DEV_INFO 0x16
  1020. /* visible vram usage */
  1021. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  1022. /* number of TTM buffer evictions */
  1023. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  1024. /* Query memory about VRAM and GTT domains */
  1025. #define AMDGPU_INFO_MEMORY 0x19
  1026. /* Query vce clock table */
  1027. #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
  1028. /* Query vbios related information */
  1029. #define AMDGPU_INFO_VBIOS 0x1B
  1030. /* Subquery id: Query vbios size */
  1031. #define AMDGPU_INFO_VBIOS_SIZE 0x1
  1032. /* Subquery id: Query vbios image */
  1033. #define AMDGPU_INFO_VBIOS_IMAGE 0x2
  1034. /* Subquery id: Query vbios info */
  1035. #define AMDGPU_INFO_VBIOS_INFO 0x3
  1036. /* Query UVD handles */
  1037. #define AMDGPU_INFO_NUM_HANDLES 0x1C
  1038. /* Query sensor related information */
  1039. #define AMDGPU_INFO_SENSOR 0x1D
  1040. /* Subquery id: Query GPU shader clock */
  1041. #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
  1042. /* Subquery id: Query GPU memory clock */
  1043. #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
  1044. /* Subquery id: Query GPU temperature */
  1045. #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
  1046. /* Subquery id: Query GPU load */
  1047. #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
  1048. /* Subquery id: Query average GPU power */
  1049. #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
  1050. /* Subquery id: Query northbridge voltage */
  1051. #define AMDGPU_INFO_SENSOR_VDDNB 0x6
  1052. /* Subquery id: Query graphics voltage */
  1053. #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
  1054. /* Subquery id: Query GPU stable pstate shader clock */
  1055. #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8
  1056. /* Subquery id: Query GPU stable pstate memory clock */
  1057. #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
  1058. /* Subquery id: Query GPU peak pstate shader clock */
  1059. #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa
  1060. /* Subquery id: Query GPU peak pstate memory clock */
  1061. #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb
  1062. /* Subquery id: Query input GPU power */
  1063. #define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc
  1064. /* Number of VRAM page faults on CPU access. */
  1065. #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
  1066. #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
  1067. /* query ras mask of enabled features*/
  1068. #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20
  1069. /* RAS MASK: UMC (VRAM) */
  1070. #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)
  1071. /* RAS MASK: SDMA */
  1072. #define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)
  1073. /* RAS MASK: GFX */
  1074. #define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)
  1075. /* RAS MASK: MMHUB */
  1076. #define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)
  1077. /* RAS MASK: ATHUB */
  1078. #define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)
  1079. /* RAS MASK: PCIE */
  1080. #define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)
  1081. /* RAS MASK: HDP */
  1082. #define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)
  1083. /* RAS MASK: XGMI */
  1084. #define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)
  1085. /* RAS MASK: DF */
  1086. #define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)
  1087. /* RAS MASK: SMN */
  1088. #define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)
  1089. /* RAS MASK: SEM */
  1090. #define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)
  1091. /* RAS MASK: MP0 */
  1092. #define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)
  1093. /* RAS MASK: MP1 */
  1094. #define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)
  1095. /* RAS MASK: FUSE */
  1096. #define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)
  1097. /* query video encode/decode caps */
  1098. #define AMDGPU_INFO_VIDEO_CAPS 0x21
  1099. /* Subquery id: Decode */
  1100. #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0
  1101. /* Subquery id: Encode */
  1102. #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1
  1103. /* Query the max number of IBs per gang per submission */
  1104. #define AMDGPU_INFO_MAX_IBS 0x22
  1105. /* query last page fault info */
  1106. #define AMDGPU_INFO_GPUVM_FAULT 0x23
  1107. /* query FW object size and alignment */
  1108. #define AMDGPU_INFO_UQ_FW_AREAS 0x24
  1109. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  1110. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  1111. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  1112. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  1113. struct drm_amdgpu_query_fw {
  1114. /** AMDGPU_INFO_FW_* */
  1115. __u32 fw_type;
  1116. /**
  1117. * Index of the IP if there are more IPs of
  1118. * the same type.
  1119. */
  1120. __u32 ip_instance;
  1121. /**
  1122. * Index of the engine. Whether this is used depends
  1123. * on the firmware type. (e.g. MEC, SDMA)
  1124. */
  1125. __u32 index;
  1126. __u32 _pad;
  1127. };
  1128. /* Input structure for the INFO ioctl */
  1129. struct drm_amdgpu_info {
  1130. /* Where the return value will be stored */
  1131. __u64 return_pointer;
  1132. /* The size of the return value. Just like "size" in "snprintf",
  1133. * it limits how many bytes the kernel can write. */
  1134. __u32 return_size;
  1135. /* The query request id. */
  1136. __u32 query;
  1137. union {
  1138. struct {
  1139. __u32 id;
  1140. __u32 _pad;
  1141. } mode_crtc;
  1142. struct {
  1143. /** AMDGPU_HW_IP_* */
  1144. __u32 type;
  1145. /**
  1146. * Index of the IP if there are more IPs of the same
  1147. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  1148. */
  1149. __u32 ip_instance;
  1150. } query_hw_ip;
  1151. struct {
  1152. __u32 dword_offset;
  1153. /** number of registers to read */
  1154. __u32 count;
  1155. __u32 instance;
  1156. /** For future use, no flags defined so far */
  1157. __u32 flags;
  1158. } read_mmr_reg;
  1159. struct drm_amdgpu_query_fw query_fw;
  1160. struct {
  1161. __u32 type;
  1162. __u32 offset;
  1163. } vbios_info;
  1164. struct {
  1165. __u32 type;
  1166. } sensor_info;
  1167. struct {
  1168. __u32 type;
  1169. } video_cap;
  1170. };
  1171. };
  1172. struct drm_amdgpu_info_gds {
  1173. /** GDS GFX partition size */
  1174. __u32 gds_gfx_partition_size;
  1175. /** GDS compute partition size */
  1176. __u32 compute_partition_size;
  1177. /** total GDS memory size */
  1178. __u32 gds_total_size;
  1179. /** GWS size per GFX partition */
  1180. __u32 gws_per_gfx_partition;
  1181. /** GSW size per compute partition */
  1182. __u32 gws_per_compute_partition;
  1183. /** OA size per GFX partition */
  1184. __u32 oa_per_gfx_partition;
  1185. /** OA size per compute partition */
  1186. __u32 oa_per_compute_partition;
  1187. __u32 _pad;
  1188. };
  1189. struct drm_amdgpu_info_vram_gtt {
  1190. __u64 vram_size;
  1191. __u64 vram_cpu_accessible_size;
  1192. __u64 gtt_size;
  1193. };
  1194. struct drm_amdgpu_heap_info {
  1195. /** max. physical memory */
  1196. __u64 total_heap_size;
  1197. /** Theoretical max. available memory in the given heap */
  1198. __u64 usable_heap_size;
  1199. /**
  1200. * Number of bytes allocated in the heap. This includes all processes
  1201. * and private allocations in the kernel. It changes when new buffers
  1202. * are allocated, freed, and moved. It cannot be larger than
  1203. * heap_size.
  1204. */
  1205. __u64 heap_usage;
  1206. /**
  1207. * Theoretical possible max. size of buffer which
  1208. * could be allocated in the given heap
  1209. */
  1210. __u64 max_allocation;
  1211. };
  1212. struct drm_amdgpu_memory_info {
  1213. struct drm_amdgpu_heap_info vram;
  1214. struct drm_amdgpu_heap_info cpu_accessible_vram;
  1215. struct drm_amdgpu_heap_info gtt;
  1216. };
  1217. struct drm_amdgpu_info_firmware {
  1218. __u32 ver;
  1219. __u32 feature;
  1220. };
  1221. struct drm_amdgpu_info_vbios {
  1222. __u8 name[64];
  1223. __u8 vbios_pn[64];
  1224. __u32 version;
  1225. __u32 pad;
  1226. __u8 vbios_ver_str[32];
  1227. __u8 date[32];
  1228. };
  1229. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  1230. #define AMDGPU_VRAM_TYPE_GDDR1 1
  1231. #define AMDGPU_VRAM_TYPE_DDR2 2
  1232. #define AMDGPU_VRAM_TYPE_GDDR3 3
  1233. #define AMDGPU_VRAM_TYPE_GDDR4 4
  1234. #define AMDGPU_VRAM_TYPE_GDDR5 5
  1235. #define AMDGPU_VRAM_TYPE_HBM 6
  1236. #define AMDGPU_VRAM_TYPE_DDR3 7
  1237. #define AMDGPU_VRAM_TYPE_DDR4 8
  1238. #define AMDGPU_VRAM_TYPE_GDDR6 9
  1239. #define AMDGPU_VRAM_TYPE_DDR5 10
  1240. #define AMDGPU_VRAM_TYPE_LPDDR4 11
  1241. #define AMDGPU_VRAM_TYPE_LPDDR5 12
  1242. struct drm_amdgpu_info_device {
  1243. /** PCI Device ID */
  1244. __u32 device_id;
  1245. /** Internal chip revision: A0, A1, etc.) */
  1246. __u32 chip_rev;
  1247. __u32 external_rev;
  1248. /** Revision id in PCI Config space */
  1249. __u32 pci_rev;
  1250. __u32 family;
  1251. __u32 num_shader_engines;
  1252. __u32 num_shader_arrays_per_engine;
  1253. /* in KHz */
  1254. __u32 gpu_counter_freq;
  1255. __u64 max_engine_clock;
  1256. __u64 max_memory_clock;
  1257. /* cu information */
  1258. __u32 cu_active_number;
  1259. /* NOTE: cu_ao_mask is INVALID, DON'T use it */
  1260. __u32 cu_ao_mask;
  1261. __u32 cu_bitmap[4][4];
  1262. /** Render backend pipe mask. One render backend is CB+DB. */
  1263. __u32 enabled_rb_pipes_mask;
  1264. __u32 num_rb_pipes;
  1265. __u32 num_hw_gfx_contexts;
  1266. /* PCIe version (the smaller of the GPU and the CPU/motherboard) */
  1267. __u32 pcie_gen;
  1268. __u64 ids_flags;
  1269. /** Starting virtual address for UMDs. */
  1270. __u64 virtual_address_offset;
  1271. /** The maximum virtual address */
  1272. __u64 virtual_address_max;
  1273. /** Required alignment of virtual addresses. */
  1274. __u32 virtual_address_alignment;
  1275. /** Page table entry - fragment size */
  1276. __u32 pte_fragment_size;
  1277. __u32 gart_page_size;
  1278. /** constant engine ram size*/
  1279. __u32 ce_ram_size;
  1280. /** video memory type info*/
  1281. __u32 vram_type;
  1282. /** video memory bit width*/
  1283. __u32 vram_bit_width;
  1284. /* vce harvesting instance */
  1285. __u32 vce_harvest_config;
  1286. /* gfx double offchip LDS buffers */
  1287. __u32 gc_double_offchip_lds_buf;
  1288. /* NGG Primitive Buffer */
  1289. __u64 prim_buf_gpu_addr;
  1290. /* NGG Position Buffer */
  1291. __u64 pos_buf_gpu_addr;
  1292. /* NGG Control Sideband */
  1293. __u64 cntl_sb_buf_gpu_addr;
  1294. /* NGG Parameter Cache */
  1295. __u64 param_buf_gpu_addr;
  1296. __u32 prim_buf_size;
  1297. __u32 pos_buf_size;
  1298. __u32 cntl_sb_buf_size;
  1299. __u32 param_buf_size;
  1300. /* wavefront size*/
  1301. __u32 wave_front_size;
  1302. /* shader visible vgprs*/
  1303. __u32 num_shader_visible_vgprs;
  1304. /* CU per shader array*/
  1305. __u32 num_cu_per_sh;
  1306. /* number of tcc blocks*/
  1307. __u32 num_tcc_blocks;
  1308. /* gs vgt table depth*/
  1309. __u32 gs_vgt_table_depth;
  1310. /* gs primitive buffer depth*/
  1311. __u32 gs_prim_buffer_depth;
  1312. /* max gs wavefront per vgt*/
  1313. __u32 max_gs_waves_per_vgt;
  1314. /* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
  1315. __u32 pcie_num_lanes;
  1316. /* always on cu bitmap */
  1317. __u32 cu_ao_bitmap[4][4];
  1318. /** Starting high virtual address for UMDs. */
  1319. __u64 high_va_offset;
  1320. /** The maximum high virtual address */
  1321. __u64 high_va_max;
  1322. /* gfx10 pa_sc_tile_steering_override */
  1323. __u32 pa_sc_tile_steering_override;
  1324. /* disabled TCCs */
  1325. __u64 tcc_disabled_mask;
  1326. __u64 min_engine_clock;
  1327. __u64 min_memory_clock;
  1328. /* The following fields are only set on gfx11+, older chips set 0. */
  1329. __u32 tcp_cache_size; /* AKA GL0, VMEM cache */
  1330. __u32 num_sqc_per_wgp;
  1331. __u32 sqc_data_cache_size; /* AKA SMEM cache */
  1332. __u32 sqc_inst_cache_size;
  1333. __u32 gl1c_cache_size;
  1334. __u32 gl2c_cache_size;
  1335. __u64 mall_size; /* AKA infinity cache */
  1336. /* high 32 bits of the rb pipes mask */
  1337. __u32 enabled_rb_pipes_mask_hi;
  1338. /* shadow area size for gfx11 */
  1339. __u32 shadow_size;
  1340. /* shadow area base virtual alignment for gfx11 */
  1341. __u32 shadow_alignment;
  1342. /* context save area size for gfx11 */
  1343. __u32 csa_size;
  1344. /* context save area base virtual alignment for gfx11 */
  1345. __u32 csa_alignment;
  1346. /* Userq IP mask (1 << AMDGPU_HW_IP_*) */
  1347. __u32 userq_ip_mask;
  1348. __u32 pad;
  1349. };
  1350. struct drm_amdgpu_info_hw_ip {
  1351. /** Version of h/w IP */
  1352. __u32 hw_ip_version_major;
  1353. __u32 hw_ip_version_minor;
  1354. /** Capabilities */
  1355. __u64 capabilities_flags;
  1356. /** command buffer address start alignment*/
  1357. __u32 ib_start_alignment;
  1358. /** command buffer size alignment*/
  1359. __u32 ib_size_alignment;
  1360. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  1361. __u32 available_rings;
  1362. /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
  1363. __u32 ip_discovery_version;
  1364. };
  1365. /* GFX metadata BO sizes and alignment info (in bytes) */
  1366. struct drm_amdgpu_info_uq_fw_areas_gfx {
  1367. /* shadow area size */
  1368. __u32 shadow_size;
  1369. /* shadow area base virtual mem alignment */
  1370. __u32 shadow_alignment;
  1371. /* context save area size */
  1372. __u32 csa_size;
  1373. /* context save area base virtual mem alignment */
  1374. __u32 csa_alignment;
  1375. };
  1376. /* IP specific metadata related information used in the
  1377. * subquery AMDGPU_INFO_UQ_FW_AREAS
  1378. */
  1379. struct drm_amdgpu_info_uq_fw_areas {
  1380. union {
  1381. struct drm_amdgpu_info_uq_fw_areas_gfx gfx;
  1382. };
  1383. };
  1384. struct drm_amdgpu_info_num_handles {
  1385. /** Max handles as supported by firmware for UVD */
  1386. __u32 uvd_max_handles;
  1387. /** Handles currently in use for UVD */
  1388. __u32 uvd_used_handles;
  1389. };
  1390. #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
  1391. struct drm_amdgpu_info_vce_clock_table_entry {
  1392. /** System clock */
  1393. __u32 sclk;
  1394. /** Memory clock */
  1395. __u32 mclk;
  1396. /** VCE clock */
  1397. __u32 eclk;
  1398. __u32 pad;
  1399. };
  1400. struct drm_amdgpu_info_vce_clock_table {
  1401. struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
  1402. __u32 num_valid_entries;
  1403. __u32 pad;
  1404. };
  1405. /* query video encode/decode caps */
  1406. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 0
  1407. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 1
  1408. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 2
  1409. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 3
  1410. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 4
  1411. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 5
  1412. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 6
  1413. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 7
  1414. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 8
  1415. struct drm_amdgpu_info_video_codec_info {
  1416. __u32 valid;
  1417. __u32 max_width;
  1418. __u32 max_height;
  1419. __u32 max_pixels_per_frame;
  1420. __u32 max_level;
  1421. __u32 pad;
  1422. };
  1423. struct drm_amdgpu_info_video_caps {
  1424. struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
  1425. };
  1426. #define AMDGPU_VMHUB_TYPE_MASK 0xff
  1427. #define AMDGPU_VMHUB_TYPE_SHIFT 0
  1428. #define AMDGPU_VMHUB_TYPE_GFX 0
  1429. #define AMDGPU_VMHUB_TYPE_MM0 1
  1430. #define AMDGPU_VMHUB_TYPE_MM1 2
  1431. #define AMDGPU_VMHUB_IDX_MASK 0xff00
  1432. #define AMDGPU_VMHUB_IDX_SHIFT 8
  1433. struct drm_amdgpu_info_gpuvm_fault {
  1434. __u64 addr;
  1435. __u32 status;
  1436. __u32 vmhub;
  1437. };
  1438. /*
  1439. * Supported GPU families
  1440. */
  1441. #define AMDGPU_FAMILY_UNKNOWN 0
  1442. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  1443. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  1444. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  1445. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  1446. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  1447. #define AMDGPU_FAMILY_AI 141 /* Vega10 */
  1448. #define AMDGPU_FAMILY_RV 142 /* Raven */
  1449. #define AMDGPU_FAMILY_NV 143 /* Navi10 */
  1450. #define AMDGPU_FAMILY_VGH 144 /* Van Gogh */
  1451. #define AMDGPU_FAMILY_GC_11_0_0 145 /* GC 11.0.0 */
  1452. #define AMDGPU_FAMILY_YC 146 /* Yellow Carp */
  1453. #define AMDGPU_FAMILY_GC_11_0_1 148 /* GC 11.0.1 */
  1454. #define AMDGPU_FAMILY_GC_10_3_6 149 /* GC 10.3.6 */
  1455. #define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */
  1456. #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */
  1457. #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */
  1458. #if defined(__cplusplus)
  1459. }
  1460. #endif
  1461. #endif