amdgpu_drm.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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 <[email protected]>
  28. * Gareth Hughes <[email protected]>
  29. * Keith Whitwell <[email protected]>
  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_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  50. #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
  51. #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
  52. #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
  53. #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
  54. #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
  55. #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
  56. #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
  57. #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
  58. #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
  59. #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
  60. #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
  61. #define AMDGPU_GEM_DOMAIN_CPU 0x1
  62. #define AMDGPU_GEM_DOMAIN_GTT 0x2
  63. #define AMDGPU_GEM_DOMAIN_VRAM 0x4
  64. #define AMDGPU_GEM_DOMAIN_GDS 0x8
  65. #define AMDGPU_GEM_DOMAIN_GWS 0x10
  66. #define AMDGPU_GEM_DOMAIN_OA 0x20
  67. /* Flag that CPU access will be required for the case of VRAM domain */
  68. #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
  69. /* Flag that CPU access will not work, this VRAM domain is invisible */
  70. #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
  71. /* Flag that USWC attributes should be used for GTT */
  72. #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
  73. /* Flag that the memory should be in VRAM and cleared */
  74. #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
  75. /* Flag that create shadow bo(GTT) while allocating vram bo */
  76. #define AMDGPU_GEM_CREATE_SHADOW (1 << 4)
  77. struct drm_amdgpu_gem_create_in {
  78. /** the requested memory size */
  79. __u64 bo_size;
  80. /** physical start_addr alignment in bytes for some HW requirements */
  81. __u64 alignment;
  82. /** the requested memory domains */
  83. __u64 domains;
  84. /** allocation flags */
  85. __u64 domain_flags;
  86. };
  87. struct drm_amdgpu_gem_create_out {
  88. /** returned GEM object handle */
  89. __u32 handle;
  90. __u32 _pad;
  91. };
  92. union drm_amdgpu_gem_create {
  93. struct drm_amdgpu_gem_create_in in;
  94. struct drm_amdgpu_gem_create_out out;
  95. };
  96. /** Opcode to create new residency list. */
  97. #define AMDGPU_BO_LIST_OP_CREATE 0
  98. /** Opcode to destroy previously created residency list */
  99. #define AMDGPU_BO_LIST_OP_DESTROY 1
  100. /** Opcode to update resource information in the list */
  101. #define AMDGPU_BO_LIST_OP_UPDATE 2
  102. struct drm_amdgpu_bo_list_in {
  103. /** Type of operation */
  104. __u32 operation;
  105. /** Handle of list or 0 if we want to create one */
  106. __u32 list_handle;
  107. /** Number of BOs in list */
  108. __u32 bo_number;
  109. /** Size of each element describing BO */
  110. __u32 bo_info_size;
  111. /** Pointer to array describing BOs */
  112. __u64 bo_info_ptr;
  113. };
  114. struct drm_amdgpu_bo_list_entry {
  115. /** Handle of BO */
  116. __u32 bo_handle;
  117. /** New (if specified) BO priority to be used during migration */
  118. __u32 bo_priority;
  119. };
  120. struct drm_amdgpu_bo_list_out {
  121. /** Handle of resource list */
  122. __u32 list_handle;
  123. __u32 _pad;
  124. };
  125. union drm_amdgpu_bo_list {
  126. struct drm_amdgpu_bo_list_in in;
  127. struct drm_amdgpu_bo_list_out out;
  128. };
  129. /* context related */
  130. #define AMDGPU_CTX_OP_ALLOC_CTX 1
  131. #define AMDGPU_CTX_OP_FREE_CTX 2
  132. #define AMDGPU_CTX_OP_QUERY_STATE 3
  133. /* GPU reset status */
  134. #define AMDGPU_CTX_NO_RESET 0
  135. /* this the context caused it */
  136. #define AMDGPU_CTX_GUILTY_RESET 1
  137. /* some other context caused it */
  138. #define AMDGPU_CTX_INNOCENT_RESET 2
  139. /* unknown cause */
  140. #define AMDGPU_CTX_UNKNOWN_RESET 3
  141. struct drm_amdgpu_ctx_in {
  142. /** AMDGPU_CTX_OP_* */
  143. __u32 op;
  144. /** For future use, no flags defined so far */
  145. __u32 flags;
  146. __u32 ctx_id;
  147. __u32 _pad;
  148. };
  149. union drm_amdgpu_ctx_out {
  150. struct {
  151. __u32 ctx_id;
  152. __u32 _pad;
  153. } alloc;
  154. struct {
  155. /** For future use, no flags defined so far */
  156. __u64 flags;
  157. /** Number of resets caused by this context so far. */
  158. __u32 hangs;
  159. /** Reset status since the last call of the ioctl. */
  160. __u32 reset_status;
  161. } state;
  162. };
  163. union drm_amdgpu_ctx {
  164. struct drm_amdgpu_ctx_in in;
  165. union drm_amdgpu_ctx_out out;
  166. };
  167. /*
  168. * This is not a reliable API and you should expect it to fail for any
  169. * number of reasons and have fallback path that do not use userptr to
  170. * perform any operation.
  171. */
  172. #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
  173. #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
  174. #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
  175. #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
  176. struct drm_amdgpu_gem_userptr {
  177. __u64 addr;
  178. __u64 size;
  179. /* AMDGPU_GEM_USERPTR_* */
  180. __u32 flags;
  181. /* Resulting GEM handle */
  182. __u32 handle;
  183. };
  184. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  185. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  186. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  187. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  188. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  189. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  190. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  191. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  192. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  193. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  194. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  195. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  196. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  197. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  198. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  199. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  200. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  201. #define AMDGPU_TILING_SET(field, value) \
  202. (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  203. #define AMDGPU_TILING_GET(value, field) \
  204. (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  205. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  206. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  207. /** The same structure is shared for input/output */
  208. struct drm_amdgpu_gem_metadata {
  209. /** GEM Object handle */
  210. __u32 handle;
  211. /** Do we want get or set metadata */
  212. __u32 op;
  213. struct {
  214. /** For future use, no flags defined so far */
  215. __u64 flags;
  216. /** family specific tiling info */
  217. __u64 tiling_info;
  218. __u32 data_size_bytes;
  219. __u32 data[64];
  220. } data;
  221. };
  222. struct drm_amdgpu_gem_mmap_in {
  223. /** the GEM object handle */
  224. __u32 handle;
  225. __u32 _pad;
  226. };
  227. struct drm_amdgpu_gem_mmap_out {
  228. /** mmap offset from the vma offset manager */
  229. __u64 addr_ptr;
  230. };
  231. union drm_amdgpu_gem_mmap {
  232. struct drm_amdgpu_gem_mmap_in in;
  233. struct drm_amdgpu_gem_mmap_out out;
  234. };
  235. struct drm_amdgpu_gem_wait_idle_in {
  236. /** GEM object handle */
  237. __u32 handle;
  238. /** For future use, no flags defined so far */
  239. __u32 flags;
  240. /** Absolute timeout to wait */
  241. __u64 timeout;
  242. };
  243. struct drm_amdgpu_gem_wait_idle_out {
  244. /** BO status: 0 - BO is idle, 1 - BO is busy */
  245. __u32 status;
  246. /** Returned current memory domain */
  247. __u32 domain;
  248. };
  249. union drm_amdgpu_gem_wait_idle {
  250. struct drm_amdgpu_gem_wait_idle_in in;
  251. struct drm_amdgpu_gem_wait_idle_out out;
  252. };
  253. struct drm_amdgpu_wait_cs_in {
  254. /** Command submission handle */
  255. __u64 handle;
  256. /** Absolute timeout to wait */
  257. __u64 timeout;
  258. __u32 ip_type;
  259. __u32 ip_instance;
  260. __u32 ring;
  261. __u32 ctx_id;
  262. };
  263. struct drm_amdgpu_wait_cs_out {
  264. /** CS status: 0 - CS completed, 1 - CS still busy */
  265. __u64 status;
  266. };
  267. union drm_amdgpu_wait_cs {
  268. struct drm_amdgpu_wait_cs_in in;
  269. struct drm_amdgpu_wait_cs_out out;
  270. };
  271. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  272. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  273. /* Sets or returns a value associated with a buffer. */
  274. struct drm_amdgpu_gem_op {
  275. /** GEM object handle */
  276. __u32 handle;
  277. /** AMDGPU_GEM_OP_* */
  278. __u32 op;
  279. /** Input or return value */
  280. __u64 value;
  281. };
  282. #define AMDGPU_VA_OP_MAP 1
  283. #define AMDGPU_VA_OP_UNMAP 2
  284. /* Delay the page table update till the next CS */
  285. #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
  286. /* Mapping flags */
  287. /* readable mapping */
  288. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  289. /* writable mapping */
  290. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  291. /* executable mapping, new for VI */
  292. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  293. struct drm_amdgpu_gem_va {
  294. /** GEM object handle */
  295. __u32 handle;
  296. __u32 _pad;
  297. /** AMDGPU_VA_OP_* */
  298. __u32 operation;
  299. /** AMDGPU_VM_PAGE_* */
  300. __u32 flags;
  301. /** va address to assign . Must be correctly aligned.*/
  302. __u64 va_address;
  303. /** Specify offset inside of BO to assign. Must be correctly aligned.*/
  304. __u64 offset_in_bo;
  305. /** Specify mapping size. Must be correctly aligned. */
  306. __u64 map_size;
  307. };
  308. #define AMDGPU_HW_IP_GFX 0
  309. #define AMDGPU_HW_IP_COMPUTE 1
  310. #define AMDGPU_HW_IP_DMA 2
  311. #define AMDGPU_HW_IP_UVD 3
  312. #define AMDGPU_HW_IP_VCE 4
  313. #define AMDGPU_HW_IP_NUM 5
  314. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  315. #define AMDGPU_CHUNK_ID_IB 0x01
  316. #define AMDGPU_CHUNK_ID_FENCE 0x02
  317. #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
  318. struct drm_amdgpu_cs_chunk {
  319. __u32 chunk_id;
  320. __u32 length_dw;
  321. __u64 chunk_data;
  322. };
  323. struct drm_amdgpu_cs_in {
  324. /** Rendering context id */
  325. __u32 ctx_id;
  326. /** Handle of resource list associated with CS */
  327. __u32 bo_list_handle;
  328. __u32 num_chunks;
  329. __u32 _pad;
  330. /** this points to __u64 * which point to cs chunks */
  331. __u64 chunks;
  332. };
  333. struct drm_amdgpu_cs_out {
  334. __u64 handle;
  335. };
  336. union drm_amdgpu_cs {
  337. struct drm_amdgpu_cs_in in;
  338. struct drm_amdgpu_cs_out out;
  339. };
  340. /* Specify flags to be used for IB */
  341. /* This IB should be submitted to CE */
  342. #define AMDGPU_IB_FLAG_CE (1<<0)
  343. /* CE Preamble */
  344. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  345. struct drm_amdgpu_cs_chunk_ib {
  346. __u32 _pad;
  347. /** AMDGPU_IB_FLAG_* */
  348. __u32 flags;
  349. /** Virtual address to begin IB execution */
  350. __u64 va_start;
  351. /** Size of submission */
  352. __u32 ib_bytes;
  353. /** HW IP to submit to */
  354. __u32 ip_type;
  355. /** HW IP index of the same type to submit to */
  356. __u32 ip_instance;
  357. /** Ring index to submit to */
  358. __u32 ring;
  359. };
  360. struct drm_amdgpu_cs_chunk_dep {
  361. __u32 ip_type;
  362. __u32 ip_instance;
  363. __u32 ring;
  364. __u32 ctx_id;
  365. __u64 handle;
  366. };
  367. struct drm_amdgpu_cs_chunk_fence {
  368. __u32 handle;
  369. __u32 offset;
  370. };
  371. struct drm_amdgpu_cs_chunk_data {
  372. union {
  373. struct drm_amdgpu_cs_chunk_ib ib_data;
  374. struct drm_amdgpu_cs_chunk_fence fence_data;
  375. };
  376. };
  377. /**
  378. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  379. *
  380. */
  381. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  382. /* indicate if acceleration can be working */
  383. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  384. /* get the crtc_id from the mode object id? */
  385. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  386. /* query hw IP info */
  387. #define AMDGPU_INFO_HW_IP_INFO 0x02
  388. /* query hw IP instance count for the specified type */
  389. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  390. /* timestamp for GL_ARB_timer_query */
  391. #define AMDGPU_INFO_TIMESTAMP 0x05
  392. /* Query the firmware version */
  393. #define AMDGPU_INFO_FW_VERSION 0x0e
  394. /* Subquery id: Query VCE firmware version */
  395. #define AMDGPU_INFO_FW_VCE 0x1
  396. /* Subquery id: Query UVD firmware version */
  397. #define AMDGPU_INFO_FW_UVD 0x2
  398. /* Subquery id: Query GMC firmware version */
  399. #define AMDGPU_INFO_FW_GMC 0x03
  400. /* Subquery id: Query GFX ME firmware version */
  401. #define AMDGPU_INFO_FW_GFX_ME 0x04
  402. /* Subquery id: Query GFX PFP firmware version */
  403. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  404. /* Subquery id: Query GFX CE firmware version */
  405. #define AMDGPU_INFO_FW_GFX_CE 0x06
  406. /* Subquery id: Query GFX RLC firmware version */
  407. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  408. /* Subquery id: Query GFX MEC firmware version */
  409. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  410. /* Subquery id: Query SMC firmware version */
  411. #define AMDGPU_INFO_FW_SMC 0x0a
  412. /* Subquery id: Query SDMA firmware version */
  413. #define AMDGPU_INFO_FW_SDMA 0x0b
  414. /* number of bytes moved for TTM migration */
  415. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  416. /* the used VRAM size */
  417. #define AMDGPU_INFO_VRAM_USAGE 0x10
  418. /* the used GTT size */
  419. #define AMDGPU_INFO_GTT_USAGE 0x11
  420. /* Information about GDS, etc. resource configuration */
  421. #define AMDGPU_INFO_GDS_CONFIG 0x13
  422. /* Query information about VRAM and GTT domains */
  423. #define AMDGPU_INFO_VRAM_GTT 0x14
  424. /* Query information about register in MMR address space*/
  425. #define AMDGPU_INFO_READ_MMR_REG 0x15
  426. /* Query information about device: rev id, family, etc. */
  427. #define AMDGPU_INFO_DEV_INFO 0x16
  428. /* visible vram usage */
  429. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  430. /* number of TTM buffer evictions */
  431. #define AMDGPU_INFO_NUM_EVICTIONS 0x18
  432. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  433. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  434. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  435. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  436. struct drm_amdgpu_query_fw {
  437. /** AMDGPU_INFO_FW_* */
  438. __u32 fw_type;
  439. /**
  440. * Index of the IP if there are more IPs of
  441. * the same type.
  442. */
  443. __u32 ip_instance;
  444. /**
  445. * Index of the engine. Whether this is used depends
  446. * on the firmware type. (e.g. MEC, SDMA)
  447. */
  448. __u32 index;
  449. __u32 _pad;
  450. };
  451. /* Input structure for the INFO ioctl */
  452. struct drm_amdgpu_info {
  453. /* Where the return value will be stored */
  454. __u64 return_pointer;
  455. /* The size of the return value. Just like "size" in "snprintf",
  456. * it limits how many bytes the kernel can write. */
  457. __u32 return_size;
  458. /* The query request id. */
  459. __u32 query;
  460. union {
  461. struct {
  462. __u32 id;
  463. __u32 _pad;
  464. } mode_crtc;
  465. struct {
  466. /** AMDGPU_HW_IP_* */
  467. __u32 type;
  468. /**
  469. * Index of the IP if there are more IPs of the same
  470. * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
  471. */
  472. __u32 ip_instance;
  473. } query_hw_ip;
  474. struct {
  475. __u32 dword_offset;
  476. /** number of registers to read */
  477. __u32 count;
  478. __u32 instance;
  479. /** For future use, no flags defined so far */
  480. __u32 flags;
  481. } read_mmr_reg;
  482. struct drm_amdgpu_query_fw query_fw;
  483. };
  484. };
  485. struct drm_amdgpu_info_gds {
  486. /** GDS GFX partition size */
  487. __u32 gds_gfx_partition_size;
  488. /** GDS compute partition size */
  489. __u32 compute_partition_size;
  490. /** total GDS memory size */
  491. __u32 gds_total_size;
  492. /** GWS size per GFX partition */
  493. __u32 gws_per_gfx_partition;
  494. /** GSW size per compute partition */
  495. __u32 gws_per_compute_partition;
  496. /** OA size per GFX partition */
  497. __u32 oa_per_gfx_partition;
  498. /** OA size per compute partition */
  499. __u32 oa_per_compute_partition;
  500. __u32 _pad;
  501. };
  502. struct drm_amdgpu_info_vram_gtt {
  503. __u64 vram_size;
  504. __u64 vram_cpu_accessible_size;
  505. __u64 gtt_size;
  506. };
  507. struct drm_amdgpu_info_firmware {
  508. __u32 ver;
  509. __u32 feature;
  510. };
  511. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  512. #define AMDGPU_VRAM_TYPE_GDDR1 1
  513. #define AMDGPU_VRAM_TYPE_DDR2 2
  514. #define AMDGPU_VRAM_TYPE_GDDR3 3
  515. #define AMDGPU_VRAM_TYPE_GDDR4 4
  516. #define AMDGPU_VRAM_TYPE_GDDR5 5
  517. #define AMDGPU_VRAM_TYPE_HBM 6
  518. #define AMDGPU_VRAM_TYPE_DDR3 7
  519. struct drm_amdgpu_info_device {
  520. /** PCI Device ID */
  521. __u32 device_id;
  522. /** Internal chip revision: A0, A1, etc.) */
  523. __u32 chip_rev;
  524. __u32 external_rev;
  525. /** Revision id in PCI Config space */
  526. __u32 pci_rev;
  527. __u32 family;
  528. __u32 num_shader_engines;
  529. __u32 num_shader_arrays_per_engine;
  530. /* in KHz */
  531. __u32 gpu_counter_freq;
  532. __u64 max_engine_clock;
  533. __u64 max_memory_clock;
  534. /* cu information */
  535. __u32 cu_active_number;
  536. __u32 cu_ao_mask;
  537. __u32 cu_bitmap[4][4];
  538. /** Render backend pipe mask. One render backend is CB+DB. */
  539. __u32 enabled_rb_pipes_mask;
  540. __u32 num_rb_pipes;
  541. __u32 num_hw_gfx_contexts;
  542. __u32 _pad;
  543. __u64 ids_flags;
  544. /** Starting virtual address for UMDs. */
  545. __u64 virtual_address_offset;
  546. /** The maximum virtual address */
  547. __u64 virtual_address_max;
  548. /** Required alignment of virtual addresses. */
  549. __u32 virtual_address_alignment;
  550. /** Page table entry - fragment size */
  551. __u32 pte_fragment_size;
  552. __u32 gart_page_size;
  553. /** constant engine ram size*/
  554. __u32 ce_ram_size;
  555. /** video memory type info*/
  556. __u32 vram_type;
  557. /** video memory bit width*/
  558. __u32 vram_bit_width;
  559. /* vce harvesting instance */
  560. __u32 vce_harvest_config;
  561. };
  562. struct drm_amdgpu_info_hw_ip {
  563. /** Version of h/w IP */
  564. __u32 hw_ip_version_major;
  565. __u32 hw_ip_version_minor;
  566. /** Capabilities */
  567. __u64 capabilities_flags;
  568. /** command buffer address start alignment*/
  569. __u32 ib_start_alignment;
  570. /** command buffer size alignment*/
  571. __u32 ib_size_alignment;
  572. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  573. __u32 available_rings;
  574. __u32 _pad;
  575. };
  576. /*
  577. * Supported GPU families
  578. */
  579. #define AMDGPU_FAMILY_UNKNOWN 0
  580. #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
  581. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  582. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  583. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  584. #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
  585. #if defined(__cplusplus)
  586. }
  587. #endif
  588. #endif