amdgpu_drm.h 37 KB

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