162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (C) 2013 Red Hat 362306a36Sopenharmony_ci * Author: Rob Clark <robdclark@gmail.com> 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 662306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 762306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 862306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 962306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 1062306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the next 1362306a36Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 1462306a36Sopenharmony_ci * Software. 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1762306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1862306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1962306a36Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2062306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2162306a36Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2262306a36Sopenharmony_ci * SOFTWARE. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#ifndef __MSM_DRM_H__ 2662306a36Sopenharmony_ci#define __MSM_DRM_H__ 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#include "drm.h" 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#if defined(__cplusplus) 3162306a36Sopenharmony_ciextern "C" { 3262306a36Sopenharmony_ci#endif 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* Please note that modifications to all structs defined here are 3562306a36Sopenharmony_ci * subject to backwards-compatibility constraints: 3662306a36Sopenharmony_ci * 1) Do not use pointers, use __u64 instead for 32 bit / 64 bit 3762306a36Sopenharmony_ci * user/kernel compatibility 3862306a36Sopenharmony_ci * 2) Keep fields aligned to their size 3962306a36Sopenharmony_ci * 3) Because of how drm_ioctl() works, we can add new fields at 4062306a36Sopenharmony_ci * the end of an ioctl if some care is taken: drm_ioctl() will 4162306a36Sopenharmony_ci * zero out the new fields at the tail of the ioctl, so a zero 4262306a36Sopenharmony_ci * value should have a backwards compatible meaning. And for 4362306a36Sopenharmony_ci * output params, userspace won't see the newly added output 4462306a36Sopenharmony_ci * fields.. so that has to be somehow ok. 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define MSM_PIPE_NONE 0x00 4862306a36Sopenharmony_ci#define MSM_PIPE_2D0 0x01 4962306a36Sopenharmony_ci#define MSM_PIPE_2D1 0x02 5062306a36Sopenharmony_ci#define MSM_PIPE_3D0 0x10 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/* The pipe-id just uses the lower bits, so can be OR'd with flags in 5362306a36Sopenharmony_ci * the upper 16 bits (which could be extended further, if needed, maybe 5462306a36Sopenharmony_ci * we extend/overload the pipe-id some day to deal with multiple rings, 5562306a36Sopenharmony_ci * but even then I don't think we need the full lower 16 bits). 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci#define MSM_PIPE_ID_MASK 0xffff 5862306a36Sopenharmony_ci#define MSM_PIPE_ID(x) ((x) & MSM_PIPE_ID_MASK) 5962306a36Sopenharmony_ci#define MSM_PIPE_FLAGS(x) ((x) & ~MSM_PIPE_ID_MASK) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* timeouts are specified in clock-monotonic absolute times (to simplify 6262306a36Sopenharmony_ci * restarting interrupted ioctls). The following struct is logically the 6362306a36Sopenharmony_ci * same as 'struct timespec' but 32/64b ABI safe. 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_cistruct drm_msm_timespec { 6662306a36Sopenharmony_ci __s64 tv_sec; /* seconds */ 6762306a36Sopenharmony_ci __s64 tv_nsec; /* nanoseconds */ 6862306a36Sopenharmony_ci}; 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* Below "RO" indicates a read-only param, "WO" indicates write-only, and 7162306a36Sopenharmony_ci * "RW" indicates a param that can be both read (GET_PARAM) and written 7262306a36Sopenharmony_ci * (SET_PARAM) 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#define MSM_PARAM_GPU_ID 0x01 /* RO */ 7562306a36Sopenharmony_ci#define MSM_PARAM_GMEM_SIZE 0x02 /* RO */ 7662306a36Sopenharmony_ci#define MSM_PARAM_CHIP_ID 0x03 /* RO */ 7762306a36Sopenharmony_ci#define MSM_PARAM_MAX_FREQ 0x04 /* RO */ 7862306a36Sopenharmony_ci#define MSM_PARAM_TIMESTAMP 0x05 /* RO */ 7962306a36Sopenharmony_ci#define MSM_PARAM_GMEM_BASE 0x06 /* RO */ 8062306a36Sopenharmony_ci#define MSM_PARAM_PRIORITIES 0x07 /* RO: The # of priority levels */ 8162306a36Sopenharmony_ci#define MSM_PARAM_PP_PGTABLE 0x08 /* RO: Deprecated, always returns zero */ 8262306a36Sopenharmony_ci#define MSM_PARAM_FAULTS 0x09 /* RO */ 8362306a36Sopenharmony_ci#define MSM_PARAM_SUSPENDS 0x0a /* RO */ 8462306a36Sopenharmony_ci#define MSM_PARAM_SYSPROF 0x0b /* WO: 1 preserves perfcntrs, 2 also disables suspend */ 8562306a36Sopenharmony_ci#define MSM_PARAM_COMM 0x0c /* WO: override for task->comm */ 8662306a36Sopenharmony_ci#define MSM_PARAM_CMDLINE 0x0d /* WO: override for task cmdline */ 8762306a36Sopenharmony_ci#define MSM_PARAM_VA_START 0x0e /* RO: start of valid GPU iova range */ 8862306a36Sopenharmony_ci#define MSM_PARAM_VA_SIZE 0x0f /* RO: size of valid GPU iova range (bytes) */ 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* For backwards compat. The original support for preemption was based on 9162306a36Sopenharmony_ci * a single ring per priority level so # of priority levels equals the # 9262306a36Sopenharmony_ci * of rings. With drm/scheduler providing additional levels of priority, 9362306a36Sopenharmony_ci * the number of priorities is greater than the # of rings. The param is 9462306a36Sopenharmony_ci * renamed to better reflect this. 9562306a36Sopenharmony_ci */ 9662306a36Sopenharmony_ci#define MSM_PARAM_NR_RINGS MSM_PARAM_PRIORITIES 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistruct drm_msm_param { 9962306a36Sopenharmony_ci __u32 pipe; /* in, MSM_PIPE_x */ 10062306a36Sopenharmony_ci __u32 param; /* in, MSM_PARAM_x */ 10162306a36Sopenharmony_ci __u64 value; /* out (get_param) or in (set_param) */ 10262306a36Sopenharmony_ci __u32 len; /* zero for non-pointer params */ 10362306a36Sopenharmony_ci __u32 pad; /* must be zero */ 10462306a36Sopenharmony_ci}; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* 10762306a36Sopenharmony_ci * GEM buffers: 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci#define MSM_BO_SCANOUT 0x00000001 /* scanout capable */ 11162306a36Sopenharmony_ci#define MSM_BO_GPU_READONLY 0x00000002 11262306a36Sopenharmony_ci#define MSM_BO_CACHE_MASK 0x000f0000 11362306a36Sopenharmony_ci/* cache modes */ 11462306a36Sopenharmony_ci#define MSM_BO_CACHED 0x00010000 11562306a36Sopenharmony_ci#define MSM_BO_WC 0x00020000 11662306a36Sopenharmony_ci#define MSM_BO_UNCACHED 0x00040000 /* deprecated, use MSM_BO_WC */ 11762306a36Sopenharmony_ci#define MSM_BO_CACHED_COHERENT 0x080000 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define MSM_BO_FLAGS (MSM_BO_SCANOUT | \ 12062306a36Sopenharmony_ci MSM_BO_GPU_READONLY | \ 12162306a36Sopenharmony_ci MSM_BO_CACHE_MASK) 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_cistruct drm_msm_gem_new { 12462306a36Sopenharmony_ci __u64 size; /* in */ 12562306a36Sopenharmony_ci __u32 flags; /* in, mask of MSM_BO_x */ 12662306a36Sopenharmony_ci __u32 handle; /* out */ 12762306a36Sopenharmony_ci}; 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* Get or set GEM buffer info. The requested value can be passed 13062306a36Sopenharmony_ci * directly in 'value', or for data larger than 64b 'value' is a 13162306a36Sopenharmony_ci * pointer to userspace buffer, with 'len' specifying the number of 13262306a36Sopenharmony_ci * bytes copied into that buffer. For info returned by pointer, 13362306a36Sopenharmony_ci * calling the GEM_INFO ioctl with null 'value' will return the 13462306a36Sopenharmony_ci * required buffer size in 'len' 13562306a36Sopenharmony_ci */ 13662306a36Sopenharmony_ci#define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */ 13762306a36Sopenharmony_ci#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */ 13862306a36Sopenharmony_ci#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */ 13962306a36Sopenharmony_ci#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */ 14062306a36Sopenharmony_ci#define MSM_INFO_SET_IOVA 0x04 /* set the iova, passed by value */ 14162306a36Sopenharmony_ci#define MSM_INFO_GET_FLAGS 0x05 /* get the MSM_BO_x flags */ 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cistruct drm_msm_gem_info { 14462306a36Sopenharmony_ci __u32 handle; /* in */ 14562306a36Sopenharmony_ci __u32 info; /* in - one of MSM_INFO_* */ 14662306a36Sopenharmony_ci __u64 value; /* in or out */ 14762306a36Sopenharmony_ci __u32 len; /* in or out */ 14862306a36Sopenharmony_ci __u32 pad; 14962306a36Sopenharmony_ci}; 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci#define MSM_PREP_READ 0x01 15262306a36Sopenharmony_ci#define MSM_PREP_WRITE 0x02 15362306a36Sopenharmony_ci#define MSM_PREP_NOSYNC 0x04 15462306a36Sopenharmony_ci#define MSM_PREP_BOOST 0x08 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci#define MSM_PREP_FLAGS (MSM_PREP_READ | \ 15762306a36Sopenharmony_ci MSM_PREP_WRITE | \ 15862306a36Sopenharmony_ci MSM_PREP_NOSYNC | \ 15962306a36Sopenharmony_ci MSM_PREP_BOOST | \ 16062306a36Sopenharmony_ci 0) 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_cistruct drm_msm_gem_cpu_prep { 16362306a36Sopenharmony_ci __u32 handle; /* in */ 16462306a36Sopenharmony_ci __u32 op; /* in, mask of MSM_PREP_x */ 16562306a36Sopenharmony_ci struct drm_msm_timespec timeout; /* in */ 16662306a36Sopenharmony_ci}; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_cistruct drm_msm_gem_cpu_fini { 16962306a36Sopenharmony_ci __u32 handle; /* in */ 17062306a36Sopenharmony_ci}; 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci/* 17362306a36Sopenharmony_ci * Cmdstream Submission: 17462306a36Sopenharmony_ci */ 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* The value written into the cmdstream is logically: 17762306a36Sopenharmony_ci * 17862306a36Sopenharmony_ci * ((relocbuf->gpuaddr + reloc_offset) << shift) | or 17962306a36Sopenharmony_ci * 18062306a36Sopenharmony_ci * When we have GPU's w/ >32bit ptrs, it should be possible to deal 18162306a36Sopenharmony_ci * with this by emit'ing two reloc entries with appropriate shift 18262306a36Sopenharmony_ci * values. Or a new MSM_SUBMIT_CMD_x type would also be an option. 18362306a36Sopenharmony_ci * 18462306a36Sopenharmony_ci * NOTE that reloc's must be sorted by order of increasing submit_offset, 18562306a36Sopenharmony_ci * otherwise EINVAL. 18662306a36Sopenharmony_ci */ 18762306a36Sopenharmony_cistruct drm_msm_gem_submit_reloc { 18862306a36Sopenharmony_ci __u32 submit_offset; /* in, offset from submit_bo */ 18962306a36Sopenharmony_ci#ifdef __cplusplus 19062306a36Sopenharmony_ci __u32 _or; /* in, value OR'd with result */ 19162306a36Sopenharmony_ci#else 19262306a36Sopenharmony_ci __u32 or; /* in, value OR'd with result */ 19362306a36Sopenharmony_ci#endif 19462306a36Sopenharmony_ci __s32 shift; /* in, amount of left shift (can be negative) */ 19562306a36Sopenharmony_ci __u32 reloc_idx; /* in, index of reloc_bo buffer */ 19662306a36Sopenharmony_ci __u64 reloc_offset; /* in, offset from start of reloc_bo */ 19762306a36Sopenharmony_ci}; 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* submit-types: 20062306a36Sopenharmony_ci * BUF - this cmd buffer is executed normally. 20162306a36Sopenharmony_ci * IB_TARGET_BUF - this cmd buffer is an IB target. Reloc's are 20262306a36Sopenharmony_ci * processed normally, but the kernel does not setup an IB to 20362306a36Sopenharmony_ci * this buffer in the first-level ringbuffer 20462306a36Sopenharmony_ci * CTX_RESTORE_BUF - only executed if there has been a GPU context 20562306a36Sopenharmony_ci * switch since the last SUBMIT ioctl 20662306a36Sopenharmony_ci */ 20762306a36Sopenharmony_ci#define MSM_SUBMIT_CMD_BUF 0x0001 20862306a36Sopenharmony_ci#define MSM_SUBMIT_CMD_IB_TARGET_BUF 0x0002 20962306a36Sopenharmony_ci#define MSM_SUBMIT_CMD_CTX_RESTORE_BUF 0x0003 21062306a36Sopenharmony_cistruct drm_msm_gem_submit_cmd { 21162306a36Sopenharmony_ci __u32 type; /* in, one of MSM_SUBMIT_CMD_x */ 21262306a36Sopenharmony_ci __u32 submit_idx; /* in, index of submit_bo cmdstream buffer */ 21362306a36Sopenharmony_ci __u32 submit_offset; /* in, offset into submit_bo */ 21462306a36Sopenharmony_ci __u32 size; /* in, cmdstream size */ 21562306a36Sopenharmony_ci __u32 pad; 21662306a36Sopenharmony_ci __u32 nr_relocs; /* in, number of submit_reloc's */ 21762306a36Sopenharmony_ci __u64 relocs; /* in, ptr to array of submit_reloc's */ 21862306a36Sopenharmony_ci}; 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* Each buffer referenced elsewhere in the cmdstream submit (ie. the 22162306a36Sopenharmony_ci * cmdstream buffer(s) themselves or reloc entries) has one (and only 22262306a36Sopenharmony_ci * one) entry in the submit->bos[] table. 22362306a36Sopenharmony_ci * 22462306a36Sopenharmony_ci * As a optimization, the current buffer (gpu virtual address) can be 22562306a36Sopenharmony_ci * passed back through the 'presumed' field. If on a subsequent reloc, 22662306a36Sopenharmony_ci * userspace passes back a 'presumed' address that is still valid, 22762306a36Sopenharmony_ci * then patching the cmdstream for this entry is skipped. This can 22862306a36Sopenharmony_ci * avoid kernel needing to map/access the cmdstream bo in the common 22962306a36Sopenharmony_ci * case. 23062306a36Sopenharmony_ci */ 23162306a36Sopenharmony_ci#define MSM_SUBMIT_BO_READ 0x0001 23262306a36Sopenharmony_ci#define MSM_SUBMIT_BO_WRITE 0x0002 23362306a36Sopenharmony_ci#define MSM_SUBMIT_BO_DUMP 0x0004 23462306a36Sopenharmony_ci#define MSM_SUBMIT_BO_NO_IMPLICIT 0x0008 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | \ 23762306a36Sopenharmony_ci MSM_SUBMIT_BO_WRITE | \ 23862306a36Sopenharmony_ci MSM_SUBMIT_BO_DUMP | \ 23962306a36Sopenharmony_ci MSM_SUBMIT_BO_NO_IMPLICIT) 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_cistruct drm_msm_gem_submit_bo { 24262306a36Sopenharmony_ci __u32 flags; /* in, mask of MSM_SUBMIT_BO_x */ 24362306a36Sopenharmony_ci __u32 handle; /* in, GEM handle */ 24462306a36Sopenharmony_ci __u64 presumed; /* in/out, presumed buffer address */ 24562306a36Sopenharmony_ci}; 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci/* Valid submit ioctl flags: */ 24862306a36Sopenharmony_ci#define MSM_SUBMIT_NO_IMPLICIT 0x80000000 /* disable implicit sync */ 24962306a36Sopenharmony_ci#define MSM_SUBMIT_FENCE_FD_IN 0x40000000 /* enable input fence_fd */ 25062306a36Sopenharmony_ci#define MSM_SUBMIT_FENCE_FD_OUT 0x20000000 /* enable output fence_fd */ 25162306a36Sopenharmony_ci#define MSM_SUBMIT_SUDO 0x10000000 /* run submitted cmds from RB */ 25262306a36Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_IN 0x08000000 /* enable input syncobj */ 25362306a36Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_OUT 0x04000000 /* enable output syncobj */ 25462306a36Sopenharmony_ci#define MSM_SUBMIT_FENCE_SN_IN 0x02000000 /* userspace passes in seqno fence */ 25562306a36Sopenharmony_ci#define MSM_SUBMIT_FLAGS ( \ 25662306a36Sopenharmony_ci MSM_SUBMIT_NO_IMPLICIT | \ 25762306a36Sopenharmony_ci MSM_SUBMIT_FENCE_FD_IN | \ 25862306a36Sopenharmony_ci MSM_SUBMIT_FENCE_FD_OUT | \ 25962306a36Sopenharmony_ci MSM_SUBMIT_SUDO | \ 26062306a36Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_IN | \ 26162306a36Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_OUT | \ 26262306a36Sopenharmony_ci MSM_SUBMIT_FENCE_SN_IN | \ 26362306a36Sopenharmony_ci 0) 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_RESET 0x00000001 /* Reset syncobj after wait. */ 26662306a36Sopenharmony_ci#define MSM_SUBMIT_SYNCOBJ_FLAGS ( \ 26762306a36Sopenharmony_ci MSM_SUBMIT_SYNCOBJ_RESET | \ 26862306a36Sopenharmony_ci 0) 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_cistruct drm_msm_gem_submit_syncobj { 27162306a36Sopenharmony_ci __u32 handle; /* in, syncobj handle. */ 27262306a36Sopenharmony_ci __u32 flags; /* in, from MSM_SUBMIT_SYNCOBJ_FLAGS */ 27362306a36Sopenharmony_ci __u64 point; /* in, timepoint for timeline syncobjs. */ 27462306a36Sopenharmony_ci}; 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci/* Each cmdstream submit consists of a table of buffers involved, and 27762306a36Sopenharmony_ci * one or more cmdstream buffers. This allows for conditional execution 27862306a36Sopenharmony_ci * (context-restore), and IB buffers needed for per tile/bin draw cmds. 27962306a36Sopenharmony_ci */ 28062306a36Sopenharmony_cistruct drm_msm_gem_submit { 28162306a36Sopenharmony_ci __u32 flags; /* MSM_PIPE_x | MSM_SUBMIT_x */ 28262306a36Sopenharmony_ci __u32 fence; /* out (or in with MSM_SUBMIT_FENCE_SN_IN flag) */ 28362306a36Sopenharmony_ci __u32 nr_bos; /* in, number of submit_bo's */ 28462306a36Sopenharmony_ci __u32 nr_cmds; /* in, number of submit_cmd's */ 28562306a36Sopenharmony_ci __u64 bos; /* in, ptr to array of submit_bo's */ 28662306a36Sopenharmony_ci __u64 cmds; /* in, ptr to array of submit_cmd's */ 28762306a36Sopenharmony_ci __s32 fence_fd; /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */ 28862306a36Sopenharmony_ci __u32 queueid; /* in, submitqueue id */ 28962306a36Sopenharmony_ci __u64 in_syncobjs; /* in, ptr to array of drm_msm_gem_submit_syncobj */ 29062306a36Sopenharmony_ci __u64 out_syncobjs; /* in, ptr to array of drm_msm_gem_submit_syncobj */ 29162306a36Sopenharmony_ci __u32 nr_in_syncobjs; /* in, number of entries in in_syncobj */ 29262306a36Sopenharmony_ci __u32 nr_out_syncobjs; /* in, number of entries in out_syncobj. */ 29362306a36Sopenharmony_ci __u32 syncobj_stride; /* in, stride of syncobj arrays. */ 29462306a36Sopenharmony_ci __u32 pad; /*in, reserved for future use, always 0. */ 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci}; 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci#define MSM_WAIT_FENCE_BOOST 0x00000001 29962306a36Sopenharmony_ci#define MSM_WAIT_FENCE_FLAGS ( \ 30062306a36Sopenharmony_ci MSM_WAIT_FENCE_BOOST | \ 30162306a36Sopenharmony_ci 0) 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci/* The normal way to synchronize with the GPU is just to CPU_PREP on 30462306a36Sopenharmony_ci * a buffer if you need to access it from the CPU (other cmdstream 30562306a36Sopenharmony_ci * submission from same or other contexts, PAGE_FLIP ioctl, etc, all 30662306a36Sopenharmony_ci * handle the required synchronization under the hood). This ioctl 30762306a36Sopenharmony_ci * mainly just exists as a way to implement the gallium pipe_fence 30862306a36Sopenharmony_ci * APIs without requiring a dummy bo to synchronize on. 30962306a36Sopenharmony_ci */ 31062306a36Sopenharmony_cistruct drm_msm_wait_fence { 31162306a36Sopenharmony_ci __u32 fence; /* in */ 31262306a36Sopenharmony_ci __u32 flags; /* in, bitmask of MSM_WAIT_FENCE_x */ 31362306a36Sopenharmony_ci struct drm_msm_timespec timeout; /* in */ 31462306a36Sopenharmony_ci __u32 queueid; /* in, submitqueue id */ 31562306a36Sopenharmony_ci}; 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci/* madvise provides a way to tell the kernel in case a buffers contents 31862306a36Sopenharmony_ci * can be discarded under memory pressure, which is useful for userspace 31962306a36Sopenharmony_ci * bo cache where we want to optimistically hold on to buffer allocate 32062306a36Sopenharmony_ci * and potential mmap, but allow the pages to be discarded under memory 32162306a36Sopenharmony_ci * pressure. 32262306a36Sopenharmony_ci * 32362306a36Sopenharmony_ci * Typical usage would involve madvise(DONTNEED) when buffer enters BO 32462306a36Sopenharmony_ci * cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache. 32562306a36Sopenharmony_ci * In the WILLNEED case, 'retained' indicates to userspace whether the 32662306a36Sopenharmony_ci * backing pages still exist. 32762306a36Sopenharmony_ci */ 32862306a36Sopenharmony_ci#define MSM_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */ 32962306a36Sopenharmony_ci#define MSM_MADV_DONTNEED 1 /* backing pages not needed */ 33062306a36Sopenharmony_ci#define __MSM_MADV_PURGED 2 /* internal state */ 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_cistruct drm_msm_gem_madvise { 33362306a36Sopenharmony_ci __u32 handle; /* in, GEM handle */ 33462306a36Sopenharmony_ci __u32 madv; /* in, MSM_MADV_x */ 33562306a36Sopenharmony_ci __u32 retained; /* out, whether backing store still exists */ 33662306a36Sopenharmony_ci}; 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci/* 33962306a36Sopenharmony_ci * Draw queues allow the user to set specific submission parameter. Command 34062306a36Sopenharmony_ci * submissions specify a specific submitqueue to use. ID 0 is reserved for 34162306a36Sopenharmony_ci * backwards compatibility as a "default" submitqueue 34262306a36Sopenharmony_ci */ 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci#define MSM_SUBMITQUEUE_FLAGS (0) 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci/* 34762306a36Sopenharmony_ci * The submitqueue priority should be between 0 and MSM_PARAM_PRIORITIES-1, 34862306a36Sopenharmony_ci * a lower numeric value is higher priority. 34962306a36Sopenharmony_ci */ 35062306a36Sopenharmony_cistruct drm_msm_submitqueue { 35162306a36Sopenharmony_ci __u32 flags; /* in, MSM_SUBMITQUEUE_x */ 35262306a36Sopenharmony_ci __u32 prio; /* in, Priority level */ 35362306a36Sopenharmony_ci __u32 id; /* out, identifier */ 35462306a36Sopenharmony_ci}; 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci#define MSM_SUBMITQUEUE_PARAM_FAULTS 0 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_cistruct drm_msm_submitqueue_query { 35962306a36Sopenharmony_ci __u64 data; 36062306a36Sopenharmony_ci __u32 id; 36162306a36Sopenharmony_ci __u32 param; 36262306a36Sopenharmony_ci __u32 len; 36362306a36Sopenharmony_ci __u32 pad; 36462306a36Sopenharmony_ci}; 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci#define DRM_MSM_GET_PARAM 0x00 36762306a36Sopenharmony_ci#define DRM_MSM_SET_PARAM 0x01 36862306a36Sopenharmony_ci#define DRM_MSM_GEM_NEW 0x02 36962306a36Sopenharmony_ci#define DRM_MSM_GEM_INFO 0x03 37062306a36Sopenharmony_ci#define DRM_MSM_GEM_CPU_PREP 0x04 37162306a36Sopenharmony_ci#define DRM_MSM_GEM_CPU_FINI 0x05 37262306a36Sopenharmony_ci#define DRM_MSM_GEM_SUBMIT 0x06 37362306a36Sopenharmony_ci#define DRM_MSM_WAIT_FENCE 0x07 37462306a36Sopenharmony_ci#define DRM_MSM_GEM_MADVISE 0x08 37562306a36Sopenharmony_ci/* placeholder: 37662306a36Sopenharmony_ci#define DRM_MSM_GEM_SVM_NEW 0x09 37762306a36Sopenharmony_ci */ 37862306a36Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_NEW 0x0A 37962306a36Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_CLOSE 0x0B 38062306a36Sopenharmony_ci#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param) 38362306a36Sopenharmony_ci#define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param) 38462306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new) 38562306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info) 38662306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep) 38762306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_FINI, struct drm_msm_gem_cpu_fini) 38862306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_SUBMIT, struct drm_msm_gem_submit) 38962306a36Sopenharmony_ci#define DRM_IOCTL_MSM_WAIT_FENCE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_WAIT_FENCE, struct drm_msm_wait_fence) 39062306a36Sopenharmony_ci#define DRM_IOCTL_MSM_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_MADVISE, struct drm_msm_gem_madvise) 39162306a36Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue) 39262306a36Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32) 39362306a36Sopenharmony_ci#define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query) 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci#if defined(__cplusplus) 39662306a36Sopenharmony_ci} 39762306a36Sopenharmony_ci#endif 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci#endif /* __MSM_DRM_H__ */ 400