/* SPDX-License-Identifier: MIT */1/*2* Copyright © 2023 Intel Corporation3*/45#ifndef _UAPI_XE_DRM_H_6#define _UAPI_XE_DRM_H_78#include "drm.h"910#if defined(__cplusplus)11extern "C" {12#endif1314/*15* Please note that modifications to all structs defined here are16* subject to backwards-compatibility constraints.17* Sections in this file are organized as follows:18* 1. IOCTL definition19* 2. Extension definition and helper structs20* 3. IOCTL's Query structs in the order of the Query's entries.21* 4. The rest of IOCTL structs in the order of IOCTL declaration.22*/2324/**25* DOC: Xe Device Block Diagram26*27* The diagram below represents a high-level simplification of a discrete28* GPU supported by the Xe driver. It shows some device components which29* are necessary to understand this API, as well as how their relations30* to each other. This diagram does not represent real hardware::31*32* ┌──────────────────────────────────────────────────────────────────┐33* │ ┌──────────────────────────────────────────────────┐ ┌─────────┐ │34* │ │ ┌───────────────────────┐ ┌─────┐ │ │ ┌─────┐ │ │35* │ │ │ VRAM0 ├───┤ ... │ │ │ │VRAM1│ │ │36* │ │ └───────────┬───────────┘ └─GT1─┘ │ │ └──┬──┘ │ │37* │ │ ┌──────────────────┴───────────────────────────┐ │ │ ┌──┴──┐ │ │38* │ │ │ ┌─────────────────────┐ ┌─────────────────┐ │ │ │ │ │ │ │39* │ │ │ │ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │ │ ┌─────┐ ┌─────┐ │ │ │ │ │ │ │ │40* │ │ │ │ │EU│ │EU│ │EU│ │EU│ │ │ │RCS0 │ │BCS0 │ │ │ │ │ │ │ │ │41* │ │ │ │ └──┘ └──┘ └──┘ └──┘ │ │ └─────┘ └─────┘ │ │ │ │ │ │ │ │42* │ │ │ │ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │ │ ┌─────┐ ┌─────┐ │ │ │ │ │ │ │ │43* │ │ │ │ │EU│ │EU│ │EU│ │EU│ │ │ │VCS0 │ │VCS1 │ │ │ │ │ │ │ │ │44* │ │ │ │ └──┘ └──┘ └──┘ └──┘ │ │ └─────┘ └─────┘ │ │ │ │ │ │ │ │45* │ │ │ │ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │ │ ┌─────┐ ┌─────┐ │ │ │ │ │ │ │ │46* │ │ │ │ │EU│ │EU│ │EU│ │EU│ │ │ │VECS0│ │VECS1│ │ │ │ │ │ ... │ │ │47* │ │ │ │ └──┘ └──┘ └──┘ └──┘ │ │ └─────┘ └─────┘ │ │ │ │ │ │ │ │48* │ │ │ │ ┌──┐ ┌──┐ ┌──┐ ┌──┐ │ │ ┌─────┐ ┌─────┐ │ │ │ │ │ │ │ │49* │ │ │ │ │EU│ │EU│ │EU│ │EU│ │ │ │CCS0 │ │CCS1 │ │ │ │ │ │ │ │ │50* │ │ │ │ └──┘ └──┘ └──┘ └──┘ │ │ └─────┘ └─────┘ │ │ │ │ │ │ │ │51* │ │ │ └─────────DSS─────────┘ │ ┌─────┐ ┌─────┐ │ │ │ │ │ │ │ │52* │ │ │ │ │CCS2 │ │CCS3 │ │ │ │ │ │ │ │ │53* │ │ │ ┌─────┐ ┌─────┐ ┌─────┐ │ └─────┘ └─────┘ │ │ │ │ │ │ │ │54* │ │ │ │ ... │ │ ... │ │ ... │ │ │ │ │ │ │ │ │ │55* │ │ │ └─DSS─┘ └─DSS─┘ └─DSS─┘ └─────Engines─────┘ │ │ │ │ │ │ │56* │ │ └───────────────────────────GT0────────────────┘ │ │ └─GT2─┘ │ │57* │ └────────────────────────────Tile0─────────────────┘ └─ Tile1──┘ │58* └─────────────────────────────Device0───────┬──────────────────────┘59* │60* ───────────────────────┴────────── PCI bus61*/6263/**64* DOC: Xe uAPI Overview65*66* This section aims to describe the Xe's IOCTL entries, its structs, and other67* Xe related uAPI such as uevents and PMU (Platform Monitoring Unit) related68* entries and usage.69*70* List of supported IOCTLs:71* - &DRM_IOCTL_XE_DEVICE_QUERY72* - &DRM_IOCTL_XE_GEM_CREATE73* - &DRM_IOCTL_XE_GEM_MMAP_OFFSET74* - &DRM_IOCTL_XE_VM_CREATE75* - &DRM_IOCTL_XE_VM_DESTROY76* - &DRM_IOCTL_XE_VM_BIND77* - &DRM_IOCTL_XE_EXEC_QUEUE_CREATE78* - &DRM_IOCTL_XE_EXEC_QUEUE_DESTROY79* - &DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY80* - &DRM_IOCTL_XE_EXEC81* - &DRM_IOCTL_XE_WAIT_USER_FENCE82* - &DRM_IOCTL_XE_OBSERVATION83*/8485/*86* xe specific ioctls.87*88* The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie89* [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset90* against DRM_COMMAND_BASE and should be between [0x0, 0x60).91*/92#define DRM_XE_DEVICE_QUERY 0x0093#define DRM_XE_GEM_CREATE 0x0194#define DRM_XE_GEM_MMAP_OFFSET 0x0295#define DRM_XE_VM_CREATE 0x0396#define DRM_XE_VM_DESTROY 0x0497#define DRM_XE_VM_BIND 0x0598#define DRM_XE_EXEC_QUEUE_CREATE 0x0699#define DRM_XE_EXEC_QUEUE_DESTROY 0x07100#define DRM_XE_EXEC_QUEUE_GET_PROPERTY 0x08101#define DRM_XE_EXEC 0x09102#define DRM_XE_WAIT_USER_FENCE 0x0a103#define DRM_XE_OBSERVATION 0x0b104105/* Must be kept compact -- no holes */106107#define DRM_IOCTL_XE_DEVICE_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_DEVICE_QUERY, struct drm_xe_device_query)108#define DRM_IOCTL_XE_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_GEM_CREATE, struct drm_xe_gem_create)109#define DRM_IOCTL_XE_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_GEM_MMAP_OFFSET, struct drm_xe_gem_mmap_offset)110#define DRM_IOCTL_XE_VM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_VM_CREATE, struct drm_xe_vm_create)111#define DRM_IOCTL_XE_VM_DESTROY DRM_IOW(DRM_COMMAND_BASE + DRM_XE_VM_DESTROY, struct drm_xe_vm_destroy)112#define DRM_IOCTL_XE_VM_BIND DRM_IOW(DRM_COMMAND_BASE + DRM_XE_VM_BIND, struct drm_xe_vm_bind)113#define DRM_IOCTL_XE_EXEC_QUEUE_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_CREATE, struct drm_xe_exec_queue_create)114#define DRM_IOCTL_XE_EXEC_QUEUE_DESTROY DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_DESTROY, struct drm_xe_exec_queue_destroy)115#define DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_GET_PROPERTY, struct drm_xe_exec_queue_get_property)116#define DRM_IOCTL_XE_EXEC DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC, struct drm_xe_exec)117#define DRM_IOCTL_XE_WAIT_USER_FENCE DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_WAIT_USER_FENCE, struct drm_xe_wait_user_fence)118#define DRM_IOCTL_XE_OBSERVATION DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param)119120/**121* DOC: Xe IOCTL Extensions122*123* Before detailing the IOCTLs and its structs, it is important to highlight124* that every IOCTL in Xe is extensible.125*126* Many interfaces need to grow over time. In most cases we can simply127* extend the struct and have userspace pass in more data. Another option,128* as demonstrated by Vulkan's approach to providing extensions for forward129* and backward compatibility, is to use a list of optional structs to130* provide those extra details.131*132* The key advantage to using an extension chain is that it allows us to133* redefine the interface more easily than an ever growing struct of134* increasing complexity, and for large parts of that interface to be135* entirely optional. The downside is more pointer chasing; chasing across136* the __user boundary with pointers encapsulated inside u64.137*138* Example chaining:139*140* .. code-block:: C141*142* struct drm_xe_user_extension ext3 {143* .next_extension = 0, // end144* .name = ...,145* };146* struct drm_xe_user_extension ext2 {147* .next_extension = (uintptr_t)&ext3,148* .name = ...,149* };150* struct drm_xe_user_extension ext1 {151* .next_extension = (uintptr_t)&ext2,152* .name = ...,153* };154*155* Typically the struct drm_xe_user_extension would be embedded in some uAPI156* struct, and in this case we would feed it the head of the chain(i.e ext1),157* which would then apply all of the above extensions.158*/159160/**161* struct drm_xe_user_extension - Base class for defining a chain of extensions162*/163struct drm_xe_user_extension {164/**165* @next_extension:166*167* Pointer to the next struct drm_xe_user_extension, or zero if the end.168*/169__u64 next_extension;170171/**172* @name: Name of the extension.173*174* Note that the name here is just some integer.175*176* Also note that the name space for this is not global for the whole177* driver, but rather its scope/meaning is limited to the specific piece178* of uAPI which has embedded the struct drm_xe_user_extension.179*/180__u32 name;181182/**183* @pad: MBZ184*185* All undefined bits must be zero.186*/187__u32 pad;188};189190/**191* struct drm_xe_ext_set_property - Generic set property extension192*193* A generic struct that allows any of the Xe's IOCTL to be extended194* with a set_property operation.195*/196struct drm_xe_ext_set_property {197/** @base: base user extension */198struct drm_xe_user_extension base;199200/** @property: property to set */201__u32 property;202203/** @pad: MBZ */204__u32 pad;205206/** @value: property value */207__u64 value;208209/** @reserved: Reserved */210__u64 reserved[2];211};212213/**214* struct drm_xe_engine_class_instance - instance of an engine class215*216* It is returned as part of the @drm_xe_engine, but it also is used as217* the input of engine selection for both @drm_xe_exec_queue_create and218* @drm_xe_query_engine_cycles219*220* The @engine_class can be:221* - %DRM_XE_ENGINE_CLASS_RENDER222* - %DRM_XE_ENGINE_CLASS_COPY223* - %DRM_XE_ENGINE_CLASS_VIDEO_DECODE224* - %DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE225* - %DRM_XE_ENGINE_CLASS_COMPUTE226* - %DRM_XE_ENGINE_CLASS_VM_BIND - Kernel only classes (not actual227* hardware engine class). Used for creating ordered queues of VM228* bind operations.229*/230struct drm_xe_engine_class_instance {231#define DRM_XE_ENGINE_CLASS_RENDER 0232#define DRM_XE_ENGINE_CLASS_COPY 1233#define DRM_XE_ENGINE_CLASS_VIDEO_DECODE 2234#define DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE 3235#define DRM_XE_ENGINE_CLASS_COMPUTE 4236#define DRM_XE_ENGINE_CLASS_VM_BIND 5237/** @engine_class: engine class id */238__u16 engine_class;239/** @engine_instance: engine instance id */240__u16 engine_instance;241/** @gt_id: Unique ID of this GT within the PCI Device */242__u16 gt_id;243/** @pad: MBZ */244__u16 pad;245};246247/**248* struct drm_xe_engine - describe hardware engine249*/250struct drm_xe_engine {251/** @instance: The @drm_xe_engine_class_instance */252struct drm_xe_engine_class_instance instance;253254/** @reserved: Reserved */255__u64 reserved[3];256};257258/**259* struct drm_xe_query_engines - describe engines260*261* If a query is made with a struct @drm_xe_device_query where .query262* is equal to %DRM_XE_DEVICE_QUERY_ENGINES, then the reply uses an array of263* struct @drm_xe_query_engines in .data.264*/265struct drm_xe_query_engines {266/** @num_engines: number of engines returned in @engines */267__u32 num_engines;268/** @pad: MBZ */269__u32 pad;270/** @engines: The returned engines for this device */271struct drm_xe_engine engines[];272};273274/**275* enum drm_xe_memory_class - Supported memory classes.276*/277enum drm_xe_memory_class {278/** @DRM_XE_MEM_REGION_CLASS_SYSMEM: Represents system memory. */279DRM_XE_MEM_REGION_CLASS_SYSMEM = 0,280/**281* @DRM_XE_MEM_REGION_CLASS_VRAM: On discrete platforms, this282* represents the memory that is local to the device, which we283* call VRAM. Not valid on integrated platforms.284*/285DRM_XE_MEM_REGION_CLASS_VRAM286};287288/**289* struct drm_xe_mem_region - Describes some region as known to290* the driver.291*/292struct drm_xe_mem_region {293/**294* @mem_class: The memory class describing this region.295*296* See enum drm_xe_memory_class for supported values.297*/298__u16 mem_class;299/**300* @instance: The unique ID for this region, which serves as the301* index in the placement bitmask used as argument for302* &DRM_IOCTL_XE_GEM_CREATE303*/304__u16 instance;305/**306* @min_page_size: Min page-size in bytes for this region.307*308* When the kernel allocates memory for this region, the309* underlying pages will be at least @min_page_size in size.310* Buffer objects with an allowable placement in this region must be311* created with a size aligned to this value.312* GPU virtual address mappings of (parts of) buffer objects that313* may be placed in this region must also have their GPU virtual314* address and range aligned to this value.315* Affected IOCTLS will return %-EINVAL if alignment restrictions are316* not met.317*/318__u32 min_page_size;319/**320* @total_size: The usable size in bytes for this region.321*/322__u64 total_size;323/**324* @used: Estimate of the memory used in bytes for this region.325*326* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable327* accounting. Without this the value here will always equal328* zero.329*/330__u64 used;331/**332* @cpu_visible_size: How much of this region can be CPU333* accessed, in bytes.334*335* This will always be <= @total_size, and the remainder (if336* any) will not be CPU accessible. If the CPU accessible part337* is smaller than @total_size then this is referred to as a338* small BAR system.339*340* On systems without small BAR (full BAR), the probed_size will341* always equal the @total_size, since all of it will be CPU342* accessible.343*344* Note this is only tracked for DRM_XE_MEM_REGION_CLASS_VRAM345* regions (for other types the value here will always equal346* zero).347*/348__u64 cpu_visible_size;349/**350* @cpu_visible_used: Estimate of CPU visible memory used, in351* bytes.352*353* Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable354* accounting. Without this the value here will always equal355* zero. Note this is only currently tracked for356* DRM_XE_MEM_REGION_CLASS_VRAM regions (for other types the value357* here will always be zero).358*/359__u64 cpu_visible_used;360/** @reserved: Reserved */361__u64 reserved[6];362};363364/**365* struct drm_xe_query_mem_regions - describe memory regions366*367* If a query is made with a struct drm_xe_device_query where .query368* is equal to DRM_XE_DEVICE_QUERY_MEM_REGIONS, then the reply uses369* struct drm_xe_query_mem_regions in .data.370*/371struct drm_xe_query_mem_regions {372/** @num_mem_regions: number of memory regions returned in @mem_regions */373__u32 num_mem_regions;374/** @pad: MBZ */375__u32 pad;376/** @mem_regions: The returned memory regions for this device */377struct drm_xe_mem_region mem_regions[];378};379380/**381* struct drm_xe_query_config - describe the device configuration382*383* If a query is made with a struct drm_xe_device_query where .query384* is equal to DRM_XE_DEVICE_QUERY_CONFIG, then the reply uses385* struct drm_xe_query_config in .data.386*387* The index in @info can be:388* - %DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID - Device ID (lower 16 bits)389* and the device revision (next 8 bits)390* - %DRM_XE_QUERY_CONFIG_FLAGS - Flags describing the device391* configuration, see list below392*393* - %DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM - Flag is set if the device394* has usable VRAM395* - %DRM_XE_QUERY_CONFIG_FLAG_HAS_LOW_LATENCY - Flag is set if the device396* has low latency hint support397* - %DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR - Flag is set if the398* device has CPU address mirroring support399* - %DRM_XE_QUERY_CONFIG_MIN_ALIGNMENT - Minimal memory alignment400* required by this device, typically SZ_4K or SZ_64K401* - %DRM_XE_QUERY_CONFIG_VA_BITS - Maximum bits of a virtual address402* - %DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY - Value of the highest403* available exec queue priority404*/405struct drm_xe_query_config {406/** @num_params: number of parameters returned in info */407__u32 num_params;408409/** @pad: MBZ */410__u32 pad;411412#define DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID 0413#define DRM_XE_QUERY_CONFIG_FLAGS 1414#define DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM (1 << 0)415#define DRM_XE_QUERY_CONFIG_FLAG_HAS_LOW_LATENCY (1 << 1)416#define DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR (1 << 2)417#define DRM_XE_QUERY_CONFIG_MIN_ALIGNMENT 2418#define DRM_XE_QUERY_CONFIG_VA_BITS 3419#define DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY 4420/** @info: array of elements containing the config info */421__u64 info[];422};423424/**425* struct drm_xe_gt - describe an individual GT.426*427* To be used with drm_xe_query_gt_list, which will return a list with all the428* existing GT individual descriptions.429* Graphics Technology (GT) is a subset of a GPU/tile that is responsible for430* implementing graphics and/or media operations.431*432* The index in @type can be:433* - %DRM_XE_QUERY_GT_TYPE_MAIN434* - %DRM_XE_QUERY_GT_TYPE_MEDIA435*/436struct drm_xe_gt {437#define DRM_XE_QUERY_GT_TYPE_MAIN 0438#define DRM_XE_QUERY_GT_TYPE_MEDIA 1439/** @type: GT type: Main or Media */440__u16 type;441/** @tile_id: Tile ID where this GT lives (Information only) */442__u16 tile_id;443/** @gt_id: Unique ID of this GT within the PCI Device */444__u16 gt_id;445/** @pad: MBZ */446__u16 pad[3];447/** @reference_clock: A clock frequency for timestamp */448__u32 reference_clock;449/**450* @near_mem_regions: Bit mask of instances from451* drm_xe_query_mem_regions that are nearest to the current engines452* of this GT.453* Each index in this mask refers directly to the struct454* drm_xe_query_mem_regions' instance, no assumptions should455* be made about order. The type of each region is described456* by struct drm_xe_query_mem_regions' mem_class.457*/458__u64 near_mem_regions;459/**460* @far_mem_regions: Bit mask of instances from461* drm_xe_query_mem_regions that are far from the engines of this GT.462* In general, they have extra indirections when compared to the463* @near_mem_regions. For a discrete device this could mean system464* memory and memory living in a different tile.465* Each index in this mask refers directly to the struct466* drm_xe_query_mem_regions' instance, no assumptions should467* be made about order. The type of each region is described468* by struct drm_xe_query_mem_regions' mem_class.469*/470__u64 far_mem_regions;471/** @ip_ver_major: Graphics/media IP major version on GMD_ID platforms */472__u16 ip_ver_major;473/** @ip_ver_minor: Graphics/media IP minor version on GMD_ID platforms */474__u16 ip_ver_minor;475/** @ip_ver_rev: Graphics/media IP revision version on GMD_ID platforms */476__u16 ip_ver_rev;477/** @pad2: MBZ */478__u16 pad2;479/** @reserved: Reserved */480__u64 reserved[7];481};482483/**484* struct drm_xe_query_gt_list - A list with GT description items.485*486* If a query is made with a struct drm_xe_device_query where .query487* is equal to DRM_XE_DEVICE_QUERY_GT_LIST, then the reply uses struct488* drm_xe_query_gt_list in .data.489*/490struct drm_xe_query_gt_list {491/** @num_gt: number of GT items returned in gt_list */492__u32 num_gt;493/** @pad: MBZ */494__u32 pad;495/** @gt_list: The GT list returned for this device */496struct drm_xe_gt gt_list[];497};498499/**500* struct drm_xe_query_topology_mask - describe the topology mask of a GT501*502* This is the hardware topology which reflects the internal physical503* structure of the GPU.504*505* If a query is made with a struct drm_xe_device_query where .query506* is equal to DRM_XE_DEVICE_QUERY_GT_TOPOLOGY, then the reply uses507* struct drm_xe_query_topology_mask in .data.508*509* The @type can be:510* - %DRM_XE_TOPO_DSS_GEOMETRY - To query the mask of Dual Sub Slices511* (DSS) available for geometry operations. For example a query response512* containing the following in mask:513* ``DSS_GEOMETRY ff ff ff ff 00 00 00 00``514* means 32 DSS are available for geometry.515* - %DRM_XE_TOPO_DSS_COMPUTE - To query the mask of Dual Sub Slices516* (DSS) available for compute operations. For example a query response517* containing the following in mask:518* ``DSS_COMPUTE ff ff ff ff 00 00 00 00``519* means 32 DSS are available for compute.520* - %DRM_XE_TOPO_L3_BANK - To query the mask of enabled L3 banks. This type521* may be omitted if the driver is unable to query the mask from the522* hardware.523* - %DRM_XE_TOPO_EU_PER_DSS - To query the mask of Execution Units (EU)524* available per Dual Sub Slices (DSS). For example a query response525* containing the following in mask:526* ``EU_PER_DSS ff ff 00 00 00 00 00 00``527* means each DSS has 16 SIMD8 EUs. This type may be omitted if device528* doesn't have SIMD8 EUs.529* - %DRM_XE_TOPO_SIMD16_EU_PER_DSS - To query the mask of SIMD16 Execution530* Units (EU) available per Dual Sub Slices (DSS). For example a query531* response containing the following in mask:532* ``SIMD16_EU_PER_DSS ff ff 00 00 00 00 00 00``533* means each DSS has 16 SIMD16 EUs. This type may be omitted if device534* doesn't have SIMD16 EUs.535*/536struct drm_xe_query_topology_mask {537/** @gt_id: GT ID the mask is associated with */538__u16 gt_id;539540#define DRM_XE_TOPO_DSS_GEOMETRY 1541#define DRM_XE_TOPO_DSS_COMPUTE 2542#define DRM_XE_TOPO_L3_BANK 3543#define DRM_XE_TOPO_EU_PER_DSS 4544#define DRM_XE_TOPO_SIMD16_EU_PER_DSS 5545/** @type: type of mask */546__u16 type;547548/** @num_bytes: number of bytes in requested mask */549__u32 num_bytes;550551/** @mask: little-endian mask of @num_bytes */552__u8 mask[];553};554555/**556* struct drm_xe_query_engine_cycles - correlate CPU and GPU timestamps557*558* If a query is made with a struct drm_xe_device_query where .query is equal to559* DRM_XE_DEVICE_QUERY_ENGINE_CYCLES, then the reply uses struct drm_xe_query_engine_cycles560* in .data. struct drm_xe_query_engine_cycles is allocated by the user and561* .data points to this allocated structure.562*563* The query returns the engine cycles, which along with GT's @reference_clock,564* can be used to calculate the engine timestamp. In addition the565* query returns a set of cpu timestamps that indicate when the command566* streamer cycle count was captured.567*/568struct drm_xe_query_engine_cycles {569/**570* @eci: This is input by the user and is the engine for which command571* streamer cycles is queried.572*/573struct drm_xe_engine_class_instance eci;574575/**576* @clockid: This is input by the user and is the reference clock id for577* CPU timestamp. For definition, see clock_gettime(2) and578* perf_event_open(2). Supported clock ids are CLOCK_MONOTONIC,579* CLOCK_MONOTONIC_RAW, CLOCK_REALTIME, CLOCK_BOOTTIME, CLOCK_TAI.580*/581__s32 clockid;582583/** @width: Width of the engine cycle counter in bits. */584__u32 width;585586/**587* @engine_cycles: Engine cycles as read from its register588* at 0x358 offset.589*/590__u64 engine_cycles;591592/**593* @cpu_timestamp: CPU timestamp in ns. The timestamp is captured before594* reading the engine_cycles register using the reference clockid set by the595* user.596*/597__u64 cpu_timestamp;598599/**600* @cpu_delta: Time delta in ns captured around reading the lower dword601* of the engine_cycles register.602*/603__u64 cpu_delta;604};605606/**607* struct drm_xe_query_uc_fw_version - query a micro-controller firmware version608*609* Given a uc_type this will return the branch, major, minor and patch version610* of the micro-controller firmware.611*/612struct drm_xe_query_uc_fw_version {613/** @uc_type: The micro-controller type to query firmware version */614#define XE_QUERY_UC_TYPE_GUC_SUBMISSION 0615#define XE_QUERY_UC_TYPE_HUC 1616__u16 uc_type;617618/** @pad: MBZ */619__u16 pad;620621/** @branch_ver: branch uc fw version */622__u32 branch_ver;623/** @major_ver: major uc fw version */624__u32 major_ver;625/** @minor_ver: minor uc fw version */626__u32 minor_ver;627/** @patch_ver: patch uc fw version */628__u32 patch_ver;629630/** @pad2: MBZ */631__u32 pad2;632633/** @reserved: Reserved */634__u64 reserved;635};636637/**638* struct drm_xe_query_pxp_status - query if PXP is ready639*640* If PXP is enabled and no fatal error has occurred, the status will be set to641* one of the following values:642* 0: PXP init still in progress643* 1: PXP init complete644*645* If PXP is not enabled or something has gone wrong, the query will be failed646* with one of the following error codes:647* -ENODEV: PXP not supported or disabled;648* -EIO: fatal error occurred during init, so PXP will never be enabled;649* -EINVAL: incorrect value provided as part of the query;650* -EFAULT: error copying the memory between kernel and userspace.651*652* The status can only be 0 in the first few seconds after driver load. If653* everything works as expected, the status will transition to init complete in654* less than 1 second, while in case of errors the driver might take longer to655* start returning an error code, but it should still take less than 10 seconds.656*657* The supported session type bitmask is based on the values in658* enum drm_xe_pxp_session_type. TYPE_NONE is always supported and therefore659* is not reported in the bitmask.660*661*/662struct drm_xe_query_pxp_status {663/** @status: current PXP status */664__u32 status;665666/** @supported_session_types: bitmask of supported PXP session types */667__u32 supported_session_types;668};669670/**671* struct drm_xe_device_query - Input of &DRM_IOCTL_XE_DEVICE_QUERY - main672* structure to query device information673*674* The user selects the type of data to query among DRM_XE_DEVICE_QUERY_*675* and sets the value in the query member. This determines the type of676* the structure provided by the driver in data, among struct drm_xe_query_*.677*678* The @query can be:679* - %DRM_XE_DEVICE_QUERY_ENGINES680* - %DRM_XE_DEVICE_QUERY_MEM_REGIONS681* - %DRM_XE_DEVICE_QUERY_CONFIG682* - %DRM_XE_DEVICE_QUERY_GT_LIST683* - %DRM_XE_DEVICE_QUERY_HWCONFIG - Query type to retrieve the hardware684* configuration of the device such as information on slices, memory,685* caches, and so on. It is provided as a table of key / value686* attributes.687* - %DRM_XE_DEVICE_QUERY_GT_TOPOLOGY688* - %DRM_XE_DEVICE_QUERY_ENGINE_CYCLES689* - %DRM_XE_DEVICE_QUERY_PXP_STATUS690*691* If size is set to 0, the driver fills it with the required size for692* the requested type of data to query. If size is equal to the required693* size, the queried information is copied into data. If size is set to694* a value different from 0 and different from the required size, the695* IOCTL call returns -EINVAL.696*697* For example the following code snippet allows retrieving and printing698* information about the device engines with DRM_XE_DEVICE_QUERY_ENGINES:699*700* .. code-block:: C701*702* struct drm_xe_query_engines *engines;703* struct drm_xe_device_query query = {704* .extensions = 0,705* .query = DRM_XE_DEVICE_QUERY_ENGINES,706* .size = 0,707* .data = 0,708* };709* ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);710* engines = malloc(query.size);711* query.data = (uintptr_t)engines;712* ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);713* for (int i = 0; i < engines->num_engines; i++) {714* printf("Engine %d: %s\n", i,715* engines->engines[i].instance.engine_class ==716* DRM_XE_ENGINE_CLASS_RENDER ? "RENDER":717* engines->engines[i].instance.engine_class ==718* DRM_XE_ENGINE_CLASS_COPY ? "COPY":719* engines->engines[i].instance.engine_class ==720* DRM_XE_ENGINE_CLASS_VIDEO_DECODE ? "VIDEO_DECODE":721* engines->engines[i].instance.engine_class ==722* DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE ? "VIDEO_ENHANCE":723* engines->engines[i].instance.engine_class ==724* DRM_XE_ENGINE_CLASS_COMPUTE ? "COMPUTE":725* "UNKNOWN");726* }727* free(engines);728*/729struct drm_xe_device_query {730/** @extensions: Pointer to the first extension struct, if any */731__u64 extensions;732733#define DRM_XE_DEVICE_QUERY_ENGINES 0734#define DRM_XE_DEVICE_QUERY_MEM_REGIONS 1735#define DRM_XE_DEVICE_QUERY_CONFIG 2736#define DRM_XE_DEVICE_QUERY_GT_LIST 3737#define DRM_XE_DEVICE_QUERY_HWCONFIG 4738#define DRM_XE_DEVICE_QUERY_GT_TOPOLOGY 5739#define DRM_XE_DEVICE_QUERY_ENGINE_CYCLES 6740#define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7741#define DRM_XE_DEVICE_QUERY_OA_UNITS 8742#define DRM_XE_DEVICE_QUERY_PXP_STATUS 9743#define DRM_XE_DEVICE_QUERY_EU_STALL 10744/** @query: The type of data to query */745__u32 query;746747/** @size: Size of the queried data */748__u32 size;749750/** @data: Queried data is placed here */751__u64 data;752753/** @reserved: Reserved */754__u64 reserved[2];755};756757/**758* struct drm_xe_gem_create - Input of &DRM_IOCTL_XE_GEM_CREATE - A structure for759* gem creation760*761* The @flags can be:762* - %DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING763* - %DRM_XE_GEM_CREATE_FLAG_SCANOUT764* - %DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM - When using VRAM as a765* possible placement, ensure that the corresponding VRAM allocation766* will always use the CPU accessible part of VRAM. This is important767* for small-bar systems (on full-bar systems this gets turned into a768* noop).769* Note1: System memory can be used as an extra placement if the kernel770* should spill the allocation to system memory, if space can't be made771* available in the CPU accessible part of VRAM (giving the same772* behaviour as the i915 interface, see773* I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS).774* Note2: For clear-color CCS surfaces the kernel needs to read the775* clear-color value stored in the buffer, and on discrete platforms we776* need to use VRAM for display surfaces, therefore the kernel requires777* setting this flag for such objects, otherwise an error is thrown on778* small-bar systems.779*780* @cpu_caching supports the following values:781* - %DRM_XE_GEM_CPU_CACHING_WB - Allocate the pages with write-back782* caching. On iGPU this can't be used for scanout surfaces. Currently783* not allowed for objects placed in VRAM.784* - %DRM_XE_GEM_CPU_CACHING_WC - Allocate the pages as write-combined. This785* is uncached. Scanout surfaces should likely use this. All objects786* that can be placed in VRAM must use this.787*788* This ioctl supports setting the following properties via the789* %DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY extension, which uses the790* generic @drm_xe_ext_set_property struct:791*792* - %DRM_XE_GEM_CREATE_SET_PROPERTY_PXP_TYPE - set the type of PXP session793* this object will be used with. Valid values are listed in enum794* drm_xe_pxp_session_type. %DRM_XE_PXP_TYPE_NONE is the default behavior, so795* there is no need to explicitly set that. Objects used with session of type796* %DRM_XE_PXP_TYPE_HWDRM will be marked as invalid if a PXP invalidation797* event occurs after their creation. Attempting to flip an invalid object798* will cause a black frame to be displayed instead. Submissions with invalid799* objects mapped in the VM will be rejected.800*/801struct drm_xe_gem_create {802#define DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY 0803#define DRM_XE_GEM_CREATE_SET_PROPERTY_PXP_TYPE 0804/** @extensions: Pointer to the first extension struct, if any */805__u64 extensions;806807/**808* @size: Size of the object to be created, must match region809* (system or vram) minimum alignment (&min_page_size).810*/811__u64 size;812813/**814* @placement: A mask of memory instances of where BO can be placed.815* Each index in this mask refers directly to the struct816* drm_xe_query_mem_regions' instance, no assumptions should817* be made about order. The type of each region is described818* by struct drm_xe_query_mem_regions' mem_class.819*/820__u32 placement;821822#define DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING (1 << 0)823#define DRM_XE_GEM_CREATE_FLAG_SCANOUT (1 << 1)824#define DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM (1 << 2)825/**826* @flags: Flags, currently a mask of memory instances of where BO can827* be placed828*/829__u32 flags;830831/**832* @vm_id: Attached VM, if any833*834* If a VM is specified, this BO must:835*836* 1. Only ever be bound to that VM.837* 2. Cannot be exported as a PRIME fd.838*/839__u32 vm_id;840841/**842* @handle: Returned handle for the object.843*844* Object handles are nonzero.845*/846__u32 handle;847848#define DRM_XE_GEM_CPU_CACHING_WB 1849#define DRM_XE_GEM_CPU_CACHING_WC 2850/**851* @cpu_caching: The CPU caching mode to select for this object. If852* mmaping the object the mode selected here will also be used. The853* exception is when mapping system memory (including data evicted854* to system) on discrete GPUs. The caching mode selected will855* then be overridden to DRM_XE_GEM_CPU_CACHING_WB, and coherency856* between GPU- and CPU is guaranteed. The caching mode of857* existing CPU-mappings will be updated transparently to858* user-space clients.859*/860__u16 cpu_caching;861/** @pad: MBZ */862__u16 pad[3];863864/** @reserved: Reserved */865__u64 reserved[2];866};867868/**869* struct drm_xe_gem_mmap_offset - Input of &DRM_IOCTL_XE_GEM_MMAP_OFFSET870*871* The @flags can be:872* - %DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER - For user to query special offset873* for use in mmap ioctl. Writing to the returned mmap address will generate a874* PCI memory barrier with low overhead (avoiding IOCTL call as well as writing875* to VRAM which would also add overhead), acting like an MI_MEM_FENCE876* instruction.877*878* Note: The mmap size can be at most 4K, due to HW limitations. As a result879* this interface is only supported on CPU architectures that support 4K page880* size. The mmap_offset ioctl will detect this and gracefully return an881* error, where userspace is expected to have a different fallback method for882* triggering a barrier.883*884* Roughly the usage would be as follows:885*886* .. code-block:: C887*888* struct drm_xe_gem_mmap_offset mmo = {889* .handle = 0, // must be set to 0890* .flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,891* };892*893* err = ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo);894* map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo.offset);895* map[i] = 0xdeadbeaf; // issue barrier896*/897struct drm_xe_gem_mmap_offset {898/** @extensions: Pointer to the first extension struct, if any */899__u64 extensions;900901/** @handle: Handle for the object being mapped. */902__u32 handle;903904#define DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER (1 << 0)905/** @flags: Flags */906__u32 flags;907908/** @offset: The fake offset to use for subsequent mmap call */909__u64 offset;910911/** @reserved: Reserved */912__u64 reserved[2];913};914915/**916* struct drm_xe_vm_create - Input of &DRM_IOCTL_XE_VM_CREATE917*918* The @flags can be:919* - %DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE - Map the whole virtual address920* space of the VM to scratch page. A vm_bind would overwrite the scratch921* page mapping. This flag is mutually exclusive with the922* %DRM_XE_VM_CREATE_FLAG_FAULT_MODE flag, with an exception of on x2 and923* xe3 platform.924* - %DRM_XE_VM_CREATE_FLAG_LR_MODE - An LR, or Long Running VM accepts925* exec submissions to its exec_queues that don't have an upper time926* limit on the job execution time. But exec submissions to these927* don't allow any of the sync types DRM_XE_SYNC_TYPE_SYNCOBJ,928* DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ, used as out-syncobjs, that is,929* together with sync flag DRM_XE_SYNC_FLAG_SIGNAL.930* LR VMs can be created in recoverable page-fault mode using931* DRM_XE_VM_CREATE_FLAG_FAULT_MODE, if the device supports it.932* If that flag is omitted, the UMD can not rely on the slightly933* different per-VM overcommit semantics that are enabled by934* DRM_XE_VM_CREATE_FLAG_FAULT_MODE (see below), but KMD may935* still enable recoverable pagefaults if supported by the device.936* - %DRM_XE_VM_CREATE_FLAG_FAULT_MODE - Requires also937* DRM_XE_VM_CREATE_FLAG_LR_MODE. It allows memory to be allocated on938* demand when accessed, and also allows per-VM overcommit of memory.939* The xe driver internally uses recoverable pagefaults to implement940* this.941*/942struct drm_xe_vm_create {943/** @extensions: Pointer to the first extension struct, if any */944__u64 extensions;945946#define DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE (1 << 0)947#define DRM_XE_VM_CREATE_FLAG_LR_MODE (1 << 1)948#define DRM_XE_VM_CREATE_FLAG_FAULT_MODE (1 << 2)949/** @flags: Flags */950__u32 flags;951952/** @vm_id: Returned VM ID */953__u32 vm_id;954955/** @reserved: Reserved */956__u64 reserved[2];957};958959/**960* struct drm_xe_vm_destroy - Input of &DRM_IOCTL_XE_VM_DESTROY961*/962struct drm_xe_vm_destroy {963/** @vm_id: VM ID */964__u32 vm_id;965966/** @pad: MBZ */967__u32 pad;968969/** @reserved: Reserved */970__u64 reserved[2];971};972973/**974* struct drm_xe_vm_bind_op - run bind operations975*976* The @op can be:977* - %DRM_XE_VM_BIND_OP_MAP978* - %DRM_XE_VM_BIND_OP_UNMAP979* - %DRM_XE_VM_BIND_OP_MAP_USERPTR980* - %DRM_XE_VM_BIND_OP_UNMAP_ALL981* - %DRM_XE_VM_BIND_OP_PREFETCH982*983* and the @flags can be:984* - %DRM_XE_VM_BIND_FLAG_READONLY - Setup the page tables as read-only985* to ensure write protection986* - %DRM_XE_VM_BIND_FLAG_IMMEDIATE - On a faulting VM, do the987* MAP operation immediately rather than deferring the MAP to the page988* fault handler. This is implied on a non-faulting VM as there is no989* fault handler to defer to.990* - %DRM_XE_VM_BIND_FLAG_NULL - When the NULL flag is set, the page991* tables are setup with a special bit which indicates writes are992* dropped and all reads return zero. In the future, the NULL flags993* will only be valid for DRM_XE_VM_BIND_OP_MAP operations, the BO994* handle MBZ, and the BO offset MBZ. This flag is intended to995* implement VK sparse bindings.996* - %DRM_XE_VM_BIND_FLAG_CHECK_PXP - If the object is encrypted via PXP,997* reject the binding if the encryption key is no longer valid. This998* flag has no effect on BOs that are not marked as using PXP.999* - %DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR - When the CPU address mirror flag is1000* set, no mappings are created rather the range is reserved for CPU address1001* mirroring which will be populated on GPU page faults or prefetches. Only1002* valid on VMs with DRM_XE_VM_CREATE_FLAG_FAULT_MODE set. The CPU address1003* mirror flag are only valid for DRM_XE_VM_BIND_OP_MAP operations, the BO1004* handle MBZ, and the BO offset MBZ.1005*/1006struct drm_xe_vm_bind_op {1007/** @extensions: Pointer to the first extension struct, if any */1008__u64 extensions;10091010/**1011* @obj: GEM object to operate on, MBZ for MAP_USERPTR, MBZ for UNMAP1012*/1013__u32 obj;10141015/**1016* @pat_index: The platform defined @pat_index to use for this mapping.1017* The index basically maps to some predefined memory attributes,1018* including things like caching, coherency, compression etc. The exact1019* meaning of the pat_index is platform specific and defined in the1020* Bspec and PRMs. When the KMD sets up the binding the index here is1021* encoded into the ppGTT PTE.1022*1023* For coherency the @pat_index needs to be at least 1way coherent when1024* drm_xe_gem_create.cpu_caching is DRM_XE_GEM_CPU_CACHING_WB. The KMD1025* will extract the coherency mode from the @pat_index and reject if1026* there is a mismatch (see note below for pre-MTL platforms).1027*1028* Note: On pre-MTL platforms there is only a caching mode and no1029* explicit coherency mode, but on such hardware there is always a1030* shared-LLC (or is dgpu) so all GT memory accesses are coherent with1031* CPU caches even with the caching mode set as uncached. It's only the1032* display engine that is incoherent (on dgpu it must be in VRAM which1033* is always mapped as WC on the CPU). However to keep the uapi somewhat1034* consistent with newer platforms the KMD groups the different cache1035* levels into the following coherency buckets on all pre-MTL platforms:1036*1037* ppGTT UC -> COH_NONE1038* ppGTT WC -> COH_NONE1039* ppGTT WT -> COH_NONE1040* ppGTT WB -> COH_AT_LEAST_1WAY1041*1042* In practice UC/WC/WT should only ever used for scanout surfaces on1043* such platforms (or perhaps in general for dma-buf if shared with1044* another device) since it is only the display engine that is actually1045* incoherent. Everything else should typically use WB given that we1046* have a shared-LLC. On MTL+ this completely changes and the HW1047* defines the coherency mode as part of the @pat_index, where1048* incoherent GT access is possible.1049*1050* Note: For userptr and externally imported dma-buf the kernel expects1051* either 1WAY or 2WAY for the @pat_index.1052*1053* For DRM_XE_VM_BIND_FLAG_NULL bindings there are no KMD restrictions1054* on the @pat_index. For such mappings there is no actual memory being1055* mapped (the address in the PTE is invalid), so the various PAT memory1056* attributes likely do not apply. Simply leaving as zero is one1057* option (still a valid pat_index). Same applies to1058* DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR bindings as for such mapping1059* there is no actual memory being mapped.1060*/1061__u16 pat_index;10621063/** @pad: MBZ */1064__u16 pad;10651066union {1067/**1068* @obj_offset: Offset into the object, MBZ for CLEAR_RANGE,1069* ignored for unbind1070*/1071__u64 obj_offset;10721073/** @userptr: user pointer to bind on */1074__u64 userptr;10751076/**1077* @cpu_addr_mirror_offset: Offset from GPU @addr to create1078* CPU address mirror mappings. MBZ with current level of1079* support (e.g. 1 to 1 mapping between GPU and CPU mappings1080* only supported).1081*/1082__s64 cpu_addr_mirror_offset;1083};10841085/**1086* @range: Number of bytes from the object to bind to addr, MBZ for UNMAP_ALL1087*/1088__u64 range;10891090/** @addr: Address to operate on, MBZ for UNMAP_ALL */1091__u64 addr;10921093#define DRM_XE_VM_BIND_OP_MAP 0x01094#define DRM_XE_VM_BIND_OP_UNMAP 0x11095#define DRM_XE_VM_BIND_OP_MAP_USERPTR 0x21096#define DRM_XE_VM_BIND_OP_UNMAP_ALL 0x31097#define DRM_XE_VM_BIND_OP_PREFETCH 0x41098/** @op: Bind operation to perform */1099__u32 op;11001101#define DRM_XE_VM_BIND_FLAG_READONLY (1 << 0)1102#define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)1103#define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)1104#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)1105#define DRM_XE_VM_BIND_FLAG_CHECK_PXP (1 << 4)1106#define DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR (1 << 5)1107/** @flags: Bind flags */1108__u32 flags;11091110/**1111* @prefetch_mem_region_instance: Memory region to prefetch VMA to.1112* It is a region instance, not a mask.1113* To be used only with %DRM_XE_VM_BIND_OP_PREFETCH operation.1114*/1115__u32 prefetch_mem_region_instance;11161117/** @pad2: MBZ */1118__u32 pad2;11191120/** @reserved: Reserved */1121__u64 reserved[3];1122};11231124/**1125* struct drm_xe_vm_bind - Input of &DRM_IOCTL_XE_VM_BIND1126*1127* Below is an example of a minimal use of @drm_xe_vm_bind to1128* asynchronously bind the buffer `data` at address `BIND_ADDRESS` to1129* illustrate `userptr`. It can be synchronized by using the example1130* provided for @drm_xe_sync.1131*1132* .. code-block:: C1133*1134* data = aligned_alloc(ALIGNMENT, BO_SIZE);1135* struct drm_xe_vm_bind bind = {1136* .vm_id = vm,1137* .num_binds = 1,1138* .bind.obj = 0,1139* .bind.obj_offset = to_user_pointer(data),1140* .bind.range = BO_SIZE,1141* .bind.addr = BIND_ADDRESS,1142* .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR,1143* .bind.flags = 0,1144* .num_syncs = 1,1145* .syncs = &sync,1146* .exec_queue_id = 0,1147* };1148* ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);1149*1150*/1151struct drm_xe_vm_bind {1152/** @extensions: Pointer to the first extension struct, if any */1153__u64 extensions;11541155/** @vm_id: The ID of the VM to bind to */1156__u32 vm_id;11571158/**1159* @exec_queue_id: exec_queue_id, must be of class DRM_XE_ENGINE_CLASS_VM_BIND1160* and exec queue must have same vm_id. If zero, the default VM bind engine1161* is used.1162*/1163__u32 exec_queue_id;11641165/** @pad: MBZ */1166__u32 pad;11671168/** @num_binds: number of binds in this IOCTL */1169__u32 num_binds;11701171union {1172/** @bind: used if num_binds == 1 */1173struct drm_xe_vm_bind_op bind;11741175/**1176* @vector_of_binds: userptr to array of struct1177* drm_xe_vm_bind_op if num_binds > 11178*/1179__u64 vector_of_binds;1180};11811182/** @pad2: MBZ */1183__u32 pad2;11841185/** @num_syncs: amount of syncs to wait on */1186__u32 num_syncs;11871188/** @syncs: pointer to struct drm_xe_sync array */1189__u64 syncs;11901191/** @reserved: Reserved */1192__u64 reserved[2];1193};11941195/**1196* struct drm_xe_exec_queue_create - Input of &DRM_IOCTL_XE_EXEC_QUEUE_CREATE1197*1198* This ioctl supports setting the following properties via the1199* %DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY extension, which uses the1200* generic @drm_xe_ext_set_property struct:1201*1202* - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY - set the queue priority.1203* CAP_SYS_NICE is required to set a value above normal.1204* - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_TIMESLICE - set the queue timeslice1205* duration in microseconds.1206* - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PXP_TYPE - set the type of PXP session1207* this queue will be used with. Valid values are listed in enum1208* drm_xe_pxp_session_type. %DRM_XE_PXP_TYPE_NONE is the default behavior, so1209* there is no need to explicitly set that. When a queue of type1210* %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session1211* (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.1212* The user is expected to query the PXP status via the query ioctl (see1213* %DRM_XE_DEVICE_QUERY_PXP_STATUS) and to wait for PXP to be ready before1214* attempting to create a queue with this property. When a queue is created1215* before PXP is ready, the ioctl will return -EBUSY if init is still in1216* progress or -EIO if init failed.1217* Given that going into a power-saving state kills PXP HWDRM sessions,1218* runtime PM will be blocked while queues of this type are alive.1219* All PXP queues will be killed if a PXP invalidation event occurs.1220*1221* The example below shows how to use @drm_xe_exec_queue_create to create1222* a simple exec_queue (no parallel submission) of class1223* &DRM_XE_ENGINE_CLASS_RENDER.1224*1225* .. code-block:: C1226*1227* struct drm_xe_engine_class_instance instance = {1228* .engine_class = DRM_XE_ENGINE_CLASS_RENDER,1229* };1230* struct drm_xe_exec_queue_create exec_queue_create = {1231* .extensions = 0,1232* .vm_id = vm,1233* .num_bb_per_exec = 1,1234* .num_eng_per_bb = 1,1235* .instances = to_user_pointer(&instance),1236* };1237* ioctl(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &exec_queue_create);1238*1239* Allow users to provide a hint to kernel for cases demanding low latency1240* profile. Please note it will have impact on power consumption. User can1241* indicate low latency hint with flag while creating exec queue as1242* mentioned below,1243*1244* struct drm_xe_exec_queue_create exec_queue_create = {1245* .flags = DRM_XE_EXEC_QUEUE_LOW_LATENCY_HINT,1246* .extensions = 0,1247* .vm_id = vm,1248* .num_bb_per_exec = 1,1249* .num_eng_per_bb = 1,1250* .instances = to_user_pointer(&instance),1251* };1252* ioctl(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, &exec_queue_create);1253*1254*/1255struct drm_xe_exec_queue_create {1256#define DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY 01257#define DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY 01258#define DRM_XE_EXEC_QUEUE_SET_PROPERTY_TIMESLICE 11259#define DRM_XE_EXEC_QUEUE_SET_PROPERTY_PXP_TYPE 21260/** @extensions: Pointer to the first extension struct, if any */1261__u64 extensions;12621263/** @width: submission width (number BB per exec) for this exec queue */1264__u16 width;12651266/** @num_placements: number of valid placements for this exec queue */1267__u16 num_placements;12681269/** @vm_id: VM to use for this exec queue */1270__u32 vm_id;12711272#define DRM_XE_EXEC_QUEUE_LOW_LATENCY_HINT (1 << 0)1273/** @flags: flags to use for this exec queue */1274__u32 flags;12751276/** @exec_queue_id: Returned exec queue ID */1277__u32 exec_queue_id;12781279/**1280* @instances: user pointer to a 2-d array of struct1281* drm_xe_engine_class_instance1282*1283* length = width (i) * num_placements (j)1284* index = j + i * width1285*/1286__u64 instances;12871288/** @reserved: Reserved */1289__u64 reserved[2];1290};12911292/**1293* struct drm_xe_exec_queue_destroy - Input of &DRM_IOCTL_XE_EXEC_QUEUE_DESTROY1294*/1295struct drm_xe_exec_queue_destroy {1296/** @exec_queue_id: Exec queue ID */1297__u32 exec_queue_id;12981299/** @pad: MBZ */1300__u32 pad;13011302/** @reserved: Reserved */1303__u64 reserved[2];1304};13051306/**1307* struct drm_xe_exec_queue_get_property - Input of &DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY1308*1309* The @property can be:1310* - %DRM_XE_EXEC_QUEUE_GET_PROPERTY_BAN1311*/1312struct drm_xe_exec_queue_get_property {1313/** @extensions: Pointer to the first extension struct, if any */1314__u64 extensions;13151316/** @exec_queue_id: Exec queue ID */1317__u32 exec_queue_id;13181319#define DRM_XE_EXEC_QUEUE_GET_PROPERTY_BAN 01320/** @property: property to get */1321__u32 property;13221323/** @value: property value */1324__u64 value;13251326/** @reserved: Reserved */1327__u64 reserved[2];1328};13291330/**1331* struct drm_xe_sync - sync object1332*1333* The @type can be:1334* - %DRM_XE_SYNC_TYPE_SYNCOBJ1335* - %DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ1336* - %DRM_XE_SYNC_TYPE_USER_FENCE1337*1338* and the @flags can be:1339* - %DRM_XE_SYNC_FLAG_SIGNAL1340*1341* A minimal use of @drm_xe_sync looks like this:1342*1343* .. code-block:: C1344*1345* struct drm_xe_sync sync = {1346* .flags = DRM_XE_SYNC_FLAG_SIGNAL,1347* .type = DRM_XE_SYNC_TYPE_SYNCOBJ,1348* };1349* struct drm_syncobj_create syncobj_create = { 0 };1350* ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &syncobj_create);1351* sync.handle = syncobj_create.handle;1352* ...1353* use of &sync in drm_xe_exec or drm_xe_vm_bind1354* ...1355* struct drm_syncobj_wait wait = {1356* .handles = &sync.handle,1357* .timeout_nsec = INT64_MAX,1358* .count_handles = 1,1359* .flags = 0,1360* .first_signaled = 0,1361* .pad = 0,1362* };1363* ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);1364*/1365struct drm_xe_sync {1366/** @extensions: Pointer to the first extension struct, if any */1367__u64 extensions;13681369#define DRM_XE_SYNC_TYPE_SYNCOBJ 0x01370#define DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ 0x11371#define DRM_XE_SYNC_TYPE_USER_FENCE 0x21372/** @type: Type of the this sync object */1373__u32 type;13741375#define DRM_XE_SYNC_FLAG_SIGNAL (1 << 0)1376/** @flags: Sync Flags */1377__u32 flags;13781379union {1380/** @handle: Handle for the object */1381__u32 handle;13821383/**1384* @addr: Address of user fence. When sync is passed in via exec1385* IOCTL this is a GPU address in the VM. When sync passed in via1386* VM bind IOCTL this is a user pointer. In either case, it is1387* the users responsibility that this address is present and1388* mapped when the user fence is signalled. Must be qword1389* aligned.1390*/1391__u64 addr;1392};13931394/**1395* @timeline_value: Input for the timeline sync object. Needs to be1396* different than 0 when used with %DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ.1397*/1398__u64 timeline_value;13991400/** @reserved: Reserved */1401__u64 reserved[2];1402};14031404/**1405* struct drm_xe_exec - Input of &DRM_IOCTL_XE_EXEC1406*1407* This is an example to use @drm_xe_exec for execution of the object1408* at BIND_ADDRESS (see example in @drm_xe_vm_bind) by an exec_queue1409* (see example in @drm_xe_exec_queue_create). It can be synchronized1410* by using the example provided for @drm_xe_sync.1411*1412* .. code-block:: C1413*1414* struct drm_xe_exec exec = {1415* .exec_queue_id = exec_queue,1416* .syncs = &sync,1417* .num_syncs = 1,1418* .address = BIND_ADDRESS,1419* .num_batch_buffer = 1,1420* };1421* ioctl(fd, DRM_IOCTL_XE_EXEC, &exec);1422*1423*/1424struct drm_xe_exec {1425/** @extensions: Pointer to the first extension struct, if any */1426__u64 extensions;14271428/** @exec_queue_id: Exec queue ID for the batch buffer */1429__u32 exec_queue_id;14301431/** @num_syncs: Amount of struct drm_xe_sync in array. */1432__u32 num_syncs;14331434/** @syncs: Pointer to struct drm_xe_sync array. */1435__u64 syncs;14361437/**1438* @address: address of batch buffer if num_batch_buffer == 1 or an1439* array of batch buffer addresses1440*/1441__u64 address;14421443/**1444* @num_batch_buffer: number of batch buffer in this exec, must match1445* the width of the engine1446*/1447__u16 num_batch_buffer;14481449/** @pad: MBZ */1450__u16 pad[3];14511452/** @reserved: Reserved */1453__u64 reserved[2];1454};14551456/**1457* struct drm_xe_wait_user_fence - Input of &DRM_IOCTL_XE_WAIT_USER_FENCE1458*1459* Wait on user fence, XE will wake-up on every HW engine interrupt in the1460* instances list and check if user fence is complete::1461*1462* (*addr & MASK) OP (VALUE & MASK)1463*1464* Returns to user on user fence completion or timeout.1465*1466* The @op can be:1467* - %DRM_XE_UFENCE_WAIT_OP_EQ1468* - %DRM_XE_UFENCE_WAIT_OP_NEQ1469* - %DRM_XE_UFENCE_WAIT_OP_GT1470* - %DRM_XE_UFENCE_WAIT_OP_GTE1471* - %DRM_XE_UFENCE_WAIT_OP_LT1472* - %DRM_XE_UFENCE_WAIT_OP_LTE1473*1474* and the @flags can be:1475* - %DRM_XE_UFENCE_WAIT_FLAG_ABSTIME1476* - %DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP1477*1478* The @mask values can be for example:1479* - 0xffu for u81480* - 0xffffu for u161481* - 0xffffffffu for u321482* - 0xffffffffffffffffu for u641483*/1484struct drm_xe_wait_user_fence {1485/** @extensions: Pointer to the first extension struct, if any */1486__u64 extensions;14871488/**1489* @addr: user pointer address to wait on, must qword aligned1490*/1491__u64 addr;14921493#define DRM_XE_UFENCE_WAIT_OP_EQ 0x01494#define DRM_XE_UFENCE_WAIT_OP_NEQ 0x11495#define DRM_XE_UFENCE_WAIT_OP_GT 0x21496#define DRM_XE_UFENCE_WAIT_OP_GTE 0x31497#define DRM_XE_UFENCE_WAIT_OP_LT 0x41498#define DRM_XE_UFENCE_WAIT_OP_LTE 0x51499/** @op: wait operation (type of comparison) */1500__u16 op;15011502#define DRM_XE_UFENCE_WAIT_FLAG_ABSTIME (1 << 0)1503/** @flags: wait flags */1504__u16 flags;15051506/** @pad: MBZ */1507__u32 pad;15081509/** @value: compare value */1510__u64 value;15111512/** @mask: comparison mask */1513__u64 mask;15141515/**1516* @timeout: how long to wait before bailing, value in nanoseconds.1517* Without DRM_XE_UFENCE_WAIT_FLAG_ABSTIME flag set (relative timeout)1518* it contains timeout expressed in nanoseconds to wait (fence will1519* expire at now() + timeout).1520* When DRM_XE_UFENCE_WAIT_FLAG_ABSTIME flat is set (absolute timeout) wait1521* will end at timeout (uses system MONOTONIC_CLOCK).1522* Passing negative timeout leads to neverending wait.1523*1524* On relative timeout this value is updated with timeout left1525* (for restarting the call in case of signal delivery).1526* On absolute timeout this value stays intact (restarted call still1527* expire at the same point of time).1528*/1529__s64 timeout;15301531/** @exec_queue_id: exec_queue_id returned from xe_exec_queue_create_ioctl */1532__u32 exec_queue_id;15331534/** @pad2: MBZ */1535__u32 pad2;15361537/** @reserved: Reserved */1538__u64 reserved[2];1539};15401541/**1542* enum drm_xe_observation_type - Observation stream types1543*/1544enum drm_xe_observation_type {1545/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */1546DRM_XE_OBSERVATION_TYPE_OA,1547/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */1548DRM_XE_OBSERVATION_TYPE_EU_STALL,1549};15501551/**1552* enum drm_xe_observation_op - Observation stream ops1553*/1554enum drm_xe_observation_op {1555/** @DRM_XE_OBSERVATION_OP_STREAM_OPEN: Open an observation stream */1556DRM_XE_OBSERVATION_OP_STREAM_OPEN,15571558/** @DRM_XE_OBSERVATION_OP_ADD_CONFIG: Add observation stream config */1559DRM_XE_OBSERVATION_OP_ADD_CONFIG,15601561/** @DRM_XE_OBSERVATION_OP_REMOVE_CONFIG: Remove observation stream config */1562DRM_XE_OBSERVATION_OP_REMOVE_CONFIG,1563};15641565/**1566* struct drm_xe_observation_param - Input of &DRM_XE_OBSERVATION1567*1568* The observation layer enables multiplexing observation streams of1569* multiple types. The actual params for a particular stream operation are1570* supplied via the @param pointer (use __copy_from_user to get these1571* params).1572*/1573struct drm_xe_observation_param {1574/** @extensions: Pointer to the first extension struct, if any */1575__u64 extensions;1576/** @observation_type: observation stream type, of enum @drm_xe_observation_type */1577__u64 observation_type;1578/** @observation_op: observation stream op, of enum @drm_xe_observation_op */1579__u64 observation_op;1580/** @param: Pointer to actual stream params */1581__u64 param;1582};15831584/**1585* enum drm_xe_observation_ioctls - Observation stream fd ioctl's1586*1587* Information exchanged between userspace and kernel for observation fd1588* ioctl's is stream type specific1589*/1590enum drm_xe_observation_ioctls {1591/** @DRM_XE_OBSERVATION_IOCTL_ENABLE: Enable data capture for an observation stream */1592DRM_XE_OBSERVATION_IOCTL_ENABLE = _IO('i', 0x0),15931594/** @DRM_XE_OBSERVATION_IOCTL_DISABLE: Disable data capture for a observation stream */1595DRM_XE_OBSERVATION_IOCTL_DISABLE = _IO('i', 0x1),15961597/** @DRM_XE_OBSERVATION_IOCTL_CONFIG: Change observation stream configuration */1598DRM_XE_OBSERVATION_IOCTL_CONFIG = _IO('i', 0x2),15991600/** @DRM_XE_OBSERVATION_IOCTL_STATUS: Return observation stream status */1601DRM_XE_OBSERVATION_IOCTL_STATUS = _IO('i', 0x3),16021603/** @DRM_XE_OBSERVATION_IOCTL_INFO: Return observation stream info */1604DRM_XE_OBSERVATION_IOCTL_INFO = _IO('i', 0x4),1605};16061607/**1608* enum drm_xe_oa_unit_type - OA unit types1609*/1610enum drm_xe_oa_unit_type {1611/**1612* @DRM_XE_OA_UNIT_TYPE_OAG: OAG OA unit. OAR/OAC are considered1613* sub-types of OAG. For OAR/OAC, use OAG.1614*/1615DRM_XE_OA_UNIT_TYPE_OAG,16161617/** @DRM_XE_OA_UNIT_TYPE_OAM: OAM OA unit */1618DRM_XE_OA_UNIT_TYPE_OAM,16191620/** @DRM_XE_OA_UNIT_TYPE_OAM_SAG: OAM_SAG OA unit */1621DRM_XE_OA_UNIT_TYPE_OAM_SAG,1622};16231624/**1625* struct drm_xe_oa_unit - describe OA unit1626*/1627struct drm_xe_oa_unit {1628/** @extensions: Pointer to the first extension struct, if any */1629__u64 extensions;16301631/** @oa_unit_id: OA unit ID */1632__u32 oa_unit_id;16331634/** @oa_unit_type: OA unit type of @drm_xe_oa_unit_type */1635__u32 oa_unit_type;16361637/** @capabilities: OA capabilities bit-mask */1638__u64 capabilities;1639#define DRM_XE_OA_CAPS_BASE (1 << 0)1640#define DRM_XE_OA_CAPS_SYNCS (1 << 1)1641#define DRM_XE_OA_CAPS_OA_BUFFER_SIZE (1 << 2)1642#define DRM_XE_OA_CAPS_WAIT_NUM_REPORTS (1 << 3)1643#define DRM_XE_OA_CAPS_OAM (1 << 4)16441645/** @oa_timestamp_freq: OA timestamp freq */1646__u64 oa_timestamp_freq;16471648/** @reserved: MBZ */1649__u64 reserved[4];16501651/** @num_engines: number of engines in @eci array */1652__u64 num_engines;16531654/** @eci: engines attached to this OA unit */1655struct drm_xe_engine_class_instance eci[];1656};16571658/**1659* struct drm_xe_query_oa_units - describe OA units1660*1661* If a query is made with a struct drm_xe_device_query where .query1662* is equal to DRM_XE_DEVICE_QUERY_OA_UNITS, then the reply uses struct1663* drm_xe_query_oa_units in .data.1664*1665* OA unit properties for all OA units can be accessed using a code block1666* such as the one below:1667*1668* .. code-block:: C1669*1670* struct drm_xe_query_oa_units *qoa;1671* struct drm_xe_oa_unit *oau;1672* u8 *poau;1673*1674* // malloc qoa and issue DRM_XE_DEVICE_QUERY_OA_UNITS. Then:1675* poau = (u8 *)&qoa->oa_units[0];1676* for (int i = 0; i < qoa->num_oa_units; i++) {1677* oau = (struct drm_xe_oa_unit *)poau;1678* // Access 'struct drm_xe_oa_unit' fields here1679* poau += sizeof(*oau) + oau->num_engines * sizeof(oau->eci[0]);1680* }1681*/1682struct drm_xe_query_oa_units {1683/** @extensions: Pointer to the first extension struct, if any */1684__u64 extensions;1685/** @num_oa_units: number of OA units returned in oau[] */1686__u32 num_oa_units;1687/** @pad: MBZ */1688__u32 pad;1689/**1690* @oa_units: struct @drm_xe_oa_unit array returned for this device.1691* Written below as a u64 array to avoid problems with nested flexible1692* arrays with some compilers1693*/1694__u64 oa_units[];1695};16961697/**1698* enum drm_xe_oa_format_type - OA format types as specified in PRM/Bspec1699* 52198/609421700*/1701enum drm_xe_oa_format_type {1702/** @DRM_XE_OA_FMT_TYPE_OAG: OAG report format */1703DRM_XE_OA_FMT_TYPE_OAG,1704/** @DRM_XE_OA_FMT_TYPE_OAR: OAR report format */1705DRM_XE_OA_FMT_TYPE_OAR,1706/** @DRM_XE_OA_FMT_TYPE_OAM: OAM report format */1707DRM_XE_OA_FMT_TYPE_OAM,1708/** @DRM_XE_OA_FMT_TYPE_OAC: OAC report format */1709DRM_XE_OA_FMT_TYPE_OAC,1710/** @DRM_XE_OA_FMT_TYPE_OAM_MPEC: OAM SAMEDIA or OAM MPEC report format */1711DRM_XE_OA_FMT_TYPE_OAM_MPEC,1712/** @DRM_XE_OA_FMT_TYPE_PEC: PEC report format */1713DRM_XE_OA_FMT_TYPE_PEC,1714};17151716/**1717* enum drm_xe_oa_property_id - OA stream property id's1718*1719* Stream params are specified as a chain of @drm_xe_ext_set_property1720* struct's, with @property values from enum @drm_xe_oa_property_id and1721* @drm_xe_user_extension base.name set to @DRM_XE_OA_EXTENSION_SET_PROPERTY.1722* @param field in struct @drm_xe_observation_param points to the first1723* @drm_xe_ext_set_property struct.1724*1725* Exactly the same mechanism is also used for stream reconfiguration using the1726* @DRM_XE_OBSERVATION_IOCTL_CONFIG observation stream fd ioctl, though only a1727* subset of properties below can be specified for stream reconfiguration.1728*/1729enum drm_xe_oa_property_id {1730#define DRM_XE_OA_EXTENSION_SET_PROPERTY 01731/**1732* @DRM_XE_OA_PROPERTY_OA_UNIT_ID: ID of the OA unit on which to open1733* the OA stream, see @oa_unit_id in 'struct1734* drm_xe_query_oa_units'. Defaults to 0 if not provided.1735*/1736DRM_XE_OA_PROPERTY_OA_UNIT_ID = 1,17371738/**1739* @DRM_XE_OA_PROPERTY_SAMPLE_OA: A value of 1 requests inclusion of raw1740* OA unit reports or stream samples in a global buffer attached to an1741* OA unit.1742*/1743DRM_XE_OA_PROPERTY_SAMPLE_OA,17441745/**1746* @DRM_XE_OA_PROPERTY_OA_METRIC_SET: OA metrics defining contents of OA1747* reports, previously added via @DRM_XE_OBSERVATION_OP_ADD_CONFIG.1748*/1749DRM_XE_OA_PROPERTY_OA_METRIC_SET,17501751/** @DRM_XE_OA_PROPERTY_OA_FORMAT: OA counter report format */1752DRM_XE_OA_PROPERTY_OA_FORMAT,1753/*1754* OA_FORMAT's are specified the same way as in PRM/Bspec 52198/60942,1755* in terms of the following quantities: a. enum @drm_xe_oa_format_type1756* b. Counter select c. Counter size and d. BC report. Also refer to the1757* oa_formats array in drivers/gpu/drm/xe/xe_oa.c.1758*/1759#define DRM_XE_OA_FORMAT_MASK_FMT_TYPE (0xffu << 0)1760#define DRM_XE_OA_FORMAT_MASK_COUNTER_SEL (0xffu << 8)1761#define DRM_XE_OA_FORMAT_MASK_COUNTER_SIZE (0xffu << 16)1762#define DRM_XE_OA_FORMAT_MASK_BC_REPORT (0xffu << 24)17631764/**1765* @DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT: Requests periodic OA unit1766* sampling with sampling frequency proportional to 2^(period_exponent + 1)1767*/1768DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT,17691770/**1771* @DRM_XE_OA_PROPERTY_OA_DISABLED: A value of 1 will open the OA1772* stream in a DISABLED state (see @DRM_XE_OBSERVATION_IOCTL_ENABLE).1773*/1774DRM_XE_OA_PROPERTY_OA_DISABLED,17751776/**1777* @DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID: Open the stream for a specific1778* @exec_queue_id. OA queries can be executed on this exec queue.1779*/1780DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID,17811782/**1783* @DRM_XE_OA_PROPERTY_OA_ENGINE_INSTANCE: Optional engine instance to1784* pass along with @DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID or will default to 0.1785*/1786DRM_XE_OA_PROPERTY_OA_ENGINE_INSTANCE,17871788/**1789* @DRM_XE_OA_PROPERTY_NO_PREEMPT: Allow preemption and timeslicing1790* to be disabled for the stream exec queue.1791*/1792DRM_XE_OA_PROPERTY_NO_PREEMPT,17931794/**1795* @DRM_XE_OA_PROPERTY_NUM_SYNCS: Number of syncs in the sync array1796* specified in @DRM_XE_OA_PROPERTY_SYNCS1797*/1798DRM_XE_OA_PROPERTY_NUM_SYNCS,17991800/**1801* @DRM_XE_OA_PROPERTY_SYNCS: Pointer to struct @drm_xe_sync array1802* with array size specified via @DRM_XE_OA_PROPERTY_NUM_SYNCS. OA1803* configuration will wait till input fences signal. Output fences1804* will signal after the new OA configuration takes effect. For1805* @DRM_XE_SYNC_TYPE_USER_FENCE, @addr is a user pointer, similar1806* to the VM bind case.1807*/1808DRM_XE_OA_PROPERTY_SYNCS,18091810/**1811* @DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE: Size of OA buffer to be1812* allocated by the driver in bytes. Supported sizes are powers of1813* 2 from 128 KiB to 128 MiB. When not specified, a 16 MiB OA1814* buffer is allocated by default.1815*/1816DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE,18171818/**1819* @DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS: Number of reports to wait1820* for before unblocking poll or read1821*/1822DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS,1823};18241825/**1826* struct drm_xe_oa_config - OA metric configuration1827*1828* Multiple OA configs can be added using @DRM_XE_OBSERVATION_OP_ADD_CONFIG. A1829* particular config can be specified when opening an OA stream using1830* @DRM_XE_OA_PROPERTY_OA_METRIC_SET property.1831*/1832struct drm_xe_oa_config {1833/** @extensions: Pointer to the first extension struct, if any */1834__u64 extensions;18351836/** @uuid: String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x" */1837char uuid[36];18381839/** @n_regs: Number of regs in @regs_ptr */1840__u32 n_regs;18411842/**1843* @regs_ptr: Pointer to (register address, value) pairs for OA config1844* registers. Expected length of buffer is: (2 * sizeof(u32) * @n_regs).1845*/1846__u64 regs_ptr;1847};18481849/**1850* struct drm_xe_oa_stream_status - OA stream status returned from1851* @DRM_XE_OBSERVATION_IOCTL_STATUS observation stream fd ioctl. Userspace can1852* call the ioctl to query stream status in response to EIO errno from1853* observation fd read().1854*/1855struct drm_xe_oa_stream_status {1856/** @extensions: Pointer to the first extension struct, if any */1857__u64 extensions;18581859/** @oa_status: OA stream status (see Bspec 46717/61226) */1860__u64 oa_status;1861#define DRM_XE_OASTATUS_MMIO_TRG_Q_FULL (1 << 3)1862#define DRM_XE_OASTATUS_COUNTER_OVERFLOW (1 << 2)1863#define DRM_XE_OASTATUS_BUFFER_OVERFLOW (1 << 1)1864#define DRM_XE_OASTATUS_REPORT_LOST (1 << 0)18651866/** @reserved: reserved for future use */1867__u64 reserved[3];1868};18691870/**1871* struct drm_xe_oa_stream_info - OA stream info returned from1872* @DRM_XE_OBSERVATION_IOCTL_INFO observation stream fd ioctl1873*/1874struct drm_xe_oa_stream_info {1875/** @extensions: Pointer to the first extension struct, if any */1876__u64 extensions;18771878/** @oa_buf_size: OA buffer size */1879__u64 oa_buf_size;18801881/** @reserved: reserved for future use */1882__u64 reserved[3];1883};18841885/**1886* enum drm_xe_pxp_session_type - Supported PXP session types.1887*1888* We currently only support HWDRM sessions, which are used for protected1889* content that ends up being displayed, but the HW supports multiple types, so1890* we might extend support in the future.1891*/1892enum drm_xe_pxp_session_type {1893/** @DRM_XE_PXP_TYPE_NONE: PXP not used */1894DRM_XE_PXP_TYPE_NONE = 0,1895/**1896* @DRM_XE_PXP_TYPE_HWDRM: HWDRM sessions are used for content that ends1897* up on the display.1898*/1899DRM_XE_PXP_TYPE_HWDRM = 1,1900};19011902/* ID of the protected content session managed by Xe when PXP is active */1903#define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf19041905/**1906* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids.1907*1908* These properties are passed to the driver at open as a chain of1909* @drm_xe_ext_set_property structures with @property set to these1910* properties' enums and @value set to the corresponding values of these1911* properties. @drm_xe_user_extension base.name should be set to1912* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY.1913*1914* With the file descriptor obtained from open, user space must enable1915* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before1916* calling read(). EIO errno from read() indicates HW dropped data1917* due to full buffer.1918*/1919enum drm_xe_eu_stall_property_id {1920#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 01921/**1922* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which1923* EU stall data will be captured.1924*/1925DRM_XE_EU_STALL_PROP_GT_ID = 1,19261927/**1928* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate in1929* GPU cycles from @sampling_rates in struct @drm_xe_query_eu_stall1930*/1931DRM_XE_EU_STALL_PROP_SAMPLE_RATE,19321933/**1934* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of1935* EU stall data reports to be present in the kernel buffer1936* before unblocking a blocked poll or read.1937*/1938DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS,1939};19401941/**1942* struct drm_xe_query_eu_stall - Information about EU stall sampling.1943*1944* If a query is made with a struct @drm_xe_device_query where .query1945* is equal to @DRM_XE_DEVICE_QUERY_EU_STALL, then the reply uses1946* struct @drm_xe_query_eu_stall in .data.1947*/1948struct drm_xe_query_eu_stall {1949/** @extensions: Pointer to the first extension struct, if any */1950__u64 extensions;19511952/** @capabilities: EU stall capabilities bit-mask */1953__u64 capabilities;1954#define DRM_XE_EU_STALL_CAPS_BASE (1 << 0)19551956/** @record_size: size of each EU stall data record */1957__u64 record_size;19581959/** @per_xecore_buf_size: internal per XeCore buffer size */1960__u64 per_xecore_buf_size;19611962/** @reserved: Reserved */1963__u64 reserved[5];19641965/** @num_sampling_rates: Number of sampling rates in @sampling_rates array */1966__u64 num_sampling_rates;19671968/**1969* @sampling_rates: Flexible array of sampling rates1970* sorted in the fastest to slowest order.1971* Sampling rates are specified in GPU clock cycles.1972*/1973__u64 sampling_rates[];1974};19751976#if defined(__cplusplus)1977}1978#endif19791980#endif /* _UAPI_XE_DRM_H_ */198119821983