amdgpu_drm.h 24 KB

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