v3d_drm.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. /*
  2. * Copyright © 2014-2018 Broadcom
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. */
  23. #ifndef _V3D_DRM_H_
  24. #define _V3D_DRM_H_
  25. #include "drm.h"
  26. #if defined(__cplusplus)
  27. extern "C" {
  28. #endif
  29. #define DRM_V3D_SUBMIT_CL 0x00
  30. #define DRM_V3D_WAIT_BO 0x01
  31. #define DRM_V3D_CREATE_BO 0x02
  32. #define DRM_V3D_MMAP_BO 0x03
  33. #define DRM_V3D_GET_PARAM 0x04
  34. #define DRM_V3D_GET_BO_OFFSET 0x05
  35. #define DRM_V3D_SUBMIT_TFU 0x06
  36. #define DRM_V3D_SUBMIT_CSD 0x07
  37. #define DRM_V3D_PERFMON_CREATE 0x08
  38. #define DRM_V3D_PERFMON_DESTROY 0x09
  39. #define DRM_V3D_PERFMON_GET_VALUES 0x0a
  40. #define DRM_V3D_SUBMIT_CPU 0x0b
  41. #define DRM_V3D_PERFMON_GET_COUNTER 0x0c
  42. #define DRM_V3D_PERFMON_SET_GLOBAL 0x0d
  43. #define DRM_IOCTL_V3D_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CL, struct drm_v3d_submit_cl)
  44. #define DRM_IOCTL_V3D_WAIT_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_WAIT_BO, struct drm_v3d_wait_bo)
  45. #define DRM_IOCTL_V3D_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_CREATE_BO, struct drm_v3d_create_bo)
  46. #define DRM_IOCTL_V3D_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_MMAP_BO, struct drm_v3d_mmap_bo)
  47. #define DRM_IOCTL_V3D_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_PARAM, struct drm_v3d_get_param)
  48. #define DRM_IOCTL_V3D_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_BO_OFFSET, struct drm_v3d_get_bo_offset)
  49. #define DRM_IOCTL_V3D_SUBMIT_TFU DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_TFU, struct drm_v3d_submit_tfu)
  50. #define DRM_IOCTL_V3D_SUBMIT_CSD DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CSD, struct drm_v3d_submit_csd)
  51. #define DRM_IOCTL_V3D_PERFMON_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_CREATE, \
  52. struct drm_v3d_perfmon_create)
  53. #define DRM_IOCTL_V3D_PERFMON_DESTROY DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_DESTROY, \
  54. struct drm_v3d_perfmon_destroy)
  55. #define DRM_IOCTL_V3D_PERFMON_GET_VALUES DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_GET_VALUES, \
  56. struct drm_v3d_perfmon_get_values)
  57. #define DRM_IOCTL_V3D_SUBMIT_CPU DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CPU, struct drm_v3d_submit_cpu)
  58. #define DRM_IOCTL_V3D_PERFMON_GET_COUNTER DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_GET_COUNTER, \
  59. struct drm_v3d_perfmon_get_counter)
  60. #define DRM_IOCTL_V3D_PERFMON_SET_GLOBAL DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_PERFMON_SET_GLOBAL, \
  61. struct drm_v3d_perfmon_set_global)
  62. #define DRM_V3D_SUBMIT_CL_FLUSH_CACHE 0x01
  63. #define DRM_V3D_SUBMIT_EXTENSION 0x02
  64. /* struct drm_v3d_extension - ioctl extensions
  65. *
  66. * Linked-list of generic extensions where the id identify which struct is
  67. * pointed by ext_data. Therefore, DRM_V3D_EXT_ID_* is used on id to identify
  68. * the extension type.
  69. */
  70. struct drm_v3d_extension {
  71. __u64 next;
  72. __u32 id;
  73. #define DRM_V3D_EXT_ID_MULTI_SYNC 0x01
  74. #define DRM_V3D_EXT_ID_CPU_INDIRECT_CSD 0x02
  75. #define DRM_V3D_EXT_ID_CPU_TIMESTAMP_QUERY 0x03
  76. #define DRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY 0x04
  77. #define DRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY 0x05
  78. #define DRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY 0x06
  79. #define DRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY 0x07
  80. __u32 flags; /* mbz */
  81. };
  82. /* struct drm_v3d_sem - wait/signal semaphore
  83. *
  84. * If binary semaphore, it only takes syncobj handle and ignores flags and
  85. * point fields. Point is defined for timeline syncobj feature.
  86. */
  87. struct drm_v3d_sem {
  88. __u32 handle; /* syncobj */
  89. /* rsv below, for future uses */
  90. __u32 flags;
  91. __u64 point; /* for timeline sem support */
  92. __u64 mbz[2]; /* must be zero, rsv */
  93. };
  94. /* Enum for each of the V3D queues. */
  95. enum v3d_queue {
  96. V3D_BIN,
  97. V3D_RENDER,
  98. V3D_TFU,
  99. V3D_CSD,
  100. V3D_CACHE_CLEAN,
  101. V3D_CPU,
  102. };
  103. /**
  104. * struct drm_v3d_multi_sync - ioctl extension to add support multiples
  105. * syncobjs for commands submission.
  106. *
  107. * When an extension of DRM_V3D_EXT_ID_MULTI_SYNC id is defined, it points to
  108. * this extension to define wait and signal dependencies, instead of single
  109. * in/out sync entries on submitting commands. The field flags is used to
  110. * determine the stage to set wait dependencies.
  111. */
  112. struct drm_v3d_multi_sync {
  113. struct drm_v3d_extension base;
  114. /* Array of wait and signal semaphores */
  115. __u64 in_syncs;
  116. __u64 out_syncs;
  117. /* Number of entries */
  118. __u32 in_sync_count;
  119. __u32 out_sync_count;
  120. /* set the stage (v3d_queue) to sync */
  121. __u32 wait_stage;
  122. __u32 pad; /* mbz */
  123. };
  124. /**
  125. * struct drm_v3d_submit_cl - ioctl argument for submitting commands to the 3D
  126. * engine.
  127. *
  128. * This asks the kernel to have the GPU execute an optional binner
  129. * command list, and a render command list.
  130. *
  131. * The L1T, slice, L2C, L2T, and GCA caches will be flushed before
  132. * each CL executes. The VCD cache should be flushed (if necessary)
  133. * by the submitted CLs. The TLB writes are guaranteed to have been
  134. * flushed by the time the render done IRQ happens, which is the
  135. * trigger for out_sync. Any dirtying of cachelines by the job (only
  136. * possible using TMU writes) must be flushed by the caller using the
  137. * DRM_V3D_SUBMIT_CL_FLUSH_CACHE_FLAG flag.
  138. */
  139. struct drm_v3d_submit_cl {
  140. /* Pointer to the binner command list.
  141. *
  142. * This is the first set of commands executed, which runs the
  143. * coordinate shader to determine where primitives land on the screen,
  144. * then writes out the state updates and draw calls necessary per tile
  145. * to the tile allocation BO.
  146. *
  147. * This BCL will block on any previous BCL submitted on the
  148. * same FD, but not on any RCL or BCLs submitted by other
  149. * clients -- that is left up to the submitter to control
  150. * using in_sync_bcl if necessary.
  151. */
  152. __u32 bcl_start;
  153. /** End address of the BCL (first byte after the BCL) */
  154. __u32 bcl_end;
  155. /* Offset of the render command list.
  156. *
  157. * This is the second set of commands executed, which will either
  158. * execute the tiles that have been set up by the BCL, or a fixed set
  159. * of tiles (in the case of RCL-only blits).
  160. *
  161. * This RCL will block on this submit's BCL, and any previous
  162. * RCL submitted on the same FD, but not on any RCL or BCLs
  163. * submitted by other clients -- that is left up to the
  164. * submitter to control using in_sync_rcl if necessary.
  165. */
  166. __u32 rcl_start;
  167. /** End address of the RCL (first byte after the RCL) */
  168. __u32 rcl_end;
  169. /** An optional sync object to wait on before starting the BCL. */
  170. __u32 in_sync_bcl;
  171. /** An optional sync object to wait on before starting the RCL. */
  172. __u32 in_sync_rcl;
  173. /** An optional sync object to place the completion fence in. */
  174. __u32 out_sync;
  175. /* Offset of the tile alloc memory
  176. *
  177. * This is optional on V3D 3.3 (where the CL can set the value) but
  178. * required on V3D 4.1.
  179. */
  180. __u32 qma;
  181. /** Size of the tile alloc memory. */
  182. __u32 qms;
  183. /** Offset of the tile state data array. */
  184. __u32 qts;
  185. /* Pointer to a u32 array of the BOs that are referenced by the job.
  186. */
  187. __u64 bo_handles;
  188. /* Number of BO handles passed in (size is that times 4). */
  189. __u32 bo_handle_count;
  190. /* DRM_V3D_SUBMIT_* properties */
  191. __u32 flags;
  192. /* ID of the perfmon to attach to this job. 0 means no perfmon. */
  193. __u32 perfmon_id;
  194. __u32 pad;
  195. /* Pointer to an array of ioctl extensions*/
  196. __u64 extensions;
  197. };
  198. /**
  199. * struct drm_v3d_wait_bo - ioctl argument for waiting for
  200. * completion of the last DRM_V3D_SUBMIT_CL on a BO.
  201. *
  202. * This is useful for cases where multiple processes might be
  203. * rendering to a BO and you want to wait for all rendering to be
  204. * completed.
  205. */
  206. struct drm_v3d_wait_bo {
  207. __u32 handle;
  208. __u32 pad;
  209. __u64 timeout_ns;
  210. };
  211. /**
  212. * struct drm_v3d_create_bo - ioctl argument for creating V3D BOs.
  213. *
  214. * There are currently no values for the flags argument, but it may be
  215. * used in a future extension.
  216. */
  217. struct drm_v3d_create_bo {
  218. __u32 size;
  219. __u32 flags;
  220. /** Returned GEM handle for the BO. */
  221. __u32 handle;
  222. /**
  223. * Returned offset for the BO in the V3D address space. This offset
  224. * is private to the DRM fd and is valid for the lifetime of the GEM
  225. * handle.
  226. *
  227. * This offset value will always be nonzero, since various HW
  228. * units treat 0 specially.
  229. */
  230. __u32 offset;
  231. };
  232. /**
  233. * struct drm_v3d_mmap_bo - ioctl argument for mapping V3D BOs.
  234. *
  235. * This doesn't actually perform an mmap. Instead, it returns the
  236. * offset you need to use in an mmap on the DRM device node. This
  237. * means that tools like valgrind end up knowing about the mapped
  238. * memory.
  239. *
  240. * There are currently no values for the flags argument, but it may be
  241. * used in a future extension.
  242. */
  243. struct drm_v3d_mmap_bo {
  244. /** Handle for the object being mapped. */
  245. __u32 handle;
  246. __u32 flags;
  247. /** offset into the drm node to use for subsequent mmap call. */
  248. __u64 offset;
  249. };
  250. enum drm_v3d_param {
  251. DRM_V3D_PARAM_V3D_UIFCFG,
  252. DRM_V3D_PARAM_V3D_HUB_IDENT1,
  253. DRM_V3D_PARAM_V3D_HUB_IDENT2,
  254. DRM_V3D_PARAM_V3D_HUB_IDENT3,
  255. DRM_V3D_PARAM_V3D_CORE0_IDENT0,
  256. DRM_V3D_PARAM_V3D_CORE0_IDENT1,
  257. DRM_V3D_PARAM_V3D_CORE0_IDENT2,
  258. DRM_V3D_PARAM_SUPPORTS_TFU,
  259. DRM_V3D_PARAM_SUPPORTS_CSD,
  260. DRM_V3D_PARAM_SUPPORTS_CACHE_FLUSH,
  261. DRM_V3D_PARAM_SUPPORTS_PERFMON,
  262. DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT,
  263. DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE,
  264. DRM_V3D_PARAM_MAX_PERF_COUNTERS,
  265. DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES,
  266. DRM_V3D_PARAM_GLOBAL_RESET_COUNTER,
  267. DRM_V3D_PARAM_CONTEXT_RESET_COUNTER,
  268. };
  269. struct drm_v3d_get_param {
  270. __u32 param;
  271. __u32 pad;
  272. __u64 value;
  273. };
  274. /**
  275. * Returns the offset for the BO in the V3D address space for this DRM fd.
  276. * This is the same value returned by drm_v3d_create_bo, if that was called
  277. * from this DRM fd.
  278. */
  279. struct drm_v3d_get_bo_offset {
  280. __u32 handle;
  281. __u32 offset;
  282. };
  283. struct drm_v3d_submit_tfu {
  284. __u32 icfg;
  285. __u32 iia;
  286. __u32 iis;
  287. __u32 ica;
  288. __u32 iua;
  289. __u32 ioa;
  290. __u32 ios;
  291. __u32 coef[4];
  292. /* First handle is the output BO, following are other inputs.
  293. * 0 for unused.
  294. */
  295. __u32 bo_handles[4];
  296. /* sync object to block on before running the TFU job. Each TFU
  297. * job will execute in the order submitted to its FD. Synchronization
  298. * against rendering jobs requires using sync objects.
  299. */
  300. __u32 in_sync;
  301. /* Sync object to signal when the TFU job is done. */
  302. __u32 out_sync;
  303. __u32 flags;
  304. /* Pointer to an array of ioctl extensions*/
  305. __u64 extensions;
  306. struct {
  307. __u32 ioc;
  308. __u32 pad;
  309. } v71;
  310. };
  311. /* Submits a compute shader for dispatch. This job will block on any
  312. * previous compute shaders submitted on this fd, and any other
  313. * synchronization must be performed with in_sync/out_sync.
  314. */
  315. struct drm_v3d_submit_csd {
  316. __u32 cfg[7];
  317. __u32 coef[4];
  318. /* Pointer to a u32 array of the BOs that are referenced by the job.
  319. */
  320. __u64 bo_handles;
  321. /* Number of BO handles passed in (size is that times 4). */
  322. __u32 bo_handle_count;
  323. /* sync object to block on before running the CSD job. Each
  324. * CSD job will execute in the order submitted to its FD.
  325. * Synchronization against rendering/TFU jobs or CSD from
  326. * other fds requires using sync objects.
  327. */
  328. __u32 in_sync;
  329. /* Sync object to signal when the CSD job is done. */
  330. __u32 out_sync;
  331. /* ID of the perfmon to attach to this job. 0 means no perfmon. */
  332. __u32 perfmon_id;
  333. /* Pointer to an array of ioctl extensions*/
  334. __u64 extensions;
  335. __u32 flags;
  336. __u32 pad;
  337. };
  338. /**
  339. * struct drm_v3d_indirect_csd - ioctl extension for the CPU job to create an
  340. * indirect CSD
  341. *
  342. * When an extension of DRM_V3D_EXT_ID_CPU_INDIRECT_CSD id is defined, it
  343. * points to this extension to define a indirect CSD submission. It creates a
  344. * CPU job linked to a CSD job. The CPU job waits for the indirect CSD
  345. * dependencies and, once they are signaled, it updates the CSD job config
  346. * before allowing the CSD job execution.
  347. */
  348. struct drm_v3d_indirect_csd {
  349. struct drm_v3d_extension base;
  350. /* Indirect CSD */
  351. struct drm_v3d_submit_csd submit;
  352. /* Handle of the indirect BO, that should be also attached to the
  353. * indirect CSD.
  354. */
  355. __u32 indirect;
  356. /* Offset within the BO where the workgroup counts are stored */
  357. __u32 offset;
  358. /* Workgroups size */
  359. __u32 wg_size;
  360. /* Indices of the uniforms with the workgroup dispatch counts
  361. * in the uniform stream. If the uniform rewrite is not needed,
  362. * the offset must be 0xffffffff.
  363. */
  364. __u32 wg_uniform_offsets[3];
  365. };
  366. /**
  367. * struct drm_v3d_timestamp_query - ioctl extension for the CPU job to calculate
  368. * a timestamp query
  369. *
  370. * When an extension DRM_V3D_EXT_ID_TIMESTAMP_QUERY is defined, it points to
  371. * this extension to define a timestamp query submission. This CPU job will
  372. * calculate the timestamp query and update the query value within the
  373. * timestamp BO. Moreover, it will signal the timestamp syncobj to indicate
  374. * query availability.
  375. */
  376. struct drm_v3d_timestamp_query {
  377. struct drm_v3d_extension base;
  378. /* Array of queries' offsets within the timestamp BO for their value */
  379. __u64 offsets;
  380. /* Array of timestamp's syncobjs to indicate its availability */
  381. __u64 syncs;
  382. /* Number of queries */
  383. __u32 count;
  384. /* mbz */
  385. __u32 pad;
  386. };
  387. /**
  388. * struct drm_v3d_reset_timestamp_query - ioctl extension for the CPU job to
  389. * reset timestamp queries
  390. *
  391. * When an extension DRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY is defined, it
  392. * points to this extension to define a reset timestamp submission. This CPU
  393. * job will reset the timestamp queries based on value offset of the first
  394. * query. Moreover, it will reset the timestamp syncobj to reset query
  395. * availability.
  396. */
  397. struct drm_v3d_reset_timestamp_query {
  398. struct drm_v3d_extension base;
  399. /* Array of timestamp's syncobjs to indicate its availability */
  400. __u64 syncs;
  401. /* Offset of the first query within the timestamp BO for its value */
  402. __u32 offset;
  403. /* Number of queries */
  404. __u32 count;
  405. };
  406. /**
  407. * struct drm_v3d_copy_timestamp_query - ioctl extension for the CPU job to copy
  408. * query results to a buffer
  409. *
  410. * When an extension DRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY is defined, it
  411. * points to this extension to define a copy timestamp query submission. This
  412. * CPU job will copy the timestamp queries results to a BO with the offset
  413. * and stride defined in the extension.
  414. */
  415. struct drm_v3d_copy_timestamp_query {
  416. struct drm_v3d_extension base;
  417. /* Define if should write to buffer using 64 or 32 bits */
  418. __u8 do_64bit;
  419. /* Define if it can write to buffer even if the query is not available */
  420. __u8 do_partial;
  421. /* Define if it should write availability bit to buffer */
  422. __u8 availability_bit;
  423. /* mbz */
  424. __u8 pad;
  425. /* Offset of the buffer in the BO */
  426. __u32 offset;
  427. /* Stride of the buffer in the BO */
  428. __u32 stride;
  429. /* Number of queries */
  430. __u32 count;
  431. /* Array of queries' offsets within the timestamp BO for their value */
  432. __u64 offsets;
  433. /* Array of timestamp's syncobjs to indicate its availability */
  434. __u64 syncs;
  435. };
  436. /**
  437. * struct drm_v3d_reset_performance_query - ioctl extension for the CPU job to
  438. * reset performance queries
  439. *
  440. * When an extension DRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY is defined, it
  441. * points to this extension to define a reset performance submission. This CPU
  442. * job will reset the performance queries by resetting the values of the
  443. * performance monitors. Moreover, it will reset the syncobj to reset query
  444. * availability.
  445. */
  446. struct drm_v3d_reset_performance_query {
  447. struct drm_v3d_extension base;
  448. /* Array of performance queries's syncobjs to indicate its availability */
  449. __u64 syncs;
  450. /* Number of queries */
  451. __u32 count;
  452. /* Number of performance monitors */
  453. __u32 nperfmons;
  454. /* Array of u64 user-pointers that point to an array of kperfmon_ids */
  455. __u64 kperfmon_ids;
  456. };
  457. /**
  458. * struct drm_v3d_copy_performance_query - ioctl extension for the CPU job to copy
  459. * performance query results to a buffer
  460. *
  461. * When an extension DRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY is defined, it
  462. * points to this extension to define a copy performance query submission. This
  463. * CPU job will copy the performance queries results to a BO with the offset
  464. * and stride defined in the extension.
  465. */
  466. struct drm_v3d_copy_performance_query {
  467. struct drm_v3d_extension base;
  468. /* Define if should write to buffer using 64 or 32 bits */
  469. __u8 do_64bit;
  470. /* Define if it can write to buffer even if the query is not available */
  471. __u8 do_partial;
  472. /* Define if it should write availability bit to buffer */
  473. __u8 availability_bit;
  474. /* mbz */
  475. __u8 pad;
  476. /* Offset of the buffer in the BO */
  477. __u32 offset;
  478. /* Stride of the buffer in the BO */
  479. __u32 stride;
  480. /* Number of performance monitors */
  481. __u32 nperfmons;
  482. /* Number of performance counters related to this query pool */
  483. __u32 ncounters;
  484. /* Number of queries */
  485. __u32 count;
  486. /* Array of performance queries's syncobjs to indicate its availability */
  487. __u64 syncs;
  488. /* Array of u64 user-pointers that point to an array of kperfmon_ids */
  489. __u64 kperfmon_ids;
  490. };
  491. struct drm_v3d_submit_cpu {
  492. /* Pointer to a u32 array of the BOs that are referenced by the job.
  493. *
  494. * For DRM_V3D_EXT_ID_CPU_INDIRECT_CSD, it must contain only one BO,
  495. * that contains the workgroup counts.
  496. *
  497. * For DRM_V3D_EXT_ID_TIMESTAMP_QUERY, it must contain only one BO,
  498. * that will contain the timestamp.
  499. *
  500. * For DRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY, it must contain only
  501. * one BO, that contains the timestamp.
  502. *
  503. * For DRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY, it must contain two
  504. * BOs. The first is the BO where the timestamp queries will be written
  505. * to. The second is the BO that contains the timestamp.
  506. *
  507. * For DRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY, it must contain no
  508. * BOs.
  509. *
  510. * For DRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY, it must contain one
  511. * BO, where the performance queries will be written.
  512. */
  513. __u64 bo_handles;
  514. /* Number of BO handles passed in (size is that times 4). */
  515. __u32 bo_handle_count;
  516. __u32 flags;
  517. /* Pointer to an array of ioctl extensions*/
  518. __u64 extensions;
  519. };
  520. /* The performance counters index represented by this enum are deprecated and
  521. * must no longer be used. These counters are only valid for V3D 4.2.
  522. *
  523. * In order to check for performance counter information,
  524. * use DRM_IOCTL_V3D_PERFMON_GET_COUNTER.
  525. *
  526. * Don't use V3D_PERFCNT_NUM to retrieve the maximum number of performance
  527. * counters. You should use DRM_IOCTL_V3D_GET_PARAM with the following
  528. * parameter: DRM_V3D_PARAM_MAX_PERF_COUNTERS.
  529. */
  530. enum {
  531. V3D_PERFCNT_FEP_VALID_PRIMTS_NO_PIXELS,
  532. V3D_PERFCNT_FEP_VALID_PRIMS,
  533. V3D_PERFCNT_FEP_EZ_NFCLIP_QUADS,
  534. V3D_PERFCNT_FEP_VALID_QUADS,
  535. V3D_PERFCNT_TLB_QUADS_STENCIL_FAIL,
  536. V3D_PERFCNT_TLB_QUADS_STENCILZ_FAIL,
  537. V3D_PERFCNT_TLB_QUADS_STENCILZ_PASS,
  538. V3D_PERFCNT_TLB_QUADS_ZERO_COV,
  539. V3D_PERFCNT_TLB_QUADS_NONZERO_COV,
  540. V3D_PERFCNT_TLB_QUADS_WRITTEN,
  541. V3D_PERFCNT_PTB_PRIM_VIEWPOINT_DISCARD,
  542. V3D_PERFCNT_PTB_PRIM_CLIP,
  543. V3D_PERFCNT_PTB_PRIM_REV,
  544. V3D_PERFCNT_QPU_IDLE_CYCLES,
  545. V3D_PERFCNT_QPU_ACTIVE_CYCLES_VERTEX_COORD_USER,
  546. V3D_PERFCNT_QPU_ACTIVE_CYCLES_FRAG,
  547. V3D_PERFCNT_QPU_CYCLES_VALID_INSTR,
  548. V3D_PERFCNT_QPU_CYCLES_TMU_STALL,
  549. V3D_PERFCNT_QPU_CYCLES_SCOREBOARD_STALL,
  550. V3D_PERFCNT_QPU_CYCLES_VARYINGS_STALL,
  551. V3D_PERFCNT_QPU_IC_HIT,
  552. V3D_PERFCNT_QPU_IC_MISS,
  553. V3D_PERFCNT_QPU_UC_HIT,
  554. V3D_PERFCNT_QPU_UC_MISS,
  555. V3D_PERFCNT_TMU_TCACHE_ACCESS,
  556. V3D_PERFCNT_TMU_TCACHE_MISS,
  557. V3D_PERFCNT_VPM_VDW_STALL,
  558. V3D_PERFCNT_VPM_VCD_STALL,
  559. V3D_PERFCNT_BIN_ACTIVE,
  560. V3D_PERFCNT_RDR_ACTIVE,
  561. V3D_PERFCNT_L2T_HITS,
  562. V3D_PERFCNT_L2T_MISSES,
  563. V3D_PERFCNT_CYCLE_COUNT,
  564. V3D_PERFCNT_QPU_CYCLES_STALLED_VERTEX_COORD_USER,
  565. V3D_PERFCNT_QPU_CYCLES_STALLED_FRAGMENT,
  566. V3D_PERFCNT_PTB_PRIMS_BINNED,
  567. V3D_PERFCNT_AXI_WRITES_WATCH_0,
  568. V3D_PERFCNT_AXI_READS_WATCH_0,
  569. V3D_PERFCNT_AXI_WRITE_STALLS_WATCH_0,
  570. V3D_PERFCNT_AXI_READ_STALLS_WATCH_0,
  571. V3D_PERFCNT_AXI_WRITE_BYTES_WATCH_0,
  572. V3D_PERFCNT_AXI_READ_BYTES_WATCH_0,
  573. V3D_PERFCNT_AXI_WRITES_WATCH_1,
  574. V3D_PERFCNT_AXI_READS_WATCH_1,
  575. V3D_PERFCNT_AXI_WRITE_STALLS_WATCH_1,
  576. V3D_PERFCNT_AXI_READ_STALLS_WATCH_1,
  577. V3D_PERFCNT_AXI_WRITE_BYTES_WATCH_1,
  578. V3D_PERFCNT_AXI_READ_BYTES_WATCH_1,
  579. V3D_PERFCNT_TLB_PARTIAL_QUADS,
  580. V3D_PERFCNT_TMU_CONFIG_ACCESSES,
  581. V3D_PERFCNT_L2T_NO_ID_STALL,
  582. V3D_PERFCNT_L2T_COM_QUE_STALL,
  583. V3D_PERFCNT_L2T_TMU_WRITES,
  584. V3D_PERFCNT_TMU_ACTIVE_CYCLES,
  585. V3D_PERFCNT_TMU_STALLED_CYCLES,
  586. V3D_PERFCNT_CLE_ACTIVE,
  587. V3D_PERFCNT_L2T_TMU_READS,
  588. V3D_PERFCNT_L2T_CLE_READS,
  589. V3D_PERFCNT_L2T_VCD_READS,
  590. V3D_PERFCNT_L2T_TMUCFG_READS,
  591. V3D_PERFCNT_L2T_SLC0_READS,
  592. V3D_PERFCNT_L2T_SLC1_READS,
  593. V3D_PERFCNT_L2T_SLC2_READS,
  594. V3D_PERFCNT_L2T_TMU_W_MISSES,
  595. V3D_PERFCNT_L2T_TMU_R_MISSES,
  596. V3D_PERFCNT_L2T_CLE_MISSES,
  597. V3D_PERFCNT_L2T_VCD_MISSES,
  598. V3D_PERFCNT_L2T_TMUCFG_MISSES,
  599. V3D_PERFCNT_L2T_SLC0_MISSES,
  600. V3D_PERFCNT_L2T_SLC1_MISSES,
  601. V3D_PERFCNT_L2T_SLC2_MISSES,
  602. V3D_PERFCNT_CORE_MEM_WRITES,
  603. V3D_PERFCNT_L2T_MEM_WRITES,
  604. V3D_PERFCNT_PTB_MEM_WRITES,
  605. V3D_PERFCNT_TLB_MEM_WRITES,
  606. V3D_PERFCNT_CORE_MEM_READS,
  607. V3D_PERFCNT_L2T_MEM_READS,
  608. V3D_PERFCNT_PTB_MEM_READS,
  609. V3D_PERFCNT_PSE_MEM_READS,
  610. V3D_PERFCNT_TLB_MEM_READS,
  611. V3D_PERFCNT_GMP_MEM_READS,
  612. V3D_PERFCNT_PTB_W_MEM_WORDS,
  613. V3D_PERFCNT_TLB_W_MEM_WORDS,
  614. V3D_PERFCNT_PSE_R_MEM_WORDS,
  615. V3D_PERFCNT_TLB_R_MEM_WORDS,
  616. V3D_PERFCNT_TMU_MRU_HITS,
  617. V3D_PERFCNT_COMPUTE_ACTIVE,
  618. V3D_PERFCNT_NUM,
  619. };
  620. #define DRM_V3D_MAX_PERF_COUNTERS 32
  621. struct drm_v3d_perfmon_create {
  622. __u32 id;
  623. __u32 ncounters;
  624. __u8 counters[DRM_V3D_MAX_PERF_COUNTERS];
  625. };
  626. struct drm_v3d_perfmon_destroy {
  627. __u32 id;
  628. };
  629. /*
  630. * Returns the values of the performance counters tracked by this
  631. * perfmon (as an array of ncounters u64 values).
  632. *
  633. * No implicit synchronization is performed, so the user has to
  634. * guarantee that any jobs using this perfmon have already been
  635. * completed (probably by blocking on the seqno returned by the
  636. * last exec that used the perfmon).
  637. */
  638. struct drm_v3d_perfmon_get_values {
  639. __u32 id;
  640. __u32 pad;
  641. __u64 values_ptr;
  642. };
  643. #define DRM_V3D_PERFCNT_MAX_NAME 64
  644. #define DRM_V3D_PERFCNT_MAX_CATEGORY 32
  645. #define DRM_V3D_PERFCNT_MAX_DESCRIPTION 256
  646. /**
  647. * struct drm_v3d_perfmon_get_counter - ioctl to get the description of a
  648. * performance counter
  649. *
  650. * As userspace needs to retrieve information about the performance counters
  651. * available, this IOCTL allows users to get information about a performance
  652. * counter (name, category and description).
  653. */
  654. struct drm_v3d_perfmon_get_counter {
  655. /*
  656. * Counter ID
  657. *
  658. * Must be smaller than the maximum number of performance counters, which
  659. * can be retrieve through DRM_V3D_PARAM_MAX_PERF_COUNTERS.
  660. */
  661. __u8 counter;
  662. /* Name of the counter */
  663. __u8 name[DRM_V3D_PERFCNT_MAX_NAME];
  664. /* Category of the counter */
  665. __u8 category[DRM_V3D_PERFCNT_MAX_CATEGORY];
  666. /* Description of the counter */
  667. __u8 description[DRM_V3D_PERFCNT_MAX_DESCRIPTION];
  668. /* mbz */
  669. __u8 reserved[7];
  670. };
  671. #define DRM_V3D_PERFMON_CLEAR_GLOBAL 0x0001
  672. /**
  673. * struct drm_v3d_perfmon_set_global - ioctl to define a global performance
  674. * monitor
  675. *
  676. * The global performance monitor will be used for all jobs. If a global
  677. * performance monitor is defined, jobs with a self-defined performance
  678. * monitor won't be allowed.
  679. */
  680. struct drm_v3d_perfmon_set_global {
  681. __u32 flags;
  682. __u32 id;
  683. };
  684. #if defined(__cplusplus)
  685. }
  686. #endif
  687. #endif /* _V3D_DRM_H_ */