18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2013 Red Hat 38c2ecf20Sopenharmony_ci * Author: Rob Clark <robdclark@gmail.com> 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 68c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 78c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 88c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 98c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 108c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 138c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 148c2ecf20Sopenharmony_ci * Software. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 198c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 208c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 218c2ecf20Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 228c2ecf20Sopenharmony_ci * SOFTWARE. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifndef __MSM_DRM_H__ 268c2ecf20Sopenharmony_ci#define __MSM_DRM_H__ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include "drm.h" 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#if defined(__cplusplus) 318c2ecf20Sopenharmony_ciextern "C" { 328c2ecf20Sopenharmony_ci#endif 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Please note that modifications to all structs defined here are 358c2ecf20Sopenharmony_ci * subject to backwards-compatibility constraints: 368c2ecf20Sopenharmony_ci * 1) Do not use pointers, use __u64 instead for 32 bit / 64 bit 378c2ecf20Sopenharmony_ci * user/kernel compatibility 388c2ecf20Sopenharmony_ci * 2) Keep fields aligned to their size 398c2ecf20Sopenharmony_ci * 3) Because of how drm_ioctl() works, we can add new fields at 408c2ecf20Sopenharmony_ci * the end of an ioctl if some care is taken: drm_ioctl() will 418c2ecf20Sopenharmony_ci * zero out the new fields at the tail of the ioctl, so a zero 428c2ecf20Sopenharmony_ci * value should have a backwards compatible meaning. And for 438c2ecf20Sopenharmony_ci * output params, userspace won't see the newly added output 448c2ecf20Sopenharmony_ci * fields.. so that has to be somehow ok. 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define MSM_PIPE_NONE 0x00 488c2ecf20Sopenharmony_ci#define MSM_PIPE_2D0 0x01 498c2ecf20Sopenharmony_ci#define MSM_PIPE_2D1 0x02 508c2ecf20Sopenharmony_ci#define MSM_PIPE_3D0 0x10 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* The pipe-id just uses the lower bits, so can be OR'd with flags in 538c2ecf20Sopenharmony_ci * the upper 16 bits (which could be extended further, if needed, maybe 548c2ecf20Sopenharmony_ci * we extend/overload the pipe-id some day to deal with multiple rings, 558c2ecf20Sopenharmony_ci * but even then I don't think we need the full lower 16 bits). 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci#define MSM_PIPE_ID_MASK 0xffff 588c2ecf20Sopenharmony_ci#define MSM_PIPE_ID(x) ((x) & MSM_PIPE_ID_MASK) 598c2ecf20Sopenharmony_ci#define MSM_PIPE_FLAGS(x) ((x) & ~MSM_PIPE_ID_MASK) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* timeouts are specified in clock-monotonic absolute times (to simplify 628c2ecf20Sopenharmony_ci * restarting interrupted ioctls). The following struct is logically the 638c2ecf20Sopenharmony_ci * same as 'struct timespec' but 32/64b ABI safe. 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_cistruct drm_msm_timespec { 668c2ecf20Sopenharmony_ci __s64 tv_sec; /* seconds */ 678c2ecf20Sopenharmony_ci __s64 tv_nsec; /* nanoseconds */ 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define MSM_PARAM_GPU_ID 0x01 718c2ecf20Sopenharmony_ci#define MSM_PARAM_GMEM_SIZE 0x02 728c2ecf20Sopenharmony_ci#define MSM_PARAM_CHIP_ID 0x03 738c2ecf20Sopenharmony_ci#define MSM_PARAM_MAX_FREQ 0x04 748c2ecf20Sopenharmony_ci#define MSM_PARAM_TIMESTAMP 0x05 758c2ecf20Sopenharmony_ci#define MSM_PARAM_GMEM_BASE 0x06 768c2ecf20Sopenharmony_ci#define MSM_PARAM_NR_RINGS 0x07 778c2ecf20Sopenharmony_ci#define MSM_PARAM_PP_PGTABLE 0x08 /* => 1 for per-process pagetables, else 0 */ 788c2ecf20Sopenharmony_ci#define MSM_PARAM_FAULTS 0x09 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistruct drm_msm_param { 818c2ecf20Sopenharmony_ci __u32 pipe; /* in, MSM_PIPE_x */ 828c2ecf20Sopenharmony_ci __u32 param; /* in, MSM_PARAM_x */ 838c2ecf20Sopenharmony_ci __u64 value; /* out (get_param) or in (set_param) */ 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* 878c2ecf20Sopenharmony_ci * GEM buffers: 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define MSM_BO_SCANOUT 0x00000001 /* scanout capable */ 918c2ecf20Sopenharmony_ci#define MSM_BO_GPU_READONLY 0x00000002 928c2ecf20Sopenharmony_ci#define MSM_BO_CACHE_MASK 0x000f0000 938c2ecf20Sopenharmony_ci/* cache modes */ 948c2ecf20Sopenharmony_ci#define MSM_BO_CACHED 0x00010000 958c2ecf20Sopenharmony_ci#define MSM_BO_WC 0x00020000 968c2ecf20Sopenharmony_ci#define MSM_BO_UNCACHED 0x00040000 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define MSM_BO_FLAGS (MSM_BO_SCANOUT | \ 998c2ecf20Sopenharmony_ci MSM_BO_GPU_READONLY | \ 1008c2ecf20Sopenharmony_ci MSM_BO_CACHED | \ 1018c2ecf20Sopenharmony_ci MSM_BO_WC | \ 1028c2ecf20Sopenharmony_ci MSM_BO_UNCACHED) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct drm_msm_gem_new { 1058c2ecf20Sopenharmony_ci __u64 size; /* in */ 1068c2ecf20Sopenharmony_ci __u32 flags; /* in, mask of MSM_BO_x */ 1078c2ecf20Sopenharmony_ci __u32 handle; /* out */ 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* Get or set GEM buffer info. The requested value can be passed 1118c2ecf20Sopenharmony_ci * directly in 'value', or for data larger than 64b 'value' is a 1128c2ecf20Sopenharmony_ci * pointer to userspace buffer, with 'len' specifying the number of 1138c2ecf20Sopenharmony_ci * bytes copied into that buffer. For info returned by pointer, 1148c2ecf20Sopenharmony_ci * calling the GEM_INFO ioctl with null 'value' will return the 1158c2ecf20Sopenharmony_ci * required buffer size in 'len' 1168c2ecf20Sopenharmony_ci */ 1178c2ecf20Sopenharmony_ci#define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */ 1188c2ecf20Sopenharmony_ci#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */ 1198c2ecf20Sopenharmony_ci#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */ 1208c2ecf20Sopenharmony_ci#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */ 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct drm_msm_gem_info { 1238c2ecf20Sopenharmony_ci __u32 handle; /* in */ 1248c2ecf20Sopenharmony_ci __u32 info; /* in - one of MSM_INFO_* */ 1258c2ecf20Sopenharmony_ci __u64 value; /* in or out */ 1268c2ecf20Sopenharmony_ci __u32 len; /* in or out */ 1278c2ecf20Sopenharmony_ci __u32 pad; 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#define MSM_PREP_READ 0x01 1318c2ecf20Sopenharmony_ci#define MSM_PREP_WRITE 0x02 1328c2ecf20Sopenharmony_ci#define MSM_PREP_NOSYNC 0x04 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define MSM_PREP_FLAGS (MSM_PREP_READ | MSM_PREP_WRITE | MSM_PREP_NOSYNC) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistruct drm_msm_gem_cpu_prep { 1378c2ecf20Sopenharmony_ci __u32 handle; /* in */ 1388c2ecf20Sopenharmony_ci __u32 op; /* in, mask of MSM_PREP_x */ 1398c2ecf20Sopenharmony_ci struct drm_msm_timespec timeout; /* in */ 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct drm_msm_gem_cpu_fini { 1438c2ecf20Sopenharmony_ci __u32 handle; /* in */ 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* 1478c2ecf20Sopenharmony_ci * Cmdstream Submission: 1488c2ecf20Sopenharmony_ci */ 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci/* The value written into the cmdstream is logically: 1518c2ecf20Sopenharmony_ci * 1528c2ecf20Sopenharmony_ci * ((relocbuf->gpuaddr + reloc_offset) << shift) | or 1538c2ecf20Sopenharmony_ci * 1548c2ecf20Sopenharmony_ci * When we have GPU's w/ >32bit ptrs, it should be possible to deal 1558c2ecf20Sopenharmony_ci * with this by emit'ing two reloc entries with appropriate shift 1568c2ecf20Sopenharmony_ci * values. Or a new MSM_SUBMIT_CMD_x type would also be an option. 1578c2ecf20Sopenharmony_ci * 1588c2ecf20Sopenharmony_ci * NOTE that reloc's must be sorted by order of increasing submit_offset, 1598c2ecf20Sopenharmony_ci * otherwise EINVAL. 1608c2ecf20Sopenharmony_ci */ 1618c2ecf20Sopenharmony_cistruct drm_msm_gem_submit_reloc { 1628c2ecf20Sopenharmony_ci __u32 submit_offset; /* in, offset from submit_bo */ 1638c2ecf20Sopenharmony_ci __u32 or; /* in, value OR'd with result */ 1648c2ecf20Sopenharmony_ci __s32 shift; /* in, amount of left shift (can be negative) */ 1658c2ecf20Sopenharmony_ci __u32 reloc_idx; /* in, index of reloc_bo buffer */ 1668c2ecf20Sopenharmony_ci __u64 reloc_offset; /* in, offset from start of reloc_bo */ 1678c2ecf20Sopenharmony_ci}; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci/* submit-types: 1708c2ecf20Sopenharmony_ci * BUF - this cmd buffer is executed normally. 1718c2ecf20Sopenharmony_ci * IB_TARGET_BUF - this cmd buffer is an IB target. Reloc's are 1728c2ecf20Sopenharmony_ci * processed normally, but the kernel does not setup an IB to 1738c2ecf20Sopenharmony_ci * this buffer in the first-level ringbuffer 1748c2ecf20Sopenharmony_ci * CTX_RESTORE_BUF - only executed if there has been a GPU context 1758c2ecf20Sopenharmony_ci * switch since the last SUBMIT ioctl 1768c2ecf20Sopenharmony_ci */ 1778c2ecf20Sopenharmony_ci#define MSM_SUBMIT_CMD_BUF 0x0001 1788c2ecf20Sopenharmony_ci#define MSM_SUBMIT_CMD_IB_TARGET_BUF 0x0002 1798c2ecf20Sopenharmony_ci#define MSM_SUBMIT_CMD_CTX_RESTORE_BUF 0x0003 1808c2ecf20Sopenharmony_cistruct drm_msm_gem_submit_cmd { 1818c2ecf20Sopenharmony_ci __u32 type; /* in, one of MSM_SUBMIT_CMD_x */ 1828c2ecf20Sopenharmony_ci __u32 submit_idx; /* in, index of submit_bo cmdstream buffer */ 1838c2ecf20Sopenharmony_ci __u32 submit_offset; /* in, offset into submit_bo */ 1848c2ecf20Sopenharmony_ci __u32 size; /* in, cmdstream size */ 1858c2ecf20Sopenharmony_ci __u32 pad; 1868c2ecf20Sopenharmony_ci __u32 nr_relocs; /* in, number of submit_reloc's */ 1878c2ecf20Sopenharmony_ci __u64 relocs; /* in, ptr to array of submit_reloc's */ 1888c2ecf20Sopenharmony_ci}; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci/* Each buffer referenced elsewhere in the cmdstream submit (ie. the 1918c2ecf20Sopenharmony_ci * cmdstream buffer(s) themselves or reloc entries) has one (and only 1928c2ecf20Sopenharmony_ci * one) entry in the submit->bos[] table. 1938c2ecf20Sopenharmony_ci * 1948c2ecf20Sopenharmony_ci * As a optimization, the current buffer (gpu virtual address) can be 1958c2ecf20Sopenharmony_ci * passed back through the 'presumed' field. If on a subsequent reloc, 1968c2ecf20Sopenharmony_ci * userspace passes back a 'presumed' address that is still valid, 1978c2ecf20Sopenharmony_ci * then patching the cmdstream for this entry is skipped. This can 1988c2ecf20Sopenharmony_ci * avoid kernel needing to map/access the cmdstream bo in the common 1998c2ecf20Sopenharmony_ci * case. 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_ci#define MSM_SUBMIT_BO_READ 0x0001 2028c2ecf20Sopenharmony_ci#define MSM_SUBMIT_BO_WRITE 0x0002 2038c2ecf20Sopenharmony_ci#define MSM_SUBMIT_BO_DUMP 0x0004 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | \ 2068c2ecf20Sopenharmony_ci MSM_SUBMIT_BO_WRITE | \ 2078c2ecf20Sopenharmony_ci MSM_SUBMIT_BO_DUMP) 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_cistruct drm_msm_gem_submit_bo { 2108c2ecf20Sopenharmony_ci __u32 flags; /* in, mask of MSM_SUBMIT_BO_x */ 2118c2ecf20Sopenharmony_ci __u32 handle; /* in, GEM handle */ 2128c2ecf20Sopenharmony_ci __u64 presumed; /* in/out, presumed buffer address */ 2138c2ecf20Sopenharmony_ci}; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/* Valid submit ioctl flags: */ 2168c2ecf20Sopenharmony_ci#define MSM_SUBMIT_NO_IMPLICIT 0x80000000 /* disable implicit sync */ 2178c2ecf20Sopenharmony_ci#define MSM_SUBMIT_FENCE_FD_IN 0x40000000 /* enable input fence_fd */ 2188c2ecf20Sopenharmony_ci#define MSM_SUBMIT_FENCE_FD_OUT 0x20000000 /* enable output fence_fd */ 2198c2ecf20Sopenharmony_ci#define MSM_SUBMIT_SUDO 0x10000000 /* run submitted cmds from RB */ 2208c2ecf20Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_IN 0x08000000 /* enable input syncobj */ 2218c2ecf20Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_OUT 0x04000000 /* enable output syncobj */ 2228c2ecf20Sopenharmony_ci#define MSM_SUBMIT_FLAGS ( \ 2238c2ecf20Sopenharmony_ci MSM_SUBMIT_NO_IMPLICIT | \ 2248c2ecf20Sopenharmony_ci MSM_SUBMIT_FENCE_FD_IN | \ 2258c2ecf20Sopenharmony_ci MSM_SUBMIT_FENCE_FD_OUT | \ 2268c2ecf20Sopenharmony_ci MSM_SUBMIT_SUDO | \ 2278c2ecf20Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_IN | \ 2288c2ecf20Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_OUT | \ 2298c2ecf20Sopenharmony_ci 0) 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_RESET 0x00000001 /* Reset syncobj after wait. */ 2328c2ecf20Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_FLAGS ( \ 2338c2ecf20Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_RESET | \ 2348c2ecf20Sopenharmony_ci 0) 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_cistruct drm_msm_gem_submit_syncobj { 2378c2ecf20Sopenharmony_ci __u32 handle; /* in, syncobj handle. */ 2388c2ecf20Sopenharmony_ci __u32 flags; /* in, from MSM_SUBMIT_SYNCOBJ_FLAGS */ 2398c2ecf20Sopenharmony_ci __u64 point; /* in, timepoint for timeline syncobjs. */ 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/* Each cmdstream submit consists of a table of buffers involved, and 2438c2ecf20Sopenharmony_ci * one or more cmdstream buffers. This allows for conditional execution 2448c2ecf20Sopenharmony_ci * (context-restore), and IB buffers needed for per tile/bin draw cmds. 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_cistruct drm_msm_gem_submit { 2478c2ecf20Sopenharmony_ci __u32 flags; /* MSM_PIPE_x | MSM_SUBMIT_x */ 2488c2ecf20Sopenharmony_ci __u32 fence; /* out */ 2498c2ecf20Sopenharmony_ci __u32 nr_bos; /* in, number of submit_bo's */ 2508c2ecf20Sopenharmony_ci __u32 nr_cmds; /* in, number of submit_cmd's */ 2518c2ecf20Sopenharmony_ci __u64 bos; /* in, ptr to array of submit_bo's */ 2528c2ecf20Sopenharmony_ci __u64 cmds; /* in, ptr to array of submit_cmd's */ 2538c2ecf20Sopenharmony_ci __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */ 2548c2ecf20Sopenharmony_ci __u32 queueid; /* in, submitqueue id */ 2558c2ecf20Sopenharmony_ci __u64 in_syncobjs; /* in, ptr to array of drm_msm_gem_submit_syncobj */ 2568c2ecf20Sopenharmony_ci __u64 out_syncobjs; /* in, ptr to array of drm_msm_gem_submit_syncobj */ 2578c2ecf20Sopenharmony_ci __u32 nr_in_syncobjs; /* in, number of entries in in_syncobj */ 2588c2ecf20Sopenharmony_ci __u32 nr_out_syncobjs; /* in, number of entries in out_syncobj. */ 2598c2ecf20Sopenharmony_ci __u32 syncobj_stride; /* in, stride of syncobj arrays. */ 2608c2ecf20Sopenharmony_ci __u32 pad; /*in, reserved for future use, always 0. */ 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci/* The normal way to synchronize with the GPU is just to CPU_PREP on 2658c2ecf20Sopenharmony_ci * a buffer if you need to access it from the CPU (other cmdstream 2668c2ecf20Sopenharmony_ci * submission from same or other contexts, PAGE_FLIP ioctl, etc, all 2678c2ecf20Sopenharmony_ci * handle the required synchronization under the hood). This ioctl 2688c2ecf20Sopenharmony_ci * mainly just exists as a way to implement the gallium pipe_fence 2698c2ecf20Sopenharmony_ci * APIs without requiring a dummy bo to synchronize on. 2708c2ecf20Sopenharmony_ci */ 2718c2ecf20Sopenharmony_cistruct drm_msm_wait_fence { 2728c2ecf20Sopenharmony_ci __u32 fence; /* in */ 2738c2ecf20Sopenharmony_ci __u32 pad; 2748c2ecf20Sopenharmony_ci struct drm_msm_timespec timeout; /* in */ 2758c2ecf20Sopenharmony_ci __u32 queueid; /* in, submitqueue id */ 2768c2ecf20Sopenharmony_ci}; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci/* madvise provides a way to tell the kernel in case a buffers contents 2798c2ecf20Sopenharmony_ci * can be discarded under memory pressure, which is useful for userspace 2808c2ecf20Sopenharmony_ci * bo cache where we want to optimistically hold on to buffer allocate 2818c2ecf20Sopenharmony_ci * and potential mmap, but allow the pages to be discarded under memory 2828c2ecf20Sopenharmony_ci * pressure. 2838c2ecf20Sopenharmony_ci * 2848c2ecf20Sopenharmony_ci * Typical usage would involve madvise(DONTNEED) when buffer enters BO 2858c2ecf20Sopenharmony_ci * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache. 2868c2ecf20Sopenharmony_ci * In the WILLNEED case, 'retained' indicates to userspace whether the 2878c2ecf20Sopenharmony_ci * backing pages still exist. 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_ci#define MSM_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */ 2908c2ecf20Sopenharmony_ci#define MSM_MADV_DONTNEED 1 /* backing pages not needed */ 2918c2ecf20Sopenharmony_ci#define __MSM_MADV_PURGED 2 /* internal state */ 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_cistruct drm_msm_gem_madvise { 2948c2ecf20Sopenharmony_ci __u32 handle; /* in, GEM handle */ 2958c2ecf20Sopenharmony_ci __u32 madv; /* in, MSM_MADV_x */ 2968c2ecf20Sopenharmony_ci __u32 retained; /* out, whether backing store still exists */ 2978c2ecf20Sopenharmony_ci}; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci/* 3008c2ecf20Sopenharmony_ci * Draw queues allow the user to set specific submission parameter. Command 3018c2ecf20Sopenharmony_ci * submissions specify a specific submitqueue to use. ID 0 is reserved for 3028c2ecf20Sopenharmony_ci * backwards compatibility as a "default" submitqueue 3038c2ecf20Sopenharmony_ci */ 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define MSM_SUBMITQUEUE_FLAGS (0) 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cistruct drm_msm_submitqueue { 3088c2ecf20Sopenharmony_ci __u32 flags; /* in, MSM_SUBMITQUEUE_x */ 3098c2ecf20Sopenharmony_ci __u32 prio; /* in, Priority level */ 3108c2ecf20Sopenharmony_ci __u32 id; /* out, identifier */ 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci#define MSM_SUBMITQUEUE_PARAM_FAULTS 0 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_cistruct drm_msm_submitqueue_query { 3168c2ecf20Sopenharmony_ci __u64 data; 3178c2ecf20Sopenharmony_ci __u32 id; 3188c2ecf20Sopenharmony_ci __u32 param; 3198c2ecf20Sopenharmony_ci __u32 len; 3208c2ecf20Sopenharmony_ci __u32 pad; 3218c2ecf20Sopenharmony_ci}; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#define DRM_MSM_GET_PARAM 0x00 3248c2ecf20Sopenharmony_ci/* placeholder: 3258c2ecf20Sopenharmony_ci#define DRM_MSM_SET_PARAM 0x01 3268c2ecf20Sopenharmony_ci */ 3278c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_NEW 0x02 3288c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_INFO 0x03 3298c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_CPU_PREP 0x04 3308c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_CPU_FINI 0x05 3318c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_SUBMIT 0x06 3328c2ecf20Sopenharmony_ci#define DRM_MSM_WAIT_FENCE 0x07 3338c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_MADVISE 0x08 3348c2ecf20Sopenharmony_ci/* placeholder: 3358c2ecf20Sopenharmony_ci#define DRM_MSM_GEM_SVM_NEW 0x09 3368c2ecf20Sopenharmony_ci */ 3378c2ecf20Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_NEW 0x0A 3388c2ecf20Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_CLOSE 0x0B 3398c2ecf20Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param) 3428c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new) 3438c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info) 3448c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep) 3458c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_FINI, struct drm_msm_gem_cpu_fini) 3468c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_SUBMIT, struct drm_msm_gem_submit) 3478c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_WAIT_FENCE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_WAIT_FENCE, struct drm_msm_wait_fence) 3488c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_MADVISE, struct drm_msm_gem_madvise) 3498c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue) 3508c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32) 3518c2ecf20Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query) 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci#if defined(__cplusplus) 3548c2ecf20Sopenharmony_ci} 3558c2ecf20Sopenharmony_ci#endif 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci#endif /* __MSM_DRM_H__ */ 358