amdgpu_drm.h 18 KB

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