amdgpu_drm.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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/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_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, union 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. #define AMDGPU_CTX_OP_STATE_RUNNING 1
  127. /* GPU reset status */
  128. #define AMDGPU_CTX_NO_RESET 0
  129. #define AMDGPU_CTX_GUILTY_RESET 1 /* this the context caused it */
  130. #define AMDGPU_CTX_INNOCENT_RESET 2 /* some other context caused it */
  131. #define AMDGPU_CTX_UNKNOWN_RESET 3 /* unknown cause */
  132. struct drm_amdgpu_ctx_in {
  133. uint32_t op;
  134. uint32_t flags;
  135. uint32_t ctx_id;
  136. uint32_t _pad;
  137. };
  138. union drm_amdgpu_ctx_out {
  139. struct {
  140. uint32_t ctx_id;
  141. uint32_t _pad;
  142. } alloc;
  143. struct {
  144. uint64_t flags;
  145. /** Number of resets caused by this context so far. */
  146. uint32_t hangs;
  147. /** Reset status since the last call of the ioctl. */
  148. uint32_t reset_status;
  149. } state;
  150. };
  151. union drm_amdgpu_ctx {
  152. struct drm_amdgpu_ctx_in in;
  153. union drm_amdgpu_ctx_out out;
  154. };
  155. /*
  156. * This is not a reliable API and you should expect it to fail for any
  157. * number of reasons and have fallback path that do not use userptr to
  158. * perform any operation.
  159. */
  160. #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
  161. #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
  162. #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
  163. #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
  164. struct drm_amdgpu_gem_userptr {
  165. uint64_t addr;
  166. uint64_t size;
  167. uint32_t flags;
  168. uint32_t handle;
  169. };
  170. /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
  171. #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
  172. #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
  173. #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
  174. #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
  175. #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
  176. #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
  177. #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
  178. #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
  179. #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
  180. #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
  181. #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
  182. #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
  183. #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
  184. #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
  185. #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
  186. #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
  187. #define AMDGPU_TILING_SET(field, value) \
  188. (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
  189. #define AMDGPU_TILING_GET(value, field) \
  190. (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
  191. #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
  192. #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
  193. /** The same structure is shared for input/output */
  194. struct drm_amdgpu_gem_metadata {
  195. uint32_t handle; /* GEM Object handle */
  196. uint32_t op; /** Do we want get or set metadata */
  197. struct {
  198. uint64_t flags;
  199. uint64_t tiling_info; /* family specific tiling info */
  200. uint32_t data_size_bytes;
  201. uint32_t data[64];
  202. } data;
  203. };
  204. struct drm_amdgpu_gem_mmap_in {
  205. uint32_t handle; /** the GEM object handle */
  206. uint32_t _pad;
  207. };
  208. struct drm_amdgpu_gem_mmap_out {
  209. uint64_t addr_ptr; /** mmap offset from the vma offset manager */
  210. };
  211. union drm_amdgpu_gem_mmap {
  212. struct drm_amdgpu_gem_mmap_in in;
  213. struct drm_amdgpu_gem_mmap_out out;
  214. };
  215. struct drm_amdgpu_gem_wait_idle_in {
  216. uint32_t handle; /* GEM object handle */
  217. uint32_t flags;
  218. uint64_t timeout; /* Timeout to wait. If 0 then returned immediately with the status */
  219. };
  220. struct drm_amdgpu_gem_wait_idle_out {
  221. uint32_t status; /* BO status: 0 - BO is idle, 1 - BO is busy */
  222. uint32_t domain; /* Returned current memory domain */
  223. };
  224. union drm_amdgpu_gem_wait_idle {
  225. struct drm_amdgpu_gem_wait_idle_in in;
  226. struct drm_amdgpu_gem_wait_idle_out out;
  227. };
  228. struct drm_amdgpu_wait_cs_in {
  229. uint64_t handle;
  230. uint64_t timeout;
  231. uint32_t ip_type;
  232. uint32_t ip_instance;
  233. uint32_t ring;
  234. uint32_t ctx_id;
  235. };
  236. struct drm_amdgpu_wait_cs_out {
  237. uint64_t status;
  238. };
  239. union drm_amdgpu_wait_cs {
  240. struct drm_amdgpu_wait_cs_in in;
  241. struct drm_amdgpu_wait_cs_out out;
  242. };
  243. /* Sets or returns a value associated with a buffer. */
  244. struct drm_amdgpu_gem_op {
  245. uint32_t handle; /* buffer */
  246. uint32_t op; /* AMDGPU_GEM_OP_* */
  247. uint64_t value; /* input or return value */
  248. };
  249. #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
  250. #define AMDGPU_GEM_OP_SET_PLACEMENT 1
  251. #define AMDGPU_VA_OP_MAP 1
  252. #define AMDGPU_VA_OP_UNMAP 2
  253. #define AMDGPU_VA_RESULT_OK 0
  254. #define AMDGPU_VA_RESULT_ERROR 1
  255. #define AMDGPU_VA_RESULT_VA_INVALID_ALIGNMENT 2
  256. /* Mapping flags */
  257. /* readable mapping */
  258. #define AMDGPU_VM_PAGE_READABLE (1 << 1)
  259. /* writable mapping */
  260. #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
  261. /* executable mapping, new for VI */
  262. #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
  263. struct drm_amdgpu_gem_va_in {
  264. /* GEM object handle */
  265. uint32_t handle;
  266. uint32_t _pad;
  267. /* map or unmap*/
  268. uint32_t operation;
  269. /* specify mapping flags */
  270. uint32_t flags;
  271. /* va address to assign . Must be correctly aligned.*/
  272. uint64_t va_address;
  273. /* Specify offset inside of BO to assign. Must be correctly aligned.*/
  274. uint64_t offset_in_bo;
  275. /* Specify mapping size. If 0 and offset is 0 then map the whole BO.*/
  276. /* Must be correctly aligned. */
  277. uint64_t map_size;
  278. };
  279. struct drm_amdgpu_gem_va_out {
  280. uint32_t result;
  281. uint32_t _pad;
  282. };
  283. union drm_amdgpu_gem_va {
  284. struct drm_amdgpu_gem_va_in in;
  285. struct drm_amdgpu_gem_va_out out;
  286. };
  287. #define AMDGPU_HW_IP_GFX 0
  288. #define AMDGPU_HW_IP_COMPUTE 1
  289. #define AMDGPU_HW_IP_DMA 2
  290. #define AMDGPU_HW_IP_UVD 3
  291. #define AMDGPU_HW_IP_VCE 4
  292. #define AMDGPU_HW_IP_NUM 5
  293. #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
  294. #define AMDGPU_CHUNK_ID_IB 0x01
  295. #define AMDGPU_CHUNK_ID_FENCE 0x02
  296. struct drm_amdgpu_cs_chunk {
  297. uint32_t chunk_id;
  298. uint32_t length_dw;
  299. uint64_t chunk_data;
  300. };
  301. struct drm_amdgpu_cs_in {
  302. /** Rendering context id */
  303. uint32_t ctx_id;
  304. /** Handle of resource list associated with CS */
  305. uint32_t bo_list_handle;
  306. uint32_t num_chunks;
  307. uint32_t _pad;
  308. /* this points to uint64_t * which point to cs chunks */
  309. uint64_t chunks;
  310. };
  311. struct drm_amdgpu_cs_out {
  312. uint64_t handle;
  313. };
  314. union drm_amdgpu_cs {
  315. struct drm_amdgpu_cs_in in;
  316. struct drm_amdgpu_cs_out out;
  317. };
  318. /* Specify flags to be used for IB */
  319. /* This IB should be submitted to CE */
  320. #define AMDGPU_IB_FLAG_CE (1<<0)
  321. /* CE Preamble */
  322. #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
  323. struct drm_amdgpu_cs_chunk_ib {
  324. uint32_t _pad;
  325. uint32_t flags; /* IB Flags */
  326. uint64_t va_start; /* Virtual address to begin IB execution */
  327. uint32_t ib_bytes; /* Size of submission */
  328. uint32_t ip_type; /* HW IP to submit to */
  329. uint32_t ip_instance; /* HW IP index of the same type to submit to */
  330. uint32_t ring; /* Ring index to submit to */
  331. };
  332. struct drm_amdgpu_cs_chunk_fence {
  333. uint32_t handle;
  334. uint32_t offset;
  335. };
  336. struct drm_amdgpu_cs_chunk_data {
  337. union {
  338. struct drm_amdgpu_cs_chunk_ib ib_data;
  339. struct drm_amdgpu_cs_chunk_fence fence_data;
  340. };
  341. };
  342. /**
  343. * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  344. *
  345. */
  346. #define AMDGPU_IDS_FLAGS_FUSION 0x1
  347. /* indicate if acceleration can be working */
  348. #define AMDGPU_INFO_ACCEL_WORKING 0x00
  349. /* get the crtc_id from the mode object id? */
  350. #define AMDGPU_INFO_CRTC_FROM_ID 0x01
  351. /* query hw IP info */
  352. #define AMDGPU_INFO_HW_IP_INFO 0x02
  353. /* query hw IP instance count for the specified type */
  354. #define AMDGPU_INFO_HW_IP_COUNT 0x03
  355. /* timestamp for GL_ARB_timer_query */
  356. #define AMDGPU_INFO_TIMESTAMP 0x05
  357. /* Query the firmware version */
  358. #define AMDGPU_INFO_FW_VERSION 0x0e
  359. /* Subquery id: Query VCE firmware version */
  360. #define AMDGPU_INFO_FW_VCE 0x1
  361. /* Subquery id: Query UVD firmware version */
  362. #define AMDGPU_INFO_FW_UVD 0x2
  363. /* Subquery id: Query GMC firmware version */
  364. #define AMDGPU_INFO_FW_GMC 0x03
  365. /* Subquery id: Query GFX ME firmware version */
  366. #define AMDGPU_INFO_FW_GFX_ME 0x04
  367. /* Subquery id: Query GFX PFP firmware version */
  368. #define AMDGPU_INFO_FW_GFX_PFP 0x05
  369. /* Subquery id: Query GFX CE firmware version */
  370. #define AMDGPU_INFO_FW_GFX_CE 0x06
  371. /* Subquery id: Query GFX RLC firmware version */
  372. #define AMDGPU_INFO_FW_GFX_RLC 0x07
  373. /* Subquery id: Query GFX MEC firmware version */
  374. #define AMDGPU_INFO_FW_GFX_MEC 0x08
  375. /* Subquery id: Query SMC firmware version */
  376. #define AMDGPU_INFO_FW_SMC 0x0a
  377. /* Subquery id: Query SDMA firmware version */
  378. #define AMDGPU_INFO_FW_SDMA 0x0b
  379. /* number of bytes moved for TTM migration */
  380. #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
  381. /* the used VRAM size */
  382. #define AMDGPU_INFO_VRAM_USAGE 0x10
  383. /* the used GTT size */
  384. #define AMDGPU_INFO_GTT_USAGE 0x11
  385. /* Information about GDS, etc. resource configuration */
  386. #define AMDGPU_INFO_GDS_CONFIG 0x13
  387. /* Query information about VRAM and GTT domains */
  388. #define AMDGPU_INFO_VRAM_GTT 0x14
  389. /* Query information about register in MMR address space*/
  390. #define AMDGPU_INFO_READ_MMR_REG 0x15
  391. /* Query information about device: rev id, family, etc. */
  392. #define AMDGPU_INFO_DEV_INFO 0x16
  393. /* visible vram usage */
  394. #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
  395. #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
  396. #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
  397. #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
  398. #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
  399. /* Input structure for the INFO ioctl */
  400. struct drm_amdgpu_info {
  401. /* Where the return value will be stored */
  402. uint64_t return_pointer;
  403. /* The size of the return value. Just like "size" in "snprintf",
  404. * it limits how many bytes the kernel can write. */
  405. uint32_t return_size;
  406. /* The query request id. */
  407. uint32_t query;
  408. union {
  409. struct {
  410. uint32_t id;
  411. uint32_t _pad;
  412. } mode_crtc;
  413. struct {
  414. /** AMDGPU_HW_IP_* */
  415. uint32_t type;
  416. /**
  417. * Index of the IP if there are more IPs of the same type.
  418. * Ignored by AMDGPU_INFO_HW_IP_COUNT.
  419. */
  420. uint32_t ip_instance;
  421. } query_hw_ip;
  422. struct {
  423. uint32_t dword_offset;
  424. uint32_t count; /* number of registers to read */
  425. uint32_t instance;
  426. uint32_t flags;
  427. } read_mmr_reg;
  428. struct {
  429. /** AMDGPU_INFO_FW_* */
  430. uint32_t fw_type;
  431. /** Index of the IP if there are more IPs of the same type. */
  432. uint32_t ip_instance;
  433. /**
  434. * Index of the engine. Whether this is used depends
  435. * on the firmware type. (e.g. MEC, SDMA)
  436. */
  437. uint32_t index;
  438. uint32_t _pad;
  439. } query_fw;
  440. };
  441. };
  442. struct drm_amdgpu_info_gds {
  443. /** GDS GFX partition size */
  444. uint32_t gds_gfx_partition_size;
  445. /** GDS compute partition size */
  446. uint32_t compute_partition_size;
  447. /** total GDS memory size */
  448. uint32_t gds_total_size;
  449. /** GWS size per GFX partition */
  450. uint32_t gws_per_gfx_partition;
  451. /** GSW size per compute partition */
  452. uint32_t gws_per_compute_partition;
  453. /** OA size per GFX partition */
  454. uint32_t oa_per_gfx_partition;
  455. /** OA size per compute partition */
  456. uint32_t oa_per_compute_partition;
  457. uint32_t _pad;
  458. };
  459. struct drm_amdgpu_info_vram_gtt {
  460. uint64_t vram_size;
  461. uint64_t vram_cpu_accessible_size;
  462. uint64_t gtt_size;
  463. };
  464. struct drm_amdgpu_info_firmware {
  465. uint32_t ver;
  466. uint32_t feature;
  467. };
  468. #define AMDGPU_VRAM_TYPE_UNKNOWN 0
  469. #define AMDGPU_VRAM_TYPE_GDDR1 1
  470. #define AMDGPU_VRAM_TYPE_DDR2 2
  471. #define AMDGPU_VRAM_TYPE_GDDR3 3
  472. #define AMDGPU_VRAM_TYPE_GDDR4 4
  473. #define AMDGPU_VRAM_TYPE_GDDR5 5
  474. #define AMDGPU_VRAM_TYPE_HBM 6
  475. #define AMDGPU_VRAM_TYPE_DDR3 7
  476. struct drm_amdgpu_info_device {
  477. /** PCI Device ID */
  478. uint32_t device_id;
  479. /** Internal chip revision: A0, A1, etc.) */
  480. uint32_t chip_rev;
  481. uint32_t external_rev;
  482. /** Revision id in PCI Config space */
  483. uint32_t pci_rev;
  484. uint32_t family;
  485. uint32_t num_shader_engines;
  486. uint32_t num_shader_arrays_per_engine;
  487. uint32_t gpu_counter_freq; /* in KHz */
  488. uint64_t max_engine_clock; /* in KHz */
  489. uint64_t max_memory_clock; /* in KHz */
  490. /* cu information */
  491. uint32_t cu_active_number;
  492. uint32_t cu_ao_mask;
  493. uint32_t cu_bitmap[4][4];
  494. /** Render backend pipe mask. One render backend is CB+DB. */
  495. uint32_t enabled_rb_pipes_mask;
  496. uint32_t num_rb_pipes;
  497. uint32_t num_hw_gfx_contexts;
  498. uint32_t _pad;
  499. uint64_t ids_flags;
  500. /** Starting virtual address for UMDs. */
  501. uint64_t virtual_address_offset;
  502. /** The maximum virtual address */
  503. uint64_t virtual_address_max;
  504. /** Required alignment of virtual addresses. */
  505. uint32_t virtual_address_alignment;
  506. /** Page table entry - fragment size */
  507. uint32_t pte_fragment_size;
  508. uint32_t gart_page_size;
  509. /** constant engine ram size*/
  510. uint32_t ce_ram_size;
  511. /** video memory type info*/
  512. uint32_t vram_type;
  513. /** video memory bit width*/
  514. uint32_t vram_bit_width;
  515. };
  516. struct drm_amdgpu_info_hw_ip {
  517. /** Version of h/w IP */
  518. uint32_t hw_ip_version_major;
  519. uint32_t hw_ip_version_minor;
  520. /** Capabilities */
  521. uint64_t capabilities_flags;
  522. /** command buffer address start alignment*/
  523. uint32_t ib_start_alignment;
  524. /** command buffer size alignment*/
  525. uint32_t ib_size_alignment;
  526. /** Bitmask of available rings. Bit 0 means ring 0, etc. */
  527. uint32_t available_rings;
  528. uint32_t _pad;
  529. };
  530. /*
  531. * Supported GPU families
  532. */
  533. #define AMDGPU_FAMILY_UNKNOWN 0
  534. #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
  535. #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
  536. #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
  537. #define AMDGPU_FAMILY_CZ 135 /* Carrizo */
  538. #endif