amdgpu_drm.h 40 KB

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