msm_drm.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifndef __MSM_DRM_H__
  25. #define __MSM_DRM_H__
  26. #include "drm.h"
  27. #if defined(__cplusplus)
  28. extern "C" {
  29. #endif
  30. /* Please note that modifications to all structs defined here are
  31. * subject to backwards-compatibility constraints:
  32. * 1) Do not use pointers, use __u64 instead for 32 bit / 64 bit
  33. * user/kernel compatibility
  34. * 2) Keep fields aligned to their size
  35. * 3) Because of how drm_ioctl() works, we can add new fields at
  36. * the end of an ioctl if some care is taken: drm_ioctl() will
  37. * zero out the new fields at the tail of the ioctl, so a zero
  38. * value should have a backwards compatible meaning. And for
  39. * output params, userspace won't see the newly added output
  40. * fields.. so that has to be somehow ok.
  41. */
  42. #define MSM_PIPE_NONE 0x00
  43. #define MSM_PIPE_2D0 0x01
  44. #define MSM_PIPE_2D1 0x02
  45. #define MSM_PIPE_3D0 0x10
  46. /* The pipe-id just uses the lower bits, so can be OR'd with flags in
  47. * the upper 16 bits (which could be extended further, if needed, maybe
  48. * we extend/overload the pipe-id some day to deal with multiple rings,
  49. * but even then I don't think we need the full lower 16 bits).
  50. */
  51. #define MSM_PIPE_ID_MASK 0xffff
  52. #define MSM_PIPE_ID(x) ((x) & MSM_PIPE_ID_MASK)
  53. #define MSM_PIPE_FLAGS(x) ((x) & ~MSM_PIPE_ID_MASK)
  54. /* timeouts are specified in clock-monotonic absolute times (to simplify
  55. * restarting interrupted ioctls). The following struct is logically the
  56. * same as 'struct timespec' but 32/64b ABI safe.
  57. */
  58. struct drm_msm_timespec {
  59. __s64 tv_sec; /* seconds */
  60. __s64 tv_nsec; /* nanoseconds */
  61. };
  62. /* Below "RO" indicates a read-only param, "WO" indicates write-only, and
  63. * "RW" indicates a param that can be both read (GET_PARAM) and written
  64. * (SET_PARAM)
  65. */
  66. #define MSM_PARAM_GPU_ID 0x01 /* RO */
  67. #define MSM_PARAM_GMEM_SIZE 0x02 /* RO */
  68. #define MSM_PARAM_CHIP_ID 0x03 /* RO */
  69. #define MSM_PARAM_MAX_FREQ 0x04 /* RO */
  70. #define MSM_PARAM_TIMESTAMP 0x05 /* RO */
  71. #define MSM_PARAM_GMEM_BASE 0x06 /* RO */
  72. #define MSM_PARAM_PRIORITIES 0x07 /* RO: The # of priority levels */
  73. #define MSM_PARAM_PP_PGTABLE 0x08 /* RO: Deprecated, always returns zero */
  74. #define MSM_PARAM_FAULTS 0x09 /* RO */
  75. #define MSM_PARAM_SUSPENDS 0x0a /* RO */
  76. #define MSM_PARAM_SYSPROF 0x0b /* WO: 1 preserves perfcntrs, 2 also disables suspend */
  77. #define MSM_PARAM_COMM 0x0c /* WO: override for task->comm */
  78. #define MSM_PARAM_CMDLINE 0x0d /* WO: override for task cmdline */
  79. #define MSM_PARAM_VA_START 0x0e /* RO: start of valid GPU iova range */
  80. #define MSM_PARAM_VA_SIZE 0x0f /* RO: size of valid GPU iova range (bytes) */
  81. #define MSM_PARAM_HIGHEST_BANK_BIT 0x10 /* RO */
  82. #define MSM_PARAM_RAYTRACING 0x11 /* RO */
  83. #define MSM_PARAM_UBWC_SWIZZLE 0x12 /* RO */
  84. #define MSM_PARAM_MACROTILE_MODE 0x13 /* RO */
  85. #define MSM_PARAM_UCHE_TRAP_BASE 0x14 /* RO */
  86. /* PRR (Partially Resident Region) is required for sparse residency: */
  87. #define MSM_PARAM_HAS_PRR 0x15 /* RO */
  88. /* MSM_PARAM_EN_VM_BIND is set to 1 to enable VM_BIND ops.
  89. *
  90. * With VM_BIND enabled, userspace is required to allocate iova and use the
  91. * VM_BIND ops for map/unmap ioctls. MSM_INFO_SET_IOVA and MSM_INFO_GET_IOVA
  92. * will be rejected. (The latter does not have a sensible meaning when a BO
  93. * can have multiple and/or partial mappings.)
  94. *
  95. * With VM_BIND enabled, userspace does not include a submit_bo table in the
  96. * SUBMIT ioctl (this will be rejected), the resident set is determined by
  97. * the the VM_BIND ops.
  98. *
  99. * Enabling VM_BIND will fail on devices which do not have per-process pgtables.
  100. * And it is not allowed to disable VM_BIND once it has been enabled.
  101. *
  102. * Enabling VM_BIND should be done (attempted) prior to allocating any BOs or
  103. * submitqueues of type MSM_SUBMITQUEUE_VM_BIND.
  104. *
  105. * Relatedly, when VM_BIND mode is enabled, the kernel will not try to recover
  106. * from GPU faults or failed async VM_BIND ops, in particular because it is
  107. * difficult to communicate to userspace which op failed so that userspace
  108. * could rewind and try again. When the VM is marked unusable, the SUBMIT
  109. * ioctl will throw -EPIPE.
  110. */
  111. #define MSM_PARAM_EN_VM_BIND 0x16 /* WO, once */
  112. /* For backwards compat. The original support for preemption was based on
  113. * a single ring per priority level so # of priority levels equals the #
  114. * of rings. With drm/scheduler providing additional levels of priority,
  115. * the number of priorities is greater than the # of rings. The param is
  116. * renamed to better reflect this.
  117. */
  118. #define MSM_PARAM_NR_RINGS MSM_PARAM_PRIORITIES
  119. struct drm_msm_param {
  120. __u32 pipe; /* in, MSM_PIPE_x */
  121. __u32 param; /* in, MSM_PARAM_x */
  122. __u64 value; /* out (get_param) or in (set_param) */
  123. __u32 len; /* zero for non-pointer params */
  124. __u32 pad; /* must be zero */
  125. };
  126. /*
  127. * GEM buffers:
  128. */
  129. #define MSM_BO_SCANOUT 0x00000001 /* scanout capable */
  130. #define MSM_BO_GPU_READONLY 0x00000002
  131. /* Private buffers do not need to be explicitly listed in the SUBMIT
  132. * ioctl, unless referenced by a drm_msm_gem_submit_cmd. Private
  133. * buffers may NOT be imported/exported or used for scanout (or any
  134. * other situation where buffers can be indefinitely pinned, but
  135. * cases other than scanout are all kernel owned BOs which are not
  136. * visible to userspace).
  137. *
  138. * In exchange for those constraints, all private BOs associated with
  139. * a single context (drm_file) share a single dma_resv, and if there
  140. * has been no eviction since the last submit, there are no per-BO
  141. * bookeeping to do, significantly cutting the SUBMIT overhead.
  142. */
  143. #define MSM_BO_NO_SHARE 0x00000004
  144. #define MSM_BO_CACHE_MASK 0x000f0000
  145. /* cache modes */
  146. #define MSM_BO_CACHED 0x00010000
  147. #define MSM_BO_WC 0x00020000
  148. #define MSM_BO_UNCACHED 0x00040000 /* deprecated, use MSM_BO_WC */
  149. #define MSM_BO_CACHED_COHERENT 0x080000
  150. #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \
  151. MSM_BO_GPU_READONLY | \
  152. MSM_BO_NO_SHARE | \
  153. MSM_BO_CACHE_MASK)
  154. struct drm_msm_gem_new {
  155. __u64 size; /* in */
  156. __u32 flags; /* in, mask of MSM_BO_x */
  157. __u32 handle; /* out */
  158. };
  159. /* Get or set GEM buffer info. The requested value can be passed
  160. * directly in 'value', or for data larger than 64b 'value' is a
  161. * pointer to userspace buffer, with 'len' specifying the number of
  162. * bytes copied into that buffer. For info returned by pointer,
  163. * calling the GEM_INFO ioctl with null 'value' will return the
  164. * required buffer size in 'len'
  165. */
  166. #define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */
  167. #define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */
  168. #define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */
  169. #define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */
  170. #define MSM_INFO_SET_IOVA 0x04 /* set the iova, passed by value */
  171. #define MSM_INFO_GET_FLAGS 0x05 /* get the MSM_BO_x flags */
  172. #define MSM_INFO_SET_METADATA 0x06 /* set userspace metadata */
  173. #define MSM_INFO_GET_METADATA 0x07 /* get userspace metadata */
  174. struct drm_msm_gem_info {
  175. __u32 handle; /* in */
  176. __u32 info; /* in - one of MSM_INFO_* */
  177. __u64 value; /* in or out */
  178. __u32 len; /* in or out */
  179. __u32 pad;
  180. };
  181. #define MSM_PREP_READ 0x01
  182. #define MSM_PREP_WRITE 0x02
  183. #define MSM_PREP_NOSYNC 0x04
  184. #define MSM_PREP_BOOST 0x08
  185. #define MSM_PREP_FLAGS (MSM_PREP_READ | \
  186. MSM_PREP_WRITE | \
  187. MSM_PREP_NOSYNC | \
  188. MSM_PREP_BOOST | \
  189. 0)
  190. struct drm_msm_gem_cpu_prep {
  191. __u32 handle; /* in */
  192. __u32 op; /* in, mask of MSM_PREP_x */
  193. struct drm_msm_timespec timeout; /* in */
  194. };
  195. struct drm_msm_gem_cpu_fini {
  196. __u32 handle; /* in */
  197. };
  198. /*
  199. * Cmdstream Submission:
  200. */
  201. #define MSM_SYNCOBJ_RESET 0x00000001 /* Reset syncobj after wait. */
  202. #define MSM_SYNCOBJ_FLAGS ( \
  203. MSM_SYNCOBJ_RESET | \
  204. 0)
  205. struct drm_msm_syncobj {
  206. __u32 handle; /* in, syncobj handle. */
  207. __u32 flags; /* in, from MSM_SUBMIT_SYNCOBJ_FLAGS */
  208. __u64 point; /* in, timepoint for timeline syncobjs. */
  209. };
  210. /* The value written into the cmdstream is logically:
  211. *
  212. * ((relocbuf->gpuaddr + reloc_offset) << shift) | or
  213. *
  214. * When we have GPU's w/ >32bit ptrs, it should be possible to deal
  215. * with this by emit'ing two reloc entries with appropriate shift
  216. * values. Or a new MSM_SUBMIT_CMD_x type would also be an option.
  217. *
  218. * NOTE that reloc's must be sorted by order of increasing submit_offset,
  219. * otherwise EINVAL.
  220. */
  221. struct drm_msm_gem_submit_reloc {
  222. __u32 submit_offset; /* in, offset from submit_bo */
  223. #ifdef __cplusplus
  224. __u32 _or; /* in, value OR'd with result */
  225. #else
  226. __u32 or; /* in, value OR'd with result */
  227. #endif
  228. __s32 shift; /* in, amount of left shift (can be negative) */
  229. __u32 reloc_idx; /* in, index of reloc_bo buffer */
  230. __u64 reloc_offset; /* in, offset from start of reloc_bo */
  231. };
  232. /* submit-types:
  233. * BUF - this cmd buffer is executed normally.
  234. * IB_TARGET_BUF - this cmd buffer is an IB target. Reloc's are
  235. * processed normally, but the kernel does not setup an IB to
  236. * this buffer in the first-level ringbuffer
  237. * CTX_RESTORE_BUF - only executed if there has been a GPU context
  238. * switch since the last SUBMIT ioctl
  239. */
  240. #define MSM_SUBMIT_CMD_BUF 0x0001
  241. #define MSM_SUBMIT_CMD_IB_TARGET_BUF 0x0002
  242. #define MSM_SUBMIT_CMD_CTX_RESTORE_BUF 0x0003
  243. struct drm_msm_gem_submit_cmd {
  244. __u32 type; /* in, one of MSM_SUBMIT_CMD_x */
  245. __u32 submit_idx; /* in, index of submit_bo cmdstream buffer */
  246. __u32 submit_offset; /* in, offset into submit_bo */
  247. __u32 size; /* in, cmdstream size */
  248. __u32 pad;
  249. __u32 nr_relocs; /* in, number of submit_reloc's */
  250. union {
  251. __u64 relocs; /* in, ptr to array of submit_reloc's */
  252. __u64 iova; /* cmdstream address (for VM_BIND contexts) */
  253. };
  254. };
  255. /* Each buffer referenced elsewhere in the cmdstream submit (ie. the
  256. * cmdstream buffer(s) themselves or reloc entries) has one (and only
  257. * one) entry in the submit->bos[] table.
  258. *
  259. * As a optimization, the current buffer (gpu virtual address) can be
  260. * passed back through the 'presumed' field. If on a subsequent reloc,
  261. * userspace passes back a 'presumed' address that is still valid,
  262. * then patching the cmdstream for this entry is skipped. This can
  263. * avoid kernel needing to map/access the cmdstream bo in the common
  264. * case.
  265. */
  266. #define MSM_SUBMIT_BO_READ 0x0001
  267. #define MSM_SUBMIT_BO_WRITE 0x0002
  268. #define MSM_SUBMIT_BO_DUMP 0x0004
  269. #define MSM_SUBMIT_BO_NO_IMPLICIT 0x0008
  270. #define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | \
  271. MSM_SUBMIT_BO_WRITE | \
  272. MSM_SUBMIT_BO_DUMP | \
  273. MSM_SUBMIT_BO_NO_IMPLICIT)
  274. struct drm_msm_gem_submit_bo {
  275. __u32 flags; /* in, mask of MSM_SUBMIT_BO_x */
  276. __u32 handle; /* in, GEM handle */
  277. __u64 presumed; /* in/out, presumed buffer address */
  278. };
  279. /* Valid submit ioctl flags: */
  280. #define MSM_SUBMIT_NO_IMPLICIT 0x80000000 /* disable implicit sync */
  281. #define MSM_SUBMIT_FENCE_FD_IN 0x40000000 /* enable input fence_fd */
  282. #define MSM_SUBMIT_FENCE_FD_OUT 0x20000000 /* enable output fence_fd */
  283. #define MSM_SUBMIT_SUDO 0x10000000 /* run submitted cmds from RB */
  284. #define MSM_SUBMIT_SYNCOBJ_IN 0x08000000 /* enable input syncobj */
  285. #define MSM_SUBMIT_SYNCOBJ_OUT 0x04000000 /* enable output syncobj */
  286. #define MSM_SUBMIT_FENCE_SN_IN 0x02000000 /* userspace passes in seqno fence */
  287. #define MSM_SUBMIT_FLAGS ( \
  288. MSM_SUBMIT_NO_IMPLICIT | \
  289. MSM_SUBMIT_FENCE_FD_IN | \
  290. MSM_SUBMIT_FENCE_FD_OUT | \
  291. MSM_SUBMIT_SUDO | \
  292. MSM_SUBMIT_SYNCOBJ_IN | \
  293. MSM_SUBMIT_SYNCOBJ_OUT | \
  294. MSM_SUBMIT_FENCE_SN_IN | \
  295. 0)
  296. /* Each cmdstream submit consists of a table of buffers involved, and
  297. * one or more cmdstream buffers. This allows for conditional execution
  298. * (context-restore), and IB buffers needed for per tile/bin draw cmds.
  299. */
  300. struct drm_msm_gem_submit {
  301. __u32 flags; /* MSM_PIPE_x | MSM_SUBMIT_x */
  302. __u32 fence; /* out (or in with MSM_SUBMIT_FENCE_SN_IN flag) */
  303. __u32 nr_bos; /* in, number of submit_bo's */
  304. __u32 nr_cmds; /* in, number of submit_cmd's */
  305. __u64 bos; /* in, ptr to array of submit_bo's */
  306. __u64 cmds; /* in, ptr to array of submit_cmd's */
  307. __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */
  308. __u32 queueid; /* in, submitqueue id */
  309. __u64 in_syncobjs; /* in, ptr to array of drm_msm_syncobj */
  310. __u64 out_syncobjs; /* in, ptr to array of drm_msm_syncobj */
  311. __u32 nr_in_syncobjs; /* in, number of entries in in_syncobj */
  312. __u32 nr_out_syncobjs; /* in, number of entries in out_syncobj. */
  313. __u32 syncobj_stride; /* in, stride of syncobj arrays. */
  314. __u32 pad; /*in, reserved for future use, always 0. */
  315. };
  316. #define MSM_VM_BIND_OP_UNMAP 0
  317. #define MSM_VM_BIND_OP_MAP 1
  318. #define MSM_VM_BIND_OP_MAP_NULL 2
  319. #define MSM_VM_BIND_OP_DUMP 1
  320. #define MSM_VM_BIND_OP_FLAGS ( \
  321. MSM_VM_BIND_OP_DUMP | \
  322. 0)
  323. /**
  324. * struct drm_msm_vm_bind_op - bind/unbind op to run
  325. */
  326. struct drm_msm_vm_bind_op {
  327. /** @op: one of MSM_VM_BIND_OP_x */
  328. __u32 op;
  329. /** @handle: GEM object handle, MBZ for UNMAP or MAP_NULL */
  330. __u32 handle;
  331. /** @obj_offset: Offset into GEM object, MBZ for UNMAP or MAP_NULL */
  332. __u64 obj_offset;
  333. /** @iova: Address to operate on */
  334. __u64 iova;
  335. /** @range: Number of bites to to map/unmap */
  336. __u64 range;
  337. /** @flags: Bitmask of MSM_VM_BIND_OP_FLAG_x */
  338. __u32 flags;
  339. /** @pad: MBZ */
  340. __u32 pad;
  341. };
  342. #define MSM_VM_BIND_FENCE_FD_IN 0x00000001
  343. #define MSM_VM_BIND_FENCE_FD_OUT 0x00000002
  344. #define MSM_VM_BIND_FLAGS ( \
  345. MSM_VM_BIND_FENCE_FD_IN | \
  346. MSM_VM_BIND_FENCE_FD_OUT | \
  347. 0)
  348. /**
  349. * struct drm_msm_vm_bind - Input of &DRM_IOCTL_MSM_VM_BIND
  350. */
  351. struct drm_msm_vm_bind {
  352. /** @flags: in, bitmask of MSM_VM_BIND_x */
  353. __u32 flags;
  354. /** @nr_ops: the number of bind ops in this ioctl */
  355. __u32 nr_ops;
  356. /** @fence_fd: in/out fence fd (see MSM_VM_BIND_FENCE_FD_IN/OUT) */
  357. __s32 fence_fd;
  358. /** @queue_id: in, submitqueue id */
  359. __u32 queue_id;
  360. /** @in_syncobjs: in, ptr to array of drm_msm_gem_syncobj */
  361. __u64 in_syncobjs;
  362. /** @out_syncobjs: in, ptr to array of drm_msm_gem_syncobj */
  363. __u64 out_syncobjs;
  364. /** @nr_in_syncobjs: in, number of entries in in_syncobj */
  365. __u32 nr_in_syncobjs;
  366. /** @nr_out_syncobjs: in, number of entries in out_syncobj */
  367. __u32 nr_out_syncobjs;
  368. /** @syncobj_stride: in, stride of syncobj arrays */
  369. __u32 syncobj_stride;
  370. /** @op_stride: sizeof each struct drm_msm_vm_bind_op in @ops */
  371. __u32 op_stride;
  372. union {
  373. /** @op: used if num_ops == 1 */
  374. struct drm_msm_vm_bind_op op;
  375. /** @ops: userptr to array of drm_msm_vm_bind_op if num_ops > 1 */
  376. __u64 ops;
  377. };
  378. };
  379. #define MSM_WAIT_FENCE_BOOST 0x00000001
  380. #define MSM_WAIT_FENCE_FLAGS ( \
  381. MSM_WAIT_FENCE_BOOST | \
  382. 0)
  383. /* The normal way to synchronize with the GPU is just to CPU_PREP on
  384. * a buffer if you need to access it from the CPU (other cmdstream
  385. * submission from same or other contexts, PAGE_FLIP ioctl, etc, all
  386. * handle the required synchronization under the hood). This ioctl
  387. * mainly just exists as a way to implement the gallium pipe_fence
  388. * APIs without requiring a dummy bo to synchronize on.
  389. */
  390. struct drm_msm_wait_fence {
  391. __u32 fence; /* in */
  392. __u32 flags; /* in, bitmask of MSM_WAIT_FENCE_x */
  393. struct drm_msm_timespec timeout; /* in */
  394. __u32 queueid; /* in, submitqueue id */
  395. };
  396. /* madvise provides a way to tell the kernel in case a buffers contents
  397. * can be discarded under memory pressure, which is useful for userspace
  398. * bo cache where we want to optimistically hold on to buffer allocate
  399. * and potential mmap, but allow the pages to be discarded under memory
  400. * pressure.
  401. *
  402. * Typical usage would involve madvise(DONTNEED) when buffer enters BO
  403. * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
  404. * In the WILLNEED case, 'retained' indicates to userspace whether the
  405. * backing pages still exist.
  406. */
  407. #define MSM_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */
  408. #define MSM_MADV_DONTNEED 1 /* backing pages not needed */
  409. #define __MSM_MADV_PURGED 2 /* internal state */
  410. struct drm_msm_gem_madvise {
  411. __u32 handle; /* in, GEM handle */
  412. __u32 madv; /* in, MSM_MADV_x */
  413. __u32 retained; /* out, whether backing store still exists */
  414. };
  415. /*
  416. * Draw queues allow the user to set specific submission parameter. Command
  417. * submissions specify a specific submitqueue to use. ID 0 is reserved for
  418. * backwards compatibility as a "default" submitqueue.
  419. *
  420. * Because VM_BIND async updates happen on the CPU, they must run on a
  421. * virtual queue created with the flag MSM_SUBMITQUEUE_VM_BIND. If we had
  422. * a way to do pgtable updates on the GPU, we could drop this restriction.
  423. */
  424. #define MSM_SUBMITQUEUE_ALLOW_PREEMPT 0x00000001
  425. #define MSM_SUBMITQUEUE_VM_BIND 0x00000002 /* virtual queue for VM_BIND ops */
  426. #define MSM_SUBMITQUEUE_FLAGS ( \
  427. MSM_SUBMITQUEUE_ALLOW_PREEMPT | \
  428. MSM_SUBMITQUEUE_VM_BIND | \
  429. 0)
  430. /*
  431. * The submitqueue priority should be between 0 and MSM_PARAM_PRIORITIES-1,
  432. * a lower numeric value is higher priority.
  433. */
  434. struct drm_msm_submitqueue {
  435. __u32 flags; /* in, MSM_SUBMITQUEUE_x */
  436. __u32 prio; /* in, Priority level */
  437. __u32 id; /* out, identifier */
  438. };
  439. #define MSM_SUBMITQUEUE_PARAM_FAULTS 0
  440. struct drm_msm_submitqueue_query {
  441. __u64 data;
  442. __u32 id;
  443. __u32 param;
  444. __u32 len;
  445. __u32 pad;
  446. };
  447. #define DRM_MSM_GET_PARAM 0x00
  448. #define DRM_MSM_SET_PARAM 0x01
  449. #define DRM_MSM_GEM_NEW 0x02
  450. #define DRM_MSM_GEM_INFO 0x03
  451. #define DRM_MSM_GEM_CPU_PREP 0x04
  452. #define DRM_MSM_GEM_CPU_FINI 0x05
  453. #define DRM_MSM_GEM_SUBMIT 0x06
  454. #define DRM_MSM_WAIT_FENCE 0x07
  455. #define DRM_MSM_GEM_MADVISE 0x08
  456. /* placeholder:
  457. #define DRM_MSM_GEM_SVM_NEW 0x09
  458. */
  459. #define DRM_MSM_SUBMITQUEUE_NEW 0x0A
  460. #define DRM_MSM_SUBMITQUEUE_CLOSE 0x0B
  461. #define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
  462. #define DRM_MSM_VM_BIND 0x0D
  463. #define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
  464. #define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
  465. #define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
  466. #define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info)
  467. #define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep)
  468. #define DRM_IOCTL_MSM_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_FINI, struct drm_msm_gem_cpu_fini)
  469. #define DRM_IOCTL_MSM_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_SUBMIT, struct drm_msm_gem_submit)
  470. #define DRM_IOCTL_MSM_WAIT_FENCE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_WAIT_FENCE, struct drm_msm_wait_fence)
  471. #define DRM_IOCTL_MSM_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_MADVISE, struct drm_msm_gem_madvise)
  472. #define DRM_IOCTL_MSM_SUBMITQUEUE_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
  473. #define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
  474. #define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
  475. #define DRM_IOCTL_MSM_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_VM_BIND, struct drm_msm_vm_bind)
  476. #if defined(__cplusplus)
  477. }
  478. #endif
  479. #endif /* __MSM_DRM_H__ */