amdgpu_drm.h 25 KB

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