/* SPDX-License-Identifier: MIT */1/*2* Copyright © 2022 Intel Corporation3*/45/**6* DOC: I915_PARAM_VM_BIND_VERSION7*8* VM_BIND feature version supported.9* See typedef drm_i915_getparam_t param.10*11* Specifies the VM_BIND feature version supported.12* The following versions of VM_BIND have been defined:13*14* 0: No VM_BIND support.15*16* 1: In VM_UNBIND calls, the UMD must specify the exact mappings created17* previously with VM_BIND, the ioctl will not support unbinding multiple18* mappings or splitting them. Similarly, VM_BIND calls will not replace19* any existing mappings.20*21* 2: The restrictions on unbinding partial or multiple mappings is22* lifted, Similarly, binding will replace any mappings in the given range.23*24* See struct drm_i915_gem_vm_bind and struct drm_i915_gem_vm_unbind.25*/26#define I915_PARAM_VM_BIND_VERSION 572728/**29* DOC: I915_VM_CREATE_FLAGS_USE_VM_BIND30*31* Flag to opt-in for VM_BIND mode of binding during VM creation.32* See struct drm_i915_gem_vm_control flags.33*34* The older execbuf2 ioctl will not support VM_BIND mode of operation.35* For VM_BIND mode, we have new execbuf3 ioctl which will not accept any36* execlist (See struct drm_i915_gem_execbuffer3 for more details).37*/38#define I915_VM_CREATE_FLAGS_USE_VM_BIND (1 << 0)3940/* VM_BIND related ioctls */41#define DRM_I915_GEM_VM_BIND 0x3d42#define DRM_I915_GEM_VM_UNBIND 0x3e43#define DRM_I915_GEM_EXECBUFFER3 0x3f4445#define DRM_IOCTL_I915_GEM_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_BIND, struct drm_i915_gem_vm_bind)46#define DRM_IOCTL_I915_GEM_VM_UNBIND DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_UNBIND, struct drm_i915_gem_vm_bind)47#define DRM_IOCTL_I915_GEM_EXECBUFFER3 DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER3, struct drm_i915_gem_execbuffer3)4849/**50* struct drm_i915_gem_timeline_fence - An input or output timeline fence.51*52* The operation will wait for input fence to signal.53*54* The returned output fence will be signaled after the completion of the55* operation.56*/57struct drm_i915_gem_timeline_fence {58/** @handle: User's handle for a drm_syncobj to wait on or signal. */59__u32 handle;6061/**62* @flags: Supported flags are:63*64* I915_TIMELINE_FENCE_WAIT:65* Wait for the input fence before the operation.66*67* I915_TIMELINE_FENCE_SIGNAL:68* Return operation completion fence as output.69*/70__u32 flags;71#define I915_TIMELINE_FENCE_WAIT (1 << 0)72#define I915_TIMELINE_FENCE_SIGNAL (1 << 1)73#define __I915_TIMELINE_FENCE_UNKNOWN_FLAGS (-(I915_TIMELINE_FENCE_SIGNAL << 1))7475/**76* @value: A point in the timeline.77* Value must be 0 for a binary drm_syncobj. A Value of 0 for a78* timeline drm_syncobj is invalid as it turns a drm_syncobj into a79* binary one.80*/81__u64 value;82};8384/**85* struct drm_i915_gem_vm_bind - VA to object mapping to bind.86*87* This structure is passed to VM_BIND ioctl and specifies the mapping of GPU88* virtual address (VA) range to the section of an object that should be bound89* in the device page table of the specified address space (VM).90* The VA range specified must be unique (ie., not currently bound) and can91* be mapped to whole object or a section of the object (partial binding).92* Multiple VA mappings can be created to the same section of the object93* (aliasing).94*95* The @start, @offset and @length must be 4K page aligned. However the DG2 has96* 64K page size for device local memory and has compact page table. On that97* platform, for binding device local-memory objects, the @start, @offset and98* @length must be 64K aligned. Also, UMDs should not mix the local memory 64K99* page and the system memory 4K page bindings in the same 2M range.100*101* Error code -EINVAL will be returned if @start, @offset and @length are not102* properly aligned. In version 1 (See I915_PARAM_VM_BIND_VERSION), error code103* -ENOSPC will be returned if the VA range specified can't be reserved.104*105* VM_BIND/UNBIND ioctl calls executed on different CPU threads concurrently106* are not ordered. Furthermore, parts of the VM_BIND operation can be done107* asynchronously, if valid @fence is specified.108*/109struct drm_i915_gem_vm_bind {110/** @vm_id: VM (address space) id to bind */111__u32 vm_id;112113/** @handle: Object handle */114__u32 handle;115116/** @start: Virtual Address start to bind */117__u64 start;118119/** @offset: Offset in object to bind */120__u64 offset;121122/** @length: Length of mapping to bind */123__u64 length;124125/**126* @flags: Supported flags are:127*128* I915_GEM_VM_BIND_CAPTURE:129* Capture this mapping in the dump upon GPU error.130*131* Note that @fence carries its own flags.132*/133__u64 flags;134#define I915_GEM_VM_BIND_CAPTURE (1 << 0)135136/**137* @fence: Timeline fence for bind completion signaling.138*139* Timeline fence is of format struct drm_i915_gem_timeline_fence.140*141* It is an out fence, hence using I915_TIMELINE_FENCE_WAIT flag142* is invalid, and an error will be returned.143*144* If I915_TIMELINE_FENCE_SIGNAL flag is not set, then out fence145* is not requested and binding is completed synchronously.146*/147struct drm_i915_gem_timeline_fence fence;148149/**150* @extensions: Zero-terminated chain of extensions.151*152* For future extensions. See struct i915_user_extension.153*/154__u64 extensions;155};156157/**158* struct drm_i915_gem_vm_unbind - VA to object mapping to unbind.159*160* This structure is passed to VM_UNBIND ioctl and specifies the GPU virtual161* address (VA) range that should be unbound from the device page table of the162* specified address space (VM). VM_UNBIND will force unbind the specified163* range from device page table without waiting for any GPU job to complete.164* It is UMDs responsibility to ensure the mapping is no longer in use before165* calling VM_UNBIND.166*167* If the specified mapping is not found, the ioctl will simply return without168* any error.169*170* VM_BIND/UNBIND ioctl calls executed on different CPU threads concurrently171* are not ordered. Furthermore, parts of the VM_UNBIND operation can be done172* asynchronously, if valid @fence is specified.173*/174struct drm_i915_gem_vm_unbind {175/** @vm_id: VM (address space) id to bind */176__u32 vm_id;177178/** @rsvd: Reserved, MBZ */179__u32 rsvd;180181/** @start: Virtual Address start to unbind */182__u64 start;183184/** @length: Length of mapping to unbind */185__u64 length;186187/**188* @flags: Currently reserved, MBZ.189*190* Note that @fence carries its own flags.191*/192__u64 flags;193194/**195* @fence: Timeline fence for unbind completion signaling.196*197* Timeline fence is of format struct drm_i915_gem_timeline_fence.198*199* It is an out fence, hence using I915_TIMELINE_FENCE_WAIT flag200* is invalid, and an error will be returned.201*202* If I915_TIMELINE_FENCE_SIGNAL flag is not set, then out fence203* is not requested and unbinding is completed synchronously.204*/205struct drm_i915_gem_timeline_fence fence;206207/**208* @extensions: Zero-terminated chain of extensions.209*210* For future extensions. See struct i915_user_extension.211*/212__u64 extensions;213};214215/**216* struct drm_i915_gem_execbuffer3 - Structure for DRM_I915_GEM_EXECBUFFER3217* ioctl.218*219* DRM_I915_GEM_EXECBUFFER3 ioctl only works in VM_BIND mode and VM_BIND mode220* only works with this ioctl for submission.221* See I915_VM_CREATE_FLAGS_USE_VM_BIND.222*/223struct drm_i915_gem_execbuffer3 {224/**225* @ctx_id: Context id226*227* Only contexts with user engine map are allowed.228*/229__u32 ctx_id;230231/**232* @engine_idx: Engine index233*234* An index in the user engine map of the context specified by @ctx_id.235*/236__u32 engine_idx;237238/**239* @batch_address: Batch gpu virtual address/es.240*241* For normal submission, it is the gpu virtual address of the batch242* buffer. For parallel submission, it is a pointer to an array of243* batch buffer gpu virtual addresses with array size equal to the244* number of (parallel) engines involved in that submission (See245* struct i915_context_engines_parallel_submit).246*/247__u64 batch_address;248249/** @flags: Currently reserved, MBZ */250__u64 flags;251252/** @rsvd1: Reserved, MBZ */253__u32 rsvd1;254255/** @fence_count: Number of fences in @timeline_fences array. */256__u32 fence_count;257258/**259* @timeline_fences: Pointer to an array of timeline fences.260*261* Timeline fences are of format struct drm_i915_gem_timeline_fence.262*/263__u64 timeline_fences;264265/** @rsvd2: Reserved, MBZ */266__u64 rsvd2;267268/**269* @extensions: Zero-terminated chain of extensions.270*271* For future extensions. See struct i915_user_extension.272*/273__u64 extensions;274};275276/**277* struct drm_i915_gem_create_ext_vm_private - Extension to make the object278* private to the specified VM.279*280* See struct drm_i915_gem_create_ext.281*/282struct drm_i915_gem_create_ext_vm_private {283#define I915_GEM_CREATE_EXT_VM_PRIVATE 2284/** @base: Extension link. See struct i915_user_extension. */285struct i915_user_extension base;286287/** @vm_id: Id of the VM to which the object is private */288__u32 vm_id;289};290291292