amdgpu_drm.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  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_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  54. #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
  55. #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
  56. #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
  57. #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
  58. #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
  59. #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
  60. #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
  61. #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
  62. #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
  63. #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
  64. #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
  65. #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
  66. #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
  67. #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
  68. #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
  69. /**
  70. * DOC: memory domains
  71. *
  72. * %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible.
  73. * Memory in this pool could be swapped out to disk if there is pressure.
  74. *
  75. * %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the
  76. * GPU's virtual address space via gart. Gart memory linearizes non-contiguous
  77. * pages of system memory, allows GPU access system memory in a linearized
  78. * fashion.
  79. *
  80. * %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory
  81. * carved out by the BIOS.
  82. *
  83. * %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data
  84. * across shader threads.
  85. *
  86. * %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the
  87. * execution of all the waves on a device.
  88. *
  89. * %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines
  90. * for appending data.
  91. *
  92. * %AMDGPU_GEM_DOMAIN_DOORBELL Doorbell. It is an MMIO region for
  93. * signalling user mode queues.
  94. */
  95. #define AMDGPU_GEM_DOMAIN_CPU 0x1
  96. #define AMDGPU_GEM_DOMAIN_GTT 0x2
  97. #define AMDGPU_GEM_DOMAIN_VRAM 0x4
  98. #define AMDGPU_GEM_DOMAIN_GDS 0x8
  99. #define AMDGPU_GEM_DOMAIN_GWS 0x10
  100. #define AMDGPU_GEM_DOMAIN_OA 0x20
  101. #define AMDGPU_GEM_DOMAIN_DOORBELL 0x40
  102. #define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \
  103. AMDGPU_GEM_DOMAIN_GTT | \
  104. AMDGPU_GEM_DOMAIN_VRAM | \
  105. AMDGPU_GEM_DOMAIN_GDS | \
  106. AMDGPU_GEM_DOMAIN_GWS | \
  107. AMDGPU_GEM_DOMAIN_OA | \
  108. AMDGPU_GEM_DOMAIN_DOORBELL)
  109. /* Flag that CPU access will be required for the case of VRAM domain */
  110. #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
  111. /* Flag that CPU access will not work, this VRAM domain is invisible */
  112. #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
  113. /* Flag that USWC attributes should be used for GTT */
  114. #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
  115. /* Flag that the memory should be in VRAM and cleared */
  116. #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
  117. /* Flag that allocating the BO should use linear VRAM */
  118. #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
  119. /* Flag that BO is always valid in this VM */
  120. #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
  121. /* Flag that BO sharing will be explicitly synchronized */
  122. #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)
  123. /* Flag that indicates allocating MQD gart on GFX9, where the mtype
  124. * for the second page onward should be set to NC. It should never
  125. * be used by user space applications.
  126. */
  127. #define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)
  128. /* Flag that BO may contain sensitive data that must be wiped before
  129. * releasing the memory
  130. */
  131. #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)
  132. /* Flag that BO will be encrypted and that the TMZ bit should be
  133. * set in the PTEs when mapping this buffer via GPUVM or
  134. * accessing it with various hw blocks
  135. */
  136. #define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)
  137. /* Flag that BO will be used only in preemptible context, which does
  138. * not require GTT memory accounting
  139. */
  140. #define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)
  141. /* Flag that BO can be discarded under memory pressure without keeping the
  142. * content.
  143. */
  144. #define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)
  145. /* Flag that BO is shared coherently between multiple devices or CPU threads.
  146. * May depend on GPU instructions to flush caches explicitly
  147. *
  148. * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
  149. * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
  150. */
  151. #define AMDGPU_GEM_CREATE_COHERENT (1 << 13)
  152. /* Flag that BO should not be cached by GPU. Coherent without having to flush
  153. * GPU caches explicitly
  154. *
  155. * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
  156. * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
  157. */
  158. #define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)
  159. struct drm_amdgpu_gem_create_in {
  160. /** the requested memory size */
  161. __u64 bo_size;
  162. /** physical start_addr alignment in bytes for some HW requirements */
  163. __u64 alignment;
  164. /** the requested memory domains */
  165. __u64 domains;
  166. /** allocation flags */
  167. __u64 domain_flags;
  168. };
  169. struct drm_amdgpu_gem_create_out {
  170. /** returned GEM object handle */
  171. __u32 handle;
  172. __u32 _pad;
  173. };
  174. union drm_amdgpu_gem_create {
  175. struct drm_amdgpu_gem_create_in in;
  176. struct drm_amdgpu_gem_create_out out;
  177. };
  178. /** Opcode to create new residency list. */
  179. #define AMDGPU_BO_LIST_OP_CREATE 0
  180. /** Opcode to destroy previously created residency list */
  181. #define AMDGPU_BO_LIST_OP_DESTROY 1
  182. /** Opcode to update resource information in the list */
  183. #define AMDGPU_BO_LIST_OP_UPDATE 2
  184. struct drm_amdgpu_bo_list_in {
  185. /** Type of operation */
  186. __u32 operation;
  187. /** Handle of list or 0 if we want to create one */
  188. __u32 list_handle;
  189. /** Number of BOs in list */
  190. __u32 bo_number;
  191. /** Size of each element describing BO */
  192. __u32 bo_info_size;
  193. /** Pointer to array describing BOs */
  194. __u64 bo_info_ptr;
  195. };
  196. struct drm_amdgpu_bo_list_entry {
  197. /** Handle of BO */
  198. __u32 bo_handle;
  199. /** New (if specified) BO priority to be used during migration */
  200. __u32 bo_priority;
  201. };
  202. struct drm_amdgpu_bo_list_out {
  203. /** Handle of resource list */
  204. __u32 list_handle;
  205. __u32 _pad;
  206. };
  207. union drm_amdgpu_bo_list {
  208. struct drm_amdgpu_bo_list_in in;
  209. struct drm_amdgpu_bo_list_out out;
  210. };
  211. /* context related */
  212. #define AMDGPU_CTX_OP_ALLOC_CTX 1
  213. #define AMDGPU_CTX_OP_FREE_CTX 2
  214. #define AMDGPU_CTX_OP_QUERY_STATE 3
  215. #define AMDGPU_CTX_OP_QUERY_STATE2 4
  216. #define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5
  217. #define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6
  218. /* GPU reset status */
  219. #define AMDGPU_CTX_NO_RESET 0
  220. /* this the context caused it */
  221. #define AMDGPU_CTX_GUILTY_RESET 1
  222. /* some other context caused it */
  223. #define AMDGPU_CTX_INNOCENT_RESET 2
  224. /* unknown cause */
  225. #define AMDGPU_CTX_UNKNOWN_RESET 3
  226. /* indicate gpu reset occured after ctx created */
  227. #define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)
  228. /* indicate vram lost occured after ctx created */
  229. #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
  230. /* indicate some job from this context once cause gpu hang */
  231. #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)
  232. /* indicate some errors are detected by RAS */
  233. #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)
  234. #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)
  235. /* indicate that the reset hasn't completed yet */
  236. #define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
  237. /* Context priority level */
  238. #define AMDGPU_CTX_PRIORITY_UNSET -2048
  239. #define AMDGPU_CTX_PRIORITY_VERY_LOW -1023
  240. #define AMDGPU_CTX_PRIORITY_LOW -512
  241. #define AMDGPU_CTX_PRIORITY_NORMAL 0
  242. /*
  243. * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
  244. * CAP_SYS_NICE or DRM_MASTER
  245. */
  246. #define AMDGPU_CTX_PRIORITY_HIGH 512
  247. #define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
  248. /* select a stable profiling pstate for perfmon tools */
  249. #define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf
  250. #define AMDGPU_CTX_STABLE_PSTATE_NONE 0
  251. #define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1
  252. #define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2
  253. #define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3
  254. #define AMDGPU_CTX_STABLE_PSTATE_PEAK 4
  255. struct drm_amdgpu_ctx_in {
  256. /** AMDGPU_CTX_OP_* */
  257. __u32 op;
  258. /** Flags */
  259. __u32 flags;
  260. __u32 ctx_id;
  261. /** AMDGPU_CTX_PRIORITY_* */
  262. __s32 priority;
  263. };
  264. union drm_amdgpu_ctx_out {
  265. struct {
  266. __u32 ctx_id;
  267. __u32 _pad;
  268. } alloc;
  269. struct {
  270. /** For future use, no flags defined so far */
  271. __u64 flags;
  272. /** Number of resets caused by this context so far. */
  273. __u32 hangs;
  274. /** Reset status since the last call of the ioctl. */
  275. __u32 reset_status;
  276. } state;
  277. struct {
  278. __u32 flags;
  279. __u32 _pad;
  280. } pstate;
  281. };
  282. union drm_amdgpu_ctx {
  283. struct drm_amdgpu_ctx_in in;
  284. union drm_amdgpu_ctx_out out;
  285. };
  286. /* vm ioctl */
  287. #define AMDGPU_VM_OP_RESERVE_VMID 1
  288. #define AMDGPU_VM_OP_UNRESERVE_VMID 2
  289. struct drm_amdgpu_vm_in {
  290. /** AMDGPU_VM_OP_* */
  291. __u32 op;
  292. __u32 flags;
  293. };
  294. struct drm_amdgpu_vm_out {
  295. /** For future use, no flags defined so far */
  296. __u64 flags;
  297. };
  298. union drm_amdgpu_vm {
  299. struct drm_amdgpu_vm_in in;
  300. struct drm_amdgpu_vm_out out;
  301. };
  302. /* sched ioctl */
  303. #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1
  304. #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2
  305. struct drm_amdgpu_sched_in {
  306. /* AMDGPU_SCHED_OP_* */
  307. __u32 op;
  308. __u32 fd;
  309. /** AMDGPU_CTX_PRIORITY_* */
  310. __s32 priority;
  311. __u32 ctx_id;
  312. };
  313. union drm_amdgpu_sched {
  314. struct drm_amdgpu_sched_in in;
  315. };
  316. /*
  317. * This is not a reliable API and you should expect it to fail for any
  318. * number of reasons and have fallback path that do not use userptr to
  319. * perform any operation.
  320. */
  321. #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
  322. #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
  323. #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
  324. #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
  325. struct drm_amdgpu_gem_userptr {
  326. __u64 addr;
  327. __u64 size;
  328. /* AMDGPU_GEM_USERPTR_* */
  329. __u32 flags;
  330. /* Resulting GEM handle */
  331. __u32 handle;
  332. };
  333. /* SI-CI-VI: */
  334. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  335. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  336. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  337. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  338. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  339. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  340. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  341. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  342. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  343. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  344. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  345. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  346. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  347. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  348. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  349. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  350. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  351. /* GFX9 and later: */
  352. #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0
  353. #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f
  354. #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5
  355. #define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF
  356. #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29
  357. #define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF
  358. #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43
  359. #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1
  360. #define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44
  361. #define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1
  362. #define AMDGPU_TILING_SCANOUT_SHIFT 63
  363. #define AMDGPU_TILING_SCANOUT_MASK 0x1
  364. /* Set/Get helpers for tiling flags. */
  365. #define AMDGPU_TILING_SET(field, value) \
  366. (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  367. #define AMDGPU_TILING_GET(value, field) \
  368. (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  369. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  370. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  371. /** The same structure is shared for input/output */
  372. struct drm_amdgpu_gem_metadata {
  373. /** GEM Object handle */
  374. __u32 handle;
  375. /** Do we want get or set metadata */
  376. __u32 op;
  377. struct {
  378. /** For future use, no flags defined so far */
  379. __u64 flags;
  380. /** family specific tiling info */
  381. __u64 tiling_info;
  382. __u32 data_size_bytes;
  383. __u32 data[64];
  384. } data;
  385. };
  386. struct drm_amdgpu_gem_mmap_in {
  387. /** the GEM object handle */
  388. __u32 handle;
  389. __u32 _pad;
  390. };
  391. struct drm_amdgpu_gem_mmap_out {
  392. /** mmap offset from the vma offset manager */
  393. __u64 addr_ptr;
  394. };
  395. union drm_amdgpu_gem_mmap {
  396. struct drm_amdgpu_gem_mmap_in in;
  397. struct drm_amdgpu_gem_mmap_out out;
  398. };
  399. struct drm_amdgpu_gem_wait_idle_in {
  400. /** GEM object handle */
  401. __u32 handle;
  402. /** For future use, no flags defined so far */
  403. __u32 flags;
  404. /** Absolute timeout to wait */
  405. __u64 timeout;
  406. };
  407. struct drm_amdgpu_gem_wait_idle_out {
  408. /** BO status: 0 - BO is idle, 1 - BO is busy */
  409. __u32 status;
  410. /** Returned current memory domain */
  411. __u32 domain;
  412. };
  413. union drm_amdgpu_gem_wait_idle {
  414. struct drm_amdgpu_gem_wait_idle_in in;
  415. struct drm_amdgpu_gem_wait_idle_out out;
  416. };
  417. struct drm_amdgpu_wait_cs_in {
  418. /* Command submission handle
  419. * handle equals 0 means none to wait for
  420. * handle equals ~0ull means wait for the latest sequence number
  421. */
  422. __u64 handle;
  423. /** Absolute timeout to wait */
  424. __u64 timeout;
  425. __u32 ip_type;
  426. __u32 ip_instance;
  427. __u32 ring;
  428. __u32 ctx_id;
  429. };
  430. struct drm_amdgpu_wait_cs_out {
  431. /** CS status: 0 - CS completed, 1 - CS still busy */
  432. __u64 status;
  433. };
  434. union drm_amdgpu_wait_cs {
  435. struct drm_amdgpu_wait_cs_in in;
  436. struct drm_amdgpu_wait_cs_out out;
  437. };
  438. struct drm_amdgpu_fence {
  439. __u32 ctx_id;
  440. __u32 ip_type;
  441. __u32 ip_instance;
  442. __u32 ring;
  443. __u64 seq_no;
  444. };
  445. struct drm_amdgpu_wait_fences_in {
  446. /** This points to uint64_t * which points to fences */
  447. __u64 fences;
  448. __u32 fence_count;
  449. __u32 wait_all;
  450. __u64 timeout_ns;
  451. };
  452. struct drm_amdgpu_wait_fences_out {
  453. __u32 status;
  454. __u32 first_signaled;
  455. };
  456. union drm_amdgpu_wait_fences {
  457. struct drm_amdgpu_wait_fences_in in;
  458. struct drm_amdgpu_wait_fences_out out;
  459. };
  460. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  461. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  462. /* Sets or returns a value associated with a buffer. */
  463. struct drm_amdgpu_gem_op {
  464. /** GEM object handle */
  465. __u32 handle;
  466. /** AMDGPU_GEM_OP_* */
  467. __u32 op;
  468. /** Input or return value */
  469. __u64 value;
  470. };
  471. #define AMDGPU_VA_OP_MAP 1
  472. #define AMDGPU_VA_OP_UNMAP 2
  473. #define AMDGPU_VA_OP_CLEAR 3
  474. #define AMDGPU_VA_OP_REPLACE 4
  475. /* Delay the page table update till the next CS */
  476. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  477. /* Mapping flags */
  478. /* readable mapping */
  479. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  480. /* writable mapping */
  481. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  482. /* executable mapping, new for VI */
  483. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  484. /* partially resident texture */
  485. #define AMDGPU_VM_PAGE_PRT (1 << 4)
  486. /* MTYPE flags use bit 5 to 8 */
  487. #define AMDGPU_VM_MTYPE_MASK (0xf << 5)
  488. /* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */
  489. #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
  490. /* Use Non Coherent MTYPE instead of default MTYPE */
  491. #define AMDGPU_VM_MTYPE_NC (1 << 5)
  492. /* Use Write Combine MTYPE instead of default MTYPE */
  493. #define AMDGPU_VM_MTYPE_WC (2 << 5)
  494. /* Use Cache Coherent MTYPE instead of default MTYPE */
  495. #define AMDGPU_VM_MTYPE_CC (3 << 5)
  496. /* Use UnCached MTYPE instead of default MTYPE */
  497. #define AMDGPU_VM_MTYPE_UC (4 << 5)
  498. /* Use Read Write MTYPE instead of default MTYPE */
  499. #define AMDGPU_VM_MTYPE_RW (5 << 5)
  500. /* don't allocate MALL */
  501. #define AMDGPU_VM_PAGE_NOALLOC (1 << 9)
  502. struct drm_amdgpu_gem_va {
  503. /** GEM object handle */
  504. __u32 handle;
  505. __u32 _pad;
  506. /** AMDGPU_VA_OP_* */
  507. __u32 operation;
  508. /** AMDGPU_VM_PAGE_* */
  509. __u32 flags;
  510. /** va address to assign . Must be correctly aligned.*/
  511. __u64 va_address;
  512. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  513. __u64 offset_in_bo;
  514. /** Specify mapping size. Must be correctly aligned. */
  515. __u64 map_size;
  516. };
  517. #define AMDGPU_HW_IP_GFX 0
  518. #define AMDGPU_HW_IP_COMPUTE 1
  519. #define AMDGPU_HW_IP_DMA 2
  520. #define AMDGPU_HW_IP_UVD 3
  521. #define AMDGPU_HW_IP_VCE 4
  522. #define AMDGPU_HW_IP_UVD_ENC 5
  523. #define AMDGPU_HW_IP_VCN_DEC 6
  524. /*
  525. * From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support
  526. * both encoding and decoding jobs.
  527. */
  528. #define AMDGPU_HW_IP_VCN_ENC 7
  529. #define AMDGPU_HW_IP_VCN_JPEG 8
  530. #define AMDGPU_HW_IP_NUM 9
  531. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  532. #define AMDGPU_CHUNK_ID_IB 0x01
  533. #define AMDGPU_CHUNK_ID_FENCE 0x02
  534. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  535. #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04
  536. #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05
  537. #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06
  538. #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
  539. #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08
  540. #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09
  541. #define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a
  542. struct drm_amdgpu_cs_chunk {
  543. __u32 chunk_id;
  544. __u32 length_dw;
  545. __u64 chunk_data;
  546. };
  547. struct drm_amdgpu_cs_in {
  548. /** Rendering context id */
  549. __u32 ctx_id;
  550. /** Handle of resource list associated with CS */
  551. __u32 bo_list_handle;
  552. __u32 num_chunks;
  553. __u32 flags;
  554. /** this points to __u64 * which point to cs chunks */
  555. __u64 chunks;
  556. };
  557. struct drm_amdgpu_cs_out {
  558. __u64 handle;
  559. };
  560. union drm_amdgpu_cs {
  561. struct drm_amdgpu_cs_in in;
  562. struct drm_amdgpu_cs_out out;
  563. };
  564. /* Specify flags to be used for IB */
  565. /* This IB should be submitted to CE */
  566. #define AMDGPU_IB_FLAG_CE (1<<0)
  567. /* Preamble flag, which means the IB could be dropped if no context switch */
  568. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  569. /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
  570. #define AMDGPU_IB_FLAG_PREEMPT (1<<2)
  571. /* The IB fence should do the L2 writeback but not invalidate any shader
  572. * caches (L2/vL1/sL1/I$). */
  573. #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
  574. /* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.
  575. * This will reset wave ID counters for the IB.
  576. */
  577. #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
  578. /* Flag the IB as secure (TMZ)
  579. */
  580. #define AMDGPU_IB_FLAGS_SECURE (1 << 5)
  581. /* Tell KMD to flush and invalidate caches
  582. */
  583. #define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)
  584. struct drm_amdgpu_cs_chunk_ib {
  585. __u32 _pad;
  586. /** AMDGPU_IB_FLAG_* */
  587. __u32 flags;
  588. /** Virtual address to begin IB execution */
  589. __u64 va_start;
  590. /** Size of submission */
  591. __u32 ib_bytes;
  592. /** HW IP to submit to */
  593. __u32 ip_type;
  594. /** HW IP index of the same type to submit to */
  595. __u32 ip_instance;
  596. /** Ring index to submit to */
  597. __u32 ring;
  598. };
  599. struct drm_amdgpu_cs_chunk_dep {
  600. __u32 ip_type;
  601. __u32 ip_instance;
  602. __u32 ring;
  603. __u32 ctx_id;
  604. __u64 handle;
  605. };
  606. struct drm_amdgpu_cs_chunk_fence {
  607. __u32 handle;
  608. __u32 offset;
  609. };
  610. struct drm_amdgpu_cs_chunk_sem {
  611. __u32 handle;
  612. };
  613. struct drm_amdgpu_cs_chunk_syncobj {
  614. __u32 handle;
  615. __u32 flags;
  616. __u64 point;
  617. };
  618. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0
  619. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1
  620. #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
  621. union drm_amdgpu_fence_to_handle {
  622. struct {
  623. struct drm_amdgpu_fence fence;
  624. __u32 what;
  625. __u32 pad;
  626. } in;
  627. struct {
  628. __u32 handle;
  629. } out;
  630. };
  631. struct drm_amdgpu_cs_chunk_data {
  632. union {
  633. struct drm_amdgpu_cs_chunk_ib ib_data;
  634. struct drm_amdgpu_cs_chunk_fence fence_data;
  635. };
  636. };
  637. #define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x1
  638. struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
  639. __u64 shadow_va;
  640. __u64 csa_va;
  641. __u64 gds_va;
  642. __u64 flags;
  643. };
  644. /*
  645. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  646. *
  647. */
  648. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  649. #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
  650. #define AMDGPU_IDS_FLAGS_TMZ 0x4
  651. #define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
  652. /* indicate if acceleration can be working */
  653. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  654. /* get the crtc_id from the mode object id? */
  655. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  656. /* query hw IP info */
  657. #define AMDGPU_INFO_HW_IP_INFO 0x02
  658. /* query hw IP instance count for the specified type */
  659. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  660. /* timestamp for GL_ARB_timer_query */
  661. #define AMDGPU_INFO_TIMESTAMP 0x05
  662. /* Query the firmware version */
  663. #define AMDGPU_INFO_FW_VERSION 0x0e
  664. /* Subquery id: Query VCE firmware version */
  665. #define AMDGPU_INFO_FW_VCE 0x1
  666. /* Subquery id: Query UVD firmware version */
  667. #define AMDGPU_INFO_FW_UVD 0x2
  668. /* Subquery id: Query GMC firmware version */
  669. #define AMDGPU_INFO_FW_GMC 0x03
  670. /* Subquery id: Query GFX ME firmware version */
  671. #define AMDGPU_INFO_FW_GFX_ME 0x04
  672. /* Subquery id: Query GFX PFP firmware version */
  673. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  674. /* Subquery id: Query GFX CE firmware version */
  675. #define AMDGPU_INFO_FW_GFX_CE 0x06
  676. /* Subquery id: Query GFX RLC firmware version */
  677. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  678. /* Subquery id: Query GFX MEC firmware version */
  679. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  680. /* Subquery id: Query SMC firmware version */
  681. #define AMDGPU_INFO_FW_SMC 0x0a
  682. /* Subquery id: Query SDMA firmware version */
  683. #define AMDGPU_INFO_FW_SDMA 0x0b
  684. /* Subquery id: Query PSP SOS firmware version */
  685. #define AMDGPU_INFO_FW_SOS 0x0c
  686. /* Subquery id: Query PSP ASD firmware version */
  687. #define AMDGPU_INFO_FW_ASD 0x0d
  688. /* Subquery id: Query VCN firmware version */
  689. #define AMDGPU_INFO_FW_VCN 0x0e
  690. /* Subquery id: Query GFX RLC SRLC firmware version */
  691. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
  692. /* Subquery id: Query GFX RLC SRLG firmware version */
  693. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
  694. /* Subquery id: Query GFX RLC SRLS firmware version */
  695. #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
  696. /* Subquery id: Query DMCU firmware version */
  697. #define AMDGPU_INFO_FW_DMCU 0x12
  698. #define AMDGPU_INFO_FW_TA 0x13
  699. /* Subquery id: Query DMCUB firmware version */
  700. #define AMDGPU_INFO_FW_DMCUB 0x14
  701. /* Subquery id: Query TOC firmware version */
  702. #define AMDGPU_INFO_FW_TOC 0x15
  703. /* Subquery id: Query CAP firmware version */
  704. #define AMDGPU_INFO_FW_CAP 0x16
  705. /* Subquery id: Query GFX RLCP firmware version */
  706. #define AMDGPU_INFO_FW_GFX_RLCP 0x17
  707. /* Subquery id: Query GFX RLCV firmware version */
  708. #define AMDGPU_INFO_FW_GFX_RLCV 0x18
  709. /* Subquery id: Query MES_KIQ firmware version */
  710. #define AMDGPU_INFO_FW_MES_KIQ 0x19
  711. /* Subquery id: Query MES firmware version */
  712. #define AMDGPU_INFO_FW_MES 0x1a
  713. /* Subquery id: Query IMU firmware version */
  714. #define AMDGPU_INFO_FW_IMU 0x1b
  715. /* number of bytes moved for TTM migration */
  716. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  717. /* the used VRAM size */
  718. #define AMDGPU_INFO_VRAM_USAGE 0x10
  719. /* the used GTT size */
  720. #define AMDGPU_INFO_GTT_USAGE 0x11
  721. /* Information about GDS, etc. resource configuration */
  722. #define AMDGPU_INFO_GDS_CONFIG 0x13
  723. /* Query information about VRAM and GTT domains */
  724. #define AMDGPU_INFO_VRAM_GTT 0x14
  725. /* Query information about register in MMR address space*/
  726. #define AMDGPU_INFO_READ_MMR_REG 0x15
  727. /* Query information about device: rev id, family, etc. */
  728. #define AMDGPU_INFO_DEV_INFO 0x16
  729. /* visible vram usage */
  730. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  731. /* number of TTM buffer evictions */
  732. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  733. /* Query memory about VRAM and GTT domains */
  734. #define AMDGPU_INFO_MEMORY 0x19
  735. /* Query vce clock table */
  736. #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
  737. /* Query vbios related information */
  738. #define AMDGPU_INFO_VBIOS 0x1B
  739. /* Subquery id: Query vbios size */
  740. #define AMDGPU_INFO_VBIOS_SIZE 0x1
  741. /* Subquery id: Query vbios image */
  742. #define AMDGPU_INFO_VBIOS_IMAGE 0x2
  743. /* Subquery id: Query vbios info */
  744. #define AMDGPU_INFO_VBIOS_INFO 0x3
  745. /* Query UVD handles */
  746. #define AMDGPU_INFO_NUM_HANDLES 0x1C
  747. /* Query sensor related information */
  748. #define AMDGPU_INFO_SENSOR 0x1D
  749. /* Subquery id: Query GPU shader clock */
  750. #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
  751. /* Subquery id: Query GPU memory clock */
  752. #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
  753. /* Subquery id: Query GPU temperature */
  754. #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
  755. /* Subquery id: Query GPU load */
  756. #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
  757. /* Subquery id: Query average GPU power */
  758. #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
  759. /* Subquery id: Query northbridge voltage */
  760. #define AMDGPU_INFO_SENSOR_VDDNB 0x6
  761. /* Subquery id: Query graphics voltage */
  762. #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
  763. /* Subquery id: Query GPU stable pstate shader clock */
  764. #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8
  765. /* Subquery id: Query GPU stable pstate memory clock */
  766. #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
  767. /* Subquery id: Query GPU peak pstate shader clock */
  768. #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa
  769. /* Subquery id: Query GPU peak pstate memory clock */
  770. #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb
  771. /* Number of VRAM page faults on CPU access. */
  772. #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
  773. #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
  774. /* query ras mask of enabled features*/
  775. #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20
  776. /* RAS MASK: UMC (VRAM) */
  777. #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)
  778. /* RAS MASK: SDMA */
  779. #define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)
  780. /* RAS MASK: GFX */
  781. #define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)
  782. /* RAS MASK: MMHUB */
  783. #define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)
  784. /* RAS MASK: ATHUB */
  785. #define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)
  786. /* RAS MASK: PCIE */
  787. #define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)
  788. /* RAS MASK: HDP */
  789. #define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)
  790. /* RAS MASK: XGMI */
  791. #define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)
  792. /* RAS MASK: DF */
  793. #define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)
  794. /* RAS MASK: SMN */
  795. #define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)
  796. /* RAS MASK: SEM */
  797. #define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)
  798. /* RAS MASK: MP0 */
  799. #define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)
  800. /* RAS MASK: MP1 */
  801. #define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)
  802. /* RAS MASK: FUSE */
  803. #define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)
  804. /* query video encode/decode caps */
  805. #define AMDGPU_INFO_VIDEO_CAPS 0x21
  806. /* Subquery id: Decode */
  807. #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0
  808. /* Subquery id: Encode */
  809. #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1
  810. /* Query the max number of IBs per gang per submission */
  811. #define AMDGPU_INFO_MAX_IBS 0x22
  812. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  813. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  814. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  815. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  816. struct drm_amdgpu_query_fw {
  817. /** AMDGPU_INFO_FW_* */
  818. __u32 fw_type;
  819. /**
  820. * Index of the IP if there are more IPs of
  821. * the same type.
  822. */
  823. __u32 ip_instance;
  824. /**
  825. * Index of the engine. Whether this is used depends
  826. * on the firmware type. (e.g. MEC, SDMA)
  827. */
  828. __u32 index;
  829. __u32 _pad;
  830. };
  831. /* Input structure for the INFO ioctl */
  832. struct drm_amdgpu_info {
  833. /* Where the return value will be stored */
  834. __u64 return_pointer;
  835. /* The size of the return value. Just like "size" in "snprintf",
  836. * it limits how many bytes the kernel can write. */
  837. __u32 return_size;
  838. /* The query request id. */
  839. __u32 query;
  840. union {
  841. struct {
  842. __u32 id;
  843. __u32 _pad;
  844. } mode_crtc;
  845. struct {
  846. /** AMDGPU_HW_IP_* */
  847. __u32 type;
  848. /**
  849. * Index of the IP if there are more IPs of the same
  850. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  851. */
  852. __u32 ip_instance;
  853. } query_hw_ip;
  854. struct {
  855. __u32 dword_offset;
  856. /** number of registers to read */
  857. __u32 count;
  858. __u32 instance;
  859. /** For future use, no flags defined so far */
  860. __u32 flags;
  861. } read_mmr_reg;
  862. struct drm_amdgpu_query_fw query_fw;
  863. struct {
  864. __u32 type;
  865. __u32 offset;
  866. } vbios_info;
  867. struct {
  868. __u32 type;
  869. } sensor_info;
  870. struct {
  871. __u32 type;
  872. } video_cap;
  873. };
  874. };
  875. struct drm_amdgpu_info_gds {
  876. /** GDS GFX partition size */
  877. __u32 gds_gfx_partition_size;
  878. /** GDS compute partition size */
  879. __u32 compute_partition_size;
  880. /** total GDS memory size */
  881. __u32 gds_total_size;
  882. /** GWS size per GFX partition */
  883. __u32 gws_per_gfx_partition;
  884. /** GSW size per compute partition */
  885. __u32 gws_per_compute_partition;
  886. /** OA size per GFX partition */
  887. __u32 oa_per_gfx_partition;
  888. /** OA size per compute partition */
  889. __u32 oa_per_compute_partition;
  890. __u32 _pad;
  891. };
  892. struct drm_amdgpu_info_vram_gtt {
  893. __u64 vram_size;
  894. __u64 vram_cpu_accessible_size;
  895. __u64 gtt_size;
  896. };
  897. struct drm_amdgpu_heap_info {
  898. /** max. physical memory */
  899. __u64 total_heap_size;
  900. /** Theoretical max. available memory in the given heap */
  901. __u64 usable_heap_size;
  902. /**
  903. * Number of bytes allocated in the heap. This includes all processes
  904. * and private allocations in the kernel. It changes when new buffers
  905. * are allocated, freed, and moved. It cannot be larger than
  906. * heap_size.
  907. */
  908. __u64 heap_usage;
  909. /**
  910. * Theoretical possible max. size of buffer which
  911. * could be allocated in the given heap
  912. */
  913. __u64 max_allocation;
  914. };
  915. struct drm_amdgpu_memory_info {
  916. struct drm_amdgpu_heap_info vram;
  917. struct drm_amdgpu_heap_info cpu_accessible_vram;
  918. struct drm_amdgpu_heap_info gtt;
  919. };
  920. struct drm_amdgpu_info_firmware {
  921. __u32 ver;
  922. __u32 feature;
  923. };
  924. struct drm_amdgpu_info_vbios {
  925. __u8 name[64];
  926. __u8 vbios_pn[64];
  927. __u32 version;
  928. __u32 pad;
  929. __u8 vbios_ver_str[32];
  930. __u8 date[32];
  931. };
  932. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  933. #define AMDGPU_VRAM_TYPE_GDDR1 1
  934. #define AMDGPU_VRAM_TYPE_DDR2 2
  935. #define AMDGPU_VRAM_TYPE_GDDR3 3
  936. #define AMDGPU_VRAM_TYPE_GDDR4 4
  937. #define AMDGPU_VRAM_TYPE_GDDR5 5
  938. #define AMDGPU_VRAM_TYPE_HBM 6
  939. #define AMDGPU_VRAM_TYPE_DDR3 7
  940. #define AMDGPU_VRAM_TYPE_DDR4 8
  941. #define AMDGPU_VRAM_TYPE_GDDR6 9
  942. #define AMDGPU_VRAM_TYPE_DDR5 10
  943. #define AMDGPU_VRAM_TYPE_LPDDR4 11
  944. #define AMDGPU_VRAM_TYPE_LPDDR5 12
  945. struct drm_amdgpu_info_device {
  946. /** PCI Device ID */
  947. __u32 device_id;
  948. /** Internal chip revision: A0, A1, etc.) */
  949. __u32 chip_rev;
  950. __u32 external_rev;
  951. /** Revision id in PCI Config space */
  952. __u32 pci_rev;
  953. __u32 family;
  954. __u32 num_shader_engines;
  955. __u32 num_shader_arrays_per_engine;
  956. /* in KHz */
  957. __u32 gpu_counter_freq;
  958. __u64 max_engine_clock;
  959. __u64 max_memory_clock;
  960. /* cu information */
  961. __u32 cu_active_number;
  962. /* NOTE: cu_ao_mask is INVALID, DON'T use it */
  963. __u32 cu_ao_mask;
  964. __u32 cu_bitmap[4][4];
  965. /** Render backend pipe mask. One render backend is CB+DB. */
  966. __u32 enabled_rb_pipes_mask;
  967. __u32 num_rb_pipes;
  968. __u32 num_hw_gfx_contexts;
  969. /* PCIe version (the smaller of the GPU and the CPU/motherboard) */
  970. __u32 pcie_gen;
  971. __u64 ids_flags;
  972. /** Starting virtual address for UMDs. */
  973. __u64 virtual_address_offset;
  974. /** The maximum virtual address */
  975. __u64 virtual_address_max;
  976. /** Required alignment of virtual addresses. */
  977. __u32 virtual_address_alignment;
  978. /** Page table entry - fragment size */
  979. __u32 pte_fragment_size;
  980. __u32 gart_page_size;
  981. /** constant engine ram size*/
  982. __u32 ce_ram_size;
  983. /** video memory type info*/
  984. __u32 vram_type;
  985. /** video memory bit width*/
  986. __u32 vram_bit_width;
  987. /* vce harvesting instance */
  988. __u32 vce_harvest_config;
  989. /* gfx double offchip LDS buffers */
  990. __u32 gc_double_offchip_lds_buf;
  991. /* NGG Primitive Buffer */
  992. __u64 prim_buf_gpu_addr;
  993. /* NGG Position Buffer */
  994. __u64 pos_buf_gpu_addr;
  995. /* NGG Control Sideband */
  996. __u64 cntl_sb_buf_gpu_addr;
  997. /* NGG Parameter Cache */
  998. __u64 param_buf_gpu_addr;
  999. __u32 prim_buf_size;
  1000. __u32 pos_buf_size;
  1001. __u32 cntl_sb_buf_size;
  1002. __u32 param_buf_size;
  1003. /* wavefront size*/
  1004. __u32 wave_front_size;
  1005. /* shader visible vgprs*/
  1006. __u32 num_shader_visible_vgprs;
  1007. /* CU per shader array*/
  1008. __u32 num_cu_per_sh;
  1009. /* number of tcc blocks*/
  1010. __u32 num_tcc_blocks;
  1011. /* gs vgt table depth*/
  1012. __u32 gs_vgt_table_depth;
  1013. /* gs primitive buffer depth*/
  1014. __u32 gs_prim_buffer_depth;
  1015. /* max gs wavefront per vgt*/
  1016. __u32 max_gs_waves_per_vgt;
  1017. /* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
  1018. __u32 pcie_num_lanes;
  1019. /* always on cu bitmap */
  1020. __u32 cu_ao_bitmap[4][4];
  1021. /** Starting high virtual address for UMDs. */
  1022. __u64 high_va_offset;
  1023. /** The maximum high virtual address */
  1024. __u64 high_va_max;
  1025. /* gfx10 pa_sc_tile_steering_override */
  1026. __u32 pa_sc_tile_steering_override;
  1027. /* disabled TCCs */
  1028. __u64 tcc_disabled_mask;
  1029. __u64 min_engine_clock;
  1030. __u64 min_memory_clock;
  1031. /* The following fields are only set on gfx11+, older chips set 0. */
  1032. __u32 tcp_cache_size; /* AKA GL0, VMEM cache */
  1033. __u32 num_sqc_per_wgp;
  1034. __u32 sqc_data_cache_size; /* AKA SMEM cache */
  1035. __u32 sqc_inst_cache_size;
  1036. __u32 gl1c_cache_size;
  1037. __u32 gl2c_cache_size;
  1038. __u64 mall_size; /* AKA infinity cache */
  1039. /* high 32 bits of the rb pipes mask */
  1040. __u32 enabled_rb_pipes_mask_hi;
  1041. /* shadow area size for gfx11 */
  1042. __u32 shadow_size;
  1043. /* shadow area base virtual alignment for gfx11 */
  1044. __u32 shadow_alignment;
  1045. /* context save area size for gfx11 */
  1046. __u32 csa_size;
  1047. /* context save area base virtual alignment for gfx11 */
  1048. __u32 csa_alignment;
  1049. };
  1050. struct drm_amdgpu_info_hw_ip {
  1051. /** Version of h/w IP */
  1052. __u32 hw_ip_version_major;
  1053. __u32 hw_ip_version_minor;
  1054. /** Capabilities */
  1055. __u64 capabilities_flags;
  1056. /** command buffer address start alignment*/
  1057. __u32 ib_start_alignment;
  1058. /** command buffer size alignment*/
  1059. __u32 ib_size_alignment;
  1060. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  1061. __u32 available_rings;
  1062. /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
  1063. __u32 ip_discovery_version;
  1064. };
  1065. struct drm_amdgpu_info_num_handles {
  1066. /** Max handles as supported by firmware for UVD */
  1067. __u32 uvd_max_handles;
  1068. /** Handles currently in use for UVD */
  1069. __u32 uvd_used_handles;
  1070. };
  1071. #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
  1072. struct drm_amdgpu_info_vce_clock_table_entry {
  1073. /** System clock */
  1074. __u32 sclk;
  1075. /** Memory clock */
  1076. __u32 mclk;
  1077. /** VCE clock */
  1078. __u32 eclk;
  1079. __u32 pad;
  1080. };
  1081. struct drm_amdgpu_info_vce_clock_table {
  1082. struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
  1083. __u32 num_valid_entries;
  1084. __u32 pad;
  1085. };
  1086. /* query video encode/decode caps */
  1087. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 0
  1088. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 1
  1089. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 2
  1090. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 3
  1091. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 4
  1092. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 5
  1093. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 6
  1094. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 7
  1095. #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 8
  1096. struct drm_amdgpu_info_video_codec_info {
  1097. __u32 valid;
  1098. __u32 max_width;
  1099. __u32 max_height;
  1100. __u32 max_pixels_per_frame;
  1101. __u32 max_level;
  1102. __u32 pad;
  1103. };
  1104. struct drm_amdgpu_info_video_caps {
  1105. struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
  1106. };
  1107. /*
  1108. * Supported GPU families
  1109. */
  1110. #define AMDGPU_FAMILY_UNKNOWN 0
  1111. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  1112. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  1113. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  1114. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  1115. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  1116. #define AMDGPU_FAMILY_AI 141 /* Vega10 */
  1117. #define AMDGPU_FAMILY_RV 142 /* Raven */
  1118. #define AMDGPU_FAMILY_NV 143 /* Navi10 */
  1119. #define AMDGPU_FAMILY_VGH 144 /* Van Gogh */
  1120. #define AMDGPU_FAMILY_GC_11_0_0 145 /* GC 11.0.0 */
  1121. #define AMDGPU_FAMILY_YC 146 /* Yellow Carp */
  1122. #define AMDGPU_FAMILY_GC_11_0_1 148 /* GC 11.0.1 */
  1123. #define AMDGPU_FAMILY_GC_10_3_6 149 /* GC 10.3.6 */
  1124. #define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */
  1125. #if defined(__cplusplus)
  1126. }
  1127. #endif
  1128. #endif