amdgpu_drm.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  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_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  52. #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
  53. #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
  54. #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
  55. #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
  56. #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
  57. #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
  58. #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
  59. #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
  60. #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
  61. #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
  62. #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
  63. #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
  64. #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
  65. #define AMDGPU_GEM_DOMAIN_CPU 0x1
  66. #define AMDGPU_GEM_DOMAIN_GTT 0x2
  67. #define AMDGPU_GEM_DOMAIN_VRAM 0x4
  68. #define AMDGPU_GEM_DOMAIN_GDS 0x8
  69. #define AMDGPU_GEM_DOMAIN_GWS 0x10
  70. #define AMDGPU_GEM_DOMAIN_OA 0x20
  71. /* Flag that CPU access will be required for the case of VRAM domain */
  72. #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
  73. /* Flag that CPU access will not work, this VRAM domain is invisible */
  74. #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
  75. /* Flag that USWC attributes should be used for GTT */
  76. #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
  77. /* Flag that the memory should be in VRAM and cleared */
  78. #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
  79. /* Flag that create shadow bo(GTT) while allocating vram bo */
  80. #define AMDGPU_GEM_CREATE_SHADOW (1 << 4)
  81. /* Flag that allocating the BO should use linear VRAM */
  82. #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
  83. struct drm_amdgpu_gem_create_in {
  84. /** the requested memory size */
  85. __u64 bo_size;
  86. /** physical start_addr alignment in bytes for some HW requirements */
  87. __u64 alignment;
  88. /** the requested memory domains */
  89. __u64 domains;
  90. /** allocation flags */
  91. __u64 domain_flags;
  92. };
  93. struct drm_amdgpu_gem_create_out {
  94. /** returned GEM object handle */
  95. __u32 handle;
  96. __u32 _pad;
  97. };
  98. union drm_amdgpu_gem_create {
  99. struct drm_amdgpu_gem_create_in in;
  100. struct drm_amdgpu_gem_create_out out;
  101. };
  102. /** Opcode to create new residency list. */
  103. #define AMDGPU_BO_LIST_OP_CREATE 0
  104. /** Opcode to destroy previously created residency list */
  105. #define AMDGPU_BO_LIST_OP_DESTROY 1
  106. /** Opcode to update resource information in the list */
  107. #define AMDGPU_BO_LIST_OP_UPDATE 2
  108. struct drm_amdgpu_bo_list_in {
  109. /** Type of operation */
  110. __u32 operation;
  111. /** Handle of list or 0 if we want to create one */
  112. __u32 list_handle;
  113. /** Number of BOs in list */
  114. __u32 bo_number;
  115. /** Size of each element describing BO */
  116. __u32 bo_info_size;
  117. /** Pointer to array describing BOs */
  118. __u64 bo_info_ptr;
  119. };
  120. struct drm_amdgpu_bo_list_entry {
  121. /** Handle of BO */
  122. __u32 bo_handle;
  123. /** New (if specified) BO priority to be used during migration */
  124. __u32 bo_priority;
  125. };
  126. struct drm_amdgpu_bo_list_out {
  127. /** Handle of resource list */
  128. __u32 list_handle;
  129. __u32 _pad;
  130. };
  131. union drm_amdgpu_bo_list {
  132. struct drm_amdgpu_bo_list_in in;
  133. struct drm_amdgpu_bo_list_out out;
  134. };
  135. /* context related */
  136. #define AMDGPU_CTX_OP_ALLOC_CTX 1
  137. #define AMDGPU_CTX_OP_FREE_CTX 2
  138. #define AMDGPU_CTX_OP_QUERY_STATE 3
  139. /* GPU reset status */
  140. #define AMDGPU_CTX_NO_RESET 0
  141. /* this the context caused it */
  142. #define AMDGPU_CTX_GUILTY_RESET 1
  143. /* some other context caused it */
  144. #define AMDGPU_CTX_INNOCENT_RESET 2
  145. /* unknown cause */
  146. #define AMDGPU_CTX_UNKNOWN_RESET 3
  147. struct drm_amdgpu_ctx_in {
  148. /** AMDGPU_CTX_OP_* */
  149. __u32 op;
  150. /** For future use, no flags defined so far */
  151. __u32 flags;
  152. __u32 ctx_id;
  153. __u32 _pad;
  154. };
  155. union drm_amdgpu_ctx_out {
  156. struct {
  157. __u32 ctx_id;
  158. __u32 _pad;
  159. } alloc;
  160. struct {
  161. /** For future use, no flags defined so far */
  162. __u64 flags;
  163. /** Number of resets caused by this context so far. */
  164. __u32 hangs;
  165. /** Reset status since the last call of the ioctl. */
  166. __u32 reset_status;
  167. } state;
  168. };
  169. union drm_amdgpu_ctx {
  170. struct drm_amdgpu_ctx_in in;
  171. union drm_amdgpu_ctx_out out;
  172. };
  173. /* vm ioctl */
  174. #define AMDGPU_VM_OP_RESERVE_VMID 1
  175. #define AMDGPU_VM_OP_UNRESERVE_VMID 2
  176. struct drm_amdgpu_vm_in {
  177. /** AMDGPU_VM_OP_* */
  178. __u32 op;
  179. __u32 flags;
  180. };
  181. struct drm_amdgpu_vm_out {
  182. /** For future use, no flags defined so far */
  183. __u64 flags;
  184. };
  185. union drm_amdgpu_vm {
  186. struct drm_amdgpu_vm_in in;
  187. struct drm_amdgpu_vm_out out;
  188. };
  189. /*
  190. * This is not a reliable API and you should expect it to fail for any
  191. * number of reasons and have fallback path that do not use userptr to
  192. * perform any operation.
  193. */
  194. #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
  195. #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
  196. #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
  197. #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
  198. struct drm_amdgpu_gem_userptr {
  199. __u64 addr;
  200. __u64 size;
  201. /* AMDGPU_GEM_USERPTR_* */
  202. __u32 flags;
  203. /* Resulting GEM handle */
  204. __u32 handle;
  205. };
  206. /* SI-CI-VI: */
  207. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  208. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  209. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  210. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  211. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  212. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  213. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  214. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  215. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  216. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  217. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  218. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  219. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  220. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  221. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  222. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  223. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  224. /* GFX9 and later: */
  225. #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0
  226. #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f
  227. /* Set/Get helpers for tiling flags. */
  228. #define AMDGPU_TILING_SET(field, value) \
  229. (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  230. #define AMDGPU_TILING_GET(value, field) \
  231. (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  232. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  233. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  234. /** The same structure is shared for input/output */
  235. struct drm_amdgpu_gem_metadata {
  236. /** GEM Object handle */
  237. __u32 handle;
  238. /** Do we want get or set metadata */
  239. __u32 op;
  240. struct {
  241. /** For future use, no flags defined so far */
  242. __u64 flags;
  243. /** family specific tiling info */
  244. __u64 tiling_info;
  245. __u32 data_size_bytes;
  246. __u32 data[64];
  247. } data;
  248. };
  249. struct drm_amdgpu_gem_mmap_in {
  250. /** the GEM object handle */
  251. __u32 handle;
  252. __u32 _pad;
  253. };
  254. struct drm_amdgpu_gem_mmap_out {
  255. /** mmap offset from the vma offset manager */
  256. __u64 addr_ptr;
  257. };
  258. union drm_amdgpu_gem_mmap {
  259. struct drm_amdgpu_gem_mmap_in in;
  260. struct drm_amdgpu_gem_mmap_out out;
  261. };
  262. struct drm_amdgpu_gem_wait_idle_in {
  263. /** GEM object handle */
  264. __u32 handle;
  265. /** For future use, no flags defined so far */
  266. __u32 flags;
  267. /** Absolute timeout to wait */
  268. __u64 timeout;
  269. };
  270. struct drm_amdgpu_gem_wait_idle_out {
  271. /** BO status: 0 - BO is idle, 1 - BO is busy */
  272. __u32 status;
  273. /** Returned current memory domain */
  274. __u32 domain;
  275. };
  276. union drm_amdgpu_gem_wait_idle {
  277. struct drm_amdgpu_gem_wait_idle_in in;
  278. struct drm_amdgpu_gem_wait_idle_out out;
  279. };
  280. struct drm_amdgpu_wait_cs_in {
  281. /* Command submission handle
  282. * handle equals 0 means none to wait for
  283. * handle equals ~0ull means wait for the latest sequence number
  284. */
  285. __u64 handle;
  286. /** Absolute timeout to wait */
  287. __u64 timeout;
  288. __u32 ip_type;
  289. __u32 ip_instance;
  290. __u32 ring;
  291. __u32 ctx_id;
  292. };
  293. struct drm_amdgpu_wait_cs_out {
  294. /** CS status: 0 - CS completed, 1 - CS still busy */
  295. __u64 status;
  296. };
  297. union drm_amdgpu_wait_cs {
  298. struct drm_amdgpu_wait_cs_in in;
  299. struct drm_amdgpu_wait_cs_out out;
  300. };
  301. struct drm_amdgpu_fence {
  302. __u32 ctx_id;
  303. __u32 ip_type;
  304. __u32 ip_instance;
  305. __u32 ring;
  306. __u64 seq_no;
  307. };
  308. struct drm_amdgpu_wait_fences_in {
  309. /** This points to uint64_t * which points to fences */
  310. __u64 fences;
  311. __u32 fence_count;
  312. __u32 wait_all;
  313. __u64 timeout_ns;
  314. };
  315. struct drm_amdgpu_wait_fences_out {
  316. __u32 status;
  317. __u32 first_signaled;
  318. };
  319. union drm_amdgpu_wait_fences {
  320. struct drm_amdgpu_wait_fences_in in;
  321. struct drm_amdgpu_wait_fences_out out;
  322. };
  323. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  324. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  325. /* Sets or returns a value associated with a buffer. */
  326. struct drm_amdgpu_gem_op {
  327. /** GEM object handle */
  328. __u32 handle;
  329. /** AMDGPU_GEM_OP_* */
  330. __u32 op;
  331. /** Input or return value */
  332. __u64 value;
  333. };
  334. #define AMDGPU_VA_OP_MAP 1
  335. #define AMDGPU_VA_OP_UNMAP 2
  336. #define AMDGPU_VA_OP_CLEAR 3
  337. #define AMDGPU_VA_OP_REPLACE 4
  338. /* Delay the page table update till the next CS */
  339. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  340. /* Mapping flags */
  341. /* readable mapping */
  342. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  343. /* writable mapping */
  344. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  345. /* executable mapping, new for VI */
  346. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  347. /* partially resident texture */
  348. #define AMDGPU_VM_PAGE_PRT (1 << 4)
  349. /* MTYPE flags use bit 5 to 8 */
  350. #define AMDGPU_VM_MTYPE_MASK (0xf << 5)
  351. /* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */
  352. #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
  353. /* Use NC MTYPE instead of default MTYPE */
  354. #define AMDGPU_VM_MTYPE_NC (1 << 5)
  355. /* Use WC MTYPE instead of default MTYPE */
  356. #define AMDGPU_VM_MTYPE_WC (2 << 5)
  357. /* Use CC MTYPE instead of default MTYPE */
  358. #define AMDGPU_VM_MTYPE_CC (3 << 5)
  359. /* Use UC MTYPE instead of default MTYPE */
  360. #define AMDGPU_VM_MTYPE_UC (4 << 5)
  361. struct drm_amdgpu_gem_va {
  362. /** GEM object handle */
  363. __u32 handle;
  364. __u32 _pad;
  365. /** AMDGPU_VA_OP_* */
  366. __u32 operation;
  367. /** AMDGPU_VM_PAGE_* */
  368. __u32 flags;
  369. /** va address to assign . Must be correctly aligned.*/
  370. __u64 va_address;
  371. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  372. __u64 offset_in_bo;
  373. /** Specify mapping size. Must be correctly aligned. */
  374. __u64 map_size;
  375. };
  376. #define AMDGPU_HW_IP_GFX 0
  377. #define AMDGPU_HW_IP_COMPUTE 1
  378. #define AMDGPU_HW_IP_DMA 2
  379. #define AMDGPU_HW_IP_UVD 3
  380. #define AMDGPU_HW_IP_VCE 4
  381. #define AMDGPU_HW_IP_UVD_ENC 5
  382. #define AMDGPU_HW_IP_VCN_DEC 6
  383. #define AMDGPU_HW_IP_VCN_ENC 7
  384. #define AMDGPU_HW_IP_NUM 8
  385. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  386. #define AMDGPU_CHUNK_ID_IB 0x01
  387. #define AMDGPU_CHUNK_ID_FENCE 0x02
  388. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  389. #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04
  390. #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05
  391. struct drm_amdgpu_cs_chunk {
  392. __u32 chunk_id;
  393. __u32 length_dw;
  394. __u64 chunk_data;
  395. };
  396. struct drm_amdgpu_cs_in {
  397. /** Rendering context id */
  398. __u32 ctx_id;
  399. /** Handle of resource list associated with CS */
  400. __u32 bo_list_handle;
  401. __u32 num_chunks;
  402. __u32 _pad;
  403. /** this points to __u64 * which point to cs chunks */
  404. __u64 chunks;
  405. };
  406. struct drm_amdgpu_cs_out {
  407. __u64 handle;
  408. };
  409. union drm_amdgpu_cs {
  410. struct drm_amdgpu_cs_in in;
  411. struct drm_amdgpu_cs_out out;
  412. };
  413. /* Specify flags to be used for IB */
  414. /* This IB should be submitted to CE */
  415. #define AMDGPU_IB_FLAG_CE (1<<0)
  416. /* Preamble flag, which means the IB could be dropped if no context switch */
  417. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  418. /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
  419. #define AMDGPU_IB_FLAG_PREEMPT (1<<2)
  420. struct drm_amdgpu_cs_chunk_ib {
  421. __u32 _pad;
  422. /** AMDGPU_IB_FLAG_* */
  423. __u32 flags;
  424. /** Virtual address to begin IB execution */
  425. __u64 va_start;
  426. /** Size of submission */
  427. __u32 ib_bytes;
  428. /** HW IP to submit to */
  429. __u32 ip_type;
  430. /** HW IP index of the same type to submit to */
  431. __u32 ip_instance;
  432. /** Ring index to submit to */
  433. __u32 ring;
  434. };
  435. struct drm_amdgpu_cs_chunk_dep {
  436. __u32 ip_type;
  437. __u32 ip_instance;
  438. __u32 ring;
  439. __u32 ctx_id;
  440. __u64 handle;
  441. };
  442. struct drm_amdgpu_cs_chunk_fence {
  443. __u32 handle;
  444. __u32 offset;
  445. };
  446. struct drm_amdgpu_cs_chunk_sem {
  447. __u32 handle;
  448. };
  449. struct drm_amdgpu_cs_chunk_data {
  450. union {
  451. struct drm_amdgpu_cs_chunk_ib ib_data;
  452. struct drm_amdgpu_cs_chunk_fence fence_data;
  453. };
  454. };
  455. /**
  456. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  457. *
  458. */
  459. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  460. #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
  461. /* indicate if acceleration can be working */
  462. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  463. /* get the crtc_id from the mode object id? */
  464. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  465. /* query hw IP info */
  466. #define AMDGPU_INFO_HW_IP_INFO 0x02
  467. /* query hw IP instance count for the specified type */
  468. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  469. /* timestamp for GL_ARB_timer_query */
  470. #define AMDGPU_INFO_TIMESTAMP 0x05
  471. /* Query the firmware version */
  472. #define AMDGPU_INFO_FW_VERSION 0x0e
  473. /* Subquery id: Query VCE firmware version */
  474. #define AMDGPU_INFO_FW_VCE 0x1
  475. /* Subquery id: Query UVD firmware version */
  476. #define AMDGPU_INFO_FW_UVD 0x2
  477. /* Subquery id: Query GMC firmware version */
  478. #define AMDGPU_INFO_FW_GMC 0x03
  479. /* Subquery id: Query GFX ME firmware version */
  480. #define AMDGPU_INFO_FW_GFX_ME 0x04
  481. /* Subquery id: Query GFX PFP firmware version */
  482. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  483. /* Subquery id: Query GFX CE firmware version */
  484. #define AMDGPU_INFO_FW_GFX_CE 0x06
  485. /* Subquery id: Query GFX RLC firmware version */
  486. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  487. /* Subquery id: Query GFX MEC firmware version */
  488. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  489. /* Subquery id: Query SMC firmware version */
  490. #define AMDGPU_INFO_FW_SMC 0x0a
  491. /* Subquery id: Query SDMA firmware version */
  492. #define AMDGPU_INFO_FW_SDMA 0x0b
  493. /* Subquery id: Query PSP SOS firmware version */
  494. #define AMDGPU_INFO_FW_SOS 0x0c
  495. /* Subquery id: Query PSP ASD firmware version */
  496. #define AMDGPU_INFO_FW_ASD 0x0d
  497. /* number of bytes moved for TTM migration */
  498. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  499. /* the used VRAM size */
  500. #define AMDGPU_INFO_VRAM_USAGE 0x10
  501. /* the used GTT size */
  502. #define AMDGPU_INFO_GTT_USAGE 0x11
  503. /* Information about GDS, etc. resource configuration */
  504. #define AMDGPU_INFO_GDS_CONFIG 0x13
  505. /* Query information about VRAM and GTT domains */
  506. #define AMDGPU_INFO_VRAM_GTT 0x14
  507. /* Query information about register in MMR address space*/
  508. #define AMDGPU_INFO_READ_MMR_REG 0x15
  509. /* Query information about device: rev id, family, etc. */
  510. #define AMDGPU_INFO_DEV_INFO 0x16
  511. /* visible vram usage */
  512. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  513. /* number of TTM buffer evictions */
  514. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  515. /* Query memory about VRAM and GTT domains */
  516. #define AMDGPU_INFO_MEMORY 0x19
  517. /* Query vce clock table */
  518. #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
  519. /* Query vbios related information */
  520. #define AMDGPU_INFO_VBIOS 0x1B
  521. /* Subquery id: Query vbios size */
  522. #define AMDGPU_INFO_VBIOS_SIZE 0x1
  523. /* Subquery id: Query vbios image */
  524. #define AMDGPU_INFO_VBIOS_IMAGE 0x2
  525. /* Query UVD handles */
  526. #define AMDGPU_INFO_NUM_HANDLES 0x1C
  527. /* Query sensor related information */
  528. #define AMDGPU_INFO_SENSOR 0x1D
  529. /* Subquery id: Query GPU shader clock */
  530. #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
  531. /* Subquery id: Query GPU memory clock */
  532. #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
  533. /* Subquery id: Query GPU temperature */
  534. #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
  535. /* Subquery id: Query GPU load */
  536. #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
  537. /* Subquery id: Query average GPU power */
  538. #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
  539. /* Subquery id: Query northbridge voltage */
  540. #define AMDGPU_INFO_SENSOR_VDDNB 0x6
  541. /* Subquery id: Query graphics voltage */
  542. #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
  543. /* Number of VRAM page faults on CPU access. */
  544. #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
  545. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  546. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  547. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  548. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  549. struct drm_amdgpu_query_fw {
  550. /** AMDGPU_INFO_FW_* */
  551. __u32 fw_type;
  552. /**
  553. * Index of the IP if there are more IPs of
  554. * the same type.
  555. */
  556. __u32 ip_instance;
  557. /**
  558. * Index of the engine. Whether this is used depends
  559. * on the firmware type. (e.g. MEC, SDMA)
  560. */
  561. __u32 index;
  562. __u32 _pad;
  563. };
  564. /* Input structure for the INFO ioctl */
  565. struct drm_amdgpu_info {
  566. /* Where the return value will be stored */
  567. __u64 return_pointer;
  568. /* The size of the return value. Just like "size" in "snprintf",
  569. * it limits how many bytes the kernel can write. */
  570. __u32 return_size;
  571. /* The query request id. */
  572. __u32 query;
  573. union {
  574. struct {
  575. __u32 id;
  576. __u32 _pad;
  577. } mode_crtc;
  578. struct {
  579. /** AMDGPU_HW_IP_* */
  580. __u32 type;
  581. /**
  582. * Index of the IP if there are more IPs of the same
  583. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  584. */
  585. __u32 ip_instance;
  586. } query_hw_ip;
  587. struct {
  588. __u32 dword_offset;
  589. /** number of registers to read */
  590. __u32 count;
  591. __u32 instance;
  592. /** For future use, no flags defined so far */
  593. __u32 flags;
  594. } read_mmr_reg;
  595. struct drm_amdgpu_query_fw query_fw;
  596. struct {
  597. __u32 type;
  598. __u32 offset;
  599. } vbios_info;
  600. struct {
  601. __u32 type;
  602. } sensor_info;
  603. };
  604. };
  605. struct drm_amdgpu_info_gds {
  606. /** GDS GFX partition size */
  607. __u32 gds_gfx_partition_size;
  608. /** GDS compute partition size */
  609. __u32 compute_partition_size;
  610. /** total GDS memory size */
  611. __u32 gds_total_size;
  612. /** GWS size per GFX partition */
  613. __u32 gws_per_gfx_partition;
  614. /** GSW size per compute partition */
  615. __u32 gws_per_compute_partition;
  616. /** OA size per GFX partition */
  617. __u32 oa_per_gfx_partition;
  618. /** OA size per compute partition */
  619. __u32 oa_per_compute_partition;
  620. __u32 _pad;
  621. };
  622. struct drm_amdgpu_info_vram_gtt {
  623. __u64 vram_size;
  624. __u64 vram_cpu_accessible_size;
  625. __u64 gtt_size;
  626. };
  627. struct drm_amdgpu_heap_info {
  628. /** max. physical memory */
  629. __u64 total_heap_size;
  630. /** Theoretical max. available memory in the given heap */
  631. __u64 usable_heap_size;
  632. /**
  633. * Number of bytes allocated in the heap. This includes all processes
  634. * and private allocations in the kernel. It changes when new buffers
  635. * are allocated, freed, and moved. It cannot be larger than
  636. * heap_size.
  637. */
  638. __u64 heap_usage;
  639. /**
  640. * Theoretical possible max. size of buffer which
  641. * could be allocated in the given heap
  642. */
  643. __u64 max_allocation;
  644. };
  645. struct drm_amdgpu_memory_info {
  646. struct drm_amdgpu_heap_info vram;
  647. struct drm_amdgpu_heap_info cpu_accessible_vram;
  648. struct drm_amdgpu_heap_info gtt;
  649. };
  650. struct drm_amdgpu_info_firmware {
  651. __u32 ver;
  652. __u32 feature;
  653. };
  654. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  655. #define AMDGPU_VRAM_TYPE_GDDR1 1
  656. #define AMDGPU_VRAM_TYPE_DDR2 2
  657. #define AMDGPU_VRAM_TYPE_GDDR3 3
  658. #define AMDGPU_VRAM_TYPE_GDDR4 4
  659. #define AMDGPU_VRAM_TYPE_GDDR5 5
  660. #define AMDGPU_VRAM_TYPE_HBM 6
  661. #define AMDGPU_VRAM_TYPE_DDR3 7
  662. struct drm_amdgpu_info_device {
  663. /** PCI Device ID */
  664. __u32 device_id;
  665. /** Internal chip revision: A0, A1, etc.) */
  666. __u32 chip_rev;
  667. __u32 external_rev;
  668. /** Revision id in PCI Config space */
  669. __u32 pci_rev;
  670. __u32 family;
  671. __u32 num_shader_engines;
  672. __u32 num_shader_arrays_per_engine;
  673. /* in KHz */
  674. __u32 gpu_counter_freq;
  675. __u64 max_engine_clock;
  676. __u64 max_memory_clock;
  677. /* cu information */
  678. __u32 cu_active_number;
  679. /* NOTE: cu_ao_mask is INVALID, DON'T use it */
  680. __u32 cu_ao_mask;
  681. __u32 cu_bitmap[4][4];
  682. /** Render backend pipe mask. One render backend is CB+DB. */
  683. __u32 enabled_rb_pipes_mask;
  684. __u32 num_rb_pipes;
  685. __u32 num_hw_gfx_contexts;
  686. __u32 _pad;
  687. __u64 ids_flags;
  688. /** Starting virtual address for UMDs. */
  689. __u64 virtual_address_offset;
  690. /** The maximum virtual address */
  691. __u64 virtual_address_max;
  692. /** Required alignment of virtual addresses. */
  693. __u32 virtual_address_alignment;
  694. /** Page table entry - fragment size */
  695. __u32 pte_fragment_size;
  696. __u32 gart_page_size;
  697. /** constant engine ram size*/
  698. __u32 ce_ram_size;
  699. /** video memory type info*/
  700. __u32 vram_type;
  701. /** video memory bit width*/
  702. __u32 vram_bit_width;
  703. /* vce harvesting instance */
  704. __u32 vce_harvest_config;
  705. /* gfx double offchip LDS buffers */
  706. __u32 gc_double_offchip_lds_buf;
  707. /* NGG Primitive Buffer */
  708. __u64 prim_buf_gpu_addr;
  709. /* NGG Position Buffer */
  710. __u64 pos_buf_gpu_addr;
  711. /* NGG Control Sideband */
  712. __u64 cntl_sb_buf_gpu_addr;
  713. /* NGG Parameter Cache */
  714. __u64 param_buf_gpu_addr;
  715. __u32 prim_buf_size;
  716. __u32 pos_buf_size;
  717. __u32 cntl_sb_buf_size;
  718. __u32 param_buf_size;
  719. /* wavefront size*/
  720. __u32 wave_front_size;
  721. /* shader visible vgprs*/
  722. __u32 num_shader_visible_vgprs;
  723. /* CU per shader array*/
  724. __u32 num_cu_per_sh;
  725. /* number of tcc blocks*/
  726. __u32 num_tcc_blocks;
  727. /* gs vgt table depth*/
  728. __u32 gs_vgt_table_depth;
  729. /* gs primitive buffer depth*/
  730. __u32 gs_prim_buffer_depth;
  731. /* max gs wavefront per vgt*/
  732. __u32 max_gs_waves_per_vgt;
  733. __u32 _pad1;
  734. /* always on cu bitmap */
  735. __u32 cu_ao_bitmap[4][4];
  736. };
  737. struct drm_amdgpu_info_hw_ip {
  738. /** Version of h/w IP */
  739. __u32 hw_ip_version_major;
  740. __u32 hw_ip_version_minor;
  741. /** Capabilities */
  742. __u64 capabilities_flags;
  743. /** command buffer address start alignment*/
  744. __u32 ib_start_alignment;
  745. /** command buffer size alignment*/
  746. __u32 ib_size_alignment;
  747. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  748. __u32 available_rings;
  749. __u32 _pad;
  750. };
  751. struct drm_amdgpu_info_num_handles {
  752. /** Max handles as supported by firmware for UVD */
  753. __u32 uvd_max_handles;
  754. /** Handles currently in use for UVD */
  755. __u32 uvd_used_handles;
  756. };
  757. #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
  758. struct drm_amdgpu_info_vce_clock_table_entry {
  759. /** System clock */
  760. __u32 sclk;
  761. /** Memory clock */
  762. __u32 mclk;
  763. /** VCE clock */
  764. __u32 eclk;
  765. __u32 pad;
  766. };
  767. struct drm_amdgpu_info_vce_clock_table {
  768. struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
  769. __u32 num_valid_entries;
  770. __u32 pad;
  771. };
  772. /*
  773. * Supported GPU families
  774. */
  775. #define AMDGPU_FAMILY_UNKNOWN 0
  776. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  777. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  778. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  779. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  780. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  781. #define AMDGPU_FAMILY_AI 141 /* Vega10 */
  782. #define AMDGPU_FAMILY_RV 142 /* Raven */
  783. #if defined(__cplusplus)
  784. }
  785. #endif
  786. #endif