amdgpu_drm.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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. #define AMDGPU_VA_OP_CLEAR 3
  311. #define AMDGPU_VA_OP_REPLACE 4
  312. /* Delay the page table update till the next CS */
  313. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  314. /* Mapping flags */
  315. /* readable mapping */
  316. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  317. /* writable mapping */
  318. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  319. /* executable mapping, new for VI */
  320. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  321. /* partially resident texture */
  322. #define AMDGPU_VM_PAGE_PRT (1 << 4)
  323. struct drm_amdgpu_gem_va {
  324. /** GEM object handle */
  325. __u32 handle;
  326. __u32 _pad;
  327. /** AMDGPU_VA_OP_* */
  328. __u32 operation;
  329. /** AMDGPU_VM_PAGE_* */
  330. __u32 flags;
  331. /** va address to assign . Must be correctly aligned.*/
  332. __u64 va_address;
  333. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  334. __u64 offset_in_bo;
  335. /** Specify mapping size. Must be correctly aligned. */
  336. __u64 map_size;
  337. };
  338. #define AMDGPU_HW_IP_GFX 0
  339. #define AMDGPU_HW_IP_COMPUTE 1
  340. #define AMDGPU_HW_IP_DMA 2
  341. #define AMDGPU_HW_IP_UVD 3
  342. #define AMDGPU_HW_IP_VCE 4
  343. #define AMDGPU_HW_IP_UVD_ENC 5
  344. #define AMDGPU_HW_IP_NUM 6
  345. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  346. #define AMDGPU_CHUNK_ID_IB 0x01
  347. #define AMDGPU_CHUNK_ID_FENCE 0x02
  348. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  349. struct drm_amdgpu_cs_chunk {
  350. __u32 chunk_id;
  351. __u32 length_dw;
  352. __u64 chunk_data;
  353. };
  354. struct drm_amdgpu_cs_in {
  355. /** Rendering context id */
  356. __u32 ctx_id;
  357. /** Handle of resource list associated with CS */
  358. __u32 bo_list_handle;
  359. __u32 num_chunks;
  360. __u32 _pad;
  361. /** this points to __u64 * which point to cs chunks */
  362. __u64 chunks;
  363. };
  364. struct drm_amdgpu_cs_out {
  365. __u64 handle;
  366. };
  367. union drm_amdgpu_cs {
  368. struct drm_amdgpu_cs_in in;
  369. struct drm_amdgpu_cs_out out;
  370. };
  371. /* Specify flags to be used for IB */
  372. /* This IB should be submitted to CE */
  373. #define AMDGPU_IB_FLAG_CE (1<<0)
  374. /* CE Preamble */
  375. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  376. struct drm_amdgpu_cs_chunk_ib {
  377. __u32 _pad;
  378. /** AMDGPU_IB_FLAG_* */
  379. __u32 flags;
  380. /** Virtual address to begin IB execution */
  381. __u64 va_start;
  382. /** Size of submission */
  383. __u32 ib_bytes;
  384. /** HW IP to submit to */
  385. __u32 ip_type;
  386. /** HW IP index of the same type to submit to */
  387. __u32 ip_instance;
  388. /** Ring index to submit to */
  389. __u32 ring;
  390. };
  391. struct drm_amdgpu_cs_chunk_dep {
  392. __u32 ip_type;
  393. __u32 ip_instance;
  394. __u32 ring;
  395. __u32 ctx_id;
  396. __u64 handle;
  397. };
  398. struct drm_amdgpu_cs_chunk_fence {
  399. __u32 handle;
  400. __u32 offset;
  401. };
  402. struct drm_amdgpu_cs_chunk_data {
  403. union {
  404. struct drm_amdgpu_cs_chunk_ib ib_data;
  405. struct drm_amdgpu_cs_chunk_fence fence_data;
  406. };
  407. };
  408. /**
  409. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  410. *
  411. */
  412. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  413. #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
  414. /* indicate if acceleration can be working */
  415. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  416. /* get the crtc_id from the mode object id? */
  417. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  418. /* query hw IP info */
  419. #define AMDGPU_INFO_HW_IP_INFO 0x02
  420. /* query hw IP instance count for the specified type */
  421. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  422. /* timestamp for GL_ARB_timer_query */
  423. #define AMDGPU_INFO_TIMESTAMP 0x05
  424. /* Query the firmware version */
  425. #define AMDGPU_INFO_FW_VERSION 0x0e
  426. /* Subquery id: Query VCE firmware version */
  427. #define AMDGPU_INFO_FW_VCE 0x1
  428. /* Subquery id: Query UVD firmware version */
  429. #define AMDGPU_INFO_FW_UVD 0x2
  430. /* Subquery id: Query GMC firmware version */
  431. #define AMDGPU_INFO_FW_GMC 0x03
  432. /* Subquery id: Query GFX ME firmware version */
  433. #define AMDGPU_INFO_FW_GFX_ME 0x04
  434. /* Subquery id: Query GFX PFP firmware version */
  435. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  436. /* Subquery id: Query GFX CE firmware version */
  437. #define AMDGPU_INFO_FW_GFX_CE 0x06
  438. /* Subquery id: Query GFX RLC firmware version */
  439. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  440. /* Subquery id: Query GFX MEC firmware version */
  441. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  442. /* Subquery id: Query SMC firmware version */
  443. #define AMDGPU_INFO_FW_SMC 0x0a
  444. /* Subquery id: Query SDMA firmware version */
  445. #define AMDGPU_INFO_FW_SDMA 0x0b
  446. /* number of bytes moved for TTM migration */
  447. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  448. /* the used VRAM size */
  449. #define AMDGPU_INFO_VRAM_USAGE 0x10
  450. /* the used GTT size */
  451. #define AMDGPU_INFO_GTT_USAGE 0x11
  452. /* Information about GDS, etc. resource configuration */
  453. #define AMDGPU_INFO_GDS_CONFIG 0x13
  454. /* Query information about VRAM and GTT domains */
  455. #define AMDGPU_INFO_VRAM_GTT 0x14
  456. /* Query information about register in MMR address space*/
  457. #define AMDGPU_INFO_READ_MMR_REG 0x15
  458. /* Query information about device: rev id, family, etc. */
  459. #define AMDGPU_INFO_DEV_INFO 0x16
  460. /* visible vram usage */
  461. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  462. /* number of TTM buffer evictions */
  463. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  464. /* Query memory about VRAM and GTT domains */
  465. #define AMDGPU_INFO_MEMORY 0x19
  466. /* Query vce clock table */
  467. #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
  468. /* Query vbios related information */
  469. #define AMDGPU_INFO_VBIOS 0x1B
  470. /* Subquery id: Query vbios size */
  471. #define AMDGPU_INFO_VBIOS_SIZE 0x1
  472. /* Subquery id: Query vbios image */
  473. #define AMDGPU_INFO_VBIOS_IMAGE 0x2
  474. /* Query UVD handles */
  475. #define AMDGPU_INFO_NUM_HANDLES 0x1C
  476. /* Query sensor related information */
  477. #define AMDGPU_INFO_SENSOR 0x1D
  478. /* Subquery id: Query GPU shader clock */
  479. #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
  480. /* Subquery id: Query GPU memory clock */
  481. #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
  482. /* Subquery id: Query GPU temperature */
  483. #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
  484. /* Subquery id: Query GPU load */
  485. #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
  486. /* Subquery id: Query average GPU power */
  487. #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
  488. /* Subquery id: Query northbridge voltage */
  489. #define AMDGPU_INFO_SENSOR_VDDNB 0x6
  490. /* Subquery id: Query graphics voltage */
  491. #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
  492. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  493. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  494. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  495. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  496. struct drm_amdgpu_query_fw {
  497. /** AMDGPU_INFO_FW_* */
  498. __u32 fw_type;
  499. /**
  500. * Index of the IP if there are more IPs of
  501. * the same type.
  502. */
  503. __u32 ip_instance;
  504. /**
  505. * Index of the engine. Whether this is used depends
  506. * on the firmware type. (e.g. MEC, SDMA)
  507. */
  508. __u32 index;
  509. __u32 _pad;
  510. };
  511. /* Input structure for the INFO ioctl */
  512. struct drm_amdgpu_info {
  513. /* Where the return value will be stored */
  514. __u64 return_pointer;
  515. /* The size of the return value. Just like "size" in "snprintf",
  516. * it limits how many bytes the kernel can write. */
  517. __u32 return_size;
  518. /* The query request id. */
  519. __u32 query;
  520. union {
  521. struct {
  522. __u32 id;
  523. __u32 _pad;
  524. } mode_crtc;
  525. struct {
  526. /** AMDGPU_HW_IP_* */
  527. __u32 type;
  528. /**
  529. * Index of the IP if there are more IPs of the same
  530. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  531. */
  532. __u32 ip_instance;
  533. } query_hw_ip;
  534. struct {
  535. __u32 dword_offset;
  536. /** number of registers to read */
  537. __u32 count;
  538. __u32 instance;
  539. /** For future use, no flags defined so far */
  540. __u32 flags;
  541. } read_mmr_reg;
  542. struct drm_amdgpu_query_fw query_fw;
  543. struct {
  544. __u32 type;
  545. __u32 offset;
  546. } vbios_info;
  547. struct {
  548. __u32 type;
  549. } sensor_info;
  550. };
  551. };
  552. struct drm_amdgpu_info_gds {
  553. /** GDS GFX partition size */
  554. __u32 gds_gfx_partition_size;
  555. /** GDS compute partition size */
  556. __u32 compute_partition_size;
  557. /** total GDS memory size */
  558. __u32 gds_total_size;
  559. /** GWS size per GFX partition */
  560. __u32 gws_per_gfx_partition;
  561. /** GSW size per compute partition */
  562. __u32 gws_per_compute_partition;
  563. /** OA size per GFX partition */
  564. __u32 oa_per_gfx_partition;
  565. /** OA size per compute partition */
  566. __u32 oa_per_compute_partition;
  567. __u32 _pad;
  568. };
  569. struct drm_amdgpu_info_vram_gtt {
  570. __u64 vram_size;
  571. __u64 vram_cpu_accessible_size;
  572. __u64 gtt_size;
  573. };
  574. struct drm_amdgpu_heap_info {
  575. /** max. physical memory */
  576. __u64 total_heap_size;
  577. /** Theoretical max. available memory in the given heap */
  578. __u64 usable_heap_size;
  579. /**
  580. * Number of bytes allocated in the heap. This includes all processes
  581. * and private allocations in the kernel. It changes when new buffers
  582. * are allocated, freed, and moved. It cannot be larger than
  583. * heap_size.
  584. */
  585. __u64 heap_usage;
  586. /**
  587. * Theoretical possible max. size of buffer which
  588. * could be allocated in the given heap
  589. */
  590. __u64 max_allocation;
  591. };
  592. struct drm_amdgpu_memory_info {
  593. struct drm_amdgpu_heap_info vram;
  594. struct drm_amdgpu_heap_info cpu_accessible_vram;
  595. struct drm_amdgpu_heap_info gtt;
  596. };
  597. struct drm_amdgpu_info_firmware {
  598. __u32 ver;
  599. __u32 feature;
  600. };
  601. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  602. #define AMDGPU_VRAM_TYPE_GDDR1 1
  603. #define AMDGPU_VRAM_TYPE_DDR2 2
  604. #define AMDGPU_VRAM_TYPE_GDDR3 3
  605. #define AMDGPU_VRAM_TYPE_GDDR4 4
  606. #define AMDGPU_VRAM_TYPE_GDDR5 5
  607. #define AMDGPU_VRAM_TYPE_HBM 6
  608. #define AMDGPU_VRAM_TYPE_DDR3 7
  609. struct drm_amdgpu_info_device {
  610. /** PCI Device ID */
  611. __u32 device_id;
  612. /** Internal chip revision: A0, A1, etc.) */
  613. __u32 chip_rev;
  614. __u32 external_rev;
  615. /** Revision id in PCI Config space */
  616. __u32 pci_rev;
  617. __u32 family;
  618. __u32 num_shader_engines;
  619. __u32 num_shader_arrays_per_engine;
  620. /* in KHz */
  621. __u32 gpu_counter_freq;
  622. __u64 max_engine_clock;
  623. __u64 max_memory_clock;
  624. /* cu information */
  625. __u32 cu_active_number;
  626. __u32 cu_ao_mask;
  627. __u32 cu_bitmap[4][4];
  628. /** Render backend pipe mask. One render backend is CB+DB. */
  629. __u32 enabled_rb_pipes_mask;
  630. __u32 num_rb_pipes;
  631. __u32 num_hw_gfx_contexts;
  632. __u32 _pad;
  633. __u64 ids_flags;
  634. /** Starting virtual address for UMDs. */
  635. __u64 virtual_address_offset;
  636. /** The maximum virtual address */
  637. __u64 virtual_address_max;
  638. /** Required alignment of virtual addresses. */
  639. __u32 virtual_address_alignment;
  640. /** Page table entry - fragment size */
  641. __u32 pte_fragment_size;
  642. __u32 gart_page_size;
  643. /** constant engine ram size*/
  644. __u32 ce_ram_size;
  645. /** video memory type info*/
  646. __u32 vram_type;
  647. /** video memory bit width*/
  648. __u32 vram_bit_width;
  649. /* vce harvesting instance */
  650. __u32 vce_harvest_config;
  651. /* gfx double offchip LDS buffers */
  652. __u32 gc_double_offchip_lds_buf;
  653. };
  654. struct drm_amdgpu_info_hw_ip {
  655. /** Version of h/w IP */
  656. __u32 hw_ip_version_major;
  657. __u32 hw_ip_version_minor;
  658. /** Capabilities */
  659. __u64 capabilities_flags;
  660. /** command buffer address start alignment*/
  661. __u32 ib_start_alignment;
  662. /** command buffer size alignment*/
  663. __u32 ib_size_alignment;
  664. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  665. __u32 available_rings;
  666. __u32 _pad;
  667. };
  668. struct drm_amdgpu_info_num_handles {
  669. /** Max handles as supported by firmware for UVD */
  670. __u32 uvd_max_handles;
  671. /** Handles currently in use for UVD */
  672. __u32 uvd_used_handles;
  673. };
  674. #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
  675. struct drm_amdgpu_info_vce_clock_table_entry {
  676. /** System clock */
  677. __u32 sclk;
  678. /** Memory clock */
  679. __u32 mclk;
  680. /** VCE clock */
  681. __u32 eclk;
  682. __u32 pad;
  683. };
  684. struct drm_amdgpu_info_vce_clock_table {
  685. struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
  686. __u32 num_valid_entries;
  687. __u32 pad;
  688. };
  689. /*
  690. * Supported GPU families
  691. */
  692. #define AMDGPU_FAMILY_UNKNOWN 0
  693. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  694. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  695. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  696. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  697. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  698. #if defined(__cplusplus)
  699. }
  700. #endif
  701. #endif