/*1* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the6* "Software"), to deal in the Software without restriction, including7* without limitation the rights to use, copy, modify, merge, publish,8* distribute, sub license, and/or sell copies of the Software, and to9* permit persons to whom the Software is furnished to do so, subject to10* the following conditions:11*12* The above copyright notice and this permission notice (including the13* next paragraph) shall be included in all copies or substantial portions14* of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS17* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.19* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR20* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,21* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE22* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*24*/2526#ifndef _UAPI_I915_DRM_H_27#define _UAPI_I915_DRM_H_2829#include "drm.h"3031#if defined(__cplusplus)32extern "C" {33#endif3435/* Please note that modifications to all structs defined here are36* subject to backwards-compatibility constraints.37*/3839/**40* DOC: uevents generated by i915 on its device node41*42* I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch43* event from the GPU L3 cache. Additional information supplied is ROW,44* BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep45* track of these events, and if a specific cache-line seems to have a46* persistent error, remap it with the L3 remapping tool supplied in47* intel-gpu-tools. The value supplied with the event is always 1.48*49* I915_ERROR_UEVENT - Generated upon error detection, currently only via50* hangcheck. The error detection event is a good indicator of when things51* began to go badly. The value supplied with the event is a 1 upon error52* detection, and a 0 upon reset completion, signifying no more error53* exists. NOTE: Disabling hangcheck or reset via module parameter will54* cause the related events to not be seen.55*56* I915_RESET_UEVENT - Event is generated just before an attempt to reset the57* GPU. The value supplied with the event is always 1. NOTE: Disable58* reset via module parameter will cause this event to not be seen.59*/60#define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR"61#define I915_ERROR_UEVENT "ERROR"62#define I915_RESET_UEVENT "RESET"6364/**65* struct i915_user_extension - Base class for defining a chain of extensions66*67* Many interfaces need to grow over time. In most cases we can simply68* extend the struct and have userspace pass in more data. Another option,69* as demonstrated by Vulkan's approach to providing extensions for forward70* and backward compatibility, is to use a list of optional structs to71* provide those extra details.72*73* The key advantage to using an extension chain is that it allows us to74* redefine the interface more easily than an ever growing struct of75* increasing complexity, and for large parts of that interface to be76* entirely optional. The downside is more pointer chasing; chasing across77* the __user boundary with pointers encapsulated inside u64.78*79* Example chaining:80*81* .. code-block:: C82*83* struct i915_user_extension ext3 {84* .next_extension = 0, // end85* .name = ...,86* };87* struct i915_user_extension ext2 {88* .next_extension = (uintptr_t)&ext3,89* .name = ...,90* };91* struct i915_user_extension ext1 {92* .next_extension = (uintptr_t)&ext2,93* .name = ...,94* };95*96* Typically the struct i915_user_extension would be embedded in some uAPI97* struct, and in this case we would feed it the head of the chain(i.e ext1),98* which would then apply all of the above extensions.99*100*/101struct i915_user_extension {102/**103* @next_extension:104*105* Pointer to the next struct i915_user_extension, or zero if the end.106*/107__u64 next_extension;108/**109* @name: Name of the extension.110*111* Note that the name here is just some integer.112*113* Also note that the name space for this is not global for the whole114* driver, but rather its scope/meaning is limited to the specific piece115* of uAPI which has embedded the struct i915_user_extension.116*/117__u32 name;118/**119* @flags: MBZ120*121* All undefined bits must be zero.122*/123__u32 flags;124/**125* @rsvd: MBZ126*127* Reserved for future use; must be zero.128*/129__u32 rsvd[4];130};131132/*133* MOCS indexes used for GPU surfaces, defining the cacheability of the134* surface data and the coherency for this data wrt. CPU vs. GPU accesses.135*/136enum i915_mocs_table_index {137/*138* Not cached anywhere, coherency between CPU and GPU accesses is139* guaranteed.140*/141I915_MOCS_UNCACHED,142/*143* Cacheability and coherency controlled by the kernel automatically144* based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current145* usage of the surface (used for display scanout or not).146*/147I915_MOCS_PTE,148/*149* Cached in all GPU caches available on the platform.150* Coherency between CPU and GPU accesses to the surface is not151* guaranteed without extra synchronization.152*/153I915_MOCS_CACHED,154};155156/**157* enum drm_i915_gem_engine_class - uapi engine type enumeration158*159* Different engines serve different roles, and there may be more than one160* engine serving each role. This enum provides a classification of the role161* of the engine, which may be used when requesting operations to be performed162* on a certain subset of engines, or for providing information about that163* group.164*/165enum drm_i915_gem_engine_class {166/**167* @I915_ENGINE_CLASS_RENDER:168*169* Render engines support instructions used for 3D, Compute (GPGPU),170* and programmable media workloads. These instructions fetch data and171* dispatch individual work items to threads that operate in parallel.172* The threads run small programs (called "kernels" or "shaders") on173* the GPU's execution units (EUs).174*/175I915_ENGINE_CLASS_RENDER = 0,176177/**178* @I915_ENGINE_CLASS_COPY:179*180* Copy engines (also referred to as "blitters") support instructions181* that move blocks of data from one location in memory to another,182* or that fill a specified location of memory with fixed data.183* Copy engines can perform pre-defined logical or bitwise operations184* on the source, destination, or pattern data.185*/186I915_ENGINE_CLASS_COPY = 1,187188/**189* @I915_ENGINE_CLASS_VIDEO:190*191* Video engines (also referred to as "bit stream decode" (BSD) or192* "vdbox") support instructions that perform fixed-function media193* decode and encode.194*/195I915_ENGINE_CLASS_VIDEO = 2,196197/**198* @I915_ENGINE_CLASS_VIDEO_ENHANCE:199*200* Video enhancement engines (also referred to as "vebox") support201* instructions related to image enhancement.202*/203I915_ENGINE_CLASS_VIDEO_ENHANCE = 3,204205/**206* @I915_ENGINE_CLASS_COMPUTE:207*208* Compute engines support a subset of the instructions available209* on render engines: compute engines support Compute (GPGPU) and210* programmable media workloads, but do not support the 3D pipeline.211*/212I915_ENGINE_CLASS_COMPUTE = 4,213214/* Values in this enum should be kept compact. */215216/**217* @I915_ENGINE_CLASS_INVALID:218*219* Placeholder value to represent an invalid engine class assignment.220*/221I915_ENGINE_CLASS_INVALID = -1222};223224/**225* struct i915_engine_class_instance - Engine class/instance identifier226*227* There may be more than one engine fulfilling any role within the system.228* Each engine of a class is given a unique instance number and therefore229* any engine can be specified by its class:instance tuplet. APIs that allow230* access to any engine in the system will use struct i915_engine_class_instance231* for this identification.232*/233struct i915_engine_class_instance {234/**235* @engine_class:236*237* Engine class from enum drm_i915_gem_engine_class238*/239__u16 engine_class;240#define I915_ENGINE_CLASS_INVALID_NONE -1241#define I915_ENGINE_CLASS_INVALID_VIRTUAL -2242243/**244* @engine_instance:245*246* Engine instance.247*/248__u16 engine_instance;249};250251/**252* DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915253*254*/255256enum drm_i915_pmu_engine_sample {257I915_SAMPLE_BUSY = 0,258I915_SAMPLE_WAIT = 1,259I915_SAMPLE_SEMA = 2260};261262#define I915_PMU_SAMPLE_BITS (4)263#define I915_PMU_SAMPLE_MASK (0xf)264#define I915_PMU_SAMPLE_INSTANCE_BITS (8)265#define I915_PMU_CLASS_SHIFT \266(I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS)267268#define __I915_PMU_ENGINE(class, instance, sample) \269((class) << I915_PMU_CLASS_SHIFT | \270(instance) << I915_PMU_SAMPLE_BITS | \271(sample))272273#define I915_PMU_ENGINE_BUSY(class, instance) \274__I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY)275276#define I915_PMU_ENGINE_WAIT(class, instance) \277__I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT)278279#define I915_PMU_ENGINE_SEMA(class, instance) \280__I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)281282/*283* Top 4 bits of every non-engine counter are GT id.284*/285#define __I915_PMU_GT_SHIFT (60)286287#define ___I915_PMU_OTHER(gt, x) \288(((__u64)__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | \289((__u64)(gt) << __I915_PMU_GT_SHIFT))290291#define __I915_PMU_OTHER(x) ___I915_PMU_OTHER(0, x)292293#define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)294#define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)295#define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2)296#define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3)297#define I915_PMU_SOFTWARE_GT_AWAKE_TIME __I915_PMU_OTHER(4)298299#define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY300301#define __I915_PMU_ACTUAL_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 0)302#define __I915_PMU_REQUESTED_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 1)303#define __I915_PMU_INTERRUPTS(gt) ___I915_PMU_OTHER(gt, 2)304#define __I915_PMU_RC6_RESIDENCY(gt) ___I915_PMU_OTHER(gt, 3)305#define __I915_PMU_SOFTWARE_GT_AWAKE_TIME(gt) ___I915_PMU_OTHER(gt, 4)306307/* Each region is a minimum of 16k, and there are at most 255 of them.308*/309#define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use310* of chars for next/prev indices */311#define I915_LOG_MIN_TEX_REGION_SIZE 14312313typedef struct _drm_i915_init {314enum {315I915_INIT_DMA = 0x01,316I915_CLEANUP_DMA = 0x02,317I915_RESUME_DMA = 0x03318} func;319unsigned int mmio_offset;320int sarea_priv_offset;321unsigned int ring_start;322unsigned int ring_end;323unsigned int ring_size;324unsigned int front_offset;325unsigned int back_offset;326unsigned int depth_offset;327unsigned int w;328unsigned int h;329unsigned int pitch;330unsigned int pitch_bits;331unsigned int back_pitch;332unsigned int depth_pitch;333unsigned int cpp;334unsigned int chipset;335} drm_i915_init_t;336337typedef struct _drm_i915_sarea {338struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];339int last_upload; /* last time texture was uploaded */340int last_enqueue; /* last time a buffer was enqueued */341int last_dispatch; /* age of the most recently dispatched buffer */342int ctxOwner; /* last context to upload state */343int texAge;344int pf_enabled; /* is pageflipping allowed? */345int pf_active;346int pf_current_page; /* which buffer is being displayed? */347int perf_boxes; /* performance boxes to be displayed */348int width, height; /* screen size in pixels */349350drm_handle_t front_handle;351int front_offset;352int front_size;353354drm_handle_t back_handle;355int back_offset;356int back_size;357358drm_handle_t depth_handle;359int depth_offset;360int depth_size;361362drm_handle_t tex_handle;363int tex_offset;364int tex_size;365int log_tex_granularity;366int pitch;367int rotation; /* 0, 90, 180 or 270 */368int rotated_offset;369int rotated_size;370int rotated_pitch;371int virtualX, virtualY;372373unsigned int front_tiled;374unsigned int back_tiled;375unsigned int depth_tiled;376unsigned int rotated_tiled;377unsigned int rotated2_tiled;378379int pipeA_x;380int pipeA_y;381int pipeA_w;382int pipeA_h;383int pipeB_x;384int pipeB_y;385int pipeB_w;386int pipeB_h;387388/* fill out some space for old userspace triple buffer */389drm_handle_t unused_handle;390__u32 unused1, unused2, unused3;391392/* buffer object handles for static buffers. May change393* over the lifetime of the client.394*/395__u32 front_bo_handle;396__u32 back_bo_handle;397__u32 unused_bo_handle;398__u32 depth_bo_handle;399400} drm_i915_sarea_t;401402/* due to userspace building against these headers we need some compat here */403#define planeA_x pipeA_x404#define planeA_y pipeA_y405#define planeA_w pipeA_w406#define planeA_h pipeA_h407#define planeB_x pipeB_x408#define planeB_y pipeB_y409#define planeB_w pipeB_w410#define planeB_h pipeB_h411412/* Flags for perf_boxes413*/414#define I915_BOX_RING_EMPTY 0x1415#define I915_BOX_FLIP 0x2416#define I915_BOX_WAIT 0x4417#define I915_BOX_TEXTURE_LOAD 0x8418#define I915_BOX_LOST_CONTEXT 0x10419420/*421* i915 specific ioctls.422*423* The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie424* [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset425* against DRM_COMMAND_BASE and should be between [0x0, 0x60).426*/427#define DRM_I915_INIT 0x00428#define DRM_I915_FLUSH 0x01429#define DRM_I915_FLIP 0x02430#define DRM_I915_BATCHBUFFER 0x03431#define DRM_I915_IRQ_EMIT 0x04432#define DRM_I915_IRQ_WAIT 0x05433#define DRM_I915_GETPARAM 0x06434#define DRM_I915_SETPARAM 0x07435#define DRM_I915_ALLOC 0x08436#define DRM_I915_FREE 0x09437#define DRM_I915_INIT_HEAP 0x0a438#define DRM_I915_CMDBUFFER 0x0b439#define DRM_I915_DESTROY_HEAP 0x0c440#define DRM_I915_SET_VBLANK_PIPE 0x0d441#define DRM_I915_GET_VBLANK_PIPE 0x0e442#define DRM_I915_VBLANK_SWAP 0x0f443#define DRM_I915_HWS_ADDR 0x11444#define DRM_I915_GEM_INIT 0x13445#define DRM_I915_GEM_EXECBUFFER 0x14446#define DRM_I915_GEM_PIN 0x15447#define DRM_I915_GEM_UNPIN 0x16448#define DRM_I915_GEM_BUSY 0x17449#define DRM_I915_GEM_THROTTLE 0x18450#define DRM_I915_GEM_ENTERVT 0x19451#define DRM_I915_GEM_LEAVEVT 0x1a452#define DRM_I915_GEM_CREATE 0x1b453#define DRM_I915_GEM_PREAD 0x1c454#define DRM_I915_GEM_PWRITE 0x1d455#define DRM_I915_GEM_MMAP 0x1e456#define DRM_I915_GEM_SET_DOMAIN 0x1f457#define DRM_I915_GEM_SW_FINISH 0x20458#define DRM_I915_GEM_SET_TILING 0x21459#define DRM_I915_GEM_GET_TILING 0x22460#define DRM_I915_GEM_GET_APERTURE 0x23461#define DRM_I915_GEM_MMAP_GTT 0x24462#define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25463#define DRM_I915_GEM_MADVISE 0x26464#define DRM_I915_OVERLAY_PUT_IMAGE 0x27465#define DRM_I915_OVERLAY_ATTRS 0x28466#define DRM_I915_GEM_EXECBUFFER2 0x29467#define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2468#define DRM_I915_GET_SPRITE_COLORKEY 0x2a469#define DRM_I915_SET_SPRITE_COLORKEY 0x2b470#define DRM_I915_GEM_WAIT 0x2c471#define DRM_I915_GEM_CONTEXT_CREATE 0x2d472#define DRM_I915_GEM_CONTEXT_DESTROY 0x2e473#define DRM_I915_GEM_SET_CACHING 0x2f474#define DRM_I915_GEM_GET_CACHING 0x30475#define DRM_I915_REG_READ 0x31476#define DRM_I915_GET_RESET_STATS 0x32477#define DRM_I915_GEM_USERPTR 0x33478#define DRM_I915_GEM_CONTEXT_GETPARAM 0x34479#define DRM_I915_GEM_CONTEXT_SETPARAM 0x35480#define DRM_I915_PERF_OPEN 0x36481#define DRM_I915_PERF_ADD_CONFIG 0x37482#define DRM_I915_PERF_REMOVE_CONFIG 0x38483#define DRM_I915_QUERY 0x39484#define DRM_I915_GEM_VM_CREATE 0x3a485#define DRM_I915_GEM_VM_DESTROY 0x3b486#define DRM_I915_GEM_CREATE_EXT 0x3c487/* Must be kept compact -- no holes */488489#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)490#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)491#define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)492#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)493#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)494#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)495#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)496#define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)497#define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)498#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)499#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)500#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)501#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)502#define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)503#define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)504#define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)505#define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)506#define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)507#define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)508#define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)509#define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2)510#define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)511#define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)512#define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)513#define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)514#define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)515#define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)516#define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)517#define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)518#define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)519#define DRM_IOCTL_I915_GEM_CREATE_EXT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE_EXT, struct drm_i915_gem_create_ext)520#define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)521#define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)522#define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)523#define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)524#define DRM_IOCTL_I915_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_offset)525#define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)526#define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)527#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)528#define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)529#define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)530#define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)531#define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)532#define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)533#define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)534#define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)535#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)536#define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)537#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)538#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create_ext)539#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)540#define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)541#define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)542#define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)543#define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)544#define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)545#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)546#define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)547#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)548#define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query)549#define DRM_IOCTL_I915_GEM_VM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_CREATE, struct drm_i915_gem_vm_control)550#define DRM_IOCTL_I915_GEM_VM_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_VM_DESTROY, struct drm_i915_gem_vm_control)551552/* Allow drivers to submit batchbuffers directly to hardware, relying553* on the security mechanisms provided by hardware.554*/555typedef struct drm_i915_batchbuffer {556int start; /* agp offset */557int used; /* nr bytes in use */558int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */559int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */560int num_cliprects; /* mulitpass with multiple cliprects? */561struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */562} drm_i915_batchbuffer_t;563564/* As above, but pass a pointer to userspace buffer which can be565* validated by the kernel prior to sending to hardware.566*/567typedef struct _drm_i915_cmdbuffer {568char __user *buf; /* pointer to userspace command buffer */569int sz; /* nr bytes in buf */570int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */571int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */572int num_cliprects; /* mulitpass with multiple cliprects? */573struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */574} drm_i915_cmdbuffer_t;575576/* Userspace can request & wait on irq's:577*/578typedef struct drm_i915_irq_emit {579int __user *irq_seq;580} drm_i915_irq_emit_t;581582typedef struct drm_i915_irq_wait {583int irq_seq;584} drm_i915_irq_wait_t;585586/*587* Different modes of per-process Graphics Translation Table,588* see I915_PARAM_HAS_ALIASING_PPGTT589*/590#define I915_GEM_PPGTT_NONE 0591#define I915_GEM_PPGTT_ALIASING 1592#define I915_GEM_PPGTT_FULL 2593594/* Ioctl to query kernel params:595*/596#define I915_PARAM_IRQ_ACTIVE 1597#define I915_PARAM_ALLOW_BATCHBUFFER 2598#define I915_PARAM_LAST_DISPATCH 3599#define I915_PARAM_CHIPSET_ID 4600#define I915_PARAM_HAS_GEM 5601#define I915_PARAM_NUM_FENCES_AVAIL 6602#define I915_PARAM_HAS_OVERLAY 7603#define I915_PARAM_HAS_PAGEFLIPPING 8604#define I915_PARAM_HAS_EXECBUF2 9605#define I915_PARAM_HAS_BSD 10606#define I915_PARAM_HAS_BLT 11607#define I915_PARAM_HAS_RELAXED_FENCING 12608#define I915_PARAM_HAS_COHERENT_RINGS 13609#define I915_PARAM_HAS_EXEC_CONSTANTS 14610#define I915_PARAM_HAS_RELAXED_DELTA 15611#define I915_PARAM_HAS_GEN7_SOL_RESET 16612#define I915_PARAM_HAS_LLC 17613#define I915_PARAM_HAS_ALIASING_PPGTT 18614#define I915_PARAM_HAS_WAIT_TIMEOUT 19615#define I915_PARAM_HAS_SEMAPHORES 20616#define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21617#define I915_PARAM_HAS_VEBOX 22618#define I915_PARAM_HAS_SECURE_BATCHES 23619#define I915_PARAM_HAS_PINNED_BATCHES 24620#define I915_PARAM_HAS_EXEC_NO_RELOC 25621#define I915_PARAM_HAS_EXEC_HANDLE_LUT 26622#define I915_PARAM_HAS_WT 27623#define I915_PARAM_CMD_PARSER_VERSION 28624#define I915_PARAM_HAS_COHERENT_PHYS_GTT 29625#define I915_PARAM_MMAP_VERSION 30626#define I915_PARAM_HAS_BSD2 31627#define I915_PARAM_REVISION 32628#define I915_PARAM_SUBSLICE_TOTAL 33629#define I915_PARAM_EU_TOTAL 34630#define I915_PARAM_HAS_GPU_RESET 35631#define I915_PARAM_HAS_RESOURCE_STREAMER 36632#define I915_PARAM_HAS_EXEC_SOFTPIN 37633#define I915_PARAM_HAS_POOLED_EU 38634#define I915_PARAM_MIN_EU_IN_POOL 39635#define I915_PARAM_MMAP_GTT_VERSION 40636637/*638* Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution639* priorities and the driver will attempt to execute batches in priority order.640* The param returns a capability bitmask, nonzero implies that the scheduler641* is enabled, with different features present according to the mask.642*643* The initial priority for each batch is supplied by the context and is644* controlled via I915_CONTEXT_PARAM_PRIORITY.645*/646#define I915_PARAM_HAS_SCHEDULER 41647#define I915_SCHEDULER_CAP_ENABLED (1ul << 0)648#define I915_SCHEDULER_CAP_PRIORITY (1ul << 1)649#define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)650#define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3)651#define I915_SCHEDULER_CAP_ENGINE_BUSY_STATS (1ul << 4)652/*653* Indicates the 2k user priority levels are statically mapped into 3 buckets as654* follows:655*656* -1k to -1 Low priority657* 0 Normal priority658* 1 to 1k Highest priority659*/660#define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5)661662/*663* Query the status of HuC load.664*665* The query can fail in the following scenarios with the listed error codes:666* -ENODEV if HuC is not present on this platform,667* -EOPNOTSUPP if HuC firmware usage is disabled,668* -ENOPKG if HuC firmware fetch failed,669* -ENOEXEC if HuC firmware is invalid or mismatched,670* -ENOMEM if i915 failed to prepare the FW objects for transfer to the uC,671* -EIO if the FW transfer or the FW authentication failed.672*673* If the IOCTL is successful, the returned parameter will be set to one of the674* following values:675* * 0 if HuC firmware load is not complete,676* * 1 if HuC firmware is loaded and fully authenticated,677* * 2 if HuC firmware is loaded and authenticated for clear media only678*/679#define I915_PARAM_HUC_STATUS 42680681/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of682* synchronisation with implicit fencing on individual objects.683* See EXEC_OBJECT_ASYNC.684*/685#define I915_PARAM_HAS_EXEC_ASYNC 43686687/* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support -688* both being able to pass in a sync_file fd to wait upon before executing,689* and being able to return a new sync_file fd that is signaled when the690* current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT.691*/692#define I915_PARAM_HAS_EXEC_FENCE 44693694/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture695* user-specified buffers for post-mortem debugging of GPU hangs. See696* EXEC_OBJECT_CAPTURE.697*/698#define I915_PARAM_HAS_EXEC_CAPTURE 45699700#define I915_PARAM_SLICE_MASK 46701702/* Assuming it's uniform for each slice, this queries the mask of subslices703* per-slice for this system.704*/705#define I915_PARAM_SUBSLICE_MASK 47706707/*708* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer709* as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.710*/711#define I915_PARAM_HAS_EXEC_BATCH_FIRST 48712713/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of714* drm_i915_gem_exec_fence structures. See I915_EXEC_FENCE_ARRAY.715*/716#define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49717718/*719* Query whether every context (both per-file default and user created) is720* isolated (insofar as HW supports). If this parameter is not true, then721* freshly created contexts may inherit values from an existing context,722* rather than default HW values. If true, it also ensures (insofar as HW723* supports) that all state set by this context will not leak to any other724* context.725*726* As not every engine across every gen support contexts, the returned727* value reports the support of context isolation for individual engines by728* returning a bitmask of each engine class set to true if that class supports729* isolation.730*/731#define I915_PARAM_HAS_CONTEXT_ISOLATION 50732733/* Frequency of the command streamer timestamps given by the *_TIMESTAMP734* registers. This used to be fixed per platform but from CNL onwards, this735* might vary depending on the parts.736*/737#define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51738739/*740* Once upon a time we supposed that writes through the GGTT would be741* immediately in physical memory (once flushed out of the CPU path). However,742* on a few different processors and chipsets, this is not necessarily the case743* as the writes appear to be buffered internally. Thus a read of the backing744* storage (physical memory) via a different path (with different physical tags745* to the indirect write via the GGTT) will see stale values from before746* the GGTT write. Inside the kernel, we can for the most part keep track of747* the different read/write domains in use (e.g. set-domain), but the assumption748* of coherency is baked into the ABI, hence reporting its true state in this749* parameter.750*751* Reports true when writes via mmap_gtt are immediately visible following an752* lfence to flush the WCB.753*754* Reports false when writes via mmap_gtt are indeterminately delayed in an in755* internal buffer and are _not_ immediately visible to third parties accessing756* directly via mmap_cpu/mmap_wc. Use of mmap_gtt as part of an IPC757* communications channel when reporting false is strongly disadvised.758*/759#define I915_PARAM_MMAP_GTT_COHERENT 52760761/*762* Query whether DRM_I915_GEM_EXECBUFFER2 supports coordination of parallel763* execution through use of explicit fence support.764* See I915_EXEC_FENCE_OUT and I915_EXEC_FENCE_SUBMIT.765*/766#define I915_PARAM_HAS_EXEC_SUBMIT_FENCE 53767768/*769* Revision of the i915-perf uAPI. The value returned helps determine what770* i915-perf features are available. See drm_i915_perf_property_id.771*/772#define I915_PARAM_PERF_REVISION 54773774/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of775* timeline syncobj through drm_i915_gem_execbuffer_ext_timeline_fences. See776* I915_EXEC_USE_EXTENSIONS.777*/778#define I915_PARAM_HAS_EXEC_TIMELINE_FENCES 55779780/* Query if the kernel supports the I915_USERPTR_PROBE flag. */781#define I915_PARAM_HAS_USERPTR_PROBE 56782783/*784* Frequency of the timestamps in OA reports. This used to be the same as the CS785* timestamp frequency, but differs on some platforms.786*/787#define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57788789/*790* Query the status of PXP support in i915.791*792* The query can fail in the following scenarios with the listed error codes:793* -ENODEV = PXP support is not available on the GPU device or in the794* kernel due to missing component drivers or kernel configs.795*796* If the IOCTL is successful, the returned parameter will be set to one of797* the following values:798* 1 = PXP feature is supported and is ready for use.799* 2 = PXP feature is supported but should be ready soon (pending800* initialization of non-i915 system dependencies).801*802* NOTE: When param is supported (positive return values), user space should803* still refer to the GEM PXP context-creation UAPI header specs to be804* aware of possible failure due to system state machine at the time.805*/806#define I915_PARAM_PXP_STATUS 58807808/*809* Query if kernel allows marking a context to send a Freq hint to SLPC. This810* will enable use of the strategies allowed by the SLPC algorithm.811*/812#define I915_PARAM_HAS_CONTEXT_FREQ_HINT 59813814/* Must be kept compact -- no holes and well documented */815816/**817* struct drm_i915_getparam - Driver parameter query structure.818*/819struct drm_i915_getparam {820/** @param: Driver parameter to query. */821__s32 param;822823/**824* @value: Address of memory where queried value should be put.825*826* WARNING: Using pointers instead of fixed-size u64 means we need to write827* compat32 code. Don't repeat this mistake.828*/829int __user *value;830};831832/**833* typedef drm_i915_getparam_t - Driver parameter query structure.834* See struct drm_i915_getparam.835*/836typedef struct drm_i915_getparam drm_i915_getparam_t;837838/* Ioctl to set kernel params:839*/840#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1841#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2842#define I915_SETPARAM_ALLOW_BATCHBUFFER 3843#define I915_SETPARAM_NUM_USED_FENCES 4844/* Must be kept compact -- no holes */845846typedef struct drm_i915_setparam {847int param;848int value;849} drm_i915_setparam_t;850851/* A memory manager for regions of shared memory:852*/853#define I915_MEM_REGION_AGP 1854855typedef struct drm_i915_mem_alloc {856int region;857int alignment;858int size;859int __user *region_offset; /* offset from start of fb or agp */860} drm_i915_mem_alloc_t;861862typedef struct drm_i915_mem_free {863int region;864int region_offset;865} drm_i915_mem_free_t;866867typedef struct drm_i915_mem_init_heap {868int region;869int size;870int start;871} drm_i915_mem_init_heap_t;872873/* Allow memory manager to be torn down and re-initialized (eg on874* rotate):875*/876typedef struct drm_i915_mem_destroy_heap {877int region;878} drm_i915_mem_destroy_heap_t;879880/* Allow X server to configure which pipes to monitor for vblank signals881*/882#define DRM_I915_VBLANK_PIPE_A 1883#define DRM_I915_VBLANK_PIPE_B 2884885typedef struct drm_i915_vblank_pipe {886int pipe;887} drm_i915_vblank_pipe_t;888889/* Schedule buffer swap at given vertical blank:890*/891typedef struct drm_i915_vblank_swap {892drm_drawable_t drawable;893enum drm_vblank_seq_type seqtype;894unsigned int sequence;895} drm_i915_vblank_swap_t;896897typedef struct drm_i915_hws_addr {898__u64 addr;899} drm_i915_hws_addr_t;900901struct drm_i915_gem_init {902/**903* Beginning offset in the GTT to be managed by the DRM memory904* manager.905*/906__u64 gtt_start;907/**908* Ending offset in the GTT to be managed by the DRM memory909* manager.910*/911__u64 gtt_end;912};913914struct drm_i915_gem_create {915/**916* Requested size for the object.917*918* The (page-aligned) allocated size for the object will be returned.919*/920__u64 size;921/**922* Returned handle for the object.923*924* Object handles are nonzero.925*/926__u32 handle;927__u32 pad;928};929930struct drm_i915_gem_pread {931/** Handle for the object being read. */932__u32 handle;933__u32 pad;934/** Offset into the object to read from */935__u64 offset;936/** Length of data to read */937__u64 size;938/**939* Pointer to write the data into.940*941* This is a fixed-size type for 32/64 compatibility.942*/943__u64 data_ptr;944};945946struct drm_i915_gem_pwrite {947/** Handle for the object being written to. */948__u32 handle;949__u32 pad;950/** Offset into the object to write to */951__u64 offset;952/** Length of data to write */953__u64 size;954/**955* Pointer to read the data from.956*957* This is a fixed-size type for 32/64 compatibility.958*/959__u64 data_ptr;960};961962struct drm_i915_gem_mmap {963/** Handle for the object being mapped. */964__u32 handle;965__u32 pad;966/** Offset in the object to map. */967__u64 offset;968/**969* Length of data to map.970*971* The value will be page-aligned.972*/973__u64 size;974/**975* Returned pointer the data was mapped at.976*977* This is a fixed-size type for 32/64 compatibility.978*/979__u64 addr_ptr;980981/**982* Flags for extended behaviour.983*984* Added in version 2.985*/986__u64 flags;987#define I915_MMAP_WC 0x1988};989990struct drm_i915_gem_mmap_gtt {991/** Handle for the object being mapped. */992__u32 handle;993__u32 pad;994/**995* Fake offset to use for subsequent mmap call996*997* This is a fixed-size type for 32/64 compatibility.998*/999__u64 offset;1000};10011002/**1003* struct drm_i915_gem_mmap_offset - Retrieve an offset so we can mmap this buffer object.1004*1005* This struct is passed as argument to the `DRM_IOCTL_I915_GEM_MMAP_OFFSET` ioctl,1006* and is used to retrieve the fake offset to mmap an object specified by &handle.1007*1008* The legacy way of using `DRM_IOCTL_I915_GEM_MMAP` is removed on gen12+.1009* `DRM_IOCTL_I915_GEM_MMAP_GTT` is an older supported alias to this struct, but will behave1010* as setting the &extensions to 0, and &flags to `I915_MMAP_OFFSET_GTT`.1011*/1012struct drm_i915_gem_mmap_offset {1013/** @handle: Handle for the object being mapped. */1014__u32 handle;1015/** @pad: Must be zero */1016__u32 pad;1017/**1018* @offset: The fake offset to use for subsequent mmap call1019*1020* This is a fixed-size type for 32/64 compatibility.1021*/1022__u64 offset;10231024/**1025* @flags: Flags for extended behaviour.1026*1027* It is mandatory that one of the `MMAP_OFFSET` types1028* should be included:1029*1030* - `I915_MMAP_OFFSET_GTT`: Use mmap with the object bound to GTT. (Write-Combined)1031* - `I915_MMAP_OFFSET_WC`: Use Write-Combined caching.1032* - `I915_MMAP_OFFSET_WB`: Use Write-Back caching.1033* - `I915_MMAP_OFFSET_FIXED`: Use object placement to determine caching.1034*1035* On devices with local memory `I915_MMAP_OFFSET_FIXED` is the only valid1036* type. On devices without local memory, this caching mode is invalid.1037*1038* As caching mode when specifying `I915_MMAP_OFFSET_FIXED`, WC or WB will1039* be used, depending on the object placement on creation. WB will be used1040* when the object can only exist in system memory, WC otherwise.1041*/1042__u64 flags;10431044#define I915_MMAP_OFFSET_GTT 01045#define I915_MMAP_OFFSET_WC 11046#define I915_MMAP_OFFSET_WB 21047#define I915_MMAP_OFFSET_UC 31048#define I915_MMAP_OFFSET_FIXED 410491050/**1051* @extensions: Zero-terminated chain of extensions.1052*1053* No current extensions defined; mbz.1054*/1055__u64 extensions;1056};10571058/**1059* struct drm_i915_gem_set_domain - Adjust the objects write or read domain, in1060* preparation for accessing the pages via some CPU domain.1061*1062* Specifying a new write or read domain will flush the object out of the1063* previous domain(if required), before then updating the objects domain1064* tracking with the new domain.1065*1066* Note this might involve waiting for the object first if it is still active on1067* the GPU.1068*1069* Supported values for @read_domains and @write_domain:1070*1071* - I915_GEM_DOMAIN_WC: Uncached write-combined domain1072* - I915_GEM_DOMAIN_CPU: CPU cache domain1073* - I915_GEM_DOMAIN_GTT: Mappable aperture domain1074*1075* All other domains are rejected.1076*1077* Note that for discrete, starting from DG1, this is no longer supported, and1078* is instead rejected. On such platforms the CPU domain is effectively static,1079* where we also only support a single &drm_i915_gem_mmap_offset cache mode,1080* which can't be set explicitly and instead depends on the object placements,1081* as per the below.1082*1083* Implicit caching rules, starting from DG1:1084*1085* - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)1086* contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and1087* mapped as write-combined only.1088*1089* - Everything else is always allocated and mapped as write-back, with the1090* guarantee that everything is also coherent with the GPU.1091*1092* Note that this is likely to change in the future again, where we might need1093* more flexibility on future devices, so making this all explicit as part of a1094* new &drm_i915_gem_create_ext extension is probable.1095*/1096struct drm_i915_gem_set_domain {1097/** @handle: Handle for the object. */1098__u32 handle;10991100/** @read_domains: New read domains. */1101__u32 read_domains;11021103/**1104* @write_domain: New write domain.1105*1106* Note that having something in the write domain implies it's in the1107* read domain, and only that read domain.1108*/1109__u32 write_domain;1110};11111112struct drm_i915_gem_sw_finish {1113/** Handle for the object */1114__u32 handle;1115};11161117struct drm_i915_gem_relocation_entry {1118/**1119* Handle of the buffer being pointed to by this relocation entry.1120*1121* It's appealing to make this be an index into the mm_validate_entry1122* list to refer to the buffer, but this allows the driver to create1123* a relocation list for state buffers and not re-write it per1124* exec using the buffer.1125*/1126__u32 target_handle;11271128/**1129* Value to be added to the offset of the target buffer to make up1130* the relocation entry.1131*/1132__u32 delta;11331134/** Offset in the buffer the relocation entry will be written into */1135__u64 offset;11361137/**1138* Offset value of the target buffer that the relocation entry was last1139* written as.1140*1141* If the buffer has the same offset as last time, we can skip syncing1142* and writing the relocation. This value is written back out by1143* the execbuffer ioctl when the relocation is written.1144*/1145__u64 presumed_offset;11461147/**1148* Target memory domains read by this operation.1149*/1150__u32 read_domains;11511152/**1153* Target memory domains written by this operation.1154*1155* Note that only one domain may be written by the whole1156* execbuffer operation, so that where there are conflicts,1157* the application will get -EINVAL back.1158*/1159__u32 write_domain;1160};11611162/** @{1163* Intel memory domains1164*1165* Most of these just align with the various caches in1166* the system and are used to flush and invalidate as1167* objects end up cached in different domains.1168*/1169/** CPU cache */1170#define I915_GEM_DOMAIN_CPU 0x000000011171/** Render cache, used by 2D and 3D drawing */1172#define I915_GEM_DOMAIN_RENDER 0x000000021173/** Sampler cache, used by texture engine */1174#define I915_GEM_DOMAIN_SAMPLER 0x000000041175/** Command queue, used to load batch buffers */1176#define I915_GEM_DOMAIN_COMMAND 0x000000081177/** Instruction cache, used by shader programs */1178#define I915_GEM_DOMAIN_INSTRUCTION 0x000000101179/** Vertex address cache */1180#define I915_GEM_DOMAIN_VERTEX 0x000000201181/** GTT domain - aperture and scanout */1182#define I915_GEM_DOMAIN_GTT 0x000000401183/** WC domain - uncached access */1184#define I915_GEM_DOMAIN_WC 0x000000801185/** @} */11861187struct drm_i915_gem_exec_object {1188/**1189* User's handle for a buffer to be bound into the GTT for this1190* operation.1191*/1192__u32 handle;11931194/** Number of relocations to be performed on this buffer */1195__u32 relocation_count;1196/**1197* Pointer to array of struct drm_i915_gem_relocation_entry containing1198* the relocations to be performed in this buffer.1199*/1200__u64 relocs_ptr;12011202/** Required alignment in graphics aperture */1203__u64 alignment;12041205/**1206* Returned value of the updated offset of the object, for future1207* presumed_offset writes.1208*/1209__u64 offset;1210};12111212/* DRM_IOCTL_I915_GEM_EXECBUFFER was removed in Linux 5.13 */1213struct drm_i915_gem_execbuffer {1214/**1215* List of buffers to be validated with their relocations to be1216* performend on them.1217*1218* This is a pointer to an array of struct drm_i915_gem_validate_entry.1219*1220* These buffers must be listed in an order such that all relocations1221* a buffer is performing refer to buffers that have already appeared1222* in the validate list.1223*/1224__u64 buffers_ptr;1225__u32 buffer_count;12261227/** Offset in the batchbuffer to start execution from. */1228__u32 batch_start_offset;1229/** Bytes used in batchbuffer from batch_start_offset */1230__u32 batch_len;1231__u32 DR1;1232__u32 DR4;1233__u32 num_cliprects;1234/** This is a struct drm_clip_rect *cliprects */1235__u64 cliprects_ptr;1236};12371238struct drm_i915_gem_exec_object2 {1239/**1240* User's handle for a buffer to be bound into the GTT for this1241* operation.1242*/1243__u32 handle;12441245/** Number of relocations to be performed on this buffer */1246__u32 relocation_count;1247/**1248* Pointer to array of struct drm_i915_gem_relocation_entry containing1249* the relocations to be performed in this buffer.1250*/1251__u64 relocs_ptr;12521253/** Required alignment in graphics aperture */1254__u64 alignment;12551256/**1257* When the EXEC_OBJECT_PINNED flag is specified this is populated by1258* the user with the GTT offset at which this object will be pinned.1259*1260* When the I915_EXEC_NO_RELOC flag is specified this must contain the1261* presumed_offset of the object.1262*1263* During execbuffer2 the kernel populates it with the value of the1264* current GTT offset of the object, for future presumed_offset writes.1265*1266* See struct drm_i915_gem_create_ext for the rules when dealing with1267* alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with1268* minimum page sizes, like DG2.1269*/1270__u64 offset;12711272#define EXEC_OBJECT_NEEDS_FENCE (1<<0)1273#define EXEC_OBJECT_NEEDS_GTT (1<<1)1274#define EXEC_OBJECT_WRITE (1<<2)1275#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)1276#define EXEC_OBJECT_PINNED (1<<4)1277#define EXEC_OBJECT_PAD_TO_SIZE (1<<5)1278/* The kernel implicitly tracks GPU activity on all GEM objects, and1279* synchronises operations with outstanding rendering. This includes1280* rendering on other devices if exported via dma-buf. However, sometimes1281* this tracking is too coarse and the user knows better. For example,1282* if the object is split into non-overlapping ranges shared between different1283* clients or engines (i.e. suballocating objects), the implicit tracking1284* by kernel assumes that each operation affects the whole object rather1285* than an individual range, causing needless synchronisation between clients.1286* The kernel will also forgo any CPU cache flushes prior to rendering from1287* the object as the client is expected to be also handling such domain1288* tracking.1289*1290* The kernel maintains the implicit tracking in order to manage resources1291* used by the GPU - this flag only disables the synchronisation prior to1292* rendering with this object in this execbuf.1293*1294* Opting out of implicit synhronisation requires the user to do its own1295* explicit tracking to avoid rendering corruption. See, for example,1296* I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.1297*/1298#define EXEC_OBJECT_ASYNC (1<<6)1299/* Request that the contents of this execobject be copied into the error1300* state upon a GPU hang involving this batch for post-mortem debugging.1301* These buffers are recorded in no particular order as "user" in1302* /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see1303* if the kernel supports this flag.1304*/1305#define EXEC_OBJECT_CAPTURE (1<<7)1306/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */1307#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)1308__u64 flags;13091310union {1311__u64 rsvd1;1312__u64 pad_to_size;1313};1314__u64 rsvd2;1315};13161317/**1318* struct drm_i915_gem_exec_fence - An input or output fence for the execbuf1319* ioctl.1320*1321* The request will wait for input fence to signal before submission.1322*1323* The returned output fence will be signaled after the completion of the1324* request.1325*/1326struct drm_i915_gem_exec_fence {1327/** @handle: User's handle for a drm_syncobj to wait on or signal. */1328__u32 handle;13291330/**1331* @flags: Supported flags are:1332*1333* I915_EXEC_FENCE_WAIT:1334* Wait for the input fence before request submission.1335*1336* I915_EXEC_FENCE_SIGNAL:1337* Return request completion fence as output1338*/1339__u32 flags;1340#define I915_EXEC_FENCE_WAIT (1<<0)1341#define I915_EXEC_FENCE_SIGNAL (1<<1)1342#define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1))1343};13441345/**1346* struct drm_i915_gem_execbuffer_ext_timeline_fences - Timeline fences1347* for execbuf ioctl.1348*1349* This structure describes an array of drm_syncobj and associated points for1350* timeline variants of drm_syncobj. It is invalid to append this structure to1351* the execbuf if I915_EXEC_FENCE_ARRAY is set.1352*/1353struct drm_i915_gem_execbuffer_ext_timeline_fences {1354#define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 01355/** @base: Extension link. See struct i915_user_extension. */1356struct i915_user_extension base;13571358/**1359* @fence_count: Number of elements in the @handles_ptr & @value_ptr1360* arrays.1361*/1362__u64 fence_count;13631364/**1365* @handles_ptr: Pointer to an array of struct drm_i915_gem_exec_fence1366* of length @fence_count.1367*/1368__u64 handles_ptr;13691370/**1371* @values_ptr: Pointer to an array of u64 values of length1372* @fence_count.1373* Values must be 0 for a binary drm_syncobj. A Value of 0 for a1374* timeline drm_syncobj is invalid as it turns a drm_syncobj into a1375* binary one.1376*/1377__u64 values_ptr;1378};13791380/**1381* struct drm_i915_gem_execbuffer2 - Structure for DRM_I915_GEM_EXECBUFFER21382* ioctl.1383*/1384struct drm_i915_gem_execbuffer2 {1385/** @buffers_ptr: Pointer to a list of gem_exec_object2 structs */1386__u64 buffers_ptr;13871388/** @buffer_count: Number of elements in @buffers_ptr array */1389__u32 buffer_count;13901391/**1392* @batch_start_offset: Offset in the batchbuffer to start execution1393* from.1394*/1395__u32 batch_start_offset;13961397/**1398* @batch_len: Length in bytes of the batch buffer, starting from the1399* @batch_start_offset. If 0, length is assumed to be the batch buffer1400* object size.1401*/1402__u32 batch_len;14031404/** @DR1: deprecated */1405__u32 DR1;14061407/** @DR4: deprecated */1408__u32 DR4;14091410/** @num_cliprects: See @cliprects_ptr */1411__u32 num_cliprects;14121413/**1414* @cliprects_ptr: Kernel clipping was a DRI1 misfeature.1415*1416* It is invalid to use this field if I915_EXEC_FENCE_ARRAY or1417* I915_EXEC_USE_EXTENSIONS flags are not set.1418*1419* If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array1420* of &drm_i915_gem_exec_fence and @num_cliprects is the length of the1421* array.1422*1423* If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a1424* single &i915_user_extension and num_cliprects is 0.1425*/1426__u64 cliprects_ptr;14271428/** @flags: Execbuf flags */1429__u64 flags;1430#define I915_EXEC_RING_MASK (0x3f)1431#define I915_EXEC_DEFAULT (0<<0)1432#define I915_EXEC_RENDER (1<<0)1433#define I915_EXEC_BSD (2<<0)1434#define I915_EXEC_BLT (3<<0)1435#define I915_EXEC_VEBOX (4<<0)14361437/* Used for switching the constants addressing mode on gen4+ RENDER ring.1438* Gen6+ only supports relative addressing to dynamic state (default) and1439* absolute addressing.1440*1441* These flags are ignored for the BSD and BLT rings.1442*/1443#define I915_EXEC_CONSTANTS_MASK (3<<6)1444#define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */1445#define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)1446#define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */14471448/** Resets the SO write offset registers for transform feedback on gen7. */1449#define I915_EXEC_GEN7_SOL_RESET (1<<8)14501451/** Request a privileged ("secure") batch buffer. Note only available for1452* DRM_ROOT_ONLY | DRM_MASTER processes.1453*/1454#define I915_EXEC_SECURE (1<<9)14551456/** Inform the kernel that the batch is and will always be pinned. This1457* negates the requirement for a workaround to be performed to avoid1458* an incoherent CS (such as can be found on 830/845). If this flag is1459* not passed, the kernel will endeavour to make sure the batch is1460* coherent with the CS before execution. If this flag is passed,1461* userspace assumes the responsibility for ensuring the same.1462*/1463#define I915_EXEC_IS_PINNED (1<<10)14641465/** Provide a hint to the kernel that the command stream and auxiliary1466* state buffers already holds the correct presumed addresses and so the1467* relocation process may be skipped if no buffers need to be moved in1468* preparation for the execbuffer.1469*/1470#define I915_EXEC_NO_RELOC (1<<11)14711472/** Use the reloc.handle as an index into the exec object array rather1473* than as the per-file handle.1474*/1475#define I915_EXEC_HANDLE_LUT (1<<12)14761477/** Used for switching BSD rings on the platforms with two BSD rings */1478#define I915_EXEC_BSD_SHIFT (13)1479#define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)1480/* default ping-pong mode */1481#define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)1482#define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)1483#define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)14841485/** Tell the kernel that the batchbuffer is processed by1486* the resource streamer.1487*/1488#define I915_EXEC_RESOURCE_STREAMER (1<<15)14891490/* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent1491* a sync_file fd to wait upon (in a nonblocking manner) prior to executing1492* the batch.1493*1494* Returns -EINVAL if the sync_file fd cannot be found.1495*/1496#define I915_EXEC_FENCE_IN (1<<16)14971498/* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd1499* in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given1500* to the caller, and it should be close() after use. (The fd is a regular1501* file descriptor and will be cleaned up on process termination. It holds1502* a reference to the request, but nothing else.)1503*1504* The sync_file fd can be combined with other sync_file and passed either1505* to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip1506* will only occur after this request completes), or to other devices.1507*1508* Using I915_EXEC_FENCE_OUT requires use of1509* DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written1510* back to userspace. Failure to do so will cause the out-fence to always1511* be reported as zero, and the real fence fd to be leaked.1512*/1513#define I915_EXEC_FENCE_OUT (1<<17)15141515/*1516* Traditionally the execbuf ioctl has only considered the final element in1517* the execobject[] to be the executable batch. Often though, the client1518* will known the batch object prior to construction and being able to place1519* it into the execobject[] array first can simplify the relocation tracking.1520* Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the1521* execobject[] as the * batch instead (the default is to use the last1522* element).1523*/1524#define I915_EXEC_BATCH_FIRST (1<<18)15251526/* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr1527* define an array of i915_gem_exec_fence structures which specify a set of1528* dma fences to wait upon or signal.1529*/1530#define I915_EXEC_FENCE_ARRAY (1<<19)15311532/*1533* Setting I915_EXEC_FENCE_SUBMIT implies that lower_32_bits(rsvd2) represent1534* a sync_file fd to wait upon (in a nonblocking manner) prior to executing1535* the batch.1536*1537* Returns -EINVAL if the sync_file fd cannot be found.1538*/1539#define I915_EXEC_FENCE_SUBMIT (1 << 20)15401541/*1542* Setting I915_EXEC_USE_EXTENSIONS implies that1543* drm_i915_gem_execbuffer2.cliprects_ptr is treated as a pointer to an linked1544* list of i915_user_extension. Each i915_user_extension node is the base of a1545* larger structure. The list of supported structures are listed in the1546* drm_i915_gem_execbuffer_ext enum.1547*/1548#define I915_EXEC_USE_EXTENSIONS (1 << 21)1549#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1))15501551/** @rsvd1: Context id */1552__u64 rsvd1;15531554/**1555* @rsvd2: in and out sync_file file descriptors.1556*1557* When I915_EXEC_FENCE_IN or I915_EXEC_FENCE_SUBMIT flag is set, the1558* lower 32 bits of this field will have the in sync_file fd (input).1559*1560* When I915_EXEC_FENCE_OUT flag is set, the upper 32 bits of this1561* field will have the out sync_file fd (output).1562*/1563__u64 rsvd2;1564};15651566#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)1567#define i915_execbuffer2_set_context_id(eb2, context) \1568(eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK1569#define i915_execbuffer2_get_context_id(eb2) \1570((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)15711572struct drm_i915_gem_pin {1573/** Handle of the buffer to be pinned. */1574__u32 handle;1575__u32 pad;15761577/** alignment required within the aperture */1578__u64 alignment;15791580/** Returned GTT offset of the buffer. */1581__u64 offset;1582};15831584struct drm_i915_gem_unpin {1585/** Handle of the buffer to be unpinned. */1586__u32 handle;1587__u32 pad;1588};15891590struct drm_i915_gem_busy {1591/** Handle of the buffer to check for busy */1592__u32 handle;15931594/** Return busy status1595*1596* A return of 0 implies that the object is idle (after1597* having flushed any pending activity), and a non-zero return that1598* the object is still in-flight on the GPU. (The GPU has not yet1599* signaled completion for all pending requests that reference the1600* object.) An object is guaranteed to become idle eventually (so1601* long as no new GPU commands are executed upon it). Due to the1602* asynchronous nature of the hardware, an object reported1603* as busy may become idle before the ioctl is completed.1604*1605* Furthermore, if the object is busy, which engine is busy is only1606* provided as a guide and only indirectly by reporting its class1607* (there may be more than one engine in each class). There are race1608* conditions which prevent the report of which engines are busy from1609* being always accurate. However, the converse is not true. If the1610* object is idle, the result of the ioctl, that all engines are idle,1611* is accurate.1612*1613* The returned dword is split into two fields to indicate both1614* the engine classes on which the object is being read, and the1615* engine class on which it is currently being written (if any).1616*1617* The low word (bits 0:15) indicate if the object is being written1618* to by any engine (there can only be one, as the GEM implicit1619* synchronisation rules force writes to be serialised). Only the1620* engine class (offset by 1, I915_ENGINE_CLASS_RENDER is reported as1621* 1 not 0 etc) for the last write is reported.1622*1623* The high word (bits 16:31) are a bitmask of which engines classes1624* are currently reading from the object. Multiple engines may be1625* reading from the object simultaneously.1626*1627* The value of each engine class is the same as specified in the1628* I915_CONTEXT_PARAM_ENGINES context parameter and via perf, i.e.1629* I915_ENGINE_CLASS_RENDER, I915_ENGINE_CLASS_COPY, etc.1630* Some hardware may have parallel execution engines, e.g. multiple1631* media engines, which are mapped to the same class identifier and so1632* are not separately reported for busyness.1633*1634* Caveat emptor:1635* Only the boolean result of this query is reliable; that is whether1636* the object is idle or busy. The report of which engines are busy1637* should be only used as a heuristic.1638*/1639__u32 busy;1640};16411642/**1643* struct drm_i915_gem_caching - Set or get the caching for given object1644* handle.1645*1646* Allow userspace to control the GTT caching bits for a given object when the1647* object is later mapped through the ppGTT(or GGTT on older platforms lacking1648* ppGTT support, or if the object is used for scanout). Note that this might1649* require unbinding the object from the GTT first, if its current caching value1650* doesn't match.1651*1652* Note that this all changes on discrete platforms, starting from DG1, the1653* set/get caching is no longer supported, and is now rejected. Instead the CPU1654* caching attributes(WB vs WC) will become an immutable creation time property1655* for the object, along with the GTT caching level. For now we don't expose any1656* new uAPI for this, instead on DG1 this is all implicit, although this largely1657* shouldn't matter since DG1 is coherent by default(without any way of1658* controlling it).1659*1660* Implicit caching rules, starting from DG1:1661*1662* - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)1663* contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and1664* mapped as write-combined only.1665*1666* - Everything else is always allocated and mapped as write-back, with the1667* guarantee that everything is also coherent with the GPU.1668*1669* Note that this is likely to change in the future again, where we might need1670* more flexibility on future devices, so making this all explicit as part of a1671* new &drm_i915_gem_create_ext extension is probable.1672*1673* Side note: Part of the reason for this is that changing the at-allocation-time CPU1674* caching attributes for the pages might be required(and is expensive) if we1675* need to then CPU map the pages later with different caching attributes. This1676* inconsistent caching behaviour, while supported on x86, is not universally1677* supported on other architectures. So for simplicity we opt for setting1678* everything at creation time, whilst also making it immutable, on discrete1679* platforms.1680*/1681struct drm_i915_gem_caching {1682/**1683* @handle: Handle of the buffer to set/get the caching level.1684*/1685__u32 handle;16861687/**1688* @caching: The GTT caching level to apply or possible return value.1689*1690* The supported @caching values:1691*1692* I915_CACHING_NONE:1693*1694* GPU access is not coherent with CPU caches. Default for machines1695* without an LLC. This means manual flushing might be needed, if we1696* want GPU access to be coherent.1697*1698* I915_CACHING_CACHED:1699*1700* GPU access is coherent with CPU caches and furthermore the data is1701* cached in last-level caches shared between CPU cores and the GPU GT.1702*1703* I915_CACHING_DISPLAY:1704*1705* Special GPU caching mode which is coherent with the scanout engines.1706* Transparently falls back to I915_CACHING_NONE on platforms where no1707* special cache mode (like write-through or gfdt flushing) is1708* available. The kernel automatically sets this mode when using a1709* buffer as a scanout target. Userspace can manually set this mode to1710* avoid a costly stall and clflush in the hotpath of drawing the first1711* frame.1712*/1713#define I915_CACHING_NONE 01714#define I915_CACHING_CACHED 11715#define I915_CACHING_DISPLAY 21716__u32 caching;1717};17181719#define I915_TILING_NONE 01720#define I915_TILING_X 11721#define I915_TILING_Y 21722/*1723* Do not add new tiling types here. The I915_TILING_* values are for1724* de-tiling fence registers that no longer exist on modern platforms. Although1725* the hardware may support new types of tiling in general (e.g., Tile4), we1726* do not need to add them to the uapi that is specific to now-defunct ioctls.1727*/1728#define I915_TILING_LAST I915_TILING_Y17291730#define I915_BIT_6_SWIZZLE_NONE 01731#define I915_BIT_6_SWIZZLE_9 11732#define I915_BIT_6_SWIZZLE_9_10 21733#define I915_BIT_6_SWIZZLE_9_11 31734#define I915_BIT_6_SWIZZLE_9_10_11 41735/* Not seen by userland */1736#define I915_BIT_6_SWIZZLE_UNKNOWN 51737/* Seen by userland. */1738#define I915_BIT_6_SWIZZLE_9_17 61739#define I915_BIT_6_SWIZZLE_9_10_17 717401741struct drm_i915_gem_set_tiling {1742/** Handle of the buffer to have its tiling state updated */1743__u32 handle;17441745/**1746* Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,1747* I915_TILING_Y).1748*1749* This value is to be set on request, and will be updated by the1750* kernel on successful return with the actual chosen tiling layout.1751*1752* The tiling mode may be demoted to I915_TILING_NONE when the system1753* has bit 6 swizzling that can't be managed correctly by GEM.1754*1755* Buffer contents become undefined when changing tiling_mode.1756*/1757__u32 tiling_mode;17581759/**1760* Stride in bytes for the object when in I915_TILING_X or1761* I915_TILING_Y.1762*/1763__u32 stride;17641765/**1766* Returned address bit 6 swizzling required for CPU access through1767* mmap mapping.1768*/1769__u32 swizzle_mode;1770};17711772struct drm_i915_gem_get_tiling {1773/** Handle of the buffer to get tiling state for. */1774__u32 handle;17751776/**1777* Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,1778* I915_TILING_Y).1779*/1780__u32 tiling_mode;17811782/**1783* Returned address bit 6 swizzling required for CPU access through1784* mmap mapping.1785*/1786__u32 swizzle_mode;17871788/**1789* Returned address bit 6 swizzling required for CPU access through1790* mmap mapping whilst bound.1791*/1792__u32 phys_swizzle_mode;1793};17941795struct drm_i915_gem_get_aperture {1796/** Total size of the aperture used by i915_gem_execbuffer, in bytes */1797__u64 aper_size;17981799/**1800* Available space in the aperture used by i915_gem_execbuffer, in1801* bytes1802*/1803__u64 aper_available_size;1804};18051806struct drm_i915_get_pipe_from_crtc_id {1807/** ID of CRTC being requested **/1808__u32 crtc_id;18091810/** pipe of requested CRTC **/1811__u32 pipe;1812};18131814#define I915_MADV_WILLNEED 01815#define I915_MADV_DONTNEED 11816#define __I915_MADV_PURGED 2 /* internal state */18171818struct drm_i915_gem_madvise {1819/** Handle of the buffer to change the backing store advice */1820__u32 handle;18211822/* Advice: either the buffer will be needed again in the near future,1823* or won't be and could be discarded under memory pressure.1824*/1825__u32 madv;18261827/** Whether the backing store still exists. */1828__u32 retained;1829};18301831/* flags */1832#define I915_OVERLAY_TYPE_MASK 0xff1833#define I915_OVERLAY_YUV_PLANAR 0x011834#define I915_OVERLAY_YUV_PACKED 0x021835#define I915_OVERLAY_RGB 0x0318361837#define I915_OVERLAY_DEPTH_MASK 0xff001838#define I915_OVERLAY_RGB24 0x10001839#define I915_OVERLAY_RGB16 0x20001840#define I915_OVERLAY_RGB15 0x30001841#define I915_OVERLAY_YUV422 0x01001842#define I915_OVERLAY_YUV411 0x02001843#define I915_OVERLAY_YUV420 0x03001844#define I915_OVERLAY_YUV410 0x040018451846#define I915_OVERLAY_SWAP_MASK 0xff00001847#define I915_OVERLAY_NO_SWAP 0x0000001848#define I915_OVERLAY_UV_SWAP 0x0100001849#define I915_OVERLAY_Y_SWAP 0x0200001850#define I915_OVERLAY_Y_AND_UV_SWAP 0x03000018511852#define I915_OVERLAY_FLAGS_MASK 0xff0000001853#define I915_OVERLAY_ENABLE 0x0100000018541855struct drm_intel_overlay_put_image {1856/* various flags and src format description */1857__u32 flags;1858/* source picture description */1859__u32 bo_handle;1860/* stride values and offsets are in bytes, buffer relative */1861__u16 stride_Y; /* stride for packed formats */1862__u16 stride_UV;1863__u32 offset_Y; /* offset for packet formats */1864__u32 offset_U;1865__u32 offset_V;1866/* in pixels */1867__u16 src_width;1868__u16 src_height;1869/* to compensate the scaling factors for partially covered surfaces */1870__u16 src_scan_width;1871__u16 src_scan_height;1872/* output crtc description */1873__u32 crtc_id;1874__u16 dst_x;1875__u16 dst_y;1876__u16 dst_width;1877__u16 dst_height;1878};18791880/* flags */1881#define I915_OVERLAY_UPDATE_ATTRS (1<<0)1882#define I915_OVERLAY_UPDATE_GAMMA (1<<1)1883#define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)1884struct drm_intel_overlay_attrs {1885__u32 flags;1886__u32 color_key;1887__s32 brightness;1888__u32 contrast;1889__u32 saturation;1890__u32 gamma0;1891__u32 gamma1;1892__u32 gamma2;1893__u32 gamma3;1894__u32 gamma4;1895__u32 gamma5;1896};18971898/*1899* Intel sprite handling1900*1901* Color keying works with a min/mask/max tuple. Both source and destination1902* color keying is allowed.1903*1904* Source keying:1905* Sprite pixels within the min & max values, masked against the color channels1906* specified in the mask field, will be transparent. All other pixels will1907* be displayed on top of the primary plane. For RGB surfaces, only the min1908* and mask fields will be used; ranged compares are not allowed.1909*1910* Destination keying:1911* Primary plane pixels that match the min value, masked against the color1912* channels specified in the mask field, will be replaced by corresponding1913* pixels from the sprite plane.1914*1915* Note that source & destination keying are exclusive; only one can be1916* active on a given plane.1917*/19181919#define I915_SET_COLORKEY_NONE (1<<0) /* Deprecated. Instead set1920* flags==0 to disable colorkeying.1921*/1922#define I915_SET_COLORKEY_DESTINATION (1<<1)1923#define I915_SET_COLORKEY_SOURCE (1<<2)1924struct drm_intel_sprite_colorkey {1925__u32 plane_id;1926__u32 min_value;1927__u32 channel_mask;1928__u32 max_value;1929__u32 flags;1930};19311932struct drm_i915_gem_wait {1933/** Handle of BO we shall wait on */1934__u32 bo_handle;1935__u32 flags;1936/** Number of nanoseconds to wait, Returns time remaining. */1937__s64 timeout_ns;1938};19391940struct drm_i915_gem_context_create {1941__u32 ctx_id; /* output: id of new context*/1942__u32 pad;1943};19441945/**1946* struct drm_i915_gem_context_create_ext - Structure for creating contexts.1947*/1948struct drm_i915_gem_context_create_ext {1949/** @ctx_id: Id of the created context (output) */1950__u32 ctx_id;19511952/**1953* @flags: Supported flags are:1954*1955* I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS:1956*1957* Extensions may be appended to this structure and driver must check1958* for those. See @extensions.1959*1960* I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE1961*1962* Created context will have single timeline.1963*/1964__u32 flags;1965#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0)1966#define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1)1967#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \1968(-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1))19691970/**1971* @extensions: Zero-terminated chain of extensions.1972*1973* I915_CONTEXT_CREATE_EXT_SETPARAM:1974* Context parameter to set or query during context creation.1975* See struct drm_i915_gem_context_create_ext_setparam.1976*1977* I915_CONTEXT_CREATE_EXT_CLONE:1978* This extension has been removed. On the off chance someone somewhere1979* has attempted to use it, never re-use this extension number.1980*/1981__u64 extensions;1982#define I915_CONTEXT_CREATE_EXT_SETPARAM 01983#define I915_CONTEXT_CREATE_EXT_CLONE 11984};19851986/**1987* struct drm_i915_gem_context_param - Context parameter to set or query.1988*/1989struct drm_i915_gem_context_param {1990/** @ctx_id: Context id */1991__u32 ctx_id;19921993/** @size: Size of the parameter @value */1994__u32 size;19951996/** @param: Parameter to set or query */1997__u64 param;1998#define I915_CONTEXT_PARAM_BAN_PERIOD 0x11999/* I915_CONTEXT_PARAM_NO_ZEROMAP has been removed. On the off chance2000* someone somewhere has attempted to use it, never re-use this context2001* param number.2002*/2003#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x22004#define I915_CONTEXT_PARAM_GTT_SIZE 0x32005#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x42006#define I915_CONTEXT_PARAM_BANNABLE 0x52007#define I915_CONTEXT_PARAM_PRIORITY 0x62008#define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */2009#define I915_CONTEXT_DEFAULT_PRIORITY 02010#define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */2011/*2012* When using the following param, value should be a pointer to2013* drm_i915_gem_context_param_sseu.2014*/2015#define I915_CONTEXT_PARAM_SSEU 0x720162017/*2018* Not all clients may want to attempt automatic recover of a context after2019* a hang (for example, some clients may only submit very small incremental2020* batches relying on known logical state of previous batches which will never2021* recover correctly and each attempt will hang), and so would prefer that2022* the context is forever banned instead.2023*2024* If set to false (0), after a reset, subsequent (and in flight) rendering2025* from this context is discarded, and the client will need to create a new2026* context to use instead.2027*2028* If set to true (1), the kernel will automatically attempt to recover the2029* context by skipping the hanging batch and executing the next batch starting2030* from the default context state (discarding the incomplete logical context2031* state lost due to the reset).2032*2033* On creation, all new contexts are marked as recoverable.2034*/2035#define I915_CONTEXT_PARAM_RECOVERABLE 0x820362037/*2038* The id of the associated virtual memory address space (ppGTT) of2039* this context. Can be retrieved and passed to another context2040* (on the same fd) for both to use the same ppGTT and so share2041* address layouts, and avoid reloading the page tables on context2042* switches between themselves.2043*2044* See DRM_I915_GEM_VM_CREATE and DRM_I915_GEM_VM_DESTROY.2045*/2046#define I915_CONTEXT_PARAM_VM 0x920472048/*2049* I915_CONTEXT_PARAM_ENGINES:2050*2051* Bind this context to operate on this subset of available engines. Henceforth,2052* the I915_EXEC_RING selector for DRM_IOCTL_I915_GEM_EXECBUFFER2 operates as2053* an index into this array of engines; I915_EXEC_DEFAULT selecting engine[0]2054* and upwards. Slots 0...N are filled in using the specified (class, instance).2055* Use2056* engine_class: I915_ENGINE_CLASS_INVALID,2057* engine_instance: I915_ENGINE_CLASS_INVALID_NONE2058* to specify a gap in the array that can be filled in later, e.g. by a2059* virtual engine used for load balancing.2060*2061* Setting the number of engines bound to the context to 0, by passing a zero2062* sized argument, will revert back to default settings.2063*2064* See struct i915_context_param_engines.2065*2066* Extensions:2067* i915_context_engines_load_balance (I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE)2068* i915_context_engines_bond (I915_CONTEXT_ENGINES_EXT_BOND)2069* i915_context_engines_parallel_submit (I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT)2070*/2071#define I915_CONTEXT_PARAM_ENGINES 0xa20722073/*2074* I915_CONTEXT_PARAM_PERSISTENCE:2075*2076* Allow the context and active rendering to survive the process until2077* completion. Persistence allows fire-and-forget clients to queue up a2078* bunch of work, hand the output over to a display server and then quit.2079* If the context is marked as not persistent, upon closing (either via2080* an explicit DRM_I915_GEM_CONTEXT_DESTROY or implicitly from file closure2081* or process termination), the context and any outstanding requests will be2082* cancelled (and exported fences for cancelled requests marked as -EIO).2083*2084* By default, new contexts allow persistence.2085*/2086#define I915_CONTEXT_PARAM_PERSISTENCE 0xb20872088/* This API has been removed. On the off chance someone somewhere has2089* attempted to use it, never re-use this context param number.2090*/2091#define I915_CONTEXT_PARAM_RINGSIZE 0xc20922093/*2094* I915_CONTEXT_PARAM_PROTECTED_CONTENT:2095*2096* Mark that the context makes use of protected content, which will result2097* in the context being invalidated when the protected content session is.2098* Given that the protected content session is killed on suspend, the device2099* is kept awake for the lifetime of a protected context, so the user should2100* make sure to dispose of them once done.2101* This flag can only be set at context creation time and, when set to true,2102* must be preceded by an explicit setting of I915_CONTEXT_PARAM_RECOVERABLE2103* to false. This flag can't be set to true in conjunction with setting the2104* I915_CONTEXT_PARAM_BANNABLE flag to false. Creation example:2105*2106* .. code-block:: C2107*2108* struct drm_i915_gem_context_create_ext_setparam p_protected = {2109* .base = {2110* .name = I915_CONTEXT_CREATE_EXT_SETPARAM,2111* },2112* .param = {2113* .param = I915_CONTEXT_PARAM_PROTECTED_CONTENT,2114* .value = 1,2115* }2116* };2117* struct drm_i915_gem_context_create_ext_setparam p_norecover = {2118* .base = {2119* .name = I915_CONTEXT_CREATE_EXT_SETPARAM,2120* .next_extension = to_user_pointer(&p_protected),2121* },2122* .param = {2123* .param = I915_CONTEXT_PARAM_RECOVERABLE,2124* .value = 0,2125* }2126* };2127* struct drm_i915_gem_context_create_ext create = {2128* .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,2129* .extensions = to_user_pointer(&p_norecover);2130* };2131*2132* ctx_id = gem_context_create_ext(drm_fd, &create);2133*2134* In addition to the normal failure cases, setting this flag during context2135* creation can result in the following errors:2136*2137* -ENODEV: feature not available2138* -EPERM: trying to mark a recoverable or not bannable context as protected2139* -ENXIO: A dependency such as a component driver or firmware is not yet2140* loaded so user space may need to attempt again. Depending on the2141* device, this error may be reported if protected context creation is2142* attempted very early after kernel start because the internal timeout2143* waiting for such dependencies is not guaranteed to be larger than2144* required (numbers differ depending on system and kernel config):2145* - ADL/RPL: dependencies may take up to 3 seconds from kernel start2146* while context creation internal timeout is 250 milisecs2147* - MTL: dependencies may take up to 8 seconds from kernel start2148* while context creation internal timeout is 250 milisecs2149* NOTE: such dependencies happen once, so a subsequent call to create a2150* protected context after a prior successful call will not experience2151* such timeouts and will not return -ENXIO (unless the driver is reloaded,2152* or, depending on the device, resumes from a suspended state).2153* -EIO: The firmware did not succeed in creating the protected context.2154*/2155#define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd21562157/*2158* I915_CONTEXT_PARAM_LOW_LATENCY:2159*2160* Mark this context as a low latency workload which requires aggressive GT2161* frequency scaling. Use I915_PARAM_HAS_CONTEXT_FREQ_HINT to check if the kernel2162* supports this per context flag.2163*/2164#define I915_CONTEXT_PARAM_LOW_LATENCY 0xe21652166/*2167* I915_CONTEXT_PARAM_CONTEXT_IMAGE:2168*2169* Allows userspace to provide own context images.2170*2171* Note that this is a debug API not available on production kernel builds.2172*/2173#define I915_CONTEXT_PARAM_CONTEXT_IMAGE 0xf2174/* Must be kept compact -- no holes and well documented */21752176/** @value: Context parameter value to be set or queried */2177__u64 value;2178};21792180/*2181* Context SSEU programming2182*2183* It may be necessary for either functional or performance reason to configure2184* a context to run with a reduced number of SSEU (where SSEU stands for Slice/2185* Sub-slice/EU).2186*2187* This is done by configuring SSEU configuration using the below2188* @struct drm_i915_gem_context_param_sseu for every supported engine which2189* userspace intends to use.2190*2191* Not all GPUs or engines support this functionality in which case an error2192* code -ENODEV will be returned.2193*2194* Also, flexibility of possible SSEU configuration permutations varies between2195* GPU generations and software imposed limitations. Requesting such a2196* combination will return an error code of -EINVAL.2197*2198* NOTE: When perf/OA is active the context's SSEU configuration is ignored in2199* favour of a single global setting.2200*/2201struct drm_i915_gem_context_param_sseu {2202/*2203* Engine class & instance to be configured or queried.2204*/2205struct i915_engine_class_instance engine;22062207/*2208* Unknown flags must be cleared to zero.2209*/2210__u32 flags;2211#define I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX (1u << 0)22122213/*2214* Mask of slices to enable for the context. Valid values are a subset2215* of the bitmask value returned for I915_PARAM_SLICE_MASK.2216*/2217__u64 slice_mask;22182219/*2220* Mask of subslices to enable for the context. Valid values are a2221* subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK.2222*/2223__u64 subslice_mask;22242225/*2226* Minimum/Maximum number of EUs to enable per subslice for the2227* context. min_eus_per_subslice must be inferior or equal to2228* max_eus_per_subslice.2229*/2230__u16 min_eus_per_subslice;2231__u16 max_eus_per_subslice;22322233/*2234* Unused for now. Must be cleared to zero.2235*/2236__u32 rsvd;2237};22382239/**2240* DOC: Virtual Engine uAPI2241*2242* Virtual engine is a concept where userspace is able to configure a set of2243* physical engines, submit a batch buffer, and let the driver execute it on any2244* engine from the set as it sees fit.2245*2246* This is primarily useful on parts which have multiple instances of a same2247* class engine, like for example GT3+ Skylake parts with their two VCS engines.2248*2249* For instance userspace can enumerate all engines of a certain class using the2250* previously described `Engine Discovery uAPI`_. After that userspace can2251* create a GEM context with a placeholder slot for the virtual engine (using2252* `I915_ENGINE_CLASS_INVALID` and `I915_ENGINE_CLASS_INVALID_NONE` for class2253* and instance respectively) and finally using the2254* `I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE` extension place a virtual engine in2255* the same reserved slot.2256*2257* Example of creating a virtual engine and submitting a batch buffer to it:2258*2259* .. code-block:: C2260*2261* I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(virtual, 2) = {2262* .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE,2263* .engine_index = 0, // Place this virtual engine into engine map slot 02264* .num_siblings = 2,2265* .engines = { { I915_ENGINE_CLASS_VIDEO, 0 },2266* { I915_ENGINE_CLASS_VIDEO, 1 }, },2267* };2268* I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = {2269* .engines = { { I915_ENGINE_CLASS_INVALID,2270* I915_ENGINE_CLASS_INVALID_NONE } },2271* .extensions = to_user_pointer(&virtual), // Chains after load_balance extension2272* };2273* struct drm_i915_gem_context_create_ext_setparam p_engines = {2274* .base = {2275* .name = I915_CONTEXT_CREATE_EXT_SETPARAM,2276* },2277* .param = {2278* .param = I915_CONTEXT_PARAM_ENGINES,2279* .value = to_user_pointer(&engines),2280* .size = sizeof(engines),2281* },2282* };2283* struct drm_i915_gem_context_create_ext create = {2284* .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,2285* .extensions = to_user_pointer(&p_engines);2286* };2287*2288* ctx_id = gem_context_create_ext(drm_fd, &create);2289*2290* // Now we have created a GEM context with its engine map containing a2291* // single virtual engine. Submissions to this slot can go either to2292* // vcs0 or vcs1, depending on the load balancing algorithm used inside2293* // the driver. The load balancing is dynamic from one batch buffer to2294* // another and transparent to userspace.2295*2296* ...2297* execbuf.rsvd1 = ctx_id;2298* execbuf.flags = 0; // Submits to index 0 which is the virtual engine2299* gem_execbuf(drm_fd, &execbuf);2300*/23012302/*2303* i915_context_engines_load_balance:2304*2305* Enable load balancing across this set of engines.2306*2307* Into the I915_EXEC_DEFAULT slot [0], a virtual engine is created that when2308* used will proxy the execbuffer request onto one of the set of engines2309* in such a way as to distribute the load evenly across the set.2310*2311* The set of engines must be compatible (e.g. the same HW class) as they2312* will share the same logical GPU context and ring.2313*2314* To intermix rendering with the virtual engine and direct rendering onto2315* the backing engines (bypassing the load balancing proxy), the context must2316* be defined to use a single timeline for all engines.2317*/2318struct i915_context_engines_load_balance {2319struct i915_user_extension base;23202321__u16 engine_index;2322__u16 num_siblings;2323__u32 flags; /* all undefined flags must be zero */23242325__u64 mbz64; /* reserved for future use; must be zero */23262327struct i915_engine_class_instance engines[];2328} __attribute__((packed));23292330#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \2331struct i915_user_extension base; \2332__u16 engine_index; \2333__u16 num_siblings; \2334__u32 flags; \2335__u64 mbz64; \2336struct i915_engine_class_instance engines[N__]; \2337} __attribute__((packed)) name__23382339/*2340* i915_context_engines_bond:2341*2342* Constructed bonded pairs for execution within a virtual engine.2343*2344* All engines are equal, but some are more equal than others. Given2345* the distribution of resources in the HW, it may be preferable to run2346* a request on a given subset of engines in parallel to a request on a2347* specific engine. We enable this selection of engines within a virtual2348* engine by specifying bonding pairs, for any given master engine we will2349* only execute on one of the corresponding siblings within the virtual engine.2350*2351* To execute a request in parallel on the master engine and a sibling requires2352* coordination with a I915_EXEC_FENCE_SUBMIT.2353*/2354struct i915_context_engines_bond {2355struct i915_user_extension base;23562357struct i915_engine_class_instance master;23582359__u16 virtual_index; /* index of virtual engine in ctx->engines[] */2360__u16 num_bonds;23612362__u64 flags; /* all undefined flags must be zero */2363__u64 mbz64[4]; /* reserved for future use; must be zero */23642365struct i915_engine_class_instance engines[];2366} __attribute__((packed));23672368#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \2369struct i915_user_extension base; \2370struct i915_engine_class_instance master; \2371__u16 virtual_index; \2372__u16 num_bonds; \2373__u64 flags; \2374__u64 mbz64[4]; \2375struct i915_engine_class_instance engines[N__]; \2376} __attribute__((packed)) name__23772378/**2379* struct i915_context_engines_parallel_submit - Configure engine for2380* parallel submission.2381*2382* Setup a slot in the context engine map to allow multiple BBs to be submitted2383* in a single execbuf IOCTL. Those BBs will then be scheduled to run on the GPU2384* in parallel. Multiple hardware contexts are created internally in the i915 to2385* run these BBs. Once a slot is configured for N BBs only N BBs can be2386* submitted in each execbuf IOCTL and this is implicit behavior e.g. The user2387* doesn't tell the execbuf IOCTL there are N BBs, the execbuf IOCTL knows how2388* many BBs there are based on the slot's configuration. The N BBs are the last2389* N buffer objects or first N if I915_EXEC_BATCH_FIRST is set.2390*2391* The default placement behavior is to create implicit bonds between each2392* context if each context maps to more than 1 physical engine (e.g. context is2393* a virtual engine). Also we only allow contexts of same engine class and these2394* contexts must be in logically contiguous order. Examples of the placement2395* behavior are described below. Lastly, the default is to not allow BBs to be2396* preempted mid-batch. Rather insert coordinated preemption points on all2397* hardware contexts between each set of BBs. Flags could be added in the future2398* to change both of these default behaviors.2399*2400* Returns -EINVAL if hardware context placement configuration is invalid or if2401* the placement configuration isn't supported on the platform / submission2402* interface.2403* Returns -ENODEV if extension isn't supported on the platform / submission2404* interface.2405*2406* .. code-block:: none2407*2408* Examples syntax:2409* CS[X] = generic engine of same class, logical instance X2410* INVALID = I915_ENGINE_CLASS_INVALID, I915_ENGINE_CLASS_INVALID_NONE2411*2412* Example 1 pseudo code:2413* set_engines(INVALID)2414* set_parallel(engine_index=0, width=2, num_siblings=1,2415* engines=CS[0],CS[1])2416*2417* Results in the following valid placement:2418* CS[0], CS[1]2419*2420* Example 2 pseudo code:2421* set_engines(INVALID)2422* set_parallel(engine_index=0, width=2, num_siblings=2,2423* engines=CS[0],CS[2],CS[1],CS[3])2424*2425* Results in the following valid placements:2426* CS[0], CS[1]2427* CS[2], CS[3]2428*2429* This can be thought of as two virtual engines, each containing two2430* engines thereby making a 2D array. However, there are bonds tying the2431* entries together and placing restrictions on how they can be scheduled.2432* Specifically, the scheduler can choose only vertical columns from the 2D2433* array. That is, CS[0] is bonded to CS[1] and CS[2] to CS[3]. So if the2434* scheduler wants to submit to CS[0], it must also choose CS[1] and vice2435* versa. Same for CS[2] requires also using CS[3].2436* VE[0] = CS[0], CS[2]2437* VE[1] = CS[1], CS[3]2438*2439* Example 3 pseudo code:2440* set_engines(INVALID)2441* set_parallel(engine_index=0, width=2, num_siblings=2,2442* engines=CS[0],CS[1],CS[1],CS[3])2443*2444* Results in the following valid and invalid placements:2445* CS[0], CS[1]2446* CS[1], CS[3] - Not logically contiguous, return -EINVAL2447*/2448struct i915_context_engines_parallel_submit {2449/**2450* @base: base user extension.2451*/2452struct i915_user_extension base;24532454/**2455* @engine_index: slot for parallel engine2456*/2457__u16 engine_index;24582459/**2460* @width: number of contexts per parallel engine or in other words the2461* number of batches in each submission2462*/2463__u16 width;24642465/**2466* @num_siblings: number of siblings per context or in other words the2467* number of possible placements for each submission2468*/2469__u16 num_siblings;24702471/**2472* @mbz16: reserved for future use; must be zero2473*/2474__u16 mbz16;24752476/**2477* @flags: all undefined flags must be zero, currently not defined flags2478*/2479__u64 flags;24802481/**2482* @mbz64: reserved for future use; must be zero2483*/2484__u64 mbz64[3];24852486/**2487* @engines: 2-d array of engine instances to configure parallel engine2488*2489* length = width (i) * num_siblings (j)2490* index = j + i * num_siblings2491*/2492struct i915_engine_class_instance engines[];24932494} __packed;24952496#define I915_DEFINE_CONTEXT_ENGINES_PARALLEL_SUBMIT(name__, N__) struct { \2497struct i915_user_extension base; \2498__u16 engine_index; \2499__u16 width; \2500__u16 num_siblings; \2501__u16 mbz16; \2502__u64 flags; \2503__u64 mbz64[3]; \2504struct i915_engine_class_instance engines[N__]; \2505} __attribute__((packed)) name__25062507/**2508* DOC: Context Engine Map uAPI2509*2510* Context engine map is a new way of addressing engines when submitting batch-2511* buffers, replacing the existing way of using identifiers like `I915_EXEC_BLT`2512* inside the flags field of `struct drm_i915_gem_execbuffer2`.2513*2514* To use it created GEM contexts need to be configured with a list of engines2515* the user is intending to submit to. This is accomplished using the2516* `I915_CONTEXT_PARAM_ENGINES` parameter and `struct2517* i915_context_param_engines`.2518*2519* For such contexts the `I915_EXEC_RING_MASK` field becomes an index into the2520* configured map.2521*2522* Example of creating such context and submitting against it:2523*2524* .. code-block:: C2525*2526* I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 2) = {2527* .engines = { { I915_ENGINE_CLASS_RENDER, 0 },2528* { I915_ENGINE_CLASS_COPY, 0 } }2529* };2530* struct drm_i915_gem_context_create_ext_setparam p_engines = {2531* .base = {2532* .name = I915_CONTEXT_CREATE_EXT_SETPARAM,2533* },2534* .param = {2535* .param = I915_CONTEXT_PARAM_ENGINES,2536* .value = to_user_pointer(&engines),2537* .size = sizeof(engines),2538* },2539* };2540* struct drm_i915_gem_context_create_ext create = {2541* .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,2542* .extensions = to_user_pointer(&p_engines);2543* };2544*2545* ctx_id = gem_context_create_ext(drm_fd, &create);2546*2547* // We have now created a GEM context with two engines in the map:2548* // Index 0 points to rcs0 while index 1 points to bcs0. Other engines2549* // will not be accessible from this context.2550*2551* ...2552* execbuf.rsvd1 = ctx_id;2553* execbuf.flags = 0; // Submits to index 0, which is rcs0 for this context2554* gem_execbuf(drm_fd, &execbuf);2555*2556* ...2557* execbuf.rsvd1 = ctx_id;2558* execbuf.flags = 1; // Submits to index 0, which is bcs0 for this context2559* gem_execbuf(drm_fd, &execbuf);2560*/25612562struct i915_context_param_engines {2563__u64 extensions; /* linked chain of extension blocks, 0 terminates */2564#define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */2565#define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */2566#define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */2567struct i915_engine_class_instance engines[];2568} __attribute__((packed));25692570#define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \2571__u64 extensions; \2572struct i915_engine_class_instance engines[N__]; \2573} __attribute__((packed)) name__25742575struct i915_gem_context_param_context_image {2576/** @engine: Engine class & instance to be configured. */2577struct i915_engine_class_instance engine;25782579/** @flags: One of the supported flags or zero. */2580__u32 flags;2581#define I915_CONTEXT_IMAGE_FLAG_ENGINE_INDEX (1u << 0)25822583/** @size: Size of the image blob pointed to by @image. */2584__u32 size;25852586/** @mbz: Must be zero. */2587__u32 mbz;25882589/** @image: Userspace memory containing the context image. */2590__u64 image;2591} __attribute__((packed));25922593/**2594* struct drm_i915_gem_context_create_ext_setparam - Context parameter2595* to set or query during context creation.2596*/2597struct drm_i915_gem_context_create_ext_setparam {2598/** @base: Extension link. See struct i915_user_extension. */2599struct i915_user_extension base;26002601/**2602* @param: Context parameter to set or query.2603* See struct drm_i915_gem_context_param.2604*/2605struct drm_i915_gem_context_param param;2606};26072608struct drm_i915_gem_context_destroy {2609__u32 ctx_id;2610__u32 pad;2611};26122613/**2614* struct drm_i915_gem_vm_control - Structure to create or destroy VM.2615*2616* DRM_I915_GEM_VM_CREATE -2617*2618* Create a new virtual memory address space (ppGTT) for use within a context2619* on the same file. Extensions can be provided to configure exactly how the2620* address space is setup upon creation.2621*2622* The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is2623* returned in the outparam @id.2624*2625* An extension chain maybe provided, starting with @extensions, and terminated2626* by the @next_extension being 0. Currently, no extensions are defined.2627*2628* DRM_I915_GEM_VM_DESTROY -2629*2630* Destroys a previously created VM id, specified in @vm_id.2631*2632* No extensions or flags are allowed currently, and so must be zero.2633*/2634struct drm_i915_gem_vm_control {2635/** @extensions: Zero-terminated chain of extensions. */2636__u64 extensions;26372638/** @flags: reserved for future usage, currently MBZ */2639__u32 flags;26402641/** @vm_id: Id of the VM created or to be destroyed */2642__u32 vm_id;2643};26442645struct drm_i915_reg_read {2646/*2647* Register offset.2648* For 64bit wide registers where the upper 32bits don't immediately2649* follow the lower 32bits, the offset of the lower 32bits must2650* be specified2651*/2652__u64 offset;2653#define I915_REG_READ_8B_WA (1ul << 0)26542655__u64 val; /* Return value */2656};26572658/* Known registers:2659*2660* Render engine timestamp - 0x2358 + 64bit - gen7+2661* - Note this register returns an invalid value if using the default2662* single instruction 8byte read, in order to workaround that pass2663* flag I915_REG_READ_8B_WA in offset field.2664*2665*/26662667/*2668* struct drm_i915_reset_stats - Return global reset and other context stats2669*2670* Driver keeps few stats for each contexts and also global reset count.2671* This struct can be used to query those stats.2672*/2673struct drm_i915_reset_stats {2674/** @ctx_id: ID of the requested context */2675__u32 ctx_id;26762677/** @flags: MBZ */2678__u32 flags;26792680/** @reset_count: All resets since boot/module reload, for all contexts */2681__u32 reset_count;26822683/** @batch_active: Number of batches lost when active in GPU, for this context */2684__u32 batch_active;26852686/** @batch_pending: Number of batches lost pending for execution, for this context */2687__u32 batch_pending;26882689/** @pad: MBZ */2690__u32 pad;2691};26922693/**2694* struct drm_i915_gem_userptr - Create GEM object from user allocated memory.2695*2696* Userptr objects have several restrictions on what ioctls can be used with the2697* object handle.2698*/2699struct drm_i915_gem_userptr {2700/**2701* @user_ptr: The pointer to the allocated memory.2702*2703* Needs to be aligned to PAGE_SIZE.2704*/2705__u64 user_ptr;27062707/**2708* @user_size:2709*2710* The size in bytes for the allocated memory. This will also become the2711* object size.2712*2713* Needs to be aligned to PAGE_SIZE, and should be at least PAGE_SIZE,2714* or larger.2715*/2716__u64 user_size;27172718/**2719* @flags:2720*2721* Supported flags:2722*2723* I915_USERPTR_READ_ONLY:2724*2725* Mark the object as readonly, this also means GPU access can only be2726* readonly. This is only supported on HW which supports readonly access2727* through the GTT. If the HW can't support readonly access, an error is2728* returned.2729*2730* I915_USERPTR_PROBE:2731*2732* Probe the provided @user_ptr range and validate that the @user_ptr is2733* indeed pointing to normal memory and that the range is also valid.2734* For example if some garbage address is given to the kernel, then this2735* should complain.2736*2737* Returns -EFAULT if the probe failed.2738*2739* Note that this doesn't populate the backing pages, and also doesn't2740* guarantee that the object will remain valid when the object is2741* eventually used.2742*2743* The kernel supports this feature if I915_PARAM_HAS_USERPTR_PROBE2744* returns a non-zero value.2745*2746* I915_USERPTR_UNSYNCHRONIZED:2747*2748* NOT USED. Setting this flag will result in an error.2749*/2750__u32 flags;2751#define I915_USERPTR_READ_ONLY 0x12752#define I915_USERPTR_PROBE 0x22753#define I915_USERPTR_UNSYNCHRONIZED 0x800000002754/**2755* @handle: Returned handle for the object.2756*2757* Object handles are nonzero.2758*/2759__u32 handle;2760};27612762enum drm_i915_oa_format {2763I915_OA_FORMAT_A13 = 1, /* HSW only */2764I915_OA_FORMAT_A29, /* HSW only */2765I915_OA_FORMAT_A13_B8_C8, /* HSW only */2766I915_OA_FORMAT_B4_C8, /* HSW only */2767I915_OA_FORMAT_A45_B8_C8, /* HSW only */2768I915_OA_FORMAT_B4_C8_A16, /* HSW only */2769I915_OA_FORMAT_C4_B8, /* HSW+ */27702771/* Gen8+ */2772I915_OA_FORMAT_A12,2773I915_OA_FORMAT_A12_B8_C8,2774I915_OA_FORMAT_A32u40_A4u32_B8_C8,27752776/* DG2 */2777I915_OAR_FORMAT_A32u40_A4u32_B8_C8,2778I915_OA_FORMAT_A24u40_A14u32_B8_C8,27792780/* MTL OAM */2781I915_OAM_FORMAT_MPEC8u64_B8_C8,2782I915_OAM_FORMAT_MPEC8u32_B8_C8,27832784I915_OA_FORMAT_MAX /* non-ABI */2785};27862787enum drm_i915_perf_property_id {2788/**2789* Open the stream for a specific context handle (as used with2790* execbuffer2). A stream opened for a specific context this way2791* won't typically require root privileges.2792*2793* This property is available in perf revision 1.2794*/2795DRM_I915_PERF_PROP_CTX_HANDLE = 1,27962797/**2798* A value of 1 requests the inclusion of raw OA unit reports as2799* part of stream samples.2800*2801* This property is available in perf revision 1.2802*/2803DRM_I915_PERF_PROP_SAMPLE_OA,28042805/**2806* The value specifies which set of OA unit metrics should be2807* configured, defining the contents of any OA unit reports.2808*2809* This property is available in perf revision 1.2810*/2811DRM_I915_PERF_PROP_OA_METRICS_SET,28122813/**2814* The value specifies the size and layout of OA unit reports.2815*2816* This property is available in perf revision 1.2817*/2818DRM_I915_PERF_PROP_OA_FORMAT,28192820/**2821* Specifying this property implicitly requests periodic OA unit2822* sampling and (at least on Haswell) the sampling frequency is derived2823* from this exponent as follows:2824*2825* 80ns * 2^(period_exponent + 1)2826*2827* This property is available in perf revision 1.2828*/2829DRM_I915_PERF_PROP_OA_EXPONENT,28302831/**2832* Specifying this property is only valid when specify a context to2833* filter with DRM_I915_PERF_PROP_CTX_HANDLE. Specifying this property2834* will hold preemption of the particular context we want to gather2835* performance data about. The execbuf2 submissions must include a2836* drm_i915_gem_execbuffer_ext_perf parameter for this to apply.2837*2838* This property is available in perf revision 3.2839*/2840DRM_I915_PERF_PROP_HOLD_PREEMPTION,28412842/**2843* Specifying this pins all contexts to the specified SSEU power2844* configuration for the duration of the recording.2845*2846* This parameter's value is a pointer to a struct2847* drm_i915_gem_context_param_sseu.2848*2849* This property is available in perf revision 4.2850*/2851DRM_I915_PERF_PROP_GLOBAL_SSEU,28522853/**2854* This optional parameter specifies the timer interval in nanoseconds2855* at which the i915 driver will check the OA buffer for available data.2856* Minimum allowed value is 100 microseconds. A default value is used by2857* the driver if this parameter is not specified. Note that larger timer2858* values will reduce cpu consumption during OA perf captures. However,2859* excessively large values would potentially result in OA buffer2860* overwrites as captures reach end of the OA buffer.2861*2862* This property is available in perf revision 5.2863*/2864DRM_I915_PERF_PROP_POLL_OA_PERIOD,28652866/**2867* Multiple engines may be mapped to the same OA unit. The OA unit is2868* identified by class:instance of any engine mapped to it.2869*2870* This parameter specifies the engine class and must be passed along2871* with DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE.2872*2873* This property is available in perf revision 6.2874*/2875DRM_I915_PERF_PROP_OA_ENGINE_CLASS,28762877/**2878* This parameter specifies the engine instance and must be passed along2879* with DRM_I915_PERF_PROP_OA_ENGINE_CLASS.2880*2881* This property is available in perf revision 6.2882*/2883DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE,28842885DRM_I915_PERF_PROP_MAX /* non-ABI */2886};28872888struct drm_i915_perf_open_param {2889__u32 flags;2890#define I915_PERF_FLAG_FD_CLOEXEC (1<<0)2891#define I915_PERF_FLAG_FD_NONBLOCK (1<<1)2892#define I915_PERF_FLAG_DISABLED (1<<2)28932894/** The number of u64 (id, value) pairs */2895__u32 num_properties;28962897/**2898* Pointer to array of u64 (id, value) pairs configuring the stream2899* to open.2900*/2901__u64 properties_ptr;2902};29032904/*2905* Enable data capture for a stream that was either opened in a disabled state2906* via I915_PERF_FLAG_DISABLED or was later disabled via2907* I915_PERF_IOCTL_DISABLE.2908*2909* It is intended to be cheaper to disable and enable a stream than it may be2910* to close and re-open a stream with the same configuration.2911*2912* It's undefined whether any pending data for the stream will be lost.2913*2914* This ioctl is available in perf revision 1.2915*/2916#define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)29172918/*2919* Disable data capture for a stream.2920*2921* It is an error to try and read a stream that is disabled.2922*2923* This ioctl is available in perf revision 1.2924*/2925#define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)29262927/*2928* Change metrics_set captured by a stream.2929*2930* If the stream is bound to a specific context, the configuration change2931* will performed inline with that context such that it takes effect before2932* the next execbuf submission.2933*2934* Returns the previously bound metrics set id, or a negative error code.2935*2936* This ioctl is available in perf revision 2.2937*/2938#define I915_PERF_IOCTL_CONFIG _IO('i', 0x2)29392940/*2941* Common to all i915 perf records2942*/2943struct drm_i915_perf_record_header {2944__u32 type;2945__u16 pad;2946__u16 size;2947};29482949enum drm_i915_perf_record_type {29502951/**2952* Samples are the work horse record type whose contents are extensible2953* and defined when opening an i915 perf stream based on the given2954* properties.2955*2956* Boolean properties following the naming convention2957* DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in2958* every sample.2959*2960* The order of these sample properties given by userspace has no2961* affect on the ordering of data within a sample. The order is2962* documented here.2963*2964* struct {2965* struct drm_i915_perf_record_header header;2966*2967* { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA2968* };2969*/2970DRM_I915_PERF_RECORD_SAMPLE = 1,29712972/*2973* Indicates that one or more OA reports were not written by the2974* hardware. This can happen for example if an MI_REPORT_PERF_COUNT2975* command collides with periodic sampling - which would be more likely2976* at higher sampling frequencies.2977*/2978DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,29792980/**2981* An error occurred that resulted in all pending OA reports being lost.2982*/2983DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,29842985DRM_I915_PERF_RECORD_MAX /* non-ABI */2986};29872988/**2989* struct drm_i915_perf_oa_config2990*2991* Structure to upload perf dynamic configuration into the kernel.2992*/2993struct drm_i915_perf_oa_config {2994/**2995* @uuid:2996*2997* String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x"2998*/2999char uuid[36];30003001/**3002* @n_mux_regs:3003*3004* Number of mux regs in &mux_regs_ptr.3005*/3006__u32 n_mux_regs;30073008/**3009* @n_boolean_regs:3010*3011* Number of boolean regs in &boolean_regs_ptr.3012*/3013__u32 n_boolean_regs;30143015/**3016* @n_flex_regs:3017*3018* Number of flex regs in &flex_regs_ptr.3019*/3020__u32 n_flex_regs;30213022/**3023* @mux_regs_ptr:3024*3025* Pointer to tuples of u32 values (register address, value) for mux3026* registers. Expected length of buffer is (2 * sizeof(u32) *3027* &n_mux_regs).3028*/3029__u64 mux_regs_ptr;30303031/**3032* @boolean_regs_ptr:3033*3034* Pointer to tuples of u32 values (register address, value) for mux3035* registers. Expected length of buffer is (2 * sizeof(u32) *3036* &n_boolean_regs).3037*/3038__u64 boolean_regs_ptr;30393040/**3041* @flex_regs_ptr:3042*3043* Pointer to tuples of u32 values (register address, value) for mux3044* registers. Expected length of buffer is (2 * sizeof(u32) *3045* &n_flex_regs).3046*/3047__u64 flex_regs_ptr;3048};30493050/**3051* struct drm_i915_query_item - An individual query for the kernel to process.3052*3053* The behaviour is determined by the @query_id. Note that exactly what3054* @data_ptr is also depends on the specific @query_id.3055*/3056struct drm_i915_query_item {3057/**3058* @query_id:3059*3060* The id for this query. Currently accepted query IDs are:3061* - %DRM_I915_QUERY_TOPOLOGY_INFO (see struct drm_i915_query_topology_info)3062* - %DRM_I915_QUERY_ENGINE_INFO (see struct drm_i915_engine_info)3063* - %DRM_I915_QUERY_PERF_CONFIG (see struct drm_i915_query_perf_config)3064* - %DRM_I915_QUERY_MEMORY_REGIONS (see struct drm_i915_query_memory_regions)3065* - %DRM_I915_QUERY_HWCONFIG_BLOB (see `GuC HWCONFIG blob uAPI`)3066* - %DRM_I915_QUERY_GEOMETRY_SUBSLICES (see struct drm_i915_query_topology_info)3067* - %DRM_I915_QUERY_GUC_SUBMISSION_VERSION (see struct drm_i915_query_guc_submission_version)3068*/3069__u64 query_id;3070#define DRM_I915_QUERY_TOPOLOGY_INFO 13071#define DRM_I915_QUERY_ENGINE_INFO 23072#define DRM_I915_QUERY_PERF_CONFIG 33073#define DRM_I915_QUERY_MEMORY_REGIONS 43074#define DRM_I915_QUERY_HWCONFIG_BLOB 53075#define DRM_I915_QUERY_GEOMETRY_SUBSLICES 63076#define DRM_I915_QUERY_GUC_SUBMISSION_VERSION 73077/* Must be kept compact -- no holes and well documented */30783079/**3080* @length:3081*3082* When set to zero by userspace, this is filled with the size of the3083* data to be written at the @data_ptr pointer. The kernel sets this3084* value to a negative value to signal an error on a particular query3085* item.3086*/3087__s32 length;30883089/**3090* @flags:3091*3092* When &query_id == %DRM_I915_QUERY_TOPOLOGY_INFO, must be 0.3093*3094* When &query_id == %DRM_I915_QUERY_PERF_CONFIG, must be one of the3095* following:3096*3097* - %DRM_I915_QUERY_PERF_CONFIG_LIST3098* - %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID3099* - %DRM_I915_QUERY_PERF_CONFIG_FOR_UUID3100*3101* When &query_id == %DRM_I915_QUERY_GEOMETRY_SUBSLICES must contain3102* a struct i915_engine_class_instance that references a render engine.3103*/3104__u32 flags;3105#define DRM_I915_QUERY_PERF_CONFIG_LIST 13106#define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 23107#define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID 331083109/**3110* @data_ptr:3111*3112* Data will be written at the location pointed by @data_ptr when the3113* value of @length matches the length of the data to be written by the3114* kernel.3115*/3116__u64 data_ptr;3117};31183119/**3120* struct drm_i915_query - Supply an array of struct drm_i915_query_item for the3121* kernel to fill out.3122*3123* Note that this is generally a two step process for each struct3124* drm_i915_query_item in the array:3125*3126* 1. Call the DRM_IOCTL_I915_QUERY, giving it our array of struct3127* drm_i915_query_item, with &drm_i915_query_item.length set to zero. The3128* kernel will then fill in the size, in bytes, which tells userspace how3129* memory it needs to allocate for the blob(say for an array of properties).3130*3131* 2. Next we call DRM_IOCTL_I915_QUERY again, this time with the3132* &drm_i915_query_item.data_ptr equal to our newly allocated blob. Note that3133* the &drm_i915_query_item.length should still be the same as what the3134* kernel previously set. At this point the kernel can fill in the blob.3135*3136* Note that for some query items it can make sense for userspace to just pass3137* in a buffer/blob equal to or larger than the required size. In this case only3138* a single ioctl call is needed. For some smaller query items this can work3139* quite well.3140*3141*/3142struct drm_i915_query {3143/** @num_items: The number of elements in the @items_ptr array */3144__u32 num_items;31453146/**3147* @flags: Unused for now. Must be cleared to zero.3148*/3149__u32 flags;31503151/**3152* @items_ptr:3153*3154* Pointer to an array of struct drm_i915_query_item. The number of3155* array elements is @num_items.3156*/3157__u64 items_ptr;3158};31593160/**3161* struct drm_i915_query_topology_info3162*3163* Describes slice/subslice/EU information queried by3164* %DRM_I915_QUERY_TOPOLOGY_INFO3165*/3166struct drm_i915_query_topology_info {3167/**3168* @flags:3169*3170* Unused for now. Must be cleared to zero.3171*/3172__u16 flags;31733174/**3175* @max_slices:3176*3177* The number of bits used to express the slice mask.3178*/3179__u16 max_slices;31803181/**3182* @max_subslices:3183*3184* The number of bits used to express the subslice mask.3185*/3186__u16 max_subslices;31873188/**3189* @max_eus_per_subslice:3190*3191* The number of bits in the EU mask that correspond to a single3192* subslice's EUs.3193*/3194__u16 max_eus_per_subslice;31953196/**3197* @subslice_offset:3198*3199* Offset in data[] at which the subslice masks are stored.3200*/3201__u16 subslice_offset;32023203/**3204* @subslice_stride:3205*3206* Stride at which each of the subslice masks for each slice are3207* stored.3208*/3209__u16 subslice_stride;32103211/**3212* @eu_offset:3213*3214* Offset in data[] at which the EU masks are stored.3215*/3216__u16 eu_offset;32173218/**3219* @eu_stride:3220*3221* Stride at which each of the EU masks for each subslice are stored.3222*/3223__u16 eu_stride;32243225/**3226* @data:3227*3228* Contains 3 pieces of information :3229*3230* - The slice mask with one bit per slice telling whether a slice is3231* available. The availability of slice X can be queried with the3232* following formula :3233*3234* .. code:: c3235*3236* (data[X / 8] >> (X % 8)) & 13237*3238* Starting with Xe_HP platforms, Intel hardware no longer has3239* traditional slices so i915 will always report a single slice3240* (hardcoded slicemask = 0x1) which contains all of the platform's3241* subslices. I.e., the mask here does not reflect any of the newer3242* hardware concepts such as "gslices" or "cslices" since userspace3243* is capable of inferring those from the subslice mask.3244*3245* - The subslice mask for each slice with one bit per subslice telling3246* whether a subslice is available. Starting with Gen12 we use the3247* term "subslice" to refer to what the hardware documentation3248* describes as a "dual-subslices." The availability of subslice Y3249* in slice X can be queried with the following formula :3250*3251* .. code:: c3252*3253* (data[subslice_offset + X * subslice_stride + Y / 8] >> (Y % 8)) & 13254*3255* - The EU mask for each subslice in each slice, with one bit per EU3256* telling whether an EU is available. The availability of EU Z in3257* subslice Y in slice X can be queried with the following formula :3258*3259* .. code:: c3260*3261* (data[eu_offset +3262* (X * max_subslices + Y) * eu_stride +3263* Z / 83264* ] >> (Z % 8)) & 13265*/3266__u8 data[];3267};32683269/**3270* DOC: Engine Discovery uAPI3271*3272* Engine discovery uAPI is a way of enumerating physical engines present in a3273* GPU associated with an open i915 DRM file descriptor. This supersedes the old3274* way of using `DRM_IOCTL_I915_GETPARAM` and engine identifiers like3275* `I915_PARAM_HAS_BLT`.3276*3277* The need for this interface came starting with Icelake and newer GPUs, which3278* started to establish a pattern of having multiple engines of a same class,3279* where not all instances were always completely functionally equivalent.3280*3281* Entry point for this uapi is `DRM_IOCTL_I915_QUERY` with the3282* `DRM_I915_QUERY_ENGINE_INFO` as the queried item id.3283*3284* Example for getting the list of engines:3285*3286* .. code-block:: C3287*3288* struct drm_i915_query_engine_info *info;3289* struct drm_i915_query_item item = {3290* .query_id = DRM_I915_QUERY_ENGINE_INFO;3291* };3292* struct drm_i915_query query = {3293* .num_items = 1,3294* .items_ptr = (uintptr_t)&item,3295* };3296* int err, i;3297*3298* // First query the size of the blob we need, this needs to be large3299* // enough to hold our array of engines. The kernel will fill out the3300* // item.length for us, which is the number of bytes we need.3301* //3302* // Alternatively a large buffer can be allocated straightaway enabling3303* // querying in one pass, in which case item.length should contain the3304* // length of the provided buffer.3305* err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);3306* if (err) ...3307*3308* info = calloc(1, item.length);3309* // Now that we allocated the required number of bytes, we call the ioctl3310* // again, this time with the data_ptr pointing to our newly allocated3311* // blob, which the kernel can then populate with info on all engines.3312* item.data_ptr = (uintptr_t)&info;3313*3314* err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);3315* if (err) ...3316*3317* // We can now access each engine in the array3318* for (i = 0; i < info->num_engines; i++) {3319* struct drm_i915_engine_info einfo = info->engines[i];3320* u16 class = einfo.engine.class;3321* u16 instance = einfo.engine.instance;3322* ....3323* }3324*3325* free(info);3326*3327* Each of the enumerated engines, apart from being defined by its class and3328* instance (see `struct i915_engine_class_instance`), also can have flags and3329* capabilities defined as documented in i915_drm.h.3330*3331* For instance video engines which support HEVC encoding will have the3332* `I915_VIDEO_CLASS_CAPABILITY_HEVC` capability bit set.3333*3334* Engine discovery only fully comes to its own when combined with the new way3335* of addressing engines when submitting batch buffers using contexts with3336* engine maps configured.3337*/33383339/**3340* struct drm_i915_engine_info3341*3342* Describes one engine and its capabilities as known to the driver.3343*/3344struct drm_i915_engine_info {3345/** @engine: Engine class and instance. */3346struct i915_engine_class_instance engine;33473348/** @rsvd0: Reserved field. */3349__u32 rsvd0;33503351/** @flags: Engine flags. */3352__u64 flags;3353#define I915_ENGINE_INFO_HAS_LOGICAL_INSTANCE (1 << 0)33543355/** @capabilities: Capabilities of this engine. */3356__u64 capabilities;3357#define I915_VIDEO_CLASS_CAPABILITY_HEVC (1 << 0)3358#define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC (1 << 1)33593360/** @logical_instance: Logical instance of engine */3361__u16 logical_instance;33623363/** @rsvd1: Reserved fields. */3364__u16 rsvd1[3];3365/** @rsvd2: Reserved fields. */3366__u64 rsvd2[3];3367};33683369/**3370* struct drm_i915_query_engine_info3371*3372* Engine info query enumerates all engines known to the driver by filling in3373* an array of struct drm_i915_engine_info structures.3374*/3375struct drm_i915_query_engine_info {3376/** @num_engines: Number of struct drm_i915_engine_info structs following. */3377__u32 num_engines;33783379/** @rsvd: MBZ */3380__u32 rsvd[3];33813382/** @engines: Marker for drm_i915_engine_info structures. */3383struct drm_i915_engine_info engines[];3384};33853386/**3387* struct drm_i915_query_perf_config3388*3389* Data written by the kernel with query %DRM_I915_QUERY_PERF_CONFIG and3390* %DRM_I915_QUERY_GEOMETRY_SUBSLICES.3391*/3392struct drm_i915_query_perf_config {3393union {3394/**3395* @n_configs:3396*3397* When &drm_i915_query_item.flags ==3398* %DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets this fields to3399* the number of configurations available.3400*/3401__u64 n_configs;34023403/**3404* @config:3405*3406* When &drm_i915_query_item.flags ==3407* %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID, i915 will use the3408* value in this field as configuration identifier to decide3409* what data to write into config_ptr.3410*/3411__u64 config;34123413/**3414* @uuid:3415*3416* When &drm_i915_query_item.flags ==3417* %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID, i915 will use the3418* value in this field as configuration identifier to decide3419* what data to write into config_ptr.3420*3421* String formatted like "%08x-%04x-%04x-%04x-%012x"3422*/3423char uuid[36];3424};34253426/**3427* @flags:3428*3429* Unused for now. Must be cleared to zero.3430*/3431__u32 flags;34323433/**3434* @data:3435*3436* When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_LIST,3437* i915 will write an array of __u64 of configuration identifiers.3438*3439* When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_DATA,3440* i915 will write a struct drm_i915_perf_oa_config. If the following3441* fields of struct drm_i915_perf_oa_config are not set to 0, i915 will3442* write into the associated pointers the values of submitted when the3443* configuration was created :3444*3445* - &drm_i915_perf_oa_config.n_mux_regs3446* - &drm_i915_perf_oa_config.n_boolean_regs3447* - &drm_i915_perf_oa_config.n_flex_regs3448*/3449__u8 data[];3450};34513452/**3453* enum drm_i915_gem_memory_class - Supported memory classes3454*/3455enum drm_i915_gem_memory_class {3456/** @I915_MEMORY_CLASS_SYSTEM: System memory */3457I915_MEMORY_CLASS_SYSTEM = 0,3458/** @I915_MEMORY_CLASS_DEVICE: Device local-memory */3459I915_MEMORY_CLASS_DEVICE,3460};34613462/**3463* struct drm_i915_gem_memory_class_instance - Identify particular memory region3464*/3465struct drm_i915_gem_memory_class_instance {3466/** @memory_class: See enum drm_i915_gem_memory_class */3467__u16 memory_class;34683469/** @memory_instance: Which instance */3470__u16 memory_instance;3471};34723473/**3474* struct drm_i915_memory_region_info - Describes one region as known to the3475* driver.3476*3477* Note this is using both struct drm_i915_query_item and struct drm_i915_query.3478* For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS3479* at &drm_i915_query_item.query_id.3480*/3481struct drm_i915_memory_region_info {3482/** @region: The class:instance pair encoding */3483struct drm_i915_gem_memory_class_instance region;34843485/** @rsvd0: MBZ */3486__u32 rsvd0;34873488/**3489* @probed_size: Memory probed by the driver3490*3491* Note that it should not be possible to ever encounter a zero value3492* here, also note that no current region type will ever return -1 here.3493* Although for future region types, this might be a possibility. The3494* same applies to the other size fields.3495*/3496__u64 probed_size;34973498/**3499* @unallocated_size: Estimate of memory remaining3500*3501* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.3502* Without this (or if this is an older kernel) the value here will3503* always equal the @probed_size. Note this is only currently tracked3504* for I915_MEMORY_CLASS_DEVICE regions (for other types the value here3505* will always equal the @probed_size).3506*/3507__u64 unallocated_size;35083509union {3510/** @rsvd1: MBZ */3511__u64 rsvd1[8];3512struct {3513/**3514* @probed_cpu_visible_size: Memory probed by the driver3515* that is CPU accessible.3516*3517* This will be always be <= @probed_size, and the3518* remainder (if there is any) will not be CPU3519* accessible.3520*3521* On systems without small BAR, the @probed_size will3522* always equal the @probed_cpu_visible_size, since all3523* of it will be CPU accessible.3524*3525* Note this is only tracked for3526* I915_MEMORY_CLASS_DEVICE regions (for other types the3527* value here will always equal the @probed_size).3528*3529* Note that if the value returned here is zero, then3530* this must be an old kernel which lacks the relevant3531* small-bar uAPI support (including3532* I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on3533* such systems we should never actually end up with a3534* small BAR configuration, assuming we are able to load3535* the kernel module. Hence it should be safe to treat3536* this the same as when @probed_cpu_visible_size ==3537* @probed_size.3538*/3539__u64 probed_cpu_visible_size;35403541/**3542* @unallocated_cpu_visible_size: Estimate of CPU3543* visible memory remaining.3544*3545* Note this is only tracked for3546* I915_MEMORY_CLASS_DEVICE regions (for other types the3547* value here will always equal the3548* @probed_cpu_visible_size).3549*3550* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable3551* accounting. Without this the value here will always3552* equal the @probed_cpu_visible_size. Note this is only3553* currently tracked for I915_MEMORY_CLASS_DEVICE3554* regions (for other types the value here will also3555* always equal the @probed_cpu_visible_size).3556*3557* If this is an older kernel the value here will be3558* zero, see also @probed_cpu_visible_size.3559*/3560__u64 unallocated_cpu_visible_size;3561};3562};3563};35643565/**3566* struct drm_i915_query_memory_regions3567*3568* The region info query enumerates all regions known to the driver by filling3569* in an array of struct drm_i915_memory_region_info structures.3570*3571* Example for getting the list of supported regions:3572*3573* .. code-block:: C3574*3575* struct drm_i915_query_memory_regions *info;3576* struct drm_i915_query_item item = {3577* .query_id = DRM_I915_QUERY_MEMORY_REGIONS;3578* };3579* struct drm_i915_query query = {3580* .num_items = 1,3581* .items_ptr = (uintptr_t)&item,3582* };3583* int err, i;3584*3585* // First query the size of the blob we need, this needs to be large3586* // enough to hold our array of regions. The kernel will fill out the3587* // item.length for us, which is the number of bytes we need.3588* err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);3589* if (err) ...3590*3591* info = calloc(1, item.length);3592* // Now that we allocated the required number of bytes, we call the ioctl3593* // again, this time with the data_ptr pointing to our newly allocated3594* // blob, which the kernel can then populate with the all the region info.3595* item.data_ptr = (uintptr_t)&info,3596*3597* err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);3598* if (err) ...3599*3600* // We can now access each region in the array3601* for (i = 0; i < info->num_regions; i++) {3602* struct drm_i915_memory_region_info mr = info->regions[i];3603* u16 class = mr.region.class;3604* u16 instance = mr.region.instance;3605*3606* ....3607* }3608*3609* free(info);3610*/3611struct drm_i915_query_memory_regions {3612/** @num_regions: Number of supported regions */3613__u32 num_regions;36143615/** @rsvd: MBZ */3616__u32 rsvd[3];36173618/** @regions: Info about each supported region */3619struct drm_i915_memory_region_info regions[];3620};36213622/**3623* struct drm_i915_query_guc_submission_version - query GuC submission interface version3624*/3625struct drm_i915_query_guc_submission_version {3626/** @branch: Firmware branch version. */3627__u32 branch;3628/** @major: Firmware major version. */3629__u32 major;3630/** @minor: Firmware minor version. */3631__u32 minor;3632/** @patch: Firmware patch version. */3633__u32 patch;3634};36353636/**3637* DOC: GuC HWCONFIG blob uAPI3638*3639* The GuC produces a blob with information about the current device.3640* i915 reads this blob from GuC and makes it available via this uAPI.3641*3642* The format and meaning of the blob content are documented in the3643* Programmer's Reference Manual.3644*/36453646/**3647* struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added3648* extension support using struct i915_user_extension.3649*3650* Note that new buffer flags should be added here, at least for the stuff that3651* is immutable. Previously we would have two ioctls, one to create the object3652* with gem_create, and another to apply various parameters, however this3653* creates some ambiguity for the params which are considered immutable. Also in3654* general we're phasing out the various SET/GET ioctls.3655*/3656struct drm_i915_gem_create_ext {3657/**3658* @size: Requested size for the object.3659*3660* The (page-aligned) allocated size for the object will be returned.3661*3662* On platforms like DG2/ATS the kernel will always use 64K or larger3663* pages for I915_MEMORY_CLASS_DEVICE. The kernel also requires a3664* minimum of 64K GTT alignment for such objects.3665*3666* NOTE: Previously the ABI here required a minimum GTT alignment of 2M3667* on DG2/ATS, due to how the hardware implemented 64K GTT page support,3668* where we had the following complications:3669*3670* 1) The entire PDE (which covers a 2MB virtual address range), must3671* contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same3672* PDE is forbidden by the hardware.3673*3674* 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM3675* objects.3676*3677* However on actual production HW this was completely changed to now3678* allow setting a TLB hint at the PTE level (see PS64), which is a lot3679* more flexible than the above. With this the 2M restriction was3680* dropped where we now only require 64K.3681*/3682__u64 size;36833684/**3685* @handle: Returned handle for the object.3686*3687* Object handles are nonzero.3688*/3689__u32 handle;36903691/**3692* @flags: Optional flags.3693*3694* Supported values:3695*3696* I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that3697* the object will need to be accessed via the CPU.3698*3699* Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only3700* strictly required on configurations where some subset of the device3701* memory is directly visible/mappable through the CPU (which we also3702* call small BAR), like on some DG2+ systems. Note that this is quite3703* undesirable, but due to various factors like the client CPU, BIOS etc3704* it's something we can expect to see in the wild. See3705* &drm_i915_memory_region_info.probed_cpu_visible_size for how to3706* determine if this system applies.3707*3708* Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to3709* ensure the kernel can always spill the allocation to system memory,3710* if the object can't be allocated in the mappable part of3711* I915_MEMORY_CLASS_DEVICE.3712*3713* Also note that since the kernel only supports flat-CCS on objects3714* that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore3715* don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with3716* flat-CCS.3717*3718* Without this hint, the kernel will assume that non-mappable3719* I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the3720* kernel can still migrate the object to the mappable part, as a last3721* resort, if userspace ever CPU faults this object, but this might be3722* expensive, and so ideally should be avoided.3723*3724* On older kernels which lack the relevant small-bar uAPI support (see3725* also &drm_i915_memory_region_info.probed_cpu_visible_size),3726* usage of the flag will result in an error, but it should NEVER be3727* possible to end up with a small BAR configuration, assuming we can3728* also successfully load the i915 kernel module. In such cases the3729* entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as3730* such there are zero restrictions on where the object can be placed.3731*/3732#define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)3733__u32 flags;37343735/**3736* @extensions: The chain of extensions to apply to this object.3737*3738* This will be useful in the future when we need to support several3739* different extensions, and we need to apply more than one when3740* creating the object. See struct i915_user_extension.3741*3742* If we don't supply any extensions then we get the same old gem_create3743* behaviour.3744*3745* For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see3746* struct drm_i915_gem_create_ext_memory_regions.3747*3748* For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see3749* struct drm_i915_gem_create_ext_protected_content.3750*3751* For I915_GEM_CREATE_EXT_SET_PAT usage see3752* struct drm_i915_gem_create_ext_set_pat.3753*/3754#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 03755#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 13756#define I915_GEM_CREATE_EXT_SET_PAT 23757__u64 extensions;3758};37593760/**3761* struct drm_i915_gem_create_ext_memory_regions - The3762* I915_GEM_CREATE_EXT_MEMORY_REGIONS extension.3763*3764* Set the object with the desired set of placements/regions in priority3765* order. Each entry must be unique and supported by the device.3766*3767* This is provided as an array of struct drm_i915_gem_memory_class_instance, or3768* an equivalent layout of class:instance pair encodings. See struct3769* drm_i915_query_memory_regions and DRM_I915_QUERY_MEMORY_REGIONS for how to3770* query the supported regions for a device.3771*3772* As an example, on discrete devices, if we wish to set the placement as3773* device local-memory we can do something like:3774*3775* .. code-block:: C3776*3777* struct drm_i915_gem_memory_class_instance region_lmem = {3778* .memory_class = I915_MEMORY_CLASS_DEVICE,3779* .memory_instance = 0,3780* };3781* struct drm_i915_gem_create_ext_memory_regions regions = {3782* .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS },3783* .regions = (uintptr_t)®ion_lmem,3784* .num_regions = 1,3785* };3786* struct drm_i915_gem_create_ext create_ext = {3787* .size = 16 * PAGE_SIZE,3788* .extensions = (uintptr_t)®ions,3789* };3790*3791* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);3792* if (err) ...3793*3794* At which point we get the object handle in &drm_i915_gem_create_ext.handle,3795* along with the final object size in &drm_i915_gem_create_ext.size, which3796* should account for any rounding up, if required.3797*3798* Note that userspace has no means of knowing the current backing region3799* for objects where @num_regions is larger than one. The kernel will only3800* ensure that the priority order of the @regions array is honoured, either3801* when initially placing the object, or when moving memory around due to3802* memory pressure3803*3804* On Flat-CCS capable HW, compression is supported for the objects residing3805* in I915_MEMORY_CLASS_DEVICE. When such objects (compressed) have other3806* memory class in @regions and migrated (by i915, due to memory3807* constraints) to the non I915_MEMORY_CLASS_DEVICE region, then i915 needs to3808* decompress the content. But i915 doesn't have the required information to3809* decompress the userspace compressed objects.3810*3811* So i915 supports Flat-CCS, on the objects which can reside only on3812* I915_MEMORY_CLASS_DEVICE regions.3813*/3814struct drm_i915_gem_create_ext_memory_regions {3815/** @base: Extension link. See struct i915_user_extension. */3816struct i915_user_extension base;38173818/** @pad: MBZ */3819__u32 pad;3820/** @num_regions: Number of elements in the @regions array. */3821__u32 num_regions;3822/**3823* @regions: The regions/placements array.3824*3825* An array of struct drm_i915_gem_memory_class_instance.3826*/3827__u64 regions;3828};38293830/**3831* struct drm_i915_gem_create_ext_protected_content - The3832* I915_OBJECT_PARAM_PROTECTED_CONTENT extension.3833*3834* If this extension is provided, buffer contents are expected to be protected3835* by PXP encryption and require decryption for scan out and processing. This3836* is only possible on platforms that have PXP enabled, on all other scenarios3837* using this extension will cause the ioctl to fail and return -ENODEV. The3838* flags parameter is reserved for future expansion and must currently be set3839* to zero.3840*3841* The buffer contents are considered invalid after a PXP session teardown.3842*3843* The encryption is guaranteed to be processed correctly only if the object3844* is submitted with a context created using the3845* I915_CONTEXT_PARAM_PROTECTED_CONTENT flag. This will also enable extra checks3846* at submission time on the validity of the objects involved.3847*3848* Below is an example on how to create a protected object:3849*3850* .. code-block:: C3851*3852* struct drm_i915_gem_create_ext_protected_content protected_ext = {3853* .base = { .name = I915_GEM_CREATE_EXT_PROTECTED_CONTENT },3854* .flags = 0,3855* };3856* struct drm_i915_gem_create_ext create_ext = {3857* .size = PAGE_SIZE,3858* .extensions = (uintptr_t)&protected_ext,3859* };3860*3861* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);3862* if (err) ...3863*/3864struct drm_i915_gem_create_ext_protected_content {3865/** @base: Extension link. See struct i915_user_extension. */3866struct i915_user_extension base;3867/** @flags: reserved for future usage, currently MBZ */3868__u32 flags;3869};38703871/**3872* struct drm_i915_gem_create_ext_set_pat - The3873* I915_GEM_CREATE_EXT_SET_PAT extension.3874*3875* If this extension is provided, the specified caching policy (PAT index) is3876* applied to the buffer object.3877*3878* Below is an example on how to create an object with specific caching policy:3879*3880* .. code-block:: C3881*3882* struct drm_i915_gem_create_ext_set_pat set_pat_ext = {3883* .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },3884* .pat_index = 0,3885* };3886* struct drm_i915_gem_create_ext create_ext = {3887* .size = PAGE_SIZE,3888* .extensions = (uintptr_t)&set_pat_ext,3889* };3890*3891* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);3892* if (err) ...3893*/3894struct drm_i915_gem_create_ext_set_pat {3895/** @base: Extension link. See struct i915_user_extension. */3896struct i915_user_extension base;3897/**3898* @pat_index: PAT index to be set3899* PAT index is a bit field in Page Table Entry to control caching3900* behaviors for GPU accesses. The definition of PAT index is3901* platform dependent and can be found in hardware specifications,3902*/3903__u32 pat_index;3904/** @rsvd: reserved for future use */3905__u32 rsvd;3906};39073908/* ID of the protected content session managed by i915 when PXP is active */3909#define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf39103911#if defined(__cplusplus)3912}3913#endif39143915#endif /* _UAPI_I915_DRM_H_ */391639173918