1 /* 2 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 */ 26 27 #ifndef _UAPI_I915_DRM_H_ 28 #define _UAPI_I915_DRM_H_ 29 30 #include "drm.h" 31 32 #if defined(__cplusplus) 33 extern "C" { 34 #endif 35 36 /* Please note that modifications to all structs defined here are 37 * subject to backwards-compatibility constraints. 38 */ 39 40 /** 41 * DOC: uevents generated by i915 on it's device node 42 * 43 * I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch 44 * event from the gpu l3 cache. Additional information supplied is ROW, 45 * BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep 46 * track of these events and if a specific cache-line seems to have a 47 * persistent error remap it with the l3 remapping tool supplied in 48 * intel-gpu-tools. The value supplied with the event is always 1. 49 * 50 * I915_ERROR_UEVENT - Generated upon error detection, currently only via 51 * hangcheck. The error detection event is a good indicator of when things 52 * began to go badly. The value supplied with the event is a 1 upon error 53 * detection, and a 0 upon reset completion, signifying no more error 54 * exists. NOTE: Disabling hangcheck or reset via module parameter will 55 * cause the related events to not be seen. 56 * 57 * I915_RESET_UEVENT - Event is generated just before an attempt to reset the 58 * GPU. The value supplied with the event is always 1. NOTE: Disable 59 * reset via module parameter will cause this event to not be seen. 60 */ 61 #define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR" 62 #define I915_ERROR_UEVENT "ERROR" 63 #define I915_RESET_UEVENT "RESET" 64 65 /** 66 * struct i915_user_extension - Base class for defining a chain of extensions 67 * 68 * Many interfaces need to grow over time. In most cases we can simply 69 * extend the struct and have userspace pass in more data. Another option, 70 * as demonstrated by Vulkan's approach to providing extensions for forward 71 * and backward compatibility, is to use a list of optional structs to 72 * provide those extra details. 73 * 74 * The key advantage to using an extension chain is that it allows us to 75 * redefine the interface more easily than an ever growing struct of 76 * increasing complexity, and for large parts of that interface to be 77 * entirely optional. The downside is more pointer chasing; chasing across 78 * the __user boundary with pointers encapsulated inside u64. 79 * 80 * Example chaining: 81 * 82 * .. code-block:: C 83 * 84 * struct i915_user_extension ext3 { 85 * .next_extension = 0, // end 86 * .name = ..., 87 * }; 88 * struct i915_user_extension ext2 { 89 * .next_extension = (uintptr_t)&ext3, 90 * .name = ..., 91 * }; 92 * struct i915_user_extension ext1 { 93 * .next_extension = (uintptr_t)&ext2, 94 * .name = ..., 95 * }; 96 * 97 * Typically the struct i915_user_extension would be embedded in some uAPI 98 * struct, and in this case we would feed it the head of the chain(i.e ext1), 99 * which would then apply all of the above extensions. 100 * 101 */ 102 struct i915_user_extension { 103 /** 104 * @next_extension: 105 * 106 * Pointer to the next struct i915_user_extension, or zero if the end. 107 */ 108 __u64 next_extension; 109 /** 110 * @name: Name of the extension. 111 * 112 * Note that the name here is just some integer. 113 * 114 * Also note that the name space for this is not global for the whole 115 * driver, but rather its scope/meaning is limited to the specific piece 116 * of uAPI which has embedded the struct i915_user_extension. 117 */ 118 __u32 name; 119 /** 120 * @flags: MBZ 121 * 122 * All undefined bits must be zero. 123 */ 124 __u32 flags; 125 /** 126 * @rsvd: MBZ 127 * 128 * Reserved for future use; must be zero. 129 */ 130 __u32 rsvd[4]; 131 }; 132 133 /* 134 * MOCS indexes used for GPU surfaces, defining the cacheability of the 135 * surface data and the coherency for this data wrt. CPU vs. GPU accesses. 136 */ 137 enum i915_mocs_table_index { 138 /* 139 * Not cached anywhere, coherency between CPU and GPU accesses is 140 * guaranteed. 141 */ 142 I915_MOCS_UNCACHED, 143 /* 144 * Cacheability and coherency controlled by the kernel automatically 145 * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current 146 * usage of the surface (used for display scanout or not). 147 */ 148 I915_MOCS_PTE, 149 /* 150 * Cached in all GPU caches available on the platform. 151 * Coherency between CPU and GPU accesses to the surface is not 152 * guaranteed without extra synchronization. 153 */ 154 I915_MOCS_CACHED, 155 }; 156 157 /* 158 * Different engines serve different roles, and there may be more than one 159 * engine serving each role. enum drm_i915_gem_engine_class provides a 160 * classification of the role of the engine, which may be used when requesting 161 * operations to be performed on a certain subset of engines, or for providing 162 * information about that group. 163 */ 164 enum drm_i915_gem_engine_class { 165 I915_ENGINE_CLASS_RENDER = 0, 166 I915_ENGINE_CLASS_COPY = 1, 167 I915_ENGINE_CLASS_VIDEO = 2, 168 I915_ENGINE_CLASS_VIDEO_ENHANCE = 3, 169 170 /* should be kept compact */ 171 172 I915_ENGINE_CLASS_INVALID = -1 173 }; 174 175 /** 176 * struct i915_engine_class_instance - Engine class/instance identifier 177 * 178 * There may be more than one engine fulfilling any role within the system. 179 * Each engine of a class is given a unique instance number and therefore 180 * any engine can be specified by its class:instance tuplet. APIs that allow 181 * access to any engine in the system will use struct i915_engine_class_instance 182 * for this identification. 183 */ 184 struct i915_engine_class_instance { 185 /** 186 * @engine_class: 187 * 188 * Engine class from enum drm_i915_gem_engine_class 189 */ 190 __u16 engine_class; 191 #define I915_ENGINE_CLASS_INVALID_NONE -1 192 #define I915_ENGINE_CLASS_INVALID_VIRTUAL -2 193 194 /** 195 * @engine_instance: 196 * 197 * Engine instance. 198 */ 199 __u16 engine_instance; 200 }; 201 202 /** 203 * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915 204 * 205 */ 206 207 enum drm_i915_pmu_engine_sample { 208 I915_SAMPLE_BUSY = 0, 209 I915_SAMPLE_WAIT = 1, 210 I915_SAMPLE_SEMA = 2 211 }; 212 213 #define I915_PMU_SAMPLE_BITS (4) 214 #define I915_PMU_SAMPLE_MASK (0xf) 215 #define I915_PMU_SAMPLE_INSTANCE_BITS (8) 216 #define I915_PMU_CLASS_SHIFT \ 217 (I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS) 218 219 #define __I915_PMU_ENGINE(class, instance, sample) \ 220 ((class) << I915_PMU_CLASS_SHIFT | \ 221 (instance) << I915_PMU_SAMPLE_BITS | \ 222 (sample)) 223 224 #define I915_PMU_ENGINE_BUSY(class, instance) \ 225 __I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY) 226 227 #define I915_PMU_ENGINE_WAIT(class, instance) \ 228 __I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT) 229 230 #define I915_PMU_ENGINE_SEMA(class, instance) \ 231 __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA) 232 233 #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) 234 235 #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0) 236 #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1) 237 #define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2) 238 #define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3) 239 #define I915_PMU_SOFTWARE_GT_AWAKE_TIME __I915_PMU_OTHER(4) 240 241 #define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY 242 243 /* Each region is a minimum of 16k, and there are at most 255 of them. 244 */ 245 #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use 246 * of chars for next/prev indices */ 247 #define I915_LOG_MIN_TEX_REGION_SIZE 14 248 249 typedef struct _drm_i915_init { 250 enum { 251 I915_INIT_DMA = 0x01, 252 I915_CLEANUP_DMA = 0x02, 253 I915_RESUME_DMA = 0x03 254 } func; 255 unsigned int mmio_offset; 256 int sarea_priv_offset; 257 unsigned int ring_start; 258 unsigned int ring_end; 259 unsigned int ring_size; 260 unsigned int front_offset; 261 unsigned int back_offset; 262 unsigned int depth_offset; 263 unsigned int w; 264 unsigned int h; 265 unsigned int pitch; 266 unsigned int pitch_bits; 267 unsigned int back_pitch; 268 unsigned int depth_pitch; 269 unsigned int cpp; 270 unsigned int chipset; 271 } drm_i915_init_t; 272 273 typedef struct _drm_i915_sarea { 274 struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1]; 275 int last_upload; /* last time texture was uploaded */ 276 int last_enqueue; /* last time a buffer was enqueued */ 277 int last_dispatch; /* age of the most recently dispatched buffer */ 278 int ctxOwner; /* last context to upload state */ 279 int texAge; 280 int pf_enabled; /* is pageflipping allowed? */ 281 int pf_active; 282 int pf_current_page; /* which buffer is being displayed? */ 283 int perf_boxes; /* performance boxes to be displayed */ 284 int width, height; /* screen size in pixels */ 285 286 drm_handle_t front_handle; 287 int front_offset; 288 int front_size; 289 290 drm_handle_t back_handle; 291 int back_offset; 292 int back_size; 293 294 drm_handle_t depth_handle; 295 int depth_offset; 296 int depth_size; 297 298 drm_handle_t tex_handle; 299 int tex_offset; 300 int tex_size; 301 int log_tex_granularity; 302 int pitch; 303 int rotation; /* 0, 90, 180 or 270 */ 304 int rotated_offset; 305 int rotated_size; 306 int rotated_pitch; 307 int virtualX, virtualY; 308 309 unsigned int front_tiled; 310 unsigned int back_tiled; 311 unsigned int depth_tiled; 312 unsigned int rotated_tiled; 313 unsigned int rotated2_tiled; 314 315 int pipeA_x; 316 int pipeA_y; 317 int pipeA_w; 318 int pipeA_h; 319 int pipeB_x; 320 int pipeB_y; 321 int pipeB_w; 322 int pipeB_h; 323 324 /* fill out some space for old userspace triple buffer */ 325 drm_handle_t unused_handle; 326 __u32 unused1, unused2, unused3; 327 328 /* buffer object handles for static buffers. May change 329 * over the lifetime of the client. 330 */ 331 __u32 front_bo_handle; 332 __u32 back_bo_handle; 333 __u32 unused_bo_handle; 334 __u32 depth_bo_handle; 335 336 } drm_i915_sarea_t; 337 338 /* due to userspace building against these headers we need some compat here */ 339 #define planeA_x pipeA_x 340 #define planeA_y pipeA_y 341 #define planeA_w pipeA_w 342 #define planeA_h pipeA_h 343 #define planeB_x pipeB_x 344 #define planeB_y pipeB_y 345 #define planeB_w pipeB_w 346 #define planeB_h pipeB_h 347 348 /* Flags for perf_boxes 349 */ 350 #define I915_BOX_RING_EMPTY 0x1 351 #define I915_BOX_FLIP 0x2 352 #define I915_BOX_WAIT 0x4 353 #define I915_BOX_TEXTURE_LOAD 0x8 354 #define I915_BOX_LOST_CONTEXT 0x10 355 356 /* 357 * i915 specific ioctls. 358 * 359 * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie 360 * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset 361 * against DRM_COMMAND_BASE and should be between [0x0, 0x60). 362 */ 363 #define DRM_I915_INIT 0x00 364 #define DRM_I915_FLUSH 0x01 365 #define DRM_I915_FLIP 0x02 366 #define DRM_I915_BATCHBUFFER 0x03 367 #define DRM_I915_IRQ_EMIT 0x04 368 #define DRM_I915_IRQ_WAIT 0x05 369 #define DRM_I915_GETPARAM 0x06 370 #define DRM_I915_SETPARAM 0x07 371 #define DRM_I915_ALLOC 0x08 372 #define DRM_I915_FREE 0x09 373 #define DRM_I915_INIT_HEAP 0x0a 374 #define DRM_I915_CMDBUFFER 0x0b 375 #define DRM_I915_DESTROY_HEAP 0x0c 376 #define DRM_I915_SET_VBLANK_PIPE 0x0d 377 #define DRM_I915_GET_VBLANK_PIPE 0x0e 378 #define DRM_I915_VBLANK_SWAP 0x0f 379 #define DRM_I915_HWS_ADDR 0x11 380 #define DRM_I915_GEM_INIT 0x13 381 #define DRM_I915_GEM_EXECBUFFER 0x14 382 #define DRM_I915_GEM_PIN 0x15 383 #define DRM_I915_GEM_UNPIN 0x16 384 #define DRM_I915_GEM_BUSY 0x17 385 #define DRM_I915_GEM_THROTTLE 0x18 386 #define DRM_I915_GEM_ENTERVT 0x19 387 #define DRM_I915_GEM_LEAVEVT 0x1a 388 #define DRM_I915_GEM_CREATE 0x1b 389 #define DRM_I915_GEM_PREAD 0x1c 390 #define DRM_I915_GEM_PWRITE 0x1d 391 #define DRM_I915_GEM_MMAP 0x1e 392 #define DRM_I915_GEM_SET_DOMAIN 0x1f 393 #define DRM_I915_GEM_SW_FINISH 0x20 394 #define DRM_I915_GEM_SET_TILING 0x21 395 #define DRM_I915_GEM_GET_TILING 0x22 396 #define DRM_I915_GEM_GET_APERTURE 0x23 397 #define DRM_I915_GEM_MMAP_GTT 0x24 398 #define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25 399 #define DRM_I915_GEM_MADVISE 0x26 400 #define DRM_I915_OVERLAY_PUT_IMAGE 0x27 401 #define DRM_I915_OVERLAY_ATTRS 0x28 402 #define DRM_I915_GEM_EXECBUFFER2 0x29 403 #define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2 404 #define DRM_I915_GET_SPRITE_COLORKEY 0x2a 405 #define DRM_I915_SET_SPRITE_COLORKEY 0x2b 406 #define DRM_I915_GEM_WAIT 0x2c 407 #define DRM_I915_GEM_CONTEXT_CREATE 0x2d 408 #define DRM_I915_GEM_CONTEXT_DESTROY 0x2e 409 #define DRM_I915_GEM_SET_CACHING 0x2f 410 #define DRM_I915_GEM_GET_CACHING 0x30 411 #define DRM_I915_REG_READ 0x31 412 #define DRM_I915_GET_RESET_STATS 0x32 413 #define DRM_I915_GEM_USERPTR 0x33 414 #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34 415 #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35 416 #define DRM_I915_PERF_OPEN 0x36 417 #define DRM_I915_PERF_ADD_CONFIG 0x37 418 #define DRM_I915_PERF_REMOVE_CONFIG 0x38 419 #define DRM_I915_QUERY 0x39 420 #define DRM_I915_GEM_VM_CREATE 0x3a 421 #define DRM_I915_GEM_VM_DESTROY 0x3b 422 #define DRM_I915_GEM_CREATE_EXT 0x3c 423 /* Must be kept compact -- no holes */ 424 425 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 426 #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 427 #define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP) 428 #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t) 429 #define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t) 430 #define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t) 431 #define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t) 432 #define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t) 433 #define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t) 434 #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) 435 #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) 436 #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) 437 #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t) 438 #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) 439 #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) 440 #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) 441 #define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init) 442 #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init) 443 #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer) 444 #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) 445 #define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2) 446 #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin) 447 #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin) 448 #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy) 449 #define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching) 450 #define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching) 451 #define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE) 452 #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT) 453 #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT) 454 #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create) 455 #define DRM_IOCTL_I915_GEM_CREATE_EXT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE_EXT, struct drm_i915_gem_create_ext) 456 #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread) 457 #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite) 458 #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap) 459 #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt) 460 #define DRM_IOCTL_I915_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_offset) 461 #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain) 462 #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) 463 #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) 464 #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling) 465 #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture) 466 #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) 467 #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise) 468 #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image) 469 #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs) 470 #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) 471 #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) 472 #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait) 473 #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create) 474 #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) 475 #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy) 476 #define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read) 477 #define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats) 478 #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr) 479 #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param) 480 #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param) 481 #define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param) 482 #define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config) 483 #define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64) 484 #define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query) 485 #define DRM_IOCTL_I915_GEM_VM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_CREATE, struct drm_i915_gem_vm_control) 486 #define DRM_IOCTL_I915_GEM_VM_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_VM_DESTROY, struct drm_i915_gem_vm_control) 487 488 /* Allow drivers to submit batchbuffers directly to hardware, relying 489 * on the security mechanisms provided by hardware. 490 */ 491 typedef struct drm_i915_batchbuffer { 492 int start; /* agp offset */ 493 int used; /* nr bytes in use */ 494 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */ 495 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */ 496 int num_cliprects; /* mulitpass with multiple cliprects? */ 497 struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */ 498 } drm_i915_batchbuffer_t; 499 500 /* As above, but pass a pointer to userspace buffer which can be 501 * validated by the kernel prior to sending to hardware. 502 */ 503 typedef struct _drm_i915_cmdbuffer { 504 char __user *buf; /* pointer to userspace command buffer */ 505 int sz; /* nr bytes in buf */ 506 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */ 507 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */ 508 int num_cliprects; /* mulitpass with multiple cliprects? */ 509 struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */ 510 } drm_i915_cmdbuffer_t; 511 512 /* Userspace can request & wait on irq's: 513 */ 514 typedef struct drm_i915_irq_emit { 515 int __user *irq_seq; 516 } drm_i915_irq_emit_t; 517 518 typedef struct drm_i915_irq_wait { 519 int irq_seq; 520 } drm_i915_irq_wait_t; 521 522 /* 523 * Different modes of per-process Graphics Translation Table, 524 * see I915_PARAM_HAS_ALIASING_PPGTT 525 */ 526 #define I915_GEM_PPGTT_NONE 0 527 #define I915_GEM_PPGTT_ALIASING 1 528 #define I915_GEM_PPGTT_FULL 2 529 530 /* Ioctl to query kernel params: 531 */ 532 #define I915_PARAM_IRQ_ACTIVE 1 533 #define I915_PARAM_ALLOW_BATCHBUFFER 2 534 #define I915_PARAM_LAST_DISPATCH 3 535 #define I915_PARAM_CHIPSET_ID 4 536 #define I915_PARAM_HAS_GEM 5 537 #define I915_PARAM_NUM_FENCES_AVAIL 6 538 #define I915_PARAM_HAS_OVERLAY 7 539 #define I915_PARAM_HAS_PAGEFLIPPING 8 540 #define I915_PARAM_HAS_EXECBUF2 9 541 #define I915_PARAM_HAS_BSD 10 542 #define I915_PARAM_HAS_BLT 11 543 #define I915_PARAM_HAS_RELAXED_FENCING 12 544 #define I915_PARAM_HAS_COHERENT_RINGS 13 545 #define I915_PARAM_HAS_EXEC_CONSTANTS 14 546 #define I915_PARAM_HAS_RELAXED_DELTA 15 547 #define I915_PARAM_HAS_GEN7_SOL_RESET 16 548 #define I915_PARAM_HAS_LLC 17 549 #define I915_PARAM_HAS_ALIASING_PPGTT 18 550 #define I915_PARAM_HAS_WAIT_TIMEOUT 19 551 #define I915_PARAM_HAS_SEMAPHORES 20 552 #define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21 553 #define I915_PARAM_HAS_VEBOX 22 554 #define I915_PARAM_HAS_SECURE_BATCHES 23 555 #define I915_PARAM_HAS_PINNED_BATCHES 24 556 #define I915_PARAM_HAS_EXEC_NO_RELOC 25 557 #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26 558 #define I915_PARAM_HAS_WT 27 559 #define I915_PARAM_CMD_PARSER_VERSION 28 560 #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29 561 #define I915_PARAM_MMAP_VERSION 30 562 #define I915_PARAM_HAS_BSD2 31 563 #define I915_PARAM_REVISION 32 564 #define I915_PARAM_SUBSLICE_TOTAL 33 565 #define I915_PARAM_EU_TOTAL 34 566 #define I915_PARAM_HAS_GPU_RESET 35 567 #define I915_PARAM_HAS_RESOURCE_STREAMER 36 568 #define I915_PARAM_HAS_EXEC_SOFTPIN 37 569 #define I915_PARAM_HAS_POOLED_EU 38 570 #define I915_PARAM_MIN_EU_IN_POOL 39 571 #define I915_PARAM_MMAP_GTT_VERSION 40 572 573 /* 574 * Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution 575 * priorities and the driver will attempt to execute batches in priority order. 576 * The param returns a capability bitmask, nonzero implies that the scheduler 577 * is enabled, with different features present according to the mask. 578 * 579 * The initial priority for each batch is supplied by the context and is 580 * controlled via I915_CONTEXT_PARAM_PRIORITY. 581 */ 582 #define I915_PARAM_HAS_SCHEDULER 41 583 #define I915_SCHEDULER_CAP_ENABLED (1ul << 0) 584 #define I915_SCHEDULER_CAP_PRIORITY (1ul << 1) 585 #define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2) 586 #define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3) 587 #define I915_SCHEDULER_CAP_ENGINE_BUSY_STATS (1ul << 4) 588 /* 589 * Indicates the 2k user priority levels are statically mapped into 3 buckets as 590 * follows: 591 * 592 * -1k to -1 Low priority 593 * 0 Normal priority 594 * 1 to 1k Highest priority 595 */ 596 #define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5) 597 598 #define I915_PARAM_HUC_STATUS 42 599 600 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of 601 * synchronisation with implicit fencing on individual objects. 602 * See EXEC_OBJECT_ASYNC. 603 */ 604 #define I915_PARAM_HAS_EXEC_ASYNC 43 605 606 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support - 607 * both being able to pass in a sync_file fd to wait upon before executing, 608 * and being able to return a new sync_file fd that is signaled when the 609 * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT. 610 */ 611 #define I915_PARAM_HAS_EXEC_FENCE 44 612 613 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture 614 * user specified bufffers for post-mortem debugging of GPU hangs. See 615 * EXEC_OBJECT_CAPTURE. 616 */ 617 #define I915_PARAM_HAS_EXEC_CAPTURE 45 618 619 #define I915_PARAM_SLICE_MASK 46 620 621 /* Assuming it's uniform for each slice, this queries the mask of subslices 622 * per-slice for this system. 623 */ 624 #define I915_PARAM_SUBSLICE_MASK 47 625 626 /* 627 * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer 628 * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST. 629 */ 630 #define I915_PARAM_HAS_EXEC_BATCH_FIRST 48 631 632 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of 633 * drm_i915_gem_exec_fence structures. See I915_EXEC_FENCE_ARRAY. 634 */ 635 #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49 636 637 /* 638 * Query whether every context (both per-file default and user created) is 639 * isolated (insofar as HW supports). If this parameter is not true, then 640 * freshly created contexts may inherit values from an existing context, 641 * rather than default HW values. If true, it also ensures (insofar as HW 642 * supports) that all state set by this context will not leak to any other 643 * context. 644 * 645 * As not every engine across every gen support contexts, the returned 646 * value reports the support of context isolation for individual engines by 647 * returning a bitmask of each engine class set to true if that class supports 648 * isolation. 649 */ 650 #define I915_PARAM_HAS_CONTEXT_ISOLATION 50 651 652 /* Frequency of the command streamer timestamps given by the *_TIMESTAMP 653 * registers. This used to be fixed per platform but from CNL onwards, this 654 * might vary depending on the parts. 655 */ 656 #define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51 657 658 /* 659 * Once upon a time we supposed that writes through the GGTT would be 660 * immediately in physical memory (once flushed out of the CPU path). However, 661 * on a few different processors and chipsets, this is not necessarily the case 662 * as the writes appear to be buffered internally. Thus a read of the backing 663 * storage (physical memory) via a different path (with different physical tags 664 * to the indirect write via the GGTT) will see stale values from before 665 * the GGTT write. Inside the kernel, we can for the most part keep track of 666 * the different read/write domains in use (e.g. set-domain), but the assumption 667 * of coherency is baked into the ABI, hence reporting its true state in this 668 * parameter. 669 * 670 * Reports true when writes via mmap_gtt are immediately visible following an 671 * lfence to flush the WCB. 672 * 673 * Reports false when writes via mmap_gtt are indeterminately delayed in an in 674 * internal buffer and are _not_ immediately visible to third parties accessing 675 * directly via mmap_cpu/mmap_wc. Use of mmap_gtt as part of an IPC 676 * communications channel when reporting false is strongly disadvised. 677 */ 678 #define I915_PARAM_MMAP_GTT_COHERENT 52 679 680 /* 681 * Query whether DRM_I915_GEM_EXECBUFFER2 supports coordination of parallel 682 * execution through use of explicit fence support. 683 * See I915_EXEC_FENCE_OUT and I915_EXEC_FENCE_SUBMIT. 684 */ 685 #define I915_PARAM_HAS_EXEC_SUBMIT_FENCE 53 686 687 /* 688 * Revision of the i915-perf uAPI. The value returned helps determine what 689 * i915-perf features are available. See drm_i915_perf_property_id. 690 */ 691 #define I915_PARAM_PERF_REVISION 54 692 693 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of 694 * timeline syncobj through drm_i915_gem_execbuffer_ext_timeline_fences. See 695 * I915_EXEC_USE_EXTENSIONS. 696 */ 697 #define I915_PARAM_HAS_EXEC_TIMELINE_FENCES 55 698 699 /* Query if the kernel supports the I915_USERPTR_PROBE flag. */ 700 #define I915_PARAM_HAS_USERPTR_PROBE 56 701 702 /* Must be kept compact -- no holes and well documented */ 703 704 typedef struct drm_i915_getparam { 705 __s32 param; 706 /* 707 * WARNING: Using pointers instead of fixed-size u64 means we need to write 708 * compat32 code. Don't repeat this mistake. 709 */ 710 int __user *value; 711 } drm_i915_getparam_t; 712 713 /* Ioctl to set kernel params: 714 */ 715 #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1 716 #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2 717 #define I915_SETPARAM_ALLOW_BATCHBUFFER 3 718 #define I915_SETPARAM_NUM_USED_FENCES 4 719 /* Must be kept compact -- no holes */ 720 721 typedef struct drm_i915_setparam { 722 int param; 723 int value; 724 } drm_i915_setparam_t; 725 726 /* A memory manager for regions of shared memory: 727 */ 728 #define I915_MEM_REGION_AGP 1 729 730 typedef struct drm_i915_mem_alloc { 731 int region; 732 int alignment; 733 int size; 734 int __user *region_offset; /* offset from start of fb or agp */ 735 } drm_i915_mem_alloc_t; 736 737 typedef struct drm_i915_mem_free { 738 int region; 739 int region_offset; 740 } drm_i915_mem_free_t; 741 742 typedef struct drm_i915_mem_init_heap { 743 int region; 744 int size; 745 int start; 746 } drm_i915_mem_init_heap_t; 747 748 /* Allow memory manager to be torn down and re-initialized (eg on 749 * rotate): 750 */ 751 typedef struct drm_i915_mem_destroy_heap { 752 int region; 753 } drm_i915_mem_destroy_heap_t; 754 755 /* Allow X server to configure which pipes to monitor for vblank signals 756 */ 757 #define DRM_I915_VBLANK_PIPE_A 1 758 #define DRM_I915_VBLANK_PIPE_B 2 759 760 typedef struct drm_i915_vblank_pipe { 761 int pipe; 762 } drm_i915_vblank_pipe_t; 763 764 /* Schedule buffer swap at given vertical blank: 765 */ 766 typedef struct drm_i915_vblank_swap { 767 drm_drawable_t drawable; 768 enum drm_vblank_seq_type seqtype; 769 unsigned int sequence; 770 } drm_i915_vblank_swap_t; 771 772 typedef struct drm_i915_hws_addr { 773 __u64 addr; 774 } drm_i915_hws_addr_t; 775 776 struct drm_i915_gem_init { 777 /** 778 * Beginning offset in the GTT to be managed by the DRM memory 779 * manager. 780 */ 781 __u64 gtt_start; 782 /** 783 * Ending offset in the GTT to be managed by the DRM memory 784 * manager. 785 */ 786 __u64 gtt_end; 787 }; 788 789 struct drm_i915_gem_create { 790 /** 791 * Requested size for the object. 792 * 793 * The (page-aligned) allocated size for the object will be returned. 794 */ 795 __u64 size; 796 /** 797 * Returned handle for the object. 798 * 799 * Object handles are nonzero. 800 */ 801 __u32 handle; 802 __u32 pad; 803 }; 804 805 struct drm_i915_gem_pread { 806 /** Handle for the object being read. */ 807 __u32 handle; 808 __u32 pad; 809 /** Offset into the object to read from */ 810 __u64 offset; 811 /** Length of data to read */ 812 __u64 size; 813 /** 814 * Pointer to write the data into. 815 * 816 * This is a fixed-size type for 32/64 compatibility. 817 */ 818 __u64 data_ptr; 819 }; 820 821 struct drm_i915_gem_pwrite { 822 /** Handle for the object being written to. */ 823 __u32 handle; 824 __u32 pad; 825 /** Offset into the object to write to */ 826 __u64 offset; 827 /** Length of data to write */ 828 __u64 size; 829 /** 830 * Pointer to read the data from. 831 * 832 * This is a fixed-size type for 32/64 compatibility. 833 */ 834 __u64 data_ptr; 835 }; 836 837 struct drm_i915_gem_mmap { 838 /** Handle for the object being mapped. */ 839 __u32 handle; 840 __u32 pad; 841 /** Offset in the object to map. */ 842 __u64 offset; 843 /** 844 * Length of data to map. 845 * 846 * The value will be page-aligned. 847 */ 848 __u64 size; 849 /** 850 * Returned pointer the data was mapped at. 851 * 852 * This is a fixed-size type for 32/64 compatibility. 853 */ 854 __u64 addr_ptr; 855 856 /** 857 * Flags for extended behaviour. 858 * 859 * Added in version 2. 860 */ 861 __u64 flags; 862 #define I915_MMAP_WC 0x1 863 }; 864 865 struct drm_i915_gem_mmap_gtt { 866 /** Handle for the object being mapped. */ 867 __u32 handle; 868 __u32 pad; 869 /** 870 * Fake offset to use for subsequent mmap call 871 * 872 * This is a fixed-size type for 32/64 compatibility. 873 */ 874 __u64 offset; 875 }; 876 877 /** 878 * struct drm_i915_gem_mmap_offset - Retrieve an offset so we can mmap this buffer object. 879 * 880 * This struct is passed as argument to the `DRM_IOCTL_I915_GEM_MMAP_OFFSET` ioctl, 881 * and is used to retrieve the fake offset to mmap an object specified by &handle. 882 * 883 * The legacy way of using `DRM_IOCTL_I915_GEM_MMAP` is removed on gen12+. 884 * `DRM_IOCTL_I915_GEM_MMAP_GTT` is an older supported alias to this struct, but will behave 885 * as setting the &extensions to 0, and &flags to `I915_MMAP_OFFSET_GTT`. 886 */ 887 struct drm_i915_gem_mmap_offset { 888 /** @handle: Handle for the object being mapped. */ 889 __u32 handle; 890 /** @pad: Must be zero */ 891 __u32 pad; 892 /** 893 * @offset: The fake offset to use for subsequent mmap call 894 * 895 * This is a fixed-size type for 32/64 compatibility. 896 */ 897 __u64 offset; 898 899 /** 900 * @flags: Flags for extended behaviour. 901 * 902 * It is mandatory that one of the `MMAP_OFFSET` types 903 * should be included: 904 * 905 * - `I915_MMAP_OFFSET_GTT`: Use mmap with the object bound to GTT. (Write-Combined) 906 * - `I915_MMAP_OFFSET_WC`: Use Write-Combined caching. 907 * - `I915_MMAP_OFFSET_WB`: Use Write-Back caching. 908 * - `I915_MMAP_OFFSET_FIXED`: Use object placement to determine caching. 909 * 910 * On devices with local memory `I915_MMAP_OFFSET_FIXED` is the only valid 911 * type. On devices without local memory, this caching mode is invalid. 912 * 913 * As caching mode when specifying `I915_MMAP_OFFSET_FIXED`, WC or WB will 914 * be used, depending on the object placement on creation. WB will be used 915 * when the object can only exist in system memory, WC otherwise. 916 */ 917 __u64 flags; 918 919 #define I915_MMAP_OFFSET_GTT 0 920 #define I915_MMAP_OFFSET_WC 1 921 #define I915_MMAP_OFFSET_WB 2 922 #define I915_MMAP_OFFSET_UC 3 923 #define I915_MMAP_OFFSET_FIXED 4 924 925 /** 926 * @extensions: Zero-terminated chain of extensions. 927 * 928 * No current extensions defined; mbz. 929 */ 930 __u64 extensions; 931 }; 932 933 /** 934 * struct drm_i915_gem_set_domain - Adjust the objects write or read domain, in 935 * preparation for accessing the pages via some CPU domain. 936 * 937 * Specifying a new write or read domain will flush the object out of the 938 * previous domain(if required), before then updating the objects domain 939 * tracking with the new domain. 940 * 941 * Note this might involve waiting for the object first if it is still active on 942 * the GPU. 943 * 944 * Supported values for @read_domains and @write_domain: 945 * 946 * - I915_GEM_DOMAIN_WC: Uncached write-combined domain 947 * - I915_GEM_DOMAIN_CPU: CPU cache domain 948 * - I915_GEM_DOMAIN_GTT: Mappable aperture domain 949 * 950 * All other domains are rejected. 951 * 952 * Note that for discrete, starting from DG1, this is no longer supported, and 953 * is instead rejected. On such platforms the CPU domain is effectively static, 954 * where we also only support a single &drm_i915_gem_mmap_offset cache mode, 955 * which can't be set explicitly and instead depends on the object placements, 956 * as per the below. 957 * 958 * Implicit caching rules, starting from DG1: 959 * 960 * - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions) 961 * contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and 962 * mapped as write-combined only. 963 * 964 * - Everything else is always allocated and mapped as write-back, with the 965 * guarantee that everything is also coherent with the GPU. 966 * 967 * Note that this is likely to change in the future again, where we might need 968 * more flexibility on future devices, so making this all explicit as part of a 969 * new &drm_i915_gem_create_ext extension is probable. 970 */ 971 struct drm_i915_gem_set_domain { 972 /** @handle: Handle for the object. */ 973 __u32 handle; 974 975 /** @read_domains: New read domains. */ 976 __u32 read_domains; 977 978 /** 979 * @write_domain: New write domain. 980 * 981 * Note that having something in the write domain implies it's in the 982 * read domain, and only that read domain. 983 */ 984 __u32 write_domain; 985 }; 986 987 struct drm_i915_gem_sw_finish { 988 /** Handle for the object */ 989 __u32 handle; 990 }; 991 992 struct drm_i915_gem_relocation_entry { 993 /** 994 * Handle of the buffer being pointed to by this relocation entry. 995 * 996 * It's appealing to make this be an index into the mm_validate_entry 997 * list to refer to the buffer, but this allows the driver to create 998 * a relocation list for state buffers and not re-write it per 999 * exec using the buffer. 1000 */ 1001 __u32 target_handle; 1002 1003 /** 1004 * Value to be added to the offset of the target buffer to make up 1005 * the relocation entry. 1006 */ 1007 __u32 delta; 1008 1009 /** Offset in the buffer the relocation entry will be written into */ 1010 __u64 offset; 1011 1012 /** 1013 * Offset value of the target buffer that the relocation entry was last 1014 * written as. 1015 * 1016 * If the buffer has the same offset as last time, we can skip syncing 1017 * and writing the relocation. This value is written back out by 1018 * the execbuffer ioctl when the relocation is written. 1019 */ 1020 __u64 presumed_offset; 1021 1022 /** 1023 * Target memory domains read by this operation. 1024 */ 1025 __u32 read_domains; 1026 1027 /** 1028 * Target memory domains written by this operation. 1029 * 1030 * Note that only one domain may be written by the whole 1031 * execbuffer operation, so that where there are conflicts, 1032 * the application will get -EINVAL back. 1033 */ 1034 __u32 write_domain; 1035 }; 1036 1037 /** @{ 1038 * Intel memory domains 1039 * 1040 * Most of these just align with the various caches in 1041 * the system and are used to flush and invalidate as 1042 * objects end up cached in different domains. 1043 */ 1044 /** CPU cache */ 1045 #define I915_GEM_DOMAIN_CPU 0x00000001 1046 /** Render cache, used by 2D and 3D drawing */ 1047 #define I915_GEM_DOMAIN_RENDER 0x00000002 1048 /** Sampler cache, used by texture engine */ 1049 #define I915_GEM_DOMAIN_SAMPLER 0x00000004 1050 /** Command queue, used to load batch buffers */ 1051 #define I915_GEM_DOMAIN_COMMAND 0x00000008 1052 /** Instruction cache, used by shader programs */ 1053 #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010 1054 /** Vertex address cache */ 1055 #define I915_GEM_DOMAIN_VERTEX 0x00000020 1056 /** GTT domain - aperture and scanout */ 1057 #define I915_GEM_DOMAIN_GTT 0x00000040 1058 /** WC domain - uncached access */ 1059 #define I915_GEM_DOMAIN_WC 0x00000080 1060 /** @} */ 1061 1062 struct drm_i915_gem_exec_object { 1063 /** 1064 * User's handle for a buffer to be bound into the GTT for this 1065 * operation. 1066 */ 1067 __u32 handle; 1068 1069 /** Number of relocations to be performed on this buffer */ 1070 __u32 relocation_count; 1071 /** 1072 * Pointer to array of struct drm_i915_gem_relocation_entry containing 1073 * the relocations to be performed in this buffer. 1074 */ 1075 __u64 relocs_ptr; 1076 1077 /** Required alignment in graphics aperture */ 1078 __u64 alignment; 1079 1080 /** 1081 * Returned value of the updated offset of the object, for future 1082 * presumed_offset writes. 1083 */ 1084 __u64 offset; 1085 }; 1086 1087 /* DRM_IOCTL_I915_GEM_EXECBUFFER was removed in Linux 5.13 */ 1088 struct drm_i915_gem_execbuffer { 1089 /** 1090 * List of buffers to be validated with their relocations to be 1091 * performend on them. 1092 * 1093 * This is a pointer to an array of struct drm_i915_gem_validate_entry. 1094 * 1095 * These buffers must be listed in an order such that all relocations 1096 * a buffer is performing refer to buffers that have already appeared 1097 * in the validate list. 1098 */ 1099 __u64 buffers_ptr; 1100 __u32 buffer_count; 1101 1102 /** Offset in the batchbuffer to start execution from. */ 1103 __u32 batch_start_offset; 1104 /** Bytes used in batchbuffer from batch_start_offset */ 1105 __u32 batch_len; 1106 __u32 DR1; 1107 __u32 DR4; 1108 __u32 num_cliprects; 1109 /** This is a struct drm_clip_rect *cliprects */ 1110 __u64 cliprects_ptr; 1111 }; 1112 1113 struct drm_i915_gem_exec_object2 { 1114 /** 1115 * User's handle for a buffer to be bound into the GTT for this 1116 * operation. 1117 */ 1118 __u32 handle; 1119 1120 /** Number of relocations to be performed on this buffer */ 1121 __u32 relocation_count; 1122 /** 1123 * Pointer to array of struct drm_i915_gem_relocation_entry containing 1124 * the relocations to be performed in this buffer. 1125 */ 1126 __u64 relocs_ptr; 1127 1128 /** Required alignment in graphics aperture */ 1129 __u64 alignment; 1130 1131 /** 1132 * When the EXEC_OBJECT_PINNED flag is specified this is populated by 1133 * the user with the GTT offset at which this object will be pinned. 1134 * 1135 * When the I915_EXEC_NO_RELOC flag is specified this must contain the 1136 * presumed_offset of the object. 1137 * 1138 * During execbuffer2 the kernel populates it with the value of the 1139 * current GTT offset of the object, for future presumed_offset writes. 1140 * 1141 * See struct drm_i915_gem_create_ext for the rules when dealing with 1142 * alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with 1143 * minimum page sizes, like DG2. 1144 */ 1145 __u64 offset; 1146 1147 #define EXEC_OBJECT_NEEDS_FENCE (1<<0) 1148 #define EXEC_OBJECT_NEEDS_GTT (1<<1) 1149 #define EXEC_OBJECT_WRITE (1<<2) 1150 #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3) 1151 #define EXEC_OBJECT_PINNED (1<<4) 1152 #define EXEC_OBJECT_PAD_TO_SIZE (1<<5) 1153 /* The kernel implicitly tracks GPU activity on all GEM objects, and 1154 * synchronises operations with outstanding rendering. This includes 1155 * rendering on other devices if exported via dma-buf. However, sometimes 1156 * this tracking is too coarse and the user knows better. For example, 1157 * if the object is split into non-overlapping ranges shared between different 1158 * clients or engines (i.e. suballocating objects), the implicit tracking 1159 * by kernel assumes that each operation affects the whole object rather 1160 * than an individual range, causing needless synchronisation between clients. 1161 * The kernel will also forgo any CPU cache flushes prior to rendering from 1162 * the object as the client is expected to be also handling such domain 1163 * tracking. 1164 * 1165 * The kernel maintains the implicit tracking in order to manage resources 1166 * used by the GPU - this flag only disables the synchronisation prior to 1167 * rendering with this object in this execbuf. 1168 * 1169 * Opting out of implicit synhronisation requires the user to do its own 1170 * explicit tracking to avoid rendering corruption. See, for example, 1171 * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously. 1172 */ 1173 #define EXEC_OBJECT_ASYNC (1<<6) 1174 /* Request that the contents of this execobject be copied into the error 1175 * state upon a GPU hang involving this batch for post-mortem debugging. 1176 * These buffers are recorded in no particular order as "user" in 1177 * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see 1178 * if the kernel supports this flag. 1179 */ 1180 #define EXEC_OBJECT_CAPTURE (1<<7) 1181 /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */ 1182 #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1) 1183 __u64 flags; 1184 1185 union { 1186 __u64 rsvd1; 1187 __u64 pad_to_size; 1188 }; 1189 __u64 rsvd2; 1190 }; 1191 1192 struct drm_i915_gem_exec_fence { 1193 /** 1194 * User's handle for a drm_syncobj to wait on or signal. 1195 */ 1196 __u32 handle; 1197 1198 #define I915_EXEC_FENCE_WAIT (1<<0) 1199 #define I915_EXEC_FENCE_SIGNAL (1<<1) 1200 #define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1)) 1201 __u32 flags; 1202 }; 1203 1204 /* 1205 * See drm_i915_gem_execbuffer_ext_timeline_fences. 1206 */ 1207 #define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0 1208 1209 /* 1210 * This structure describes an array of drm_syncobj and associated points for 1211 * timeline variants of drm_syncobj. It is invalid to append this structure to 1212 * the execbuf if I915_EXEC_FENCE_ARRAY is set. 1213 */ 1214 struct drm_i915_gem_execbuffer_ext_timeline_fences { 1215 struct i915_user_extension base; 1216 1217 /** 1218 * Number of element in the handles_ptr & value_ptr arrays. 1219 */ 1220 __u64 fence_count; 1221 1222 /** 1223 * Pointer to an array of struct drm_i915_gem_exec_fence of length 1224 * fence_count. 1225 */ 1226 __u64 handles_ptr; 1227 1228 /** 1229 * Pointer to an array of u64 values of length fence_count. Values 1230 * must be 0 for a binary drm_syncobj. A Value of 0 for a timeline 1231 * drm_syncobj is invalid as it turns a drm_syncobj into a binary one. 1232 */ 1233 __u64 values_ptr; 1234 }; 1235 1236 struct drm_i915_gem_execbuffer2 { 1237 /** 1238 * List of gem_exec_object2 structs 1239 */ 1240 __u64 buffers_ptr; 1241 __u32 buffer_count; 1242 1243 /** Offset in the batchbuffer to start execution from. */ 1244 __u32 batch_start_offset; 1245 /** Bytes used in batchbuffer from batch_start_offset */ 1246 __u32 batch_len; 1247 __u32 DR1; 1248 __u32 DR4; 1249 __u32 num_cliprects; 1250 /** 1251 * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY 1252 * & I915_EXEC_USE_EXTENSIONS are not set. 1253 * 1254 * If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array 1255 * of struct drm_i915_gem_exec_fence and num_cliprects is the length 1256 * of the array. 1257 * 1258 * If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a 1259 * single struct i915_user_extension and num_cliprects is 0. 1260 */ 1261 __u64 cliprects_ptr; 1262 #define I915_EXEC_RING_MASK (0x3f) 1263 #define I915_EXEC_DEFAULT (0<<0) 1264 #define I915_EXEC_RENDER (1<<0) 1265 #define I915_EXEC_BSD (2<<0) 1266 #define I915_EXEC_BLT (3<<0) 1267 #define I915_EXEC_VEBOX (4<<0) 1268 1269 /* Used for switching the constants addressing mode on gen4+ RENDER ring. 1270 * Gen6+ only supports relative addressing to dynamic state (default) and 1271 * absolute addressing. 1272 * 1273 * These flags are ignored for the BSD and BLT rings. 1274 */ 1275 #define I915_EXEC_CONSTANTS_MASK (3<<6) 1276 #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */ 1277 #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6) 1278 #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */ 1279 __u64 flags; 1280 __u64 rsvd1; /* now used for context info */ 1281 __u64 rsvd2; 1282 }; 1283 1284 /** Resets the SO write offset registers for transform feedback on gen7. */ 1285 #define I915_EXEC_GEN7_SOL_RESET (1<<8) 1286 1287 /** Request a privileged ("secure") batch buffer. Note only available for 1288 * DRM_ROOT_ONLY | DRM_MASTER processes. 1289 */ 1290 #define I915_EXEC_SECURE (1<<9) 1291 1292 /** Inform the kernel that the batch is and will always be pinned. This 1293 * negates the requirement for a workaround to be performed to avoid 1294 * an incoherent CS (such as can be found on 830/845). If this flag is 1295 * not passed, the kernel will endeavour to make sure the batch is 1296 * coherent with the CS before execution. If this flag is passed, 1297 * userspace assumes the responsibility for ensuring the same. 1298 */ 1299 #define I915_EXEC_IS_PINNED (1<<10) 1300 1301 /** Provide a hint to the kernel that the command stream and auxiliary 1302 * state buffers already holds the correct presumed addresses and so the 1303 * relocation process may be skipped if no buffers need to be moved in 1304 * preparation for the execbuffer. 1305 */ 1306 #define I915_EXEC_NO_RELOC (1<<11) 1307 1308 /** Use the reloc.handle as an index into the exec object array rather 1309 * than as the per-file handle. 1310 */ 1311 #define I915_EXEC_HANDLE_LUT (1<<12) 1312 1313 /** Used for switching BSD rings on the platforms with two BSD rings */ 1314 #define I915_EXEC_BSD_SHIFT (13) 1315 #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT) 1316 /* default ping-pong mode */ 1317 #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT) 1318 #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT) 1319 #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT) 1320 1321 /** Tell the kernel that the batchbuffer is processed by 1322 * the resource streamer. 1323 */ 1324 #define I915_EXEC_RESOURCE_STREAMER (1<<15) 1325 1326 /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent 1327 * a sync_file fd to wait upon (in a nonblocking manner) prior to executing 1328 * the batch. 1329 * 1330 * Returns -EINVAL if the sync_file fd cannot be found. 1331 */ 1332 #define I915_EXEC_FENCE_IN (1<<16) 1333 1334 /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd 1335 * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given 1336 * to the caller, and it should be close() after use. (The fd is a regular 1337 * file descriptor and will be cleaned up on process termination. It holds 1338 * a reference to the request, but nothing else.) 1339 * 1340 * The sync_file fd can be combined with other sync_file and passed either 1341 * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip 1342 * will only occur after this request completes), or to other devices. 1343 * 1344 * Using I915_EXEC_FENCE_OUT requires use of 1345 * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written 1346 * back to userspace. Failure to do so will cause the out-fence to always 1347 * be reported as zero, and the real fence fd to be leaked. 1348 */ 1349 #define I915_EXEC_FENCE_OUT (1<<17) 1350 1351 /* 1352 * Traditionally the execbuf ioctl has only considered the final element in 1353 * the execobject[] to be the executable batch. Often though, the client 1354 * will known the batch object prior to construction and being able to place 1355 * it into the execobject[] array first can simplify the relocation tracking. 1356 * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the 1357 * execobject[] as the * batch instead (the default is to use the last 1358 * element). 1359 */ 1360 #define I915_EXEC_BATCH_FIRST (1<<18) 1361 1362 /* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr 1363 * define an array of i915_gem_exec_fence structures which specify a set of 1364 * dma fences to wait upon or signal. 1365 */ 1366 #define I915_EXEC_FENCE_ARRAY (1<<19) 1367 1368 /* 1369 * Setting I915_EXEC_FENCE_SUBMIT implies that lower_32_bits(rsvd2) represent 1370 * a sync_file fd to wait upon (in a nonblocking manner) prior to executing 1371 * the batch. 1372 * 1373 * Returns -EINVAL if the sync_file fd cannot be found. 1374 */ 1375 #define I915_EXEC_FENCE_SUBMIT (1 << 20) 1376 1377 /* 1378 * Setting I915_EXEC_USE_EXTENSIONS implies that 1379 * drm_i915_gem_execbuffer2.cliprects_ptr is treated as a pointer to an linked 1380 * list of i915_user_extension. Each i915_user_extension node is the base of a 1381 * larger structure. The list of supported structures are listed in the 1382 * drm_i915_gem_execbuffer_ext enum. 1383 */ 1384 #define I915_EXEC_USE_EXTENSIONS (1 << 21) 1385 1386 #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1)) 1387 1388 #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) 1389 #define i915_execbuffer2_set_context_id(eb2, context) \ 1390 (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK 1391 #define i915_execbuffer2_get_context_id(eb2) \ 1392 ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) 1393 1394 struct drm_i915_gem_pin { 1395 /** Handle of the buffer to be pinned. */ 1396 __u32 handle; 1397 __u32 pad; 1398 1399 /** alignment required within the aperture */ 1400 __u64 alignment; 1401 1402 /** Returned GTT offset of the buffer. */ 1403 __u64 offset; 1404 }; 1405 1406 struct drm_i915_gem_unpin { 1407 /** Handle of the buffer to be unpinned. */ 1408 __u32 handle; 1409 __u32 pad; 1410 }; 1411 1412 struct drm_i915_gem_busy { 1413 /** Handle of the buffer to check for busy */ 1414 __u32 handle; 1415 1416 /** Return busy status 1417 * 1418 * A return of 0 implies that the object is idle (after 1419 * having flushed any pending activity), and a non-zero return that 1420 * the object is still in-flight on the GPU. (The GPU has not yet 1421 * signaled completion for all pending requests that reference the 1422 * object.) An object is guaranteed to become idle eventually (so 1423 * long as no new GPU commands are executed upon it). Due to the 1424 * asynchronous nature of the hardware, an object reported 1425 * as busy may become idle before the ioctl is completed. 1426 * 1427 * Furthermore, if the object is busy, which engine is busy is only 1428 * provided as a guide and only indirectly by reporting its class 1429 * (there may be more than one engine in each class). There are race 1430 * conditions which prevent the report of which engines are busy from 1431 * being always accurate. However, the converse is not true. If the 1432 * object is idle, the result of the ioctl, that all engines are idle, 1433 * is accurate. 1434 * 1435 * The returned dword is split into two fields to indicate both 1436 * the engine classess on which the object is being read, and the 1437 * engine class on which it is currently being written (if any). 1438 * 1439 * The low word (bits 0:15) indicate if the object is being written 1440 * to by any engine (there can only be one, as the GEM implicit 1441 * synchronisation rules force writes to be serialised). Only the 1442 * engine class (offset by 1, I915_ENGINE_CLASS_RENDER is reported as 1443 * 1 not 0 etc) for the last write is reported. 1444 * 1445 * The high word (bits 16:31) are a bitmask of which engines classes 1446 * are currently reading from the object. Multiple engines may be 1447 * reading from the object simultaneously. 1448 * 1449 * The value of each engine class is the same as specified in the 1450 * I915_CONTEXT_PARAM_ENGINES context parameter and via perf, i.e. 1451 * I915_ENGINE_CLASS_RENDER, I915_ENGINE_CLASS_COPY, etc. 1452 * Some hardware may have parallel execution engines, e.g. multiple 1453 * media engines, which are mapped to the same class identifier and so 1454 * are not separately reported for busyness. 1455 * 1456 * Caveat emptor: 1457 * Only the boolean result of this query is reliable; that is whether 1458 * the object is idle or busy. The report of which engines are busy 1459 * should be only used as a heuristic. 1460 */ 1461 __u32 busy; 1462 }; 1463 1464 /** 1465 * struct drm_i915_gem_caching - Set or get the caching for given object 1466 * handle. 1467 * 1468 * Allow userspace to control the GTT caching bits for a given object when the 1469 * object is later mapped through the ppGTT(or GGTT on older platforms lacking 1470 * ppGTT support, or if the object is used for scanout). Note that this might 1471 * require unbinding the object from the GTT first, if its current caching value 1472 * doesn't match. 1473 * 1474 * Note that this all changes on discrete platforms, starting from DG1, the 1475 * set/get caching is no longer supported, and is now rejected. Instead the CPU 1476 * caching attributes(WB vs WC) will become an immutable creation time property 1477 * for the object, along with the GTT caching level. For now we don't expose any 1478 * new uAPI for this, instead on DG1 this is all implicit, although this largely 1479 * shouldn't matter since DG1 is coherent by default(without any way of 1480 * controlling it). 1481 * 1482 * Implicit caching rules, starting from DG1: 1483 * 1484 * - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions) 1485 * contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and 1486 * mapped as write-combined only. 1487 * 1488 * - Everything else is always allocated and mapped as write-back, with the 1489 * guarantee that everything is also coherent with the GPU. 1490 * 1491 * Note that this is likely to change in the future again, where we might need 1492 * more flexibility on future devices, so making this all explicit as part of a 1493 * new &drm_i915_gem_create_ext extension is probable. 1494 * 1495 * Side note: Part of the reason for this is that changing the at-allocation-time CPU 1496 * caching attributes for the pages might be required(and is expensive) if we 1497 * need to then CPU map the pages later with different caching attributes. This 1498 * inconsistent caching behaviour, while supported on x86, is not universally 1499 * supported on other architectures. So for simplicity we opt for setting 1500 * everything at creation time, whilst also making it immutable, on discrete 1501 * platforms. 1502 */ 1503 struct drm_i915_gem_caching { 1504 /** 1505 * @handle: Handle of the buffer to set/get the caching level. 1506 */ 1507 __u32 handle; 1508 1509 /** 1510 * @caching: The GTT caching level to apply or possible return value. 1511 * 1512 * The supported @caching values: 1513 * 1514 * I915_CACHING_NONE: 1515 * 1516 * GPU access is not coherent with CPU caches. Default for machines 1517 * without an LLC. This means manual flushing might be needed, if we 1518 * want GPU access to be coherent. 1519 * 1520 * I915_CACHING_CACHED: 1521 * 1522 * GPU access is coherent with CPU caches and furthermore the data is 1523 * cached in last-level caches shared between CPU cores and the GPU GT. 1524 * 1525 * I915_CACHING_DISPLAY: 1526 * 1527 * Special GPU caching mode which is coherent with the scanout engines. 1528 * Transparently falls back to I915_CACHING_NONE on platforms where no 1529 * special cache mode (like write-through or gfdt flushing) is 1530 * available. The kernel automatically sets this mode when using a 1531 * buffer as a scanout target. Userspace can manually set this mode to 1532 * avoid a costly stall and clflush in the hotpath of drawing the first 1533 * frame. 1534 */ 1535 #define I915_CACHING_NONE 0 1536 #define I915_CACHING_CACHED 1 1537 #define I915_CACHING_DISPLAY 2 1538 __u32 caching; 1539 }; 1540 1541 #define I915_TILING_NONE 0 1542 #define I915_TILING_X 1 1543 #define I915_TILING_Y 2 1544 /* 1545 * Do not add new tiling types here. The I915_TILING_* values are for 1546 * de-tiling fence registers that no longer exist on modern platforms. Although 1547 * the hardware may support new types of tiling in general (e.g., Tile4), we 1548 * do not need to add them to the uapi that is specific to now-defunct ioctls. 1549 */ 1550 #define I915_TILING_LAST I915_TILING_Y 1551 1552 #define I915_BIT_6_SWIZZLE_NONE 0 1553 #define I915_BIT_6_SWIZZLE_9 1 1554 #define I915_BIT_6_SWIZZLE_9_10 2 1555 #define I915_BIT_6_SWIZZLE_9_11 3 1556 #define I915_BIT_6_SWIZZLE_9_10_11 4 1557 /* Not seen by userland */ 1558 #define I915_BIT_6_SWIZZLE_UNKNOWN 5 1559 /* Seen by userland. */ 1560 #define I915_BIT_6_SWIZZLE_9_17 6 1561 #define I915_BIT_6_SWIZZLE_9_10_17 7 1562 1563 struct drm_i915_gem_set_tiling { 1564 /** Handle of the buffer to have its tiling state updated */ 1565 __u32 handle; 1566 1567 /** 1568 * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X, 1569 * I915_TILING_Y). 1570 * 1571 * This value is to be set on request, and will be updated by the 1572 * kernel on successful return with the actual chosen tiling layout. 1573 * 1574 * The tiling mode may be demoted to I915_TILING_NONE when the system 1575 * has bit 6 swizzling that can't be managed correctly by GEM. 1576 * 1577 * Buffer contents become undefined when changing tiling_mode. 1578 */ 1579 __u32 tiling_mode; 1580 1581 /** 1582 * Stride in bytes for the object when in I915_TILING_X or 1583 * I915_TILING_Y. 1584 */ 1585 __u32 stride; 1586 1587 /** 1588 * Returned address bit 6 swizzling required for CPU access through 1589 * mmap mapping. 1590 */ 1591 __u32 swizzle_mode; 1592 }; 1593 1594 struct drm_i915_gem_get_tiling { 1595 /** Handle of the buffer to get tiling state for. */ 1596 __u32 handle; 1597 1598 /** 1599 * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X, 1600 * I915_TILING_Y). 1601 */ 1602 __u32 tiling_mode; 1603 1604 /** 1605 * Returned address bit 6 swizzling required for CPU access through 1606 * mmap mapping. 1607 */ 1608 __u32 swizzle_mode; 1609 1610 /** 1611 * Returned address bit 6 swizzling required for CPU access through 1612 * mmap mapping whilst bound. 1613 */ 1614 __u32 phys_swizzle_mode; 1615 }; 1616 1617 struct drm_i915_gem_get_aperture { 1618 /** Total size of the aperture used by i915_gem_execbuffer, in bytes */ 1619 __u64 aper_size; 1620 1621 /** 1622 * Available space in the aperture used by i915_gem_execbuffer, in 1623 * bytes 1624 */ 1625 __u64 aper_available_size; 1626 }; 1627 1628 struct drm_i915_get_pipe_from_crtc_id { 1629 /** ID of CRTC being requested **/ 1630 __u32 crtc_id; 1631 1632 /** pipe of requested CRTC **/ 1633 __u32 pipe; 1634 }; 1635 1636 #define I915_MADV_WILLNEED 0 1637 #define I915_MADV_DONTNEED 1 1638 #define __I915_MADV_PURGED 2 /* internal state */ 1639 1640 struct drm_i915_gem_madvise { 1641 /** Handle of the buffer to change the backing store advice */ 1642 __u32 handle; 1643 1644 /* Advice: either the buffer will be needed again in the near future, 1645 * or wont be and could be discarded under memory pressure. 1646 */ 1647 __u32 madv; 1648 1649 /** Whether the backing store still exists. */ 1650 __u32 retained; 1651 }; 1652 1653 /* flags */ 1654 #define I915_OVERLAY_TYPE_MASK 0xff 1655 #define I915_OVERLAY_YUV_PLANAR 0x01 1656 #define I915_OVERLAY_YUV_PACKED 0x02 1657 #define I915_OVERLAY_RGB 0x03 1658 1659 #define I915_OVERLAY_DEPTH_MASK 0xff00 1660 #define I915_OVERLAY_RGB24 0x1000 1661 #define I915_OVERLAY_RGB16 0x2000 1662 #define I915_OVERLAY_RGB15 0x3000 1663 #define I915_OVERLAY_YUV422 0x0100 1664 #define I915_OVERLAY_YUV411 0x0200 1665 #define I915_OVERLAY_YUV420 0x0300 1666 #define I915_OVERLAY_YUV410 0x0400 1667 1668 #define I915_OVERLAY_SWAP_MASK 0xff0000 1669 #define I915_OVERLAY_NO_SWAP 0x000000 1670 #define I915_OVERLAY_UV_SWAP 0x010000 1671 #define I915_OVERLAY_Y_SWAP 0x020000 1672 #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000 1673 1674 #define I915_OVERLAY_FLAGS_MASK 0xff000000 1675 #define I915_OVERLAY_ENABLE 0x01000000 1676 1677 struct drm_intel_overlay_put_image { 1678 /* various flags and src format description */ 1679 __u32 flags; 1680 /* source picture description */ 1681 __u32 bo_handle; 1682 /* stride values and offsets are in bytes, buffer relative */ 1683 __u16 stride_Y; /* stride for packed formats */ 1684 __u16 stride_UV; 1685 __u32 offset_Y; /* offset for packet formats */ 1686 __u32 offset_U; 1687 __u32 offset_V; 1688 /* in pixels */ 1689 __u16 src_width; 1690 __u16 src_height; 1691 /* to compensate the scaling factors for partially covered surfaces */ 1692 __u16 src_scan_width; 1693 __u16 src_scan_height; 1694 /* output crtc description */ 1695 __u32 crtc_id; 1696 __u16 dst_x; 1697 __u16 dst_y; 1698 __u16 dst_width; 1699 __u16 dst_height; 1700 }; 1701 1702 /* flags */ 1703 #define I915_OVERLAY_UPDATE_ATTRS (1<<0) 1704 #define I915_OVERLAY_UPDATE_GAMMA (1<<1) 1705 #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2) 1706 struct drm_intel_overlay_attrs { 1707 __u32 flags; 1708 __u32 color_key; 1709 __s32 brightness; 1710 __u32 contrast; 1711 __u32 saturation; 1712 __u32 gamma0; 1713 __u32 gamma1; 1714 __u32 gamma2; 1715 __u32 gamma3; 1716 __u32 gamma4; 1717 __u32 gamma5; 1718 }; 1719 1720 /* 1721 * Intel sprite handling 1722 * 1723 * Color keying works with a min/mask/max tuple. Both source and destination 1724 * color keying is allowed. 1725 * 1726 * Source keying: 1727 * Sprite pixels within the min & max values, masked against the color channels 1728 * specified in the mask field, will be transparent. All other pixels will 1729 * be displayed on top of the primary plane. For RGB surfaces, only the min 1730 * and mask fields will be used; ranged compares are not allowed. 1731 * 1732 * Destination keying: 1733 * Primary plane pixels that match the min value, masked against the color 1734 * channels specified in the mask field, will be replaced by corresponding 1735 * pixels from the sprite plane. 1736 * 1737 * Note that source & destination keying are exclusive; only one can be 1738 * active on a given plane. 1739 */ 1740 1741 #define I915_SET_COLORKEY_NONE (1<<0) /* Deprecated. Instead set 1742 * flags==0 to disable colorkeying. 1743 */ 1744 #define I915_SET_COLORKEY_DESTINATION (1<<1) 1745 #define I915_SET_COLORKEY_SOURCE (1<<2) 1746 struct drm_intel_sprite_colorkey { 1747 __u32 plane_id; 1748 __u32 min_value; 1749 __u32 channel_mask; 1750 __u32 max_value; 1751 __u32 flags; 1752 }; 1753 1754 struct drm_i915_gem_wait { 1755 /** Handle of BO we shall wait on */ 1756 __u32 bo_handle; 1757 __u32 flags; 1758 /** Number of nanoseconds to wait, Returns time remaining. */ 1759 __s64 timeout_ns; 1760 }; 1761 1762 struct drm_i915_gem_context_create { 1763 __u32 ctx_id; /* output: id of new context*/ 1764 __u32 pad; 1765 }; 1766 1767 struct drm_i915_gem_context_create_ext { 1768 __u32 ctx_id; /* output: id of new context*/ 1769 __u32 flags; 1770 #define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0) 1771 #define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1) 1772 #define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \ 1773 (-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1)) 1774 __u64 extensions; 1775 }; 1776 1777 struct drm_i915_gem_context_param { 1778 __u32 ctx_id; 1779 __u32 size; 1780 __u64 param; 1781 #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 1782 /* I915_CONTEXT_PARAM_NO_ZEROMAP has been removed. On the off chance 1783 * someone somewhere has attempted to use it, never re-use this context 1784 * param number. 1785 */ 1786 #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 1787 #define I915_CONTEXT_PARAM_GTT_SIZE 0x3 1788 #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4 1789 #define I915_CONTEXT_PARAM_BANNABLE 0x5 1790 #define I915_CONTEXT_PARAM_PRIORITY 0x6 1791 #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */ 1792 #define I915_CONTEXT_DEFAULT_PRIORITY 0 1793 #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */ 1794 /* 1795 * When using the following param, value should be a pointer to 1796 * drm_i915_gem_context_param_sseu. 1797 */ 1798 #define I915_CONTEXT_PARAM_SSEU 0x7 1799 1800 /* 1801 * Not all clients may want to attempt automatic recover of a context after 1802 * a hang (for example, some clients may only submit very small incremental 1803 * batches relying on known logical state of previous batches which will never 1804 * recover correctly and each attempt will hang), and so would prefer that 1805 * the context is forever banned instead. 1806 * 1807 * If set to false (0), after a reset, subsequent (and in flight) rendering 1808 * from this context is discarded, and the client will need to create a new 1809 * context to use instead. 1810 * 1811 * If set to true (1), the kernel will automatically attempt to recover the 1812 * context by skipping the hanging batch and executing the next batch starting 1813 * from the default context state (discarding the incomplete logical context 1814 * state lost due to the reset). 1815 * 1816 * On creation, all new contexts are marked as recoverable. 1817 */ 1818 #define I915_CONTEXT_PARAM_RECOVERABLE 0x8 1819 1820 /* 1821 * The id of the associated virtual memory address space (ppGTT) of 1822 * this context. Can be retrieved and passed to another context 1823 * (on the same fd) for both to use the same ppGTT and so share 1824 * address layouts, and avoid reloading the page tables on context 1825 * switches between themselves. 1826 * 1827 * See DRM_I915_GEM_VM_CREATE and DRM_I915_GEM_VM_DESTROY. 1828 */ 1829 #define I915_CONTEXT_PARAM_VM 0x9 1830 1831 /* 1832 * I915_CONTEXT_PARAM_ENGINES: 1833 * 1834 * Bind this context to operate on this subset of available engines. Henceforth, 1835 * the I915_EXEC_RING selector for DRM_IOCTL_I915_GEM_EXECBUFFER2 operates as 1836 * an index into this array of engines; I915_EXEC_DEFAULT selecting engine[0] 1837 * and upwards. Slots 0...N are filled in using the specified (class, instance). 1838 * Use 1839 * engine_class: I915_ENGINE_CLASS_INVALID, 1840 * engine_instance: I915_ENGINE_CLASS_INVALID_NONE 1841 * to specify a gap in the array that can be filled in later, e.g. by a 1842 * virtual engine used for load balancing. 1843 * 1844 * Setting the number of engines bound to the context to 0, by passing a zero 1845 * sized argument, will revert back to default settings. 1846 * 1847 * See struct i915_context_param_engines. 1848 * 1849 * Extensions: 1850 * i915_context_engines_load_balance (I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE) 1851 * i915_context_engines_bond (I915_CONTEXT_ENGINES_EXT_BOND) 1852 * i915_context_engines_parallel_submit (I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT) 1853 */ 1854 #define I915_CONTEXT_PARAM_ENGINES 0xa 1855 1856 /* 1857 * I915_CONTEXT_PARAM_PERSISTENCE: 1858 * 1859 * Allow the context and active rendering to survive the process until 1860 * completion. Persistence allows fire-and-forget clients to queue up a 1861 * bunch of work, hand the output over to a display server and then quit. 1862 * If the context is marked as not persistent, upon closing (either via 1863 * an explicit DRM_I915_GEM_CONTEXT_DESTROY or implicitly from file closure 1864 * or process termination), the context and any outstanding requests will be 1865 * cancelled (and exported fences for cancelled requests marked as -EIO). 1866 * 1867 * By default, new contexts allow persistence. 1868 */ 1869 #define I915_CONTEXT_PARAM_PERSISTENCE 0xb 1870 1871 /* This API has been removed. On the off chance someone somewhere has 1872 * attempted to use it, never re-use this context param number. 1873 */ 1874 #define I915_CONTEXT_PARAM_RINGSIZE 0xc 1875 1876 /* 1877 * I915_CONTEXT_PARAM_PROTECTED_CONTENT: 1878 * 1879 * Mark that the context makes use of protected content, which will result 1880 * in the context being invalidated when the protected content session is. 1881 * Given that the protected content session is killed on suspend, the device 1882 * is kept awake for the lifetime of a protected context, so the user should 1883 * make sure to dispose of them once done. 1884 * This flag can only be set at context creation time and, when set to true, 1885 * must be preceded by an explicit setting of I915_CONTEXT_PARAM_RECOVERABLE 1886 * to false. This flag can't be set to true in conjunction with setting the 1887 * I915_CONTEXT_PARAM_BANNABLE flag to false. Creation example: 1888 * 1889 * .. code-block:: C 1890 * 1891 * struct drm_i915_gem_context_create_ext_setparam p_protected = { 1892 * .base = { 1893 * .name = I915_CONTEXT_CREATE_EXT_SETPARAM, 1894 * }, 1895 * .param = { 1896 * .param = I915_CONTEXT_PARAM_PROTECTED_CONTENT, 1897 * .value = 1, 1898 * } 1899 * }; 1900 * struct drm_i915_gem_context_create_ext_setparam p_norecover = { 1901 * .base = { 1902 * .name = I915_CONTEXT_CREATE_EXT_SETPARAM, 1903 * .next_extension = to_user_pointer(&p_protected), 1904 * }, 1905 * .param = { 1906 * .param = I915_CONTEXT_PARAM_RECOVERABLE, 1907 * .value = 0, 1908 * } 1909 * }; 1910 * struct drm_i915_gem_context_create_ext create = { 1911 * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, 1912 * .extensions = to_user_pointer(&p_norecover); 1913 * }; 1914 * 1915 * ctx_id = gem_context_create_ext(drm_fd, &create); 1916 * 1917 * In addition to the normal failure cases, setting this flag during context 1918 * creation can result in the following errors: 1919 * 1920 * -ENODEV: feature not available 1921 * -EPERM: trying to mark a recoverable or not bannable context as protected 1922 */ 1923 #define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd 1924 /* Must be kept compact -- no holes and well documented */ 1925 1926 __u64 value; 1927 }; 1928 1929 /* 1930 * Context SSEU programming 1931 * 1932 * It may be necessary for either functional or performance reason to configure 1933 * a context to run with a reduced number of SSEU (where SSEU stands for Slice/ 1934 * Sub-slice/EU). 1935 * 1936 * This is done by configuring SSEU configuration using the below 1937 * @struct drm_i915_gem_context_param_sseu for every supported engine which 1938 * userspace intends to use. 1939 * 1940 * Not all GPUs or engines support this functionality in which case an error 1941 * code -ENODEV will be returned. 1942 * 1943 * Also, flexibility of possible SSEU configuration permutations varies between 1944 * GPU generations and software imposed limitations. Requesting such a 1945 * combination will return an error code of -EINVAL. 1946 * 1947 * NOTE: When perf/OA is active the context's SSEU configuration is ignored in 1948 * favour of a single global setting. 1949 */ 1950 struct drm_i915_gem_context_param_sseu { 1951 /* 1952 * Engine class & instance to be configured or queried. 1953 */ 1954 struct i915_engine_class_instance engine; 1955 1956 /* 1957 * Unknown flags must be cleared to zero. 1958 */ 1959 __u32 flags; 1960 #define I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX (1u << 0) 1961 1962 /* 1963 * Mask of slices to enable for the context. Valid values are a subset 1964 * of the bitmask value returned for I915_PARAM_SLICE_MASK. 1965 */ 1966 __u64 slice_mask; 1967 1968 /* 1969 * Mask of subslices to enable for the context. Valid values are a 1970 * subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK. 1971 */ 1972 __u64 subslice_mask; 1973 1974 /* 1975 * Minimum/Maximum number of EUs to enable per subslice for the 1976 * context. min_eus_per_subslice must be inferior or equal to 1977 * max_eus_per_subslice. 1978 */ 1979 __u16 min_eus_per_subslice; 1980 __u16 max_eus_per_subslice; 1981 1982 /* 1983 * Unused for now. Must be cleared to zero. 1984 */ 1985 __u32 rsvd; 1986 }; 1987 1988 /** 1989 * DOC: Virtual Engine uAPI 1990 * 1991 * Virtual engine is a concept where userspace is able to configure a set of 1992 * physical engines, submit a batch buffer, and let the driver execute it on any 1993 * engine from the set as it sees fit. 1994 * 1995 * This is primarily useful on parts which have multiple instances of a same 1996 * class engine, like for example GT3+ Skylake parts with their two VCS engines. 1997 * 1998 * For instance userspace can enumerate all engines of a certain class using the 1999 * previously described `Engine Discovery uAPI`_. After that userspace can 2000 * create a GEM context with a placeholder slot for the virtual engine (using 2001 * `I915_ENGINE_CLASS_INVALID` and `I915_ENGINE_CLASS_INVALID_NONE` for class 2002 * and instance respectively) and finally using the 2003 * `I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE` extension place a virtual engine in 2004 * the same reserved slot. 2005 * 2006 * Example of creating a virtual engine and submitting a batch buffer to it: 2007 * 2008 * .. code-block:: C 2009 * 2010 * I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(virtual, 2) = { 2011 * .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE, 2012 * .engine_index = 0, // Place this virtual engine into engine map slot 0 2013 * .num_siblings = 2, 2014 * .engines = { { I915_ENGINE_CLASS_VIDEO, 0 }, 2015 * { I915_ENGINE_CLASS_VIDEO, 1 }, }, 2016 * }; 2017 * I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = { 2018 * .engines = { { I915_ENGINE_CLASS_INVALID, 2019 * I915_ENGINE_CLASS_INVALID_NONE } }, 2020 * .extensions = to_user_pointer(&virtual), // Chains after load_balance extension 2021 * }; 2022 * struct drm_i915_gem_context_create_ext_setparam p_engines = { 2023 * .base = { 2024 * .name = I915_CONTEXT_CREATE_EXT_SETPARAM, 2025 * }, 2026 * .param = { 2027 * .param = I915_CONTEXT_PARAM_ENGINES, 2028 * .value = to_user_pointer(&engines), 2029 * .size = sizeof(engines), 2030 * }, 2031 * }; 2032 * struct drm_i915_gem_context_create_ext create = { 2033 * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, 2034 * .extensions = to_user_pointer(&p_engines); 2035 * }; 2036 * 2037 * ctx_id = gem_context_create_ext(drm_fd, &create); 2038 * 2039 * // Now we have created a GEM context with its engine map containing a 2040 * // single virtual engine. Submissions to this slot can go either to 2041 * // vcs0 or vcs1, depending on the load balancing algorithm used inside 2042 * // the driver. The load balancing is dynamic from one batch buffer to 2043 * // another and transparent to userspace. 2044 * 2045 * ... 2046 * execbuf.rsvd1 = ctx_id; 2047 * execbuf.flags = 0; // Submits to index 0 which is the virtual engine 2048 * gem_execbuf(drm_fd, &execbuf); 2049 */ 2050 2051 /* 2052 * i915_context_engines_load_balance: 2053 * 2054 * Enable load balancing across this set of engines. 2055 * 2056 * Into the I915_EXEC_DEFAULT slot [0], a virtual engine is created that when 2057 * used will proxy the execbuffer request onto one of the set of engines 2058 * in such a way as to distribute the load evenly across the set. 2059 * 2060 * The set of engines must be compatible (e.g. the same HW class) as they 2061 * will share the same logical GPU context and ring. 2062 * 2063 * To intermix rendering with the virtual engine and direct rendering onto 2064 * the backing engines (bypassing the load balancing proxy), the context must 2065 * be defined to use a single timeline for all engines. 2066 */ 2067 struct i915_context_engines_load_balance { 2068 struct i915_user_extension base; 2069 2070 __u16 engine_index; 2071 __u16 num_siblings; 2072 __u32 flags; /* all undefined flags must be zero */ 2073 2074 __u64 mbz64; /* reserved for future use; must be zero */ 2075 2076 struct i915_engine_class_instance engines[0]; 2077 } __attribute__((packed)); 2078 2079 #define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \ 2080 struct i915_user_extension base; \ 2081 __u16 engine_index; \ 2082 __u16 num_siblings; \ 2083 __u32 flags; \ 2084 __u64 mbz64; \ 2085 struct i915_engine_class_instance engines[N__]; \ 2086 } __attribute__((packed)) name__ 2087 2088 /* 2089 * i915_context_engines_bond: 2090 * 2091 * Constructed bonded pairs for execution within a virtual engine. 2092 * 2093 * All engines are equal, but some are more equal than others. Given 2094 * the distribution of resources in the HW, it may be preferable to run 2095 * a request on a given subset of engines in parallel to a request on a 2096 * specific engine. We enable this selection of engines within a virtual 2097 * engine by specifying bonding pairs, for any given master engine we will 2098 * only execute on one of the corresponding siblings within the virtual engine. 2099 * 2100 * To execute a request in parallel on the master engine and a sibling requires 2101 * coordination with a I915_EXEC_FENCE_SUBMIT. 2102 */ 2103 struct i915_context_engines_bond { 2104 struct i915_user_extension base; 2105 2106 struct i915_engine_class_instance master; 2107 2108 __u16 virtual_index; /* index of virtual engine in ctx->engines[] */ 2109 __u16 num_bonds; 2110 2111 __u64 flags; /* all undefined flags must be zero */ 2112 __u64 mbz64[4]; /* reserved for future use; must be zero */ 2113 2114 struct i915_engine_class_instance engines[0]; 2115 } __attribute__((packed)); 2116 2117 #define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \ 2118 struct i915_user_extension base; \ 2119 struct i915_engine_class_instance master; \ 2120 __u16 virtual_index; \ 2121 __u16 num_bonds; \ 2122 __u64 flags; \ 2123 __u64 mbz64[4]; \ 2124 struct i915_engine_class_instance engines[N__]; \ 2125 } __attribute__((packed)) name__ 2126 2127 /** 2128 * struct i915_context_engines_parallel_submit - Configure engine for 2129 * parallel submission. 2130 * 2131 * Setup a slot in the context engine map to allow multiple BBs to be submitted 2132 * in a single execbuf IOCTL. Those BBs will then be scheduled to run on the GPU 2133 * in parallel. Multiple hardware contexts are created internally in the i915 to 2134 * run these BBs. Once a slot is configured for N BBs only N BBs can be 2135 * submitted in each execbuf IOCTL and this is implicit behavior e.g. The user 2136 * doesn't tell the execbuf IOCTL there are N BBs, the execbuf IOCTL knows how 2137 * many BBs there are based on the slot's configuration. The N BBs are the last 2138 * N buffer objects or first N if I915_EXEC_BATCH_FIRST is set. 2139 * 2140 * The default placement behavior is to create implicit bonds between each 2141 * context if each context maps to more than 1 physical engine (e.g. context is 2142 * a virtual engine). Also we only allow contexts of same engine class and these 2143 * contexts must be in logically contiguous order. Examples of the placement 2144 * behavior are described below. Lastly, the default is to not allow BBs to be 2145 * preempted mid-batch. Rather insert coordinated preemption points on all 2146 * hardware contexts between each set of BBs. Flags could be added in the future 2147 * to change both of these default behaviors. 2148 * 2149 * Returns -EINVAL if hardware context placement configuration is invalid or if 2150 * the placement configuration isn't supported on the platform / submission 2151 * interface. 2152 * Returns -ENODEV if extension isn't supported on the platform / submission 2153 * interface. 2154 * 2155 * .. code-block:: none 2156 * 2157 * Examples syntax: 2158 * CS[X] = generic engine of same class, logical instance X 2159 * INVALID = I915_ENGINE_CLASS_INVALID, I915_ENGINE_CLASS_INVALID_NONE 2160 * 2161 * Example 1 pseudo code: 2162 * set_engines(INVALID) 2163 * set_parallel(engine_index=0, width=2, num_siblings=1, 2164 * engines=CS[0],CS[1]) 2165 * 2166 * Results in the following valid placement: 2167 * CS[0], CS[1] 2168 * 2169 * Example 2 pseudo code: 2170 * set_engines(INVALID) 2171 * set_parallel(engine_index=0, width=2, num_siblings=2, 2172 * engines=CS[0],CS[2],CS[1],CS[3]) 2173 * 2174 * Results in the following valid placements: 2175 * CS[0], CS[1] 2176 * CS[2], CS[3] 2177 * 2178 * This can be thought of as two virtual engines, each containing two 2179 * engines thereby making a 2D array. However, there are bonds tying the 2180 * entries together and placing restrictions on how they can be scheduled. 2181 * Specifically, the scheduler can choose only vertical columns from the 2D 2182 * array. That is, CS[0] is bonded to CS[1] and CS[2] to CS[3]. So if the 2183 * scheduler wants to submit to CS[0], it must also choose CS[1] and vice 2184 * versa. Same for CS[2] requires also using CS[3]. 2185 * VE[0] = CS[0], CS[2] 2186 * VE[1] = CS[1], CS[3] 2187 * 2188 * Example 3 pseudo code: 2189 * set_engines(INVALID) 2190 * set_parallel(engine_index=0, width=2, num_siblings=2, 2191 * engines=CS[0],CS[1],CS[1],CS[3]) 2192 * 2193 * Results in the following valid and invalid placements: 2194 * CS[0], CS[1] 2195 * CS[1], CS[3] - Not logically contiguous, return -EINVAL 2196 */ 2197 struct i915_context_engines_parallel_submit { 2198 /** 2199 * @base: base user extension. 2200 */ 2201 struct i915_user_extension base; 2202 2203 /** 2204 * @engine_index: slot for parallel engine 2205 */ 2206 __u16 engine_index; 2207 2208 /** 2209 * @width: number of contexts per parallel engine or in other words the 2210 * number of batches in each submission 2211 */ 2212 __u16 width; 2213 2214 /** 2215 * @num_siblings: number of siblings per context or in other words the 2216 * number of possible placements for each submission 2217 */ 2218 __u16 num_siblings; 2219 2220 /** 2221 * @mbz16: reserved for future use; must be zero 2222 */ 2223 __u16 mbz16; 2224 2225 /** 2226 * @flags: all undefined flags must be zero, currently not defined flags 2227 */ 2228 __u64 flags; 2229 2230 /** 2231 * @mbz64: reserved for future use; must be zero 2232 */ 2233 __u64 mbz64[3]; 2234 2235 /** 2236 * @engines: 2-d array of engine instances to configure parallel engine 2237 * 2238 * length = width (i) * num_siblings (j) 2239 * index = j + i * num_siblings 2240 */ 2241 struct i915_engine_class_instance engines[0]; 2242 2243 } __packed; 2244 2245 #define I915_DEFINE_CONTEXT_ENGINES_PARALLEL_SUBMIT(name__, N__) struct { \ 2246 struct i915_user_extension base; \ 2247 __u16 engine_index; \ 2248 __u16 width; \ 2249 __u16 num_siblings; \ 2250 __u16 mbz16; \ 2251 __u64 flags; \ 2252 __u64 mbz64[3]; \ 2253 struct i915_engine_class_instance engines[N__]; \ 2254 } __attribute__((packed)) name__ 2255 2256 /** 2257 * DOC: Context Engine Map uAPI 2258 * 2259 * Context engine map is a new way of addressing engines when submitting batch- 2260 * buffers, replacing the existing way of using identifiers like `I915_EXEC_BLT` 2261 * inside the flags field of `struct drm_i915_gem_execbuffer2`. 2262 * 2263 * To use it created GEM contexts need to be configured with a list of engines 2264 * the user is intending to submit to. This is accomplished using the 2265 * `I915_CONTEXT_PARAM_ENGINES` parameter and `struct 2266 * i915_context_param_engines`. 2267 * 2268 * For such contexts the `I915_EXEC_RING_MASK` field becomes an index into the 2269 * configured map. 2270 * 2271 * Example of creating such context and submitting against it: 2272 * 2273 * .. code-block:: C 2274 * 2275 * I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 2) = { 2276 * .engines = { { I915_ENGINE_CLASS_RENDER, 0 }, 2277 * { I915_ENGINE_CLASS_COPY, 0 } } 2278 * }; 2279 * struct drm_i915_gem_context_create_ext_setparam p_engines = { 2280 * .base = { 2281 * .name = I915_CONTEXT_CREATE_EXT_SETPARAM, 2282 * }, 2283 * .param = { 2284 * .param = I915_CONTEXT_PARAM_ENGINES, 2285 * .value = to_user_pointer(&engines), 2286 * .size = sizeof(engines), 2287 * }, 2288 * }; 2289 * struct drm_i915_gem_context_create_ext create = { 2290 * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, 2291 * .extensions = to_user_pointer(&p_engines); 2292 * }; 2293 * 2294 * ctx_id = gem_context_create_ext(drm_fd, &create); 2295 * 2296 * // We have now created a GEM context with two engines in the map: 2297 * // Index 0 points to rcs0 while index 1 points to bcs0. Other engines 2298 * // will not be accessible from this context. 2299 * 2300 * ... 2301 * execbuf.rsvd1 = ctx_id; 2302 * execbuf.flags = 0; // Submits to index 0, which is rcs0 for this context 2303 * gem_execbuf(drm_fd, &execbuf); 2304 * 2305 * ... 2306 * execbuf.rsvd1 = ctx_id; 2307 * execbuf.flags = 1; // Submits to index 0, which is bcs0 for this context 2308 * gem_execbuf(drm_fd, &execbuf); 2309 */ 2310 2311 struct i915_context_param_engines { 2312 __u64 extensions; /* linked chain of extension blocks, 0 terminates */ 2313 #define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */ 2314 #define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */ 2315 #define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */ 2316 struct i915_engine_class_instance engines[0]; 2317 } __attribute__((packed)); 2318 2319 #define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \ 2320 __u64 extensions; \ 2321 struct i915_engine_class_instance engines[N__]; \ 2322 } __attribute__((packed)) name__ 2323 2324 struct drm_i915_gem_context_create_ext_setparam { 2325 #define I915_CONTEXT_CREATE_EXT_SETPARAM 0 2326 struct i915_user_extension base; 2327 struct drm_i915_gem_context_param param; 2328 }; 2329 2330 /* This API has been removed. On the off chance someone somewhere has 2331 * attempted to use it, never re-use this extension number. 2332 */ 2333 #define I915_CONTEXT_CREATE_EXT_CLONE 1 2334 2335 struct drm_i915_gem_context_destroy { 2336 __u32 ctx_id; 2337 __u32 pad; 2338 }; 2339 2340 /* 2341 * DRM_I915_GEM_VM_CREATE - 2342 * 2343 * Create a new virtual memory address space (ppGTT) for use within a context 2344 * on the same file. Extensions can be provided to configure exactly how the 2345 * address space is setup upon creation. 2346 * 2347 * The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is 2348 * returned in the outparam @id. 2349 * 2350 * No flags are defined, with all bits reserved and must be zero. 2351 * 2352 * An extension chain maybe provided, starting with @extensions, and terminated 2353 * by the @next_extension being 0. Currently, no extensions are defined. 2354 * 2355 * DRM_I915_GEM_VM_DESTROY - 2356 * 2357 * Destroys a previously created VM id, specified in @id. 2358 * 2359 * No extensions or flags are allowed currently, and so must be zero. 2360 */ 2361 struct drm_i915_gem_vm_control { 2362 __u64 extensions; 2363 __u32 flags; 2364 __u32 vm_id; 2365 }; 2366 2367 struct drm_i915_reg_read { 2368 /* 2369 * Register offset. 2370 * For 64bit wide registers where the upper 32bits don't immediately 2371 * follow the lower 32bits, the offset of the lower 32bits must 2372 * be specified 2373 */ 2374 __u64 offset; 2375 #define I915_REG_READ_8B_WA (1ul << 0) 2376 2377 __u64 val; /* Return value */ 2378 }; 2379 2380 /* Known registers: 2381 * 2382 * Render engine timestamp - 0x2358 + 64bit - gen7+ 2383 * - Note this register returns an invalid value if using the default 2384 * single instruction 8byte read, in order to workaround that pass 2385 * flag I915_REG_READ_8B_WA in offset field. 2386 * 2387 */ 2388 2389 struct drm_i915_reset_stats { 2390 __u32 ctx_id; 2391 __u32 flags; 2392 2393 /* All resets since boot/module reload, for all contexts */ 2394 __u32 reset_count; 2395 2396 /* Number of batches lost when active in GPU, for this context */ 2397 __u32 batch_active; 2398 2399 /* Number of batches lost pending for execution, for this context */ 2400 __u32 batch_pending; 2401 2402 __u32 pad; 2403 }; 2404 2405 /** 2406 * struct drm_i915_gem_userptr - Create GEM object from user allocated memory. 2407 * 2408 * Userptr objects have several restrictions on what ioctls can be used with the 2409 * object handle. 2410 */ 2411 struct drm_i915_gem_userptr { 2412 /** 2413 * @user_ptr: The pointer to the allocated memory. 2414 * 2415 * Needs to be aligned to PAGE_SIZE. 2416 */ 2417 __u64 user_ptr; 2418 2419 /** 2420 * @user_size: 2421 * 2422 * The size in bytes for the allocated memory. This will also become the 2423 * object size. 2424 * 2425 * Needs to be aligned to PAGE_SIZE, and should be at least PAGE_SIZE, 2426 * or larger. 2427 */ 2428 __u64 user_size; 2429 2430 /** 2431 * @flags: 2432 * 2433 * Supported flags: 2434 * 2435 * I915_USERPTR_READ_ONLY: 2436 * 2437 * Mark the object as readonly, this also means GPU access can only be 2438 * readonly. This is only supported on HW which supports readonly access 2439 * through the GTT. If the HW can't support readonly access, an error is 2440 * returned. 2441 * 2442 * I915_USERPTR_PROBE: 2443 * 2444 * Probe the provided @user_ptr range and validate that the @user_ptr is 2445 * indeed pointing to normal memory and that the range is also valid. 2446 * For example if some garbage address is given to the kernel, then this 2447 * should complain. 2448 * 2449 * Returns -EFAULT if the probe failed. 2450 * 2451 * Note that this doesn't populate the backing pages, and also doesn't 2452 * guarantee that the object will remain valid when the object is 2453 * eventually used. 2454 * 2455 * The kernel supports this feature if I915_PARAM_HAS_USERPTR_PROBE 2456 * returns a non-zero value. 2457 * 2458 * I915_USERPTR_UNSYNCHRONIZED: 2459 * 2460 * NOT USED. Setting this flag will result in an error. 2461 */ 2462 __u32 flags; 2463 #define I915_USERPTR_READ_ONLY 0x1 2464 #define I915_USERPTR_PROBE 0x2 2465 #define I915_USERPTR_UNSYNCHRONIZED 0x80000000 2466 /** 2467 * @handle: Returned handle for the object. 2468 * 2469 * Object handles are nonzero. 2470 */ 2471 __u32 handle; 2472 }; 2473 2474 enum drm_i915_oa_format { 2475 I915_OA_FORMAT_A13 = 1, /* HSW only */ 2476 I915_OA_FORMAT_A29, /* HSW only */ 2477 I915_OA_FORMAT_A13_B8_C8, /* HSW only */ 2478 I915_OA_FORMAT_B4_C8, /* HSW only */ 2479 I915_OA_FORMAT_A45_B8_C8, /* HSW only */ 2480 I915_OA_FORMAT_B4_C8_A16, /* HSW only */ 2481 I915_OA_FORMAT_C4_B8, /* HSW+ */ 2482 2483 /* Gen8+ */ 2484 I915_OA_FORMAT_A12, 2485 I915_OA_FORMAT_A12_B8_C8, 2486 I915_OA_FORMAT_A32u40_A4u32_B8_C8, 2487 2488 I915_OA_FORMAT_MAX /* non-ABI */ 2489 }; 2490 2491 enum drm_i915_perf_property_id { 2492 /** 2493 * Open the stream for a specific context handle (as used with 2494 * execbuffer2). A stream opened for a specific context this way 2495 * won't typically require root privileges. 2496 * 2497 * This property is available in perf revision 1. 2498 */ 2499 DRM_I915_PERF_PROP_CTX_HANDLE = 1, 2500 2501 /** 2502 * A value of 1 requests the inclusion of raw OA unit reports as 2503 * part of stream samples. 2504 * 2505 * This property is available in perf revision 1. 2506 */ 2507 DRM_I915_PERF_PROP_SAMPLE_OA, 2508 2509 /** 2510 * The value specifies which set of OA unit metrics should be 2511 * configured, defining the contents of any OA unit reports. 2512 * 2513 * This property is available in perf revision 1. 2514 */ 2515 DRM_I915_PERF_PROP_OA_METRICS_SET, 2516 2517 /** 2518 * The value specifies the size and layout of OA unit reports. 2519 * 2520 * This property is available in perf revision 1. 2521 */ 2522 DRM_I915_PERF_PROP_OA_FORMAT, 2523 2524 /** 2525 * Specifying this property implicitly requests periodic OA unit 2526 * sampling and (at least on Haswell) the sampling frequency is derived 2527 * from this exponent as follows: 2528 * 2529 * 80ns * 2^(period_exponent + 1) 2530 * 2531 * This property is available in perf revision 1. 2532 */ 2533 DRM_I915_PERF_PROP_OA_EXPONENT, 2534 2535 /** 2536 * Specifying this property is only valid when specify a context to 2537 * filter with DRM_I915_PERF_PROP_CTX_HANDLE. Specifying this property 2538 * will hold preemption of the particular context we want to gather 2539 * performance data about. The execbuf2 submissions must include a 2540 * drm_i915_gem_execbuffer_ext_perf parameter for this to apply. 2541 * 2542 * This property is available in perf revision 3. 2543 */ 2544 DRM_I915_PERF_PROP_HOLD_PREEMPTION, 2545 2546 /** 2547 * Specifying this pins all contexts to the specified SSEU power 2548 * configuration for the duration of the recording. 2549 * 2550 * This parameter's value is a pointer to a struct 2551 * drm_i915_gem_context_param_sseu. 2552 * 2553 * This property is available in perf revision 4. 2554 */ 2555 DRM_I915_PERF_PROP_GLOBAL_SSEU, 2556 2557 /** 2558 * This optional parameter specifies the timer interval in nanoseconds 2559 * at which the i915 driver will check the OA buffer for available data. 2560 * Minimum allowed value is 100 microseconds. A default value is used by 2561 * the driver if this parameter is not specified. Note that larger timer 2562 * values will reduce cpu consumption during OA perf captures. However, 2563 * excessively large values would potentially result in OA buffer 2564 * overwrites as captures reach end of the OA buffer. 2565 * 2566 * This property is available in perf revision 5. 2567 */ 2568 DRM_I915_PERF_PROP_POLL_OA_PERIOD, 2569 2570 DRM_I915_PERF_PROP_MAX /* non-ABI */ 2571 }; 2572 2573 struct drm_i915_perf_open_param { 2574 __u32 flags; 2575 #define I915_PERF_FLAG_FD_CLOEXEC (1<<0) 2576 #define I915_PERF_FLAG_FD_NONBLOCK (1<<1) 2577 #define I915_PERF_FLAG_DISABLED (1<<2) 2578 2579 /** The number of u64 (id, value) pairs */ 2580 __u32 num_properties; 2581 2582 /** 2583 * Pointer to array of u64 (id, value) pairs configuring the stream 2584 * to open. 2585 */ 2586 __u64 properties_ptr; 2587 }; 2588 2589 /* 2590 * Enable data capture for a stream that was either opened in a disabled state 2591 * via I915_PERF_FLAG_DISABLED or was later disabled via 2592 * I915_PERF_IOCTL_DISABLE. 2593 * 2594 * It is intended to be cheaper to disable and enable a stream than it may be 2595 * to close and re-open a stream with the same configuration. 2596 * 2597 * It's undefined whether any pending data for the stream will be lost. 2598 * 2599 * This ioctl is available in perf revision 1. 2600 */ 2601 #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0) 2602 2603 /* 2604 * Disable data capture for a stream. 2605 * 2606 * It is an error to try and read a stream that is disabled. 2607 * 2608 * This ioctl is available in perf revision 1. 2609 */ 2610 #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1) 2611 2612 /* 2613 * Change metrics_set captured by a stream. 2614 * 2615 * If the stream is bound to a specific context, the configuration change 2616 * will performed inline with that context such that it takes effect before 2617 * the next execbuf submission. 2618 * 2619 * Returns the previously bound metrics set id, or a negative error code. 2620 * 2621 * This ioctl is available in perf revision 2. 2622 */ 2623 #define I915_PERF_IOCTL_CONFIG _IO('i', 0x2) 2624 2625 /* 2626 * Common to all i915 perf records 2627 */ 2628 struct drm_i915_perf_record_header { 2629 __u32 type; 2630 __u16 pad; 2631 __u16 size; 2632 }; 2633 2634 enum drm_i915_perf_record_type { 2635 2636 /** 2637 * Samples are the work horse record type whose contents are extensible 2638 * and defined when opening an i915 perf stream based on the given 2639 * properties. 2640 * 2641 * Boolean properties following the naming convention 2642 * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in 2643 * every sample. 2644 * 2645 * The order of these sample properties given by userspace has no 2646 * affect on the ordering of data within a sample. The order is 2647 * documented here. 2648 * 2649 * struct { 2650 * struct drm_i915_perf_record_header header; 2651 * 2652 * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA 2653 * }; 2654 */ 2655 DRM_I915_PERF_RECORD_SAMPLE = 1, 2656 2657 /* 2658 * Indicates that one or more OA reports were not written by the 2659 * hardware. This can happen for example if an MI_REPORT_PERF_COUNT 2660 * command collides with periodic sampling - which would be more likely 2661 * at higher sampling frequencies. 2662 */ 2663 DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2, 2664 2665 /** 2666 * An error occurred that resulted in all pending OA reports being lost. 2667 */ 2668 DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3, 2669 2670 DRM_I915_PERF_RECORD_MAX /* non-ABI */ 2671 }; 2672 2673 /** 2674 * struct drm_i915_perf_oa_config 2675 * 2676 * Structure to upload perf dynamic configuration into the kernel. 2677 */ 2678 struct drm_i915_perf_oa_config { 2679 /** 2680 * @uuid: 2681 * 2682 * String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x" 2683 */ 2684 char uuid[36]; 2685 2686 /** 2687 * @n_mux_regs: 2688 * 2689 * Number of mux regs in &mux_regs_ptr. 2690 */ 2691 __u32 n_mux_regs; 2692 2693 /** 2694 * @n_boolean_regs: 2695 * 2696 * Number of boolean regs in &boolean_regs_ptr. 2697 */ 2698 __u32 n_boolean_regs; 2699 2700 /** 2701 * @n_flex_regs: 2702 * 2703 * Number of flex regs in &flex_regs_ptr. 2704 */ 2705 __u32 n_flex_regs; 2706 2707 /** 2708 * @mux_regs_ptr: 2709 * 2710 * Pointer to tuples of u32 values (register address, value) for mux 2711 * registers. Expected length of buffer is (2 * sizeof(u32) * 2712 * &n_mux_regs). 2713 */ 2714 __u64 mux_regs_ptr; 2715 2716 /** 2717 * @boolean_regs_ptr: 2718 * 2719 * Pointer to tuples of u32 values (register address, value) for mux 2720 * registers. Expected length of buffer is (2 * sizeof(u32) * 2721 * &n_boolean_regs). 2722 */ 2723 __u64 boolean_regs_ptr; 2724 2725 /** 2726 * @flex_regs_ptr: 2727 * 2728 * Pointer to tuples of u32 values (register address, value) for mux 2729 * registers. Expected length of buffer is (2 * sizeof(u32) * 2730 * &n_flex_regs). 2731 */ 2732 __u64 flex_regs_ptr; 2733 }; 2734 2735 /** 2736 * struct drm_i915_query_item - An individual query for the kernel to process. 2737 * 2738 * The behaviour is determined by the @query_id. Note that exactly what 2739 * @data_ptr is also depends on the specific @query_id. 2740 */ 2741 struct drm_i915_query_item { 2742 /** 2743 * @query_id: 2744 * 2745 * The id for this query. Currently accepted query IDs are: 2746 * - %DRM_I915_QUERY_TOPOLOGY_INFO (see struct drm_i915_query_topology_info) 2747 * - %DRM_I915_QUERY_ENGINE_INFO (see struct drm_i915_engine_info) 2748 * - %DRM_I915_QUERY_PERF_CONFIG (see struct drm_i915_query_perf_config) 2749 * - %DRM_I915_QUERY_MEMORY_REGIONS (see struct drm_i915_query_memory_regions) 2750 * - %DRM_I915_QUERY_HWCONFIG_BLOB (see `GuC HWCONFIG blob uAPI`) 2751 * - %DRM_I915_QUERY_GEOMETRY_SUBSLICES (see struct drm_i915_query_topology_info) 2752 */ 2753 __u64 query_id; 2754 #define DRM_I915_QUERY_TOPOLOGY_INFO 1 2755 #define DRM_I915_QUERY_ENGINE_INFO 2 2756 #define DRM_I915_QUERY_PERF_CONFIG 3 2757 #define DRM_I915_QUERY_MEMORY_REGIONS 4 2758 #define DRM_I915_QUERY_HWCONFIG_BLOB 5 2759 #define DRM_I915_QUERY_GEOMETRY_SUBSLICES 6 2760 /* Must be kept compact -- no holes and well documented */ 2761 2762 /** 2763 * @length: 2764 * 2765 * When set to zero by userspace, this is filled with the size of the 2766 * data to be written at the @data_ptr pointer. The kernel sets this 2767 * value to a negative value to signal an error on a particular query 2768 * item. 2769 */ 2770 __s32 length; 2771 2772 /** 2773 * @flags: 2774 * 2775 * When &query_id == %DRM_I915_QUERY_TOPOLOGY_INFO, must be 0. 2776 * 2777 * When &query_id == %DRM_I915_QUERY_PERF_CONFIG, must be one of the 2778 * following: 2779 * 2780 * - %DRM_I915_QUERY_PERF_CONFIG_LIST 2781 * - %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 2782 * - %DRM_I915_QUERY_PERF_CONFIG_FOR_UUID 2783 * 2784 * When &query_id == %DRM_I915_QUERY_GEOMETRY_SUBSLICES must contain 2785 * a struct i915_engine_class_instance that references a render engine. 2786 */ 2787 __u32 flags; 2788 #define DRM_I915_QUERY_PERF_CONFIG_LIST 1 2789 #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 2 2790 #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID 3 2791 2792 /** 2793 * @data_ptr: 2794 * 2795 * Data will be written at the location pointed by @data_ptr when the 2796 * value of @length matches the length of the data to be written by the 2797 * kernel. 2798 */ 2799 __u64 data_ptr; 2800 }; 2801 2802 /** 2803 * struct drm_i915_query - Supply an array of struct drm_i915_query_item for the 2804 * kernel to fill out. 2805 * 2806 * Note that this is generally a two step process for each struct 2807 * drm_i915_query_item in the array: 2808 * 2809 * 1. Call the DRM_IOCTL_I915_QUERY, giving it our array of struct 2810 * drm_i915_query_item, with &drm_i915_query_item.length set to zero. The 2811 * kernel will then fill in the size, in bytes, which tells userspace how 2812 * memory it needs to allocate for the blob(say for an array of properties). 2813 * 2814 * 2. Next we call DRM_IOCTL_I915_QUERY again, this time with the 2815 * &drm_i915_query_item.data_ptr equal to our newly allocated blob. Note that 2816 * the &drm_i915_query_item.length should still be the same as what the 2817 * kernel previously set. At this point the kernel can fill in the blob. 2818 * 2819 * Note that for some query items it can make sense for userspace to just pass 2820 * in a buffer/blob equal to or larger than the required size. In this case only 2821 * a single ioctl call is needed. For some smaller query items this can work 2822 * quite well. 2823 * 2824 */ 2825 struct drm_i915_query { 2826 /** @num_items: The number of elements in the @items_ptr array */ 2827 __u32 num_items; 2828 2829 /** 2830 * @flags: Unused for now. Must be cleared to zero. 2831 */ 2832 __u32 flags; 2833 2834 /** 2835 * @items_ptr: 2836 * 2837 * Pointer to an array of struct drm_i915_query_item. The number of 2838 * array elements is @num_items. 2839 */ 2840 __u64 items_ptr; 2841 }; 2842 2843 /** 2844 * struct drm_i915_query_topology_info 2845 * 2846 * Describes slice/subslice/EU information queried by 2847 * %DRM_I915_QUERY_TOPOLOGY_INFO 2848 */ 2849 struct drm_i915_query_topology_info { 2850 /** 2851 * @flags: 2852 * 2853 * Unused for now. Must be cleared to zero. 2854 */ 2855 __u16 flags; 2856 2857 /** 2858 * @max_slices: 2859 * 2860 * The number of bits used to express the slice mask. 2861 */ 2862 __u16 max_slices; 2863 2864 /** 2865 * @max_subslices: 2866 * 2867 * The number of bits used to express the subslice mask. 2868 */ 2869 __u16 max_subslices; 2870 2871 /** 2872 * @max_eus_per_subslice: 2873 * 2874 * The number of bits in the EU mask that correspond to a single 2875 * subslice's EUs. 2876 */ 2877 __u16 max_eus_per_subslice; 2878 2879 /** 2880 * @subslice_offset: 2881 * 2882 * Offset in data[] at which the subslice masks are stored. 2883 */ 2884 __u16 subslice_offset; 2885 2886 /** 2887 * @subslice_stride: 2888 * 2889 * Stride at which each of the subslice masks for each slice are 2890 * stored. 2891 */ 2892 __u16 subslice_stride; 2893 2894 /** 2895 * @eu_offset: 2896 * 2897 * Offset in data[] at which the EU masks are stored. 2898 */ 2899 __u16 eu_offset; 2900 2901 /** 2902 * @eu_stride: 2903 * 2904 * Stride at which each of the EU masks for each subslice are stored. 2905 */ 2906 __u16 eu_stride; 2907 2908 /** 2909 * @data: 2910 * 2911 * Contains 3 pieces of information : 2912 * 2913 * - The slice mask with one bit per slice telling whether a slice is 2914 * available. The availability of slice X can be queried with the 2915 * following formula : 2916 * 2917 * .. code:: c 2918 * 2919 * (data[X / 8] >> (X % 8)) & 1 2920 * 2921 * Starting with Xe_HP platforms, Intel hardware no longer has 2922 * traditional slices so i915 will always report a single slice 2923 * (hardcoded slicemask = 0x1) which contains all of the platform's 2924 * subslices. I.e., the mask here does not reflect any of the newer 2925 * hardware concepts such as "gslices" or "cslices" since userspace 2926 * is capable of inferring those from the subslice mask. 2927 * 2928 * - The subslice mask for each slice with one bit per subslice telling 2929 * whether a subslice is available. Starting with Gen12 we use the 2930 * term "subslice" to refer to what the hardware documentation 2931 * describes as a "dual-subslices." The availability of subslice Y 2932 * in slice X can be queried with the following formula : 2933 * 2934 * .. code:: c 2935 * 2936 * (data[subslice_offset + X * subslice_stride + Y / 8] >> (Y % 8)) & 1 2937 * 2938 * - The EU mask for each subslice in each slice, with one bit per EU 2939 * telling whether an EU is available. The availability of EU Z in 2940 * subslice Y in slice X can be queried with the following formula : 2941 * 2942 * .. code:: c 2943 * 2944 * (data[eu_offset + 2945 * (X * max_subslices + Y) * eu_stride + 2946 * Z / 8 2947 * ] >> (Z % 8)) & 1 2948 */ 2949 __u8 data[]; 2950 }; 2951 2952 /** 2953 * DOC: Engine Discovery uAPI 2954 * 2955 * Engine discovery uAPI is a way of enumerating physical engines present in a 2956 * GPU associated with an open i915 DRM file descriptor. This supersedes the old 2957 * way of using `DRM_IOCTL_I915_GETPARAM` and engine identifiers like 2958 * `I915_PARAM_HAS_BLT`. 2959 * 2960 * The need for this interface came starting with Icelake and newer GPUs, which 2961 * started to establish a pattern of having multiple engines of a same class, 2962 * where not all instances were always completely functionally equivalent. 2963 * 2964 * Entry point for this uapi is `DRM_IOCTL_I915_QUERY` with the 2965 * `DRM_I915_QUERY_ENGINE_INFO` as the queried item id. 2966 * 2967 * Example for getting the list of engines: 2968 * 2969 * .. code-block:: C 2970 * 2971 * struct drm_i915_query_engine_info *info; 2972 * struct drm_i915_query_item item = { 2973 * .query_id = DRM_I915_QUERY_ENGINE_INFO; 2974 * }; 2975 * struct drm_i915_query query = { 2976 * .num_items = 1, 2977 * .items_ptr = (uintptr_t)&item, 2978 * }; 2979 * int err, i; 2980 * 2981 * // First query the size of the blob we need, this needs to be large 2982 * // enough to hold our array of engines. The kernel will fill out the 2983 * // item.length for us, which is the number of bytes we need. 2984 * // 2985 * // Alternatively a large buffer can be allocated straight away enabling 2986 * // querying in one pass, in which case item.length should contain the 2987 * // length of the provided buffer. 2988 * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); 2989 * if (err) ... 2990 * 2991 * info = calloc(1, item.length); 2992 * // Now that we allocated the required number of bytes, we call the ioctl 2993 * // again, this time with the data_ptr pointing to our newly allocated 2994 * // blob, which the kernel can then populate with info on all engines. 2995 * item.data_ptr = (uintptr_t)&info, 2996 * 2997 * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); 2998 * if (err) ... 2999 * 3000 * // We can now access each engine in the array 3001 * for (i = 0; i < info->num_engines; i++) { 3002 * struct drm_i915_engine_info einfo = info->engines[i]; 3003 * u16 class = einfo.engine.class; 3004 * u16 instance = einfo.engine.instance; 3005 * .... 3006 * } 3007 * 3008 * free(info); 3009 * 3010 * Each of the enumerated engines, apart from being defined by its class and 3011 * instance (see `struct i915_engine_class_instance`), also can have flags and 3012 * capabilities defined as documented in i915_drm.h. 3013 * 3014 * For instance video engines which support HEVC encoding will have the 3015 * `I915_VIDEO_CLASS_CAPABILITY_HEVC` capability bit set. 3016 * 3017 * Engine discovery only fully comes to its own when combined with the new way 3018 * of addressing engines when submitting batch buffers using contexts with 3019 * engine maps configured. 3020 */ 3021 3022 /** 3023 * struct drm_i915_engine_info 3024 * 3025 * Describes one engine and it's capabilities as known to the driver. 3026 */ 3027 struct drm_i915_engine_info { 3028 /** @engine: Engine class and instance. */ 3029 struct i915_engine_class_instance engine; 3030 3031 /** @rsvd0: Reserved field. */ 3032 __u32 rsvd0; 3033 3034 /** @flags: Engine flags. */ 3035 __u64 flags; 3036 #define I915_ENGINE_INFO_HAS_LOGICAL_INSTANCE (1 << 0) 3037 3038 /** @capabilities: Capabilities of this engine. */ 3039 __u64 capabilities; 3040 #define I915_VIDEO_CLASS_CAPABILITY_HEVC (1 << 0) 3041 #define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC (1 << 1) 3042 3043 /** @logical_instance: Logical instance of engine */ 3044 __u16 logical_instance; 3045 3046 /** @rsvd1: Reserved fields. */ 3047 __u16 rsvd1[3]; 3048 /** @rsvd2: Reserved fields. */ 3049 __u64 rsvd2[3]; 3050 }; 3051 3052 /** 3053 * struct drm_i915_query_engine_info 3054 * 3055 * Engine info query enumerates all engines known to the driver by filling in 3056 * an array of struct drm_i915_engine_info structures. 3057 */ 3058 struct drm_i915_query_engine_info { 3059 /** @num_engines: Number of struct drm_i915_engine_info structs following. */ 3060 __u32 num_engines; 3061 3062 /** @rsvd: MBZ */ 3063 __u32 rsvd[3]; 3064 3065 /** @engines: Marker for drm_i915_engine_info structures. */ 3066 struct drm_i915_engine_info engines[]; 3067 }; 3068 3069 /** 3070 * struct drm_i915_query_perf_config 3071 * 3072 * Data written by the kernel with query %DRM_I915_QUERY_PERF_CONFIG and 3073 * %DRM_I915_QUERY_GEOMETRY_SUBSLICES. 3074 */ 3075 struct drm_i915_query_perf_config { 3076 union { 3077 /** 3078 * @n_configs: 3079 * 3080 * When &drm_i915_query_item.flags == 3081 * %DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets this fields to 3082 * the number of configurations available. 3083 */ 3084 __u64 n_configs; 3085 3086 /** 3087 * @config: 3088 * 3089 * When &drm_i915_query_item.flags == 3090 * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID, i915 will use the 3091 * value in this field as configuration identifier to decide 3092 * what data to write into config_ptr. 3093 */ 3094 __u64 config; 3095 3096 /** 3097 * @uuid: 3098 * 3099 * When &drm_i915_query_item.flags == 3100 * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID, i915 will use the 3101 * value in this field as configuration identifier to decide 3102 * what data to write into config_ptr. 3103 * 3104 * String formatted like "%08x-%04x-%04x-%04x-%012x" 3105 */ 3106 char uuid[36]; 3107 }; 3108 3109 /** 3110 * @flags: 3111 * 3112 * Unused for now. Must be cleared to zero. 3113 */ 3114 __u32 flags; 3115 3116 /** 3117 * @data: 3118 * 3119 * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_LIST, 3120 * i915 will write an array of __u64 of configuration identifiers. 3121 * 3122 * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_DATA, 3123 * i915 will write a struct drm_i915_perf_oa_config. If the following 3124 * fields of struct drm_i915_perf_oa_config are not set to 0, i915 will 3125 * write into the associated pointers the values of submitted when the 3126 * configuration was created : 3127 * 3128 * - &drm_i915_perf_oa_config.n_mux_regs 3129 * - &drm_i915_perf_oa_config.n_boolean_regs 3130 * - &drm_i915_perf_oa_config.n_flex_regs 3131 */ 3132 __u8 data[]; 3133 }; 3134 3135 /** 3136 * enum drm_i915_gem_memory_class - Supported memory classes 3137 */ 3138 enum drm_i915_gem_memory_class { 3139 /** @I915_MEMORY_CLASS_SYSTEM: System memory */ 3140 I915_MEMORY_CLASS_SYSTEM = 0, 3141 /** @I915_MEMORY_CLASS_DEVICE: Device local-memory */ 3142 I915_MEMORY_CLASS_DEVICE, 3143 }; 3144 3145 /** 3146 * struct drm_i915_gem_memory_class_instance - Identify particular memory region 3147 */ 3148 struct drm_i915_gem_memory_class_instance { 3149 /** @memory_class: See enum drm_i915_gem_memory_class */ 3150 __u16 memory_class; 3151 3152 /** @memory_instance: Which instance */ 3153 __u16 memory_instance; 3154 }; 3155 3156 /** 3157 * struct drm_i915_memory_region_info - Describes one region as known to the 3158 * driver. 3159 * 3160 * Note that we reserve some stuff here for potential future work. As an example 3161 * we might want expose the capabilities for a given region, which could include 3162 * things like if the region is CPU mappable/accessible, what are the supported 3163 * mapping types etc. 3164 * 3165 * Note that to extend struct drm_i915_memory_region_info and struct 3166 * drm_i915_query_memory_regions in the future the plan is to do the following: 3167 * 3168 * .. code-block:: C 3169 * 3170 * struct drm_i915_memory_region_info { 3171 * struct drm_i915_gem_memory_class_instance region; 3172 * union { 3173 * __u32 rsvd0; 3174 * __u32 new_thing1; 3175 * }; 3176 * ... 3177 * union { 3178 * __u64 rsvd1[8]; 3179 * struct { 3180 * __u64 new_thing2; 3181 * __u64 new_thing3; 3182 * ... 3183 * }; 3184 * }; 3185 * }; 3186 * 3187 * With this things should remain source compatible between versions for 3188 * userspace, even as we add new fields. 3189 * 3190 * Note this is using both struct drm_i915_query_item and struct drm_i915_query. 3191 * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS 3192 * at &drm_i915_query_item.query_id. 3193 */ 3194 struct drm_i915_memory_region_info { 3195 /** @region: The class:instance pair encoding */ 3196 struct drm_i915_gem_memory_class_instance region; 3197 3198 /** @rsvd0: MBZ */ 3199 __u32 rsvd0; 3200 3201 /** @probed_size: Memory probed by the driver (-1 = unknown) */ 3202 __u64 probed_size; 3203 3204 /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */ 3205 __u64 unallocated_size; 3206 3207 /** @rsvd1: MBZ */ 3208 __u64 rsvd1[8]; 3209 }; 3210 3211 /** 3212 * struct drm_i915_query_memory_regions 3213 * 3214 * The region info query enumerates all regions known to the driver by filling 3215 * in an array of struct drm_i915_memory_region_info structures. 3216 * 3217 * Example for getting the list of supported regions: 3218 * 3219 * .. code-block:: C 3220 * 3221 * struct drm_i915_query_memory_regions *info; 3222 * struct drm_i915_query_item item = { 3223 * .query_id = DRM_I915_QUERY_MEMORY_REGIONS; 3224 * }; 3225 * struct drm_i915_query query = { 3226 * .num_items = 1, 3227 * .items_ptr = (uintptr_t)&item, 3228 * }; 3229 * int err, i; 3230 * 3231 * // First query the size of the blob we need, this needs to be large 3232 * // enough to hold our array of regions. The kernel will fill out the 3233 * // item.length for us, which is the number of bytes we need. 3234 * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); 3235 * if (err) ... 3236 * 3237 * info = calloc(1, item.length); 3238 * // Now that we allocated the required number of bytes, we call the ioctl 3239 * // again, this time with the data_ptr pointing to our newly allocated 3240 * // blob, which the kernel can then populate with the all the region info. 3241 * item.data_ptr = (uintptr_t)&info, 3242 * 3243 * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); 3244 * if (err) ... 3245 * 3246 * // We can now access each region in the array 3247 * for (i = 0; i < info->num_regions; i++) { 3248 * struct drm_i915_memory_region_info mr = info->regions[i]; 3249 * u16 class = mr.region.class; 3250 * u16 instance = mr.region.instance; 3251 * 3252 * .... 3253 * } 3254 * 3255 * free(info); 3256 */ 3257 struct drm_i915_query_memory_regions { 3258 /** @num_regions: Number of supported regions */ 3259 __u32 num_regions; 3260 3261 /** @rsvd: MBZ */ 3262 __u32 rsvd[3]; 3263 3264 /** @regions: Info about each supported region */ 3265 struct drm_i915_memory_region_info regions[]; 3266 }; 3267 3268 /** 3269 * DOC: GuC HWCONFIG blob uAPI 3270 * 3271 * The GuC produces a blob with information about the current device. 3272 * i915 reads this blob from GuC and makes it available via this uAPI. 3273 * 3274 * The format and meaning of the blob content are documented in the 3275 * Programmer's Reference Manual. 3276 */ 3277 3278 /** 3279 * struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added 3280 * extension support using struct i915_user_extension. 3281 * 3282 * Note that in the future we want to have our buffer flags here, at least for 3283 * the stuff that is immutable. Previously we would have two ioctls, one to 3284 * create the object with gem_create, and another to apply various parameters, 3285 * however this creates some ambiguity for the params which are considered 3286 * immutable. Also in general we're phasing out the various SET/GET ioctls. 3287 */ 3288 struct drm_i915_gem_create_ext { 3289 /** 3290 * @size: Requested size for the object. 3291 * 3292 * The (page-aligned) allocated size for the object will be returned. 3293 * 3294 * 3295 * DG2 64K min page size implications: 3296 * 3297 * On discrete platforms, starting from DG2, we have to contend with GTT 3298 * page size restrictions when dealing with I915_MEMORY_CLASS_DEVICE 3299 * objects. Specifically the hardware only supports 64K or larger GTT 3300 * page sizes for such memory. The kernel will already ensure that all 3301 * I915_MEMORY_CLASS_DEVICE memory is allocated using 64K or larger page 3302 * sizes underneath. 3303 * 3304 * Note that the returned size here will always reflect any required 3305 * rounding up done by the kernel, i.e 4K will now become 64K on devices 3306 * such as DG2. 3307 * 3308 * Special DG2 GTT address alignment requirement: 3309 * 3310 * The GTT alignment will also need to be at least 2M for such objects. 3311 * 3312 * Note that due to how the hardware implements 64K GTT page support, we 3313 * have some further complications: 3314 * 3315 * 1) The entire PDE (which covers a 2MB virtual address range), must 3316 * contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same 3317 * PDE is forbidden by the hardware. 3318 * 3319 * 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM 3320 * objects. 3321 * 3322 * To keep things simple for userland, we mandate that any GTT mappings 3323 * must be aligned to and rounded up to 2MB. The kernel will internally 3324 * pad them out to the next 2MB boundary. As this only wastes virtual 3325 * address space and avoids userland having to copy any needlessly 3326 * complicated PDE sharing scheme (coloring) and only affects DG2, this 3327 * is deemed to be a good compromise. 3328 */ 3329 __u64 size; 3330 /** 3331 * @handle: Returned handle for the object. 3332 * 3333 * Object handles are nonzero. 3334 */ 3335 __u32 handle; 3336 /** @flags: MBZ */ 3337 __u32 flags; 3338 /** 3339 * @extensions: The chain of extensions to apply to this object. 3340 * 3341 * This will be useful in the future when we need to support several 3342 * different extensions, and we need to apply more than one when 3343 * creating the object. See struct i915_user_extension. 3344 * 3345 * If we don't supply any extensions then we get the same old gem_create 3346 * behaviour. 3347 * 3348 * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see 3349 * struct drm_i915_gem_create_ext_memory_regions. 3350 * 3351 * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see 3352 * struct drm_i915_gem_create_ext_protected_content. 3353 */ 3354 #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0 3355 #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1 3356 __u64 extensions; 3357 }; 3358 3359 /** 3360 * struct drm_i915_gem_create_ext_memory_regions - The 3361 * I915_GEM_CREATE_EXT_MEMORY_REGIONS extension. 3362 * 3363 * Set the object with the desired set of placements/regions in priority 3364 * order. Each entry must be unique and supported by the device. 3365 * 3366 * This is provided as an array of struct drm_i915_gem_memory_class_instance, or 3367 * an equivalent layout of class:instance pair encodings. See struct 3368 * drm_i915_query_memory_regions and DRM_I915_QUERY_MEMORY_REGIONS for how to 3369 * query the supported regions for a device. 3370 * 3371 * As an example, on discrete devices, if we wish to set the placement as 3372 * device local-memory we can do something like: 3373 * 3374 * .. code-block:: C 3375 * 3376 * struct drm_i915_gem_memory_class_instance region_lmem = { 3377 * .memory_class = I915_MEMORY_CLASS_DEVICE, 3378 * .memory_instance = 0, 3379 * }; 3380 * struct drm_i915_gem_create_ext_memory_regions regions = { 3381 * .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS }, 3382 * .regions = (uintptr_t)®ion_lmem, 3383 * .num_regions = 1, 3384 * }; 3385 * struct drm_i915_gem_create_ext create_ext = { 3386 * .size = 16 * PAGE_SIZE, 3387 * .extensions = (uintptr_t)®ions, 3388 * }; 3389 * 3390 * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); 3391 * if (err) ... 3392 * 3393 * At which point we get the object handle in &drm_i915_gem_create_ext.handle, 3394 * along with the final object size in &drm_i915_gem_create_ext.size, which 3395 * should account for any rounding up, if required. 3396 */ 3397 struct drm_i915_gem_create_ext_memory_regions { 3398 /** @base: Extension link. See struct i915_user_extension. */ 3399 struct i915_user_extension base; 3400 3401 /** @pad: MBZ */ 3402 __u32 pad; 3403 /** @num_regions: Number of elements in the @regions array. */ 3404 __u32 num_regions; 3405 /** 3406 * @regions: The regions/placements array. 3407 * 3408 * An array of struct drm_i915_gem_memory_class_instance. 3409 */ 3410 __u64 regions; 3411 }; 3412 3413 /** 3414 * struct drm_i915_gem_create_ext_protected_content - The 3415 * I915_OBJECT_PARAM_PROTECTED_CONTENT extension. 3416 * 3417 * If this extension is provided, buffer contents are expected to be protected 3418 * by PXP encryption and require decryption for scan out and processing. This 3419 * is only possible on platforms that have PXP enabled, on all other scenarios 3420 * using this extension will cause the ioctl to fail and return -ENODEV. The 3421 * flags parameter is reserved for future expansion and must currently be set 3422 * to zero. 3423 * 3424 * The buffer contents are considered invalid after a PXP session teardown. 3425 * 3426 * The encryption is guaranteed to be processed correctly only if the object 3427 * is submitted with a context created using the 3428 * I915_CONTEXT_PARAM_PROTECTED_CONTENT flag. This will also enable extra checks 3429 * at submission time on the validity of the objects involved. 3430 * 3431 * Below is an example on how to create a protected object: 3432 * 3433 * .. code-block:: C 3434 * 3435 * struct drm_i915_gem_create_ext_protected_content protected_ext = { 3436 * .base = { .name = I915_GEM_CREATE_EXT_PROTECTED_CONTENT }, 3437 * .flags = 0, 3438 * }; 3439 * struct drm_i915_gem_create_ext create_ext = { 3440 * .size = PAGE_SIZE, 3441 * .extensions = (uintptr_t)&protected_ext, 3442 * }; 3443 * 3444 * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); 3445 * if (err) ... 3446 */ 3447 struct drm_i915_gem_create_ext_protected_content { 3448 /** @base: Extension link. See struct i915_user_extension. */ 3449 struct i915_user_extension base; 3450 /** @flags: reserved for future usage, currently MBZ */ 3451 __u32 flags; 3452 }; 3453 3454 /* ID of the protected content session managed by i915 when PXP is active */ 3455 #define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf 3456 3457 #if defined(__cplusplus) 3458 } 3459 #endif 3460 3461 #endif /* _UAPI_I915_DRM_H_ */ 3462