amdgpu_drm.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  189. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  190. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  191. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  192. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  193. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  194. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  195. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  196. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  197. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  198. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  199. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  200. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  201. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  202. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  203. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  204. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  205. #define AMDGPU_TILING_SET(field, value) \
  206. (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  207. #define AMDGPU_TILING_GET(value, field) \
  208. (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  209. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  210. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  211. /** The same structure is shared for input/output */
  212. struct drm_amdgpu_gem_metadata {
  213. /** GEM Object handle */
  214. __u32 handle;
  215. /** Do we want get or set metadata */
  216. __u32 op;
  217. struct {
  218. /** For future use, no flags defined so far */
  219. __u64 flags;
  220. /** family specific tiling info */
  221. __u64 tiling_info;
  222. __u32 data_size_bytes;
  223. __u32 data[64];
  224. } data;
  225. };
  226. struct drm_amdgpu_gem_mmap_in {
  227. /** the GEM object handle */
  228. __u32 handle;
  229. __u32 _pad;
  230. };
  231. struct drm_amdgpu_gem_mmap_out {
  232. /** mmap offset from the vma offset manager */
  233. __u64 addr_ptr;
  234. };
  235. union drm_amdgpu_gem_mmap {
  236. struct drm_amdgpu_gem_mmap_in in;
  237. struct drm_amdgpu_gem_mmap_out out;
  238. };
  239. struct drm_amdgpu_gem_wait_idle_in {
  240. /** GEM object handle */
  241. __u32 handle;
  242. /** For future use, no flags defined so far */
  243. __u32 flags;
  244. /** Absolute timeout to wait */
  245. __u64 timeout;
  246. };
  247. struct drm_amdgpu_gem_wait_idle_out {
  248. /** BO status: 0 - BO is idle, 1 - BO is busy */
  249. __u32 status;
  250. /** Returned current memory domain */
  251. __u32 domain;
  252. };
  253. union drm_amdgpu_gem_wait_idle {
  254. struct drm_amdgpu_gem_wait_idle_in in;
  255. struct drm_amdgpu_gem_wait_idle_out out;
  256. };
  257. struct drm_amdgpu_wait_cs_in {
  258. /** Command submission handle */
  259. __u64 handle;
  260. /** Absolute timeout to wait */
  261. __u64 timeout;
  262. __u32 ip_type;
  263. __u32 ip_instance;
  264. __u32 ring;
  265. __u32 ctx_id;
  266. };
  267. struct drm_amdgpu_wait_cs_out {
  268. /** CS status: 0 - CS completed, 1 - CS still busy */
  269. __u64 status;
  270. };
  271. union drm_amdgpu_wait_cs {
  272. struct drm_amdgpu_wait_cs_in in;
  273. struct drm_amdgpu_wait_cs_out out;
  274. };
  275. struct drm_amdgpu_fence {
  276. __u32 ctx_id;
  277. __u32 ip_type;
  278. __u32 ip_instance;
  279. __u32 ring;
  280. __u64 seq_no;
  281. };
  282. struct drm_amdgpu_wait_fences_in {
  283. /** This points to uint64_t * which points to fences */
  284. __u64 fences;
  285. __u32 fence_count;
  286. __u32 wait_all;
  287. __u64 timeout_ns;
  288. };
  289. struct drm_amdgpu_wait_fences_out {
  290. __u32 status;
  291. __u32 first_signaled;
  292. };
  293. union drm_amdgpu_wait_fences {
  294. struct drm_amdgpu_wait_fences_in in;
  295. struct drm_amdgpu_wait_fences_out out;
  296. };
  297. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  298. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  299. /* Sets or returns a value associated with a buffer. */
  300. struct drm_amdgpu_gem_op {
  301. /** GEM object handle */
  302. __u32 handle;
  303. /** AMDGPU_GEM_OP_* */
  304. __u32 op;
  305. /** Input or return value */
  306. __u64 value;
  307. };
  308. #define AMDGPU_VA_OP_MAP 1
  309. #define AMDGPU_VA_OP_UNMAP 2
  310. /* Delay the page table update till the next CS */
  311. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  312. /* Mapping flags */
  313. /* readable mapping */
  314. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  315. /* writable mapping */
  316. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  317. /* executable mapping, new for VI */
  318. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  319. struct drm_amdgpu_gem_va {
  320. /** GEM object handle */
  321. __u32 handle;
  322. __u32 _pad;
  323. /** AMDGPU_VA_OP_* */
  324. __u32 operation;
  325. /** AMDGPU_VM_PAGE_* */
  326. __u32 flags;
  327. /** va address to assign . Must be correctly aligned.*/
  328. __u64 va_address;
  329. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  330. __u64 offset_in_bo;
  331. /** Specify mapping size. Must be correctly aligned. */
  332. __u64 map_size;
  333. };
  334. #define AMDGPU_HW_IP_GFX 0
  335. #define AMDGPU_HW_IP_COMPUTE 1
  336. #define AMDGPU_HW_IP_DMA 2
  337. #define AMDGPU_HW_IP_UVD 3
  338. #define AMDGPU_HW_IP_VCE 4
  339. #define AMDGPU_HW_IP_NUM 5
  340. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  341. #define AMDGPU_CHUNK_ID_IB 0x01
  342. #define AMDGPU_CHUNK_ID_FENCE 0x02
  343. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  344. struct drm_amdgpu_cs_chunk {
  345. __u32 chunk_id;
  346. __u32 length_dw;
  347. __u64 chunk_data;
  348. };
  349. struct drm_amdgpu_cs_in {
  350. /** Rendering context id */
  351. __u32 ctx_id;
  352. /** Handle of resource list associated with CS */
  353. __u32 bo_list_handle;
  354. __u32 num_chunks;
  355. __u32 _pad;
  356. /** this points to __u64 * which point to cs chunks */
  357. __u64 chunks;
  358. };
  359. struct drm_amdgpu_cs_out {
  360. __u64 handle;
  361. };
  362. union drm_amdgpu_cs {
  363. struct drm_amdgpu_cs_in in;
  364. struct drm_amdgpu_cs_out out;
  365. };
  366. /* Specify flags to be used for IB */
  367. /* This IB should be submitted to CE */
  368. #define AMDGPU_IB_FLAG_CE (1<<0)
  369. /* CE Preamble */
  370. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  371. struct drm_amdgpu_cs_chunk_ib {
  372. __u32 _pad;
  373. /** AMDGPU_IB_FLAG_* */
  374. __u32 flags;
  375. /** Virtual address to begin IB execution */
  376. __u64 va_start;
  377. /** Size of submission */
  378. __u32 ib_bytes;
  379. /** HW IP to submit to */
  380. __u32 ip_type;
  381. /** HW IP index of the same type to submit to */
  382. __u32 ip_instance;
  383. /** Ring index to submit to */
  384. __u32 ring;
  385. };
  386. struct drm_amdgpu_cs_chunk_dep {
  387. __u32 ip_type;
  388. __u32 ip_instance;
  389. __u32 ring;
  390. __u32 ctx_id;
  391. __u64 handle;
  392. };
  393. struct drm_amdgpu_cs_chunk_fence {
  394. __u32 handle;
  395. __u32 offset;
  396. };
  397. struct drm_amdgpu_cs_chunk_data {
  398. union {
  399. struct drm_amdgpu_cs_chunk_ib ib_data;
  400. struct drm_amdgpu_cs_chunk_fence fence_data;
  401. };
  402. };
  403. /**
  404. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  405. *
  406. */
  407. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  408. #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
  409. /* indicate if acceleration can be working */
  410. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  411. /* get the crtc_id from the mode object id? */
  412. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  413. /* query hw IP info */
  414. #define AMDGPU_INFO_HW_IP_INFO 0x02
  415. /* query hw IP instance count for the specified type */
  416. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  417. /* timestamp for GL_ARB_timer_query */
  418. #define AMDGPU_INFO_TIMESTAMP 0x05
  419. /* Query the firmware version */
  420. #define AMDGPU_INFO_FW_VERSION 0x0e
  421. /* Subquery id: Query VCE firmware version */
  422. #define AMDGPU_INFO_FW_VCE 0x1
  423. /* Subquery id: Query UVD firmware version */
  424. #define AMDGPU_INFO_FW_UVD 0x2
  425. /* Subquery id: Query GMC firmware version */
  426. #define AMDGPU_INFO_FW_GMC 0x03
  427. /* Subquery id: Query GFX ME firmware version */
  428. #define AMDGPU_INFO_FW_GFX_ME 0x04
  429. /* Subquery id: Query GFX PFP firmware version */
  430. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  431. /* Subquery id: Query GFX CE firmware version */
  432. #define AMDGPU_INFO_FW_GFX_CE 0x06
  433. /* Subquery id: Query GFX RLC firmware version */
  434. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  435. /* Subquery id: Query GFX MEC firmware version */
  436. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  437. /* Subquery id: Query SMC firmware version */
  438. #define AMDGPU_INFO_FW_SMC 0x0a
  439. /* Subquery id: Query SDMA firmware version */
  440. #define AMDGPU_INFO_FW_SDMA 0x0b
  441. /* number of bytes moved for TTM migration */
  442. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  443. /* the used VRAM size */
  444. #define AMDGPU_INFO_VRAM_USAGE 0x10
  445. /* the used GTT size */
  446. #define AMDGPU_INFO_GTT_USAGE 0x11
  447. /* Information about GDS, etc. resource configuration */
  448. #define AMDGPU_INFO_GDS_CONFIG 0x13
  449. /* Query information about VRAM and GTT domains */
  450. #define AMDGPU_INFO_VRAM_GTT 0x14
  451. /* Query information about register in MMR address space*/
  452. #define AMDGPU_INFO_READ_MMR_REG 0x15
  453. /* Query information about device: rev id, family, etc. */
  454. #define AMDGPU_INFO_DEV_INFO 0x16
  455. /* visible vram usage */
  456. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  457. /* number of TTM buffer evictions */
  458. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  459. /* Query memory about VRAM and GTT domains */
  460. #define AMDGPU_INFO_MEMORY 0x19
  461. /* Query vce clock table */
  462. #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
  463. /* Query vbios related information */
  464. #define AMDGPU_INFO_VBIOS 0x1B
  465. /* Subquery id: Query vbios size */
  466. #define AMDGPU_INFO_VBIOS_SIZE 0x1
  467. /* Subquery id: Query vbios image */
  468. #define AMDGPU_INFO_VBIOS_IMAGE 0x2
  469. /* Query UVD handles */
  470. #define AMDGPU_INFO_NUM_HANDLES 0x1C
  471. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  472. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  473. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  474. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  475. struct drm_amdgpu_query_fw {
  476. /** AMDGPU_INFO_FW_* */
  477. __u32 fw_type;
  478. /**
  479. * Index of the IP if there are more IPs of
  480. * the same type.
  481. */
  482. __u32 ip_instance;
  483. /**
  484. * Index of the engine. Whether this is used depends
  485. * on the firmware type. (e.g. MEC, SDMA)
  486. */
  487. __u32 index;
  488. __u32 _pad;
  489. };
  490. /* Input structure for the INFO ioctl */
  491. struct drm_amdgpu_info {
  492. /* Where the return value will be stored */
  493. __u64 return_pointer;
  494. /* The size of the return value. Just like "size" in "snprintf",
  495. * it limits how many bytes the kernel can write. */
  496. __u32 return_size;
  497. /* The query request id. */
  498. __u32 query;
  499. union {
  500. struct {
  501. __u32 id;
  502. __u32 _pad;
  503. } mode_crtc;
  504. struct {
  505. /** AMDGPU_HW_IP_* */
  506. __u32 type;
  507. /**
  508. * Index of the IP if there are more IPs of the same
  509. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  510. */
  511. __u32 ip_instance;
  512. } query_hw_ip;
  513. struct {
  514. __u32 dword_offset;
  515. /** number of registers to read */
  516. __u32 count;
  517. __u32 instance;
  518. /** For future use, no flags defined so far */
  519. __u32 flags;
  520. } read_mmr_reg;
  521. struct drm_amdgpu_query_fw query_fw;
  522. struct {
  523. __u32 type;
  524. __u32 offset;
  525. } vbios_info;
  526. };
  527. };
  528. struct drm_amdgpu_info_gds {
  529. /** GDS GFX partition size */
  530. __u32 gds_gfx_partition_size;
  531. /** GDS compute partition size */
  532. __u32 compute_partition_size;
  533. /** total GDS memory size */
  534. __u32 gds_total_size;
  535. /** GWS size per GFX partition */
  536. __u32 gws_per_gfx_partition;
  537. /** GSW size per compute partition */
  538. __u32 gws_per_compute_partition;
  539. /** OA size per GFX partition */
  540. __u32 oa_per_gfx_partition;
  541. /** OA size per compute partition */
  542. __u32 oa_per_compute_partition;
  543. __u32 _pad;
  544. };
  545. struct drm_amdgpu_info_vram_gtt {
  546. __u64 vram_size;
  547. __u64 vram_cpu_accessible_size;
  548. __u64 gtt_size;
  549. };
  550. struct drm_amdgpu_heap_info {
  551. /** max. physical memory */
  552. __u64 total_heap_size;
  553. /** Theoretical max. available memory in the given heap */
  554. __u64 usable_heap_size;
  555. /**
  556. * Number of bytes allocated in the heap. This includes all processes
  557. * and private allocations in the kernel. It changes when new buffers
  558. * are allocated, freed, and moved. It cannot be larger than
  559. * heap_size.
  560. */
  561. __u64 heap_usage;
  562. /**
  563. * Theoretical possible max. size of buffer which
  564. * could be allocated in the given heap
  565. */
  566. __u64 max_allocation;
  567. };
  568. struct drm_amdgpu_memory_info {
  569. struct drm_amdgpu_heap_info vram;
  570. struct drm_amdgpu_heap_info cpu_accessible_vram;
  571. struct drm_amdgpu_heap_info gtt;
  572. };
  573. struct drm_amdgpu_info_firmware {
  574. __u32 ver;
  575. __u32 feature;
  576. };
  577. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  578. #define AMDGPU_VRAM_TYPE_GDDR1 1
  579. #define AMDGPU_VRAM_TYPE_DDR2 2
  580. #define AMDGPU_VRAM_TYPE_GDDR3 3
  581. #define AMDGPU_VRAM_TYPE_GDDR4 4
  582. #define AMDGPU_VRAM_TYPE_GDDR5 5
  583. #define AMDGPU_VRAM_TYPE_HBM 6
  584. #define AMDGPU_VRAM_TYPE_DDR3 7
  585. struct drm_amdgpu_info_device {
  586. /** PCI Device ID */
  587. __u32 device_id;
  588. /** Internal chip revision: A0, A1, etc.) */
  589. __u32 chip_rev;
  590. __u32 external_rev;
  591. /** Revision id in PCI Config space */
  592. __u32 pci_rev;
  593. __u32 family;
  594. __u32 num_shader_engines;
  595. __u32 num_shader_arrays_per_engine;
  596. /* in KHz */
  597. __u32 gpu_counter_freq;
  598. __u64 max_engine_clock;
  599. __u64 max_memory_clock;
  600. /* cu information */
  601. __u32 cu_active_number;
  602. __u32 cu_ao_mask;
  603. __u32 cu_bitmap[4][4];
  604. /** Render backend pipe mask. One render backend is CB+DB. */
  605. __u32 enabled_rb_pipes_mask;
  606. __u32 num_rb_pipes;
  607. __u32 num_hw_gfx_contexts;
  608. __u32 _pad;
  609. __u64 ids_flags;
  610. /** Starting virtual address for UMDs. */
  611. __u64 virtual_address_offset;
  612. /** The maximum virtual address */
  613. __u64 virtual_address_max;
  614. /** Required alignment of virtual addresses. */
  615. __u32 virtual_address_alignment;
  616. /** Page table entry - fragment size */
  617. __u32 pte_fragment_size;
  618. __u32 gart_page_size;
  619. /** constant engine ram size*/
  620. __u32 ce_ram_size;
  621. /** video memory type info*/
  622. __u32 vram_type;
  623. /** video memory bit width*/
  624. __u32 vram_bit_width;
  625. /* vce harvesting instance */
  626. __u32 vce_harvest_config;
  627. };
  628. struct drm_amdgpu_info_hw_ip {
  629. /** Version of h/w IP */
  630. __u32 hw_ip_version_major;
  631. __u32 hw_ip_version_minor;
  632. /** Capabilities */
  633. __u64 capabilities_flags;
  634. /** command buffer address start alignment*/
  635. __u32 ib_start_alignment;
  636. /** command buffer size alignment*/
  637. __u32 ib_size_alignment;
  638. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  639. __u32 available_rings;
  640. __u32 _pad;
  641. };
  642. struct drm_amdgpu_info_num_handles {
  643. /** Max handles as supported by firmware for UVD */
  644. __u32 uvd_max_handles;
  645. /** Handles currently in use for UVD */
  646. __u32 uvd_used_handles;
  647. };
  648. #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
  649. struct drm_amdgpu_info_vce_clock_table_entry {
  650. /** System clock */
  651. __u32 sclk;
  652. /** Memory clock */
  653. __u32 mclk;
  654. /** VCE clock */
  655. __u32 eclk;
  656. __u32 pad;
  657. };
  658. struct drm_amdgpu_info_vce_clock_table {
  659. struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
  660. __u32 num_valid_entries;
  661. __u32 pad;
  662. };
  663. /*
  664. * Supported GPU families
  665. */
  666. #define AMDGPU_FAMILY_UNKNOWN 0
  667. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  668. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  669. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  670. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  671. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  672. #if defined(__cplusplus)
  673. }
  674. #endif
  675. #endif