amdgpu_drm.h 51 KB

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