• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2021 Intel Corporation
4  */
5 
6 #ifndef __I915_DRM_PRELIM_H__
7 #define __I915_DRM_PRELIM_H__
8 
9 #include "i915_drm.h"
10 
11 /*
12  * Modifications to structs/values defined here are subject to
13  * backwards-compatibility constraints.
14  *
15  * Internal/downstream declarations must be added here, not to
16  * i915_drm.h. The values in i915_drm_prelim.h must also be kept
17  * synchronized with values in i915_drm.h.
18  */
19 
20 struct prelim_i915_uevent {
21 /*
22  * PRELIM_I915_RESET_FAILED_UEVENT - Event is generated when engine or GPU
23  *	resets fail and also when GPU is declared wedged. The value
24  *	supplied with the event is always 1. Event is also generated when
25  *	resets are disabled by module parameter and an attempt to reset
26  *	either engine or GPU is made.
27  */
28 #define PRELIM_I915_RESET_FAILED_UEVENT	"RESET_FAILED"
29 
30 /*
31  * PRELIM_I915_MEMORY_HEALTH_UEVENT - Generated when driver receives a memory
32  *	degradation error from the GPU FW. The event serves as notification to
33  *	an Admin to reboot the system as soon as possible, due to the fact that
34  *	device is no longer RUNTIME recoverable again. This event will always
35  *	have a value of 1, which indicates that uncorrectable error has been
36  *	detected, and that runtime memory sparing is not feasible without system
37  *	reboot - for recovery of failed BANK.
38  */
39 #define PRELIM_I915_MEMORY_HEALTH_UEVENT	"MEMORY_HEALTH"
40 };
41 
42 struct prelim_i915_user_extension {
43 #define PRELIM_I915_USER_EXT		(1 << 16)
44 #define PRELIM_I915_USER_EXT_MASK(x)	(x & 0xffff)
45 #define PRELIM_I915_CONTEXT_ENGINES_EXT_PARALLEL2_SUBMIT (PRELIM_I915_USER_EXT | 3)
46 };
47 
48 /* This API has been removed.  On the off chance someone somewhere has
49  * attempted to use it, never re-use this extension number.
50  */
51 
52 #define PRELIM_I915_CONTEXT_CREATE_EXT_CLONE	(PRELIM_I915_USER_EXT | 1)
53 
54 /*
55  * PRELIM UAPI VERSION - /sys/<...>/drm/card<n>/prelim_uapi_version
56  * MAJOR - to be incremented right after a major public Production branch
57  *         release containing PRELIM uAPIs
58  *         PROD_DG1_201210.0 released so starting with major = 2, although
59  *         it didn't have the proper prelim api infrastructure yet.
60  * MINOR - Reset to 0 when MAJOR is bumped.
61  *         Bumped as needed when some kind of API incompatibility is identified.
62  *         This patch, which introduces this, should be the only patch in
63  *         the pile that is changing this number.
64  */
65 #define PRELIM_UAPI_MAJOR	2
66 #define PRELIM_UAPI_MINOR	1
67 
68 /*
69  * Top 8 bits of every non-engine counter are GT id.
70  * FIXME: __PRELIM_I915_PMU_GT_SHIFT will be changed to 56
71  */
72 #define __PRELIM_I915_PMU_GT_SHIFT (60)
73 
74 #define ___PRELIM_I915_PMU_OTHER(gt, x) \
75 	(((__u64)__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | \
76 	((__u64)(gt) << __PRELIM_I915_PMU_GT_SHIFT))
77 
78 #define __I915_PMU_OTHER(x) ___PRELIM_I915_PMU_OTHER(0, x)
79 
80 #define __PRELIM_I915_PMU_ACTUAL_FREQUENCY(gt)		___PRELIM_I915_PMU_OTHER(gt, 0)
81 #define __PRELIM_I915_PMU_REQUESTED_FREQUENCY(gt)	___PRELIM_I915_PMU_OTHER(gt, 1)
82 #define __PRELIM_I915_PMU_INTERRUPTS(gt)		___PRELIM_I915_PMU_OTHER(gt, 2)
83 #define __PRELIM_I915_PMU_RC6_RESIDENCY(gt)		___PRELIM_I915_PMU_OTHER(gt, 3)
84 #define __PRELIM_I915_PMU_SOFTWARE_GT_AWAKE_TIME(gt)	___PRELIM_I915_PMU_OTHER(gt, 4)
85 #define __PRELIM_I915_PMU_ENGINE_RESET_COUNT(gt)	___PRELIM_I915_PMU_OTHER(gt, 5)
86 #define __PRELIM_I915_PMU_EU_ATTENTION_COUNT(gt)	___PRELIM_I915_PMU_OTHER(gt, 6)
87 #define __PRELIM_I915_PMU_RENDER_GROUP_BUSY(gt)		___PRELIM_I915_PMU_OTHER(gt, 7)
88 #define __PRELIM_I915_PMU_COPY_GROUP_BUSY(gt)		___PRELIM_I915_PMU_OTHER(gt, 8)
89 #define __PRELIM_I915_PMU_MEDIA_GROUP_BUSY(gt)		___PRELIM_I915_PMU_OTHER(gt, 9)
90 #define __PRELIM_I915_PMU_ANY_ENGINE_GROUP_BUSY(gt)	___PRELIM_I915_PMU_OTHER(gt, 10)
91 
92 
93 #define __PRELIM_I915_PMU_HW_ERROR_EVENT_ID_OFFSET	(__I915_PMU_OTHER(0) + 1000)
94 
95 #define PRELIM_I915_PMU_ENGINE_RESET_COUNT	__PRELIM_I915_PMU_ENGINE_RESET_COUNT(0)
96 #define PRELIM_I915_PMU_EU_ATTENTION_COUNT	__PRELIM_I915_PMU_EU_ATTENTION_COUNT(0)
97 #define PRELIM_I915_PMU_RENDER_GROUP_BUSY              __PRELIM_I915_PMU_RENDER_GROUP_BUSY(0)
98 #define PRELIM_I915_PMU_COPY_GROUP_BUSY                __PRELIM_I915_PMU_COPY_GROUP_BUSY(0)
99 #define PRELIM_I915_PMU_MEDIA_GROUP_BUSY               __PRELIM_I915_PMU_MEDIA_GROUP_BUSY(0)
100 #define PRELIM_I915_PMU_ANY_ENGINE_GROUP_BUSY          __PRELIM_I915_PMU_ANY_ENGINE_GROUP_BUSY(0)
101 
102 /*
103  * HW error counters.
104  */
105 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_L3_SNG		(0)
106 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_GUC		(1)
107 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_SAMPLER		(2)
108 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_SLM		(3)
109 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_EU_IC		(4)
110 #define PRELIM_I915_PMU_GT_ERROR_CORRECTABLE_EU_GRF		(5)
111 #define PRELIM_I915_PMU_GT_ERROR_FATAL_ARR_BIST			(6)
112 #define PRELIM_I915_PMU_GT_ERROR_FATAL_L3_DOUB			(7)
113 #define PRELIM_I915_PMU_GT_ERROR_FATAL_L3_ECC_CHK		(8)
114 #define PRELIM_I915_PMU_GT_ERROR_FATAL_GUC			(9)
115 #define PRELIM_I915_PMU_GT_ERROR_FATAL_IDI_PAR			(10)
116 #define PRELIM_I915_PMU_GT_ERROR_FATAL_SQIDI			(11)
117 #define PRELIM_I915_PMU_GT_ERROR_FATAL_SAMPLER			(12)
118 #define PRELIM_I915_PMU_GT_ERROR_FATAL_SLM			(13)
119 #define PRELIM_I915_PMU_GT_ERROR_FATAL_EU_IC			(14)
120 #define PRELIM_I915_PMU_GT_ERROR_FATAL_EU_GRF			(15)
121 #define PRELIM_I915_PMU_SGUNIT_ERROR_CORRECTABLE		(16)
122 #define PRELIM_I915_PMU_SGUNIT_ERROR_NONFATAL			(17)
123 #define PRELIM_I915_PMU_SGUNIT_ERROR_FATAL			(18)
124 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_PSF_CSC_0		(19)
125 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_PSF_CSC_1		(20)
126 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_PSF_CSC_2		(21)
127 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_PUNIT			(22)
128 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_MDFI_EAST		(23)
129 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_MDFI_WEST		(24)
130 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_MDFI_SOUTH		(25)
131 
132 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_FBR(ss, n) \
133 	(PRELIM_I915_PMU_SOC_ERROR_FATAL_MDFI_SOUTH + 0x1 + (ss) * 0x4 + (n))
134 
135 #define PRELIM_I915_PMU_SOC_ERROR_FATAL_HBM(ss, n)\
136 	(PRELIM_I915_PMU_SOC_ERROR_FATAL_FBR(1, 5) + (ss) * 0x10 + (n))
137 
138 #define PRELIM_I915_PMU_GT_ERROR_FATAL_FPU			(67)
139 #define PRELIM_I915_PMU_GT_ERROR_FATAL_TLB			(68)
140 #define PRELIM_I915_PMU_GT_ERROR_FATAL_L3_FABRIC		(69)
141 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_PSF_0		(70)
142 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_PSF_1		(71)
143 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_PSF_2		(72)
144 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_CD0			(73)
145 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_CD0_MDFI		(74)
146 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_MDFI_EAST		(75)
147 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_MDFI_SOUTH		(76)
148 
149 #define PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_HBM(ss, n)\
150 	(PRELIM_I915_PVC_PMU_SOC_ERROR_FATAL_MDFI_SOUTH + 0x1 + (ss) * 0x10 + (n))
151 
152 /* 108 is the last ID used by SOC errors */
153 #define PRELIM_I915_PMU_HW_ERROR(gt, id) \
154 	((__PRELIM_I915_PMU_HW_ERROR_EVENT_ID_OFFSET + (id)) | \
155 	((__u64)(gt) << __PRELIM_I915_PMU_GT_SHIFT))
156 
157 /* Per GT driver error counters */
158 #define __PRELIM_I915_PMU_GT_DRIVER_ERROR_EVENT_ID_OFFSET (__I915_PMU_OTHER(0) + 2000)
159 
160 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_GGTT			(0)
161 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_ENGINE_OTHER		(1)
162 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_GUC_COMMUNICATION	(2)
163 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_RPS			(3)
164 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_GT_OTHER		(4)
165 #define PRELIM_I915_PMU_GT_DRIVER_ERROR_INTERRUPT		(5)
166 
167 #define PRELIM_I915_PMU_GT_DRIVER_ERROR(gt, id) \
168 	((__PRELIM_I915_PMU_GT_DRIVER_ERROR_EVENT_ID_OFFSET + (id)) | \
169 	 ((__u64)(gt) << __PRELIM_I915_PMU_GT_SHIFT))
170 
171 /* Global driver error counters */
172 #define __PRELIM_I915_PMU_DRIVER_ERROR_EVENT_ID_OFFSET (__I915_PMU_OTHER(0) + 3000)
173 #define PRELIM_I915_PMU_DRIVER_ERROR_OBJECT_MIGRATION	(0)
174 #define PRELIM_I915_PMU_DRIVER_ERROR(id)	(__PRELIM_I915_PMU_DRIVER_ERROR_EVENT_ID_OFFSET + (id))
175 
176 /* PRELIM ioctl's */
177 
178 /* PRELIM ioctl numbers go down from 0x5f */
179 #define PRELIM_DRM_I915_RESERVED_FOR_VERSION	0x5f
180 /* 0x5e is free, please use if needed */
181 #define PRELIM_DRM_I915_GEM_VM_BIND		0x5d
182 #define PRELIM_DRM_I915_GEM_VM_UNBIND		0x5c
183 #define PRELIM_DRM_I915_GEM_VM_ADVISE		0x5b
184 #define PRELIM_DRM_I915_GEM_WAIT_USER_FENCE	0x5a
185 #define PRELIM_DRM_I915_GEM_VM_PREFETCH		0x59
186 #define PRELIM_DRM_I915_UUID_REGISTER		0x58
187 #define PRELIM_DRM_I915_UUID_UNREGISTER		0x57
188 #define PRELIM_DRM_I915_DEBUGGER_OPEN		0x56
189 #define PRELIM_DRM_I915_GEM_CLOS_RESERVE	0x55
190 #define PRELIM_DRM_I915_GEM_CLOS_FREE		0x54
191 #define PRELIM_DRM_I915_GEM_CACHE_RESERVE	0x53
192 #define PRELIM_DRM_I915_GEM_VM_GETPARAM		DRM_I915_GEM_CONTEXT_GETPARAM
193 #define PRELIM_DRM_I915_GEM_VM_SETPARAM		DRM_I915_GEM_CONTEXT_SETPARAM
194 
195 
196 #define PRELIM_DRM_IOCTL_I915_GEM_CREATE_EXT		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct prelim_drm_i915_gem_create_ext)
197 #define PRELIM_DRM_IOCTL_I915_GEM_VM_BIND		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_BIND, struct prelim_drm_i915_gem_vm_bind)
198 #define PRELIM_DRM_IOCTL_I915_GEM_VM_UNBIND		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_UNBIND, struct prelim_drm_i915_gem_vm_bind)
199 #define PRELIM_DRM_IOCTL_I915_GEM_VM_ADVISE		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_ADVISE, struct prelim_drm_i915_gem_vm_advise)
200 #define PRELIM_DRM_IOCTL_I915_GEM_WAIT_USER_FENCE	DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_WAIT_USER_FENCE, struct prelim_drm_i915_gem_wait_user_fence)
201 #define PRELIM_DRM_IOCTL_I915_GEM_VM_PREFETCH		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_PREFETCH, struct prelim_drm_i915_gem_vm_prefetch)
202 #define PRELIM_DRM_IOCTL_I915_UUID_REGISTER		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_UUID_REGISTER, struct prelim_drm_i915_uuid_control)
203 #define PRELIM_DRM_IOCTL_I915_UUID_UNREGISTER		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_UUID_UNREGISTER, struct prelim_drm_i915_uuid_control)
204 #define PRELIM_DRM_IOCTL_I915_DEBUGGER_OPEN		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_DEBUGGER_OPEN, struct prelim_drm_i915_debugger_open_param)
205 #define PRELIM_DRM_IOCTL_I915_GEM_CLOS_RESERVE		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_CLOS_RESERVE, struct prelim_drm_i915_gem_clos_reserve)
206 #define PRELIM_DRM_IOCTL_I915_GEM_CLOS_FREE		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_CLOS_FREE, struct prelim_drm_i915_gem_clos_free)
207 #define PRELIM_DRM_IOCTL_I915_GEM_CACHE_RESERVE		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_CACHE_RESERVE, struct prelim_drm_i915_gem_cache_reserve)
208 #define PRELIM_DRM_IOCTL_I915_GEM_VM_GETPARAM		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_GETPARAM, struct prelim_drm_i915_gem_vm_param)
209 #define PRELIM_DRM_IOCTL_I915_GEM_VM_SETPARAM		DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_GEM_VM_SETPARAM, struct prelim_drm_i915_gem_vm_param)
210 /* End PRELIM ioctl's */
211 
212 /* getparam */
213 #define PRELIM_I915_PARAM               (1 << 16)
214 /*
215  * Querying I915_PARAM_EXECBUF2_MAX_ENGINE will return the number of context
216  * map engines addressable via the low bits of execbuf2 flags, or in the
217  * cases where the parameter is not supported (-EINVAL), legacy maximum of
218  * 64 engines should be assumed.
219  */
220 #define PRELIM_I915_PARAM_EXECBUF2_MAX_ENGINE	(PRELIM_I915_PARAM | 1)
221 
222 /* Total local memory in bytes */
223 #define PRELIM_I915_PARAM_LMEM_TOTAL_BYTES	(PRELIM_I915_PARAM | 2)
224 
225 /* Available local memory in bytes */
226 #define PRELIM_I915_PARAM_LMEM_AVAIL_BYTES	(PRELIM_I915_PARAM | 3)
227 
228 /* Shared Virtual Memory (SVM) support capability */
229 #define PRELIM_I915_PARAM_HAS_SVM		(PRELIM_I915_PARAM | 4)
230 
231 /*
232  * Frequency of the timestamps in OA reports. This used to be the same as the CS
233  * timestamp frequency, but differs on some platforms.
234  */
235 #define PRELIM_I915_PARAM_OA_TIMESTAMP_FREQUENCY	(PRELIM_I915_PARAM | 5)
236 
237 /* VM_BIND feature availability */
238 #define PRELIM_I915_PARAM_HAS_VM_BIND	(PRELIM_I915_PARAM | 6)
239 
240 /* Recoverable pagefault support */
241 #define PRELIM_I915_PARAM_HAS_PAGE_FAULT	(PRELIM_I915_PARAM | 7)
242 /* End getparam */
243 
244 struct prelim_drm_i915_gem_create_ext {
245 
246 	/**
247 	 * Requested size for the object.
248 	 *
249 	 * The (page-aligned) allocated size for the object will be returned.
250 	 */
251 	__u64 size;
252 	/**
253 	 * Returned handle for the object.
254 	 *
255 	 * Object handles are nonzero.
256 	 */
257 	__u32 handle;
258 	__u32 pad;
259 
260 #define PRELIM_I915_GEM_CREATE_EXT_SETPARAM	(PRELIM_I915_USER_EXT | 1)
261 #define PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE	(PRELIM_I915_USER_EXT | 3)
262 #define PRELIM_I915_GEM_CREATE_EXT_FLAGS_UNKNOWN			\
263 	(~(PRELIM_I915_GEM_CREATE_EXT_SETPARAM |			\
264 	   PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE))
265 	__u64 extensions;
266 };
267 
268 struct prelim_drm_i915_gem_object_param {
269 	/* Object handle (0 for I915_GEM_CREATE_EXT_SETPARAM) */
270 	__u32 handle;
271 
272 	/* Data pointer size */
273 	__u32 size;
274 
275 /*
276  * PRELIM_I915_OBJECT_PARAM:
277  *
278  * Select object namespace for the param.
279  */
280 #define PRELIM_I915_OBJECT_PARAM  (1ull << 48)
281 
282 /*
283  * PRELIM_I915_PARAM_MEMORY_REGIONS:
284  *
285  * Set the data pointer with the desired set of placements in priority
286  * order(each entry must be unique and supported by the device), as an array of
287  * prelim_drm_i915_gem_memory_class_instance, or an equivalent layout of class:instance
288  * pair encodings. See PRELIM_DRM_I915_QUERY_MEMORY_REGIONS for how to query the
289  * supported regions.
290  *
291  * Note that this requires the PRELIM_I915_OBJECT_PARAM namespace:
292  *	.param = PRELIM_I915_OBJECT_PARAM | PRELIM_I915_PARAM_MEMORY_REGIONS
293  */
294 #define PRELIM_I915_PARAM_MEMORY_REGIONS ((1 << 16) | 0x1)
295 	__u64 param;
296 
297 	/* Data value or pointer */
298 	__u64 data;
299 };
300 
301 struct prelim_drm_i915_gem_create_ext_setparam {
302 	struct i915_user_extension base;
303 	struct prelim_drm_i915_gem_object_param param;
304 };
305 
306 struct prelim_drm_i915_gem_create_ext_vm_private {
307 	/** @base: Extension link. See struct i915_user_extension. */
308 	struct i915_user_extension base;
309 	/** @vm_id: Id of the VM to which Object is private */
310 	__u32 vm_id;
311 };
312 
313 #define PRELIM_PERF_VERSION	(1000)
314 
315 /**
316  * Returns OA buffer properties to be used with mmap.
317  *
318  * This ioctl is available in perf revision 1000.
319  */
320 #define PRELIM_I915_PERF_IOCTL_GET_OA_BUFFER_INFO _IOWR('i', 0x80, struct prelim_drm_i915_perf_oa_buffer_info)
321 
322 /**
323  * OA buffer size and offset.
324  *
325  * OA output buffer
326  *   type: 0
327  *   flags: mbz
328  *
329  *   After querying the info, pass (size,offset) to mmap(),
330  *
331  *   mmap(0, info.size, PROT_READ, MAP_PRIVATE, perf_fd, info.offset).
332  *
333  *   Note that only a private (not shared between processes, or across fork())
334  *   read-only mmapping is allowed.
335  *
336  *   Userspace must treat the incoming data as tainted, but it conforms to the OA
337  *   format as specified by user config. The buffer provides reports that have
338  *   OA counters - A, B and C.
339  */
340 struct prelim_drm_i915_perf_oa_buffer_info {
341 	__u32 type;   /* in */
342 	__u32 flags;  /* in */
343 	__u64 size;   /* out */
344 	__u64 offset; /* out */
345 	__u64 rsvd;   /* mbz */
346 };
347 
348 enum prelim_drm_i915_eu_stall_property_id {
349 	/**
350 	 * This field specifies the Per DSS Memory Buffer Size.
351 	 * Valid values are 128 KB, 256 KB, and 512 KB.
352 	 */
353 	PRELIM_DRM_I915_EU_STALL_PROP_BUF_SZ = 1001,
354 
355 	/**
356 	 * This field specifies the sampling rate per tile
357 	 * in multiples of 251 cycles. Valid values are 1 to 7.
358 	 * If the value is 1, sampling interval is 251 cycles.
359 	 * If the value is 7, sampling interval is 7 x 251 cycles.
360 	 */
361 	PRELIM_DRM_I915_EU_STALL_PROP_SAMPLE_RATE,
362 
363 	/**
364 	 * This field specifies the EU stall data poll period
365 	 * in nanoseconds. Minimum allowed value is 100 ms.
366 	 * A default value is used by the driver if this field
367 	 * is not specified.
368 	 */
369 	PRELIM_DRM_I915_EU_STALL_PROP_POLL_PERIOD,
370 
371 	PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_CLASS,
372 
373 	PRELIM_DRM_I915_EU_STALL_PROP_ENGINE_INSTANCE,
374 
375 	/**
376 	 * This field specifies the minimum number of
377 	 * EU stall data rows to be present in the kernel
378 	 * buffer for poll() to set POLLIN (data present).
379 	 * A default value of 1 is used by the driver if this
380 	 * field is not specified.
381 	 */
382 	PRELIM_DRM_I915_EU_STALL_PROP_EVENT_REPORT_COUNT,
383 
384 	PRELIM_DRM_I915_EU_STALL_PROP_MAX
385 };
386 
387 /*
388  * Info that the driver adds to each entry in the EU stall counters data.
389  */
390 struct prelim_drm_i915_stall_cntr_info {
391 	__u16 subslice;
392 	__u16 flags;
393 /* EU stall data line dropped due to memory buffer being full */
394 #define PRELIM_I915_EUSTALL_FLAG_OVERFLOW_DROP	(1 << 8)
395 };
396 
397 struct prelim_drm_i915_perf_open_param {
398 	/* PRELIM flags */
399 #define PRELIM_I915_PERF_FLAG_FD_EU_STALL	(1 << 16)
400 };
401 
402 struct prelim_drm_i915_gem_memory_class_instance {
403 	__u16 memory_class; /* see enum prelim_drm_i915_gem_memory_class */
404 	__u16 memory_instance;
405 };
406 
407 struct prelim_drm_i915_query_item {
408 #define PRELIM_DRM_I915_QUERY			(1 << 16)
409 #define PRELIM_DRM_I915_QUERY_MASK(x)		(x & 0xffff)
410 #define PRELIM_DRM_I915_QUERY_MEMORY_REGIONS	(PRELIM_DRM_I915_QUERY | 4)
411 #define PRELIM_DRM_I915_QUERY_DISTANCE_INFO	(PRELIM_DRM_I915_QUERY | 5)
412 /* Deprecated: HWConfig is now upstream, do not use the prelim version anymore */
413 #define PRELIM_DRM_I915_QUERY_HWCONFIG_TABLE	(PRELIM_DRM_I915_QUERY | 6)
414 	/**
415 	 * Query Geometry Subslices: returns the items found in query_topology info
416 	 * with a mask for geometry_subslice_mask applied
417 	 *
418 	 * @flags:
419 	 *
420 	 * bits 0:7 must be a valid engine class and bits 8:15 must be a valid engine
421 	 * instance.
422 	 */
423 #define PRELIM_DRM_I915_QUERY_GEOMETRY_SUBSLICES	(PRELIM_DRM_I915_QUERY | 7)
424 	/**
425 	 * Query Compute Subslices: returns the items found in query_topology info
426 	 * with a mask for compute_subslice_mask applied
427 	 *
428 	 * @flags:
429 	 *
430 	 * bits 0:7 must be a valid engine class and bits 8:15 must be a valid engine
431 	 * instance.
432 	 */
433 #define PRELIM_DRM_I915_QUERY_COMPUTE_SUBSLICES		(PRELIM_DRM_I915_QUERY | 8)
434 	/**
435 	 * Query Command Streamer timestamp register.
436 	 */
437 #define PRELIM_DRM_I915_QUERY_CS_CYCLES			(PRELIM_DRM_I915_QUERY | 9)
438 #define PRELIM_DRM_I915_QUERY_FABRIC_INFO		(PRELIM_DRM_I915_QUERY | 11)
439 #define PRELIM_DRM_I915_QUERY_ENGINE_INFO		(PRELIM_DRM_I915_QUERY | 13)
440 };
441 
442 /*
443  * In XEHPSDV total number of engines can be more than the maximum supported
444  * engines by I915_EXEC_RING_MASK.
445  * PRELIM_I915_EXEC_ENGINE_MASK expands the total number of engines from 64 to 256.
446  *
447  * To use PRELIM_I915_EXEC_ENGINE_MASK, userspace needs to query
448  * I915_PARAM_EXECBUF2_MAX_ENGINE. On getting valid value, userspace needs
449  * to set PRELIM_I915_EXEC_ENGINE_MASK_SELECT to enable PRELIM_I915_EXEC_ENGINE_MASK.
450  *
451  * Bitfield associated with legacy I915_EXEC_CONSTANTS_MASK which was
452  * restricted previously, will be utilized by PRELIM_I915_EXEC_ENGINE_MASK.
453  *
454  * PRELIM_I915_EXEC_ENGINE_MASK only applies to contexts with engine map set up.
455  */
456 #define PRELIM_I915_EXEC_ENGINE_MASK    (0xff)
457 #define PRELIM_I915_EXEC_ENGINE_MASK_SELECT (1ull << 55)
458 
459 #define __PRELIM_I915_EXEC_UNKNOWN_FLAGS (~(GENMASK_ULL(55, 48) | ~__I915_EXEC_UNKNOWN_FLAGS))
460 
461 /*
462  * Indicates the 2k user priority levels are statically mapped into 3 buckets as
463  * follows:
464  *
465  * -1k to -1	Low priority
466  * 0		Normal priority
467  * 1 to 1k	Highest priority
468  */
469 #define   PRELIM_I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP	(1ul << 31)
470 
471 enum prelim_drm_i915_gem_engine_class {
472 #define	PRELIM_I915_ENGINE_CLASS		(1 << 8)
473 #define	PRELIM_I915_ENGINE_CLASS_MASK(x)	(x & 0xff)
474 
475 	PRELIM_I915_ENGINE_CLASS_COMPUTE = 4,
476 };
477 
478 struct prelim_i915_context_param_engines {
479 #define PRELIM_I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT (PRELIM_I915_USER_EXT | 2) /* see prelim_i915_context_engines_parallel_submit */
480 };
481 
482 /* PRELIM OA formats */
483 enum prelim_drm_i915_oa_format {
484 	PRELIM_I915_OA_FORMAT_START = 128,
485 
486 	/* XEHPSDV */
487 	PRELIM_I915_OAR_FORMAT_A32u40_A4u32_B8_C8 = PRELIM_I915_OA_FORMAT_START,
488 	PRELIM_I915_OA_FORMAT_A24u40_A14u32_B8_C8,
489 	PRELIM_I915_OAM_FORMAT_A2u64_B8_C8,
490 
491 	/* DG2 */
492 	PRELIM_I915_OAR_FORMAT_A36u64_B8_C8,
493 	PRELIM_I915_OAC_FORMAT_A24u64_B8_C8,
494 	PRELIM_I915_OA_FORMAT_A38u64_R2u64_B8_C8,
495 	PRELIM_I915_OAM_FORMAT_A2u64_R2u64_B8_C8,
496 	PRELIM_I915_OAC_FORMAT_A22u32_R2u32_B8_C8,
497 
498 	PRELIM_I915_OA_FORMAT_MAX	/* non-ABI */
499 };
500 
501 enum prelim_drm_i915_perf_record_type {
502 #define PRELIM_DRM_I915_PERF_RECORD	(1 << 16)
503 	/*
504 	 * MMIO trigger queue is full.
505 	 * This record type is available in perf revision 1003.
506 	 */
507 	PRELIM_DRM_I915_PERF_RECORD_OA_MMIO_TRG_Q_FULL = (PRELIM_DRM_I915_PERF_RECORD | 1),
508 };
509 
510 /*
511  * Access Counter programming
512  *
513  * The programmable access counters enable hardware to detect and report
514  * frequently accessed pages. The report generated by hardware can be used by
515  * software for influencing page migration and data placement decisions.
516  *
517  * Once the count reaches the value set by trigger, HW generates trigger
518  * interrupt. DRM driver then starts the page migration from SMEM to
519  * LMEM so the upcoming access to the same page(s) from GPU will access LMEM
520  * to achive better performance.
521  *
522  * Due to the HW capacity limitation, an access counter can be de-allocated on
523  * the fly. If the counter getting de-allocated has reached at least notify
524  * it is reported to SW via interrupt. The driver interrupt handling is TBD.
525  *
526  * The use case is to let the upper layer SW such as Open CL to make the
527  * decision to program all the configurations and the DRM driver will handle
528  * the interrupts generated by HW.
529  *
530  * NOTE: if ac_notify is set to 0, access counter notification reporting is disabled
531  *       if ac_trigger is set to 0, access counter triggering is disabled.
532  *
533  *	Only allowed in i915_gem_context_create_ioctl extension
534  */
535 struct prelim_drm_i915_gem_context_param_acc {
536 		__u16 trigger;
537 		__u16 notify;
538 		__u8  granularity;
539 #define   PRELIM_I915_CONTEXT_ACG_128K      0
540 #define   PRELIM_I915_CONTEXT_ACG_2M        1
541 #define   PRELIM_I915_CONTEXT_ACG_16M       2
542 #define   PRELIM_I915_CONTEXT_ACG_64M       3
543 		__u8 pad1;
544 		__u16 pad2;
545 };
546 
547 struct prelim_drm_i915_gem_context_param {
548 /*
549  * I915_CONTEXT_PARAM_DEBUG_FLAGS
550  *
551  * Set or clear debug flags associated with this context.
552  * The flags works with 32 bit masking to enable/disable individual
553  * flags. For example to set debug flag of bit position 0, the
554  * value needs to be 0x0000000100000001, and to clear flag of
555  * bit position 0, the value needs to be 0x0000000100000000.
556  *
557  */
558 #define PRELIM_I915_CONTEXT_PARAM		(1 << 16)
559 #define PRELIM_I915_CONTEXT_PARAM_DEBUG_FLAGS	(PRELIM_I915_CONTEXT_PARAM | 0xfd)
560 
561 /*
562  * Notify driver that SIP is provided with the pipeline setup.
563  * Driver raises exception on hang resolution and waits for pipeline's
564  * sip to signal attention before capturing state of user objects
565  * associated with the context.
566  *
567  */
568 #define PRELIM_I915_CONTEXT_PARAM_DEBUG_FLAG_SIP	(1ull << 0)
569 
570 /*
571  *  PRELIM_I915_CONTEXT_PARAM_ACC:
572  *
573  *  To be able to change the access counter thresholds and configurations.
574  *
575  *  By default: access counter feature is disabled.
576  */
577 #define PRELIM_I915_CONTEXT_PARAM_ACC		(PRELIM_I915_CONTEXT_PARAM | 0xd)
578 };
579 
580 struct prelim_drm_i915_gem_context_create_ext {
581 /* Depricated in favor of PRELIM_I915_CONTEXT_CREATE_FLAGS_LONG_RUNNING */
582 #define PRELIM_I915_CONTEXT_CREATE_FLAGS_ULLS		(1u << 31)
583 #define PRELIM_I915_CONTEXT_CREATE_FLAGS_LONG_RUNNING	(1u << 31)
584 #define PRELIM_I915_CONTEXT_CREATE_FLAGS_UNKNOWN			\
585 	(~(PRELIM_I915_CONTEXT_CREATE_FLAGS_LONG_RUNNING | ~I915_CONTEXT_CREATE_FLAGS_UNKNOWN))
586 };
587 
588 /*
589  *  PRELIM_I915_CONTEXT_PARAM_RUNALONE:
590  *
591  *  Enable runalone mode on a context, disabled by default.
592  */
593 #define PRELIM_I915_CONTEXT_PARAM_RUNALONE      (PRELIM_I915_CONTEXT_PARAM | 0xf)
594 
595 /* Downstream PRELIM properties */
596 enum prelim_drm_i915_perf_property_id {
597 	PRELIM_DRM_I915_PERF_PROP = (1 << 16),
598 
599 	/**
600 	 * Specify a global OA buffer size to be allocated in bytes. The size
601 	 * specified must be supported by HW (before XEHPSDV supported sizes are
602 	 * powers of 2 ranging from 128Kb to 16Mb. With XEHPSDV max supported size
603 	 * is 128Mb).
604 	 *
605 	 * This property is available in perf revision 1001.
606 	 */
607 	PRELIM_DRM_I915_PERF_PROP_OA_BUFFER_SIZE = (PRELIM_DRM_I915_PERF_PROP | 1),
608 
609 	/**
610 	 * Specify the engine class defined in @enum drm_i915_gem_engine_class.
611 	 * This defaults to I915_ENGINE_CLASS_RENDER or
612 	 * I915_ENGINE_CLASS_COMPUTE based on the platform.
613 	 *
614 	 * This property is available in perf revision 1002
615 	 *
616 	 * Perf revision 1004 supports I915_ENGINE_CLASS_VIDEO and
617 	 * I915_ENGINE_CLASS_VIDEO_ENHANCE.
618 	 */
619 	PRELIM_DRM_I915_PERF_PROP_OA_ENGINE_CLASS = (PRELIM_DRM_I915_PERF_PROP | 2),
620 
621 	/**
622 	 * Specify the engine instance. Defaults to 0.
623 	 *
624 	 * This property is available in perf revision 1002.
625 	 */
626 	PRELIM_DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE = (PRELIM_DRM_I915_PERF_PROP | 3),
627 
628 	PRELIM_DRM_I915_PERF_PROP_LAST,
629 
630 	PRELIM_DRM_I915_PERF_PROP_MAX = DRM_I915_PERF_PROP_MAX - 1 + \
631 					(PRELIM_DRM_I915_PERF_PROP_LAST & 0xffff)
632 };
633 
634 struct prelim_drm_i915_uuid_control {
635 	char  uuid[36]; /* String formatted like
636 			 *      "%08x-%04x-%04x-%04x-%012x"
637 			 */
638 
639 	__u32 uuid_class; /* Predefined UUID class or handle to
640 			   * the previously registered UUID Class
641 			   */
642 
643 	__u32 flags;	/* MBZ */
644 
645 	__u64 ptr;	/* Pointer to CPU memory payload associated
646 			 * with the UUID Resource.
647 			 * For uuid_class I915_UUID_CLASS_STRING
648 			 * it must point to valid string buffer.
649 			 * Otherwise must point to page aligned buffer
650 			 * or be NULL.
651 			 */
652 
653 	__u64 size;	/* Length of the payload in bytes */
654 
655 #define PRELIM_I915_UUID_CLASS_STRING	((__u32)-1)
656 /*
657  * d9900de4-be09-56ab-84a5-dfc280f52ee5 =
658  *                          sha1("I915_UUID_CLASS_STRING")[0..35]
659  */
660 #define PRELIM_I915_UUID_CLASS_MAX_RESERVED ((__u32)-1024)
661 
662 	__u32 handle; /* Output: Registered handle ID */
663 
664 	__u64 extensions; /* MBZ */
665 };
666 
667 /*
668  * struct prelim_drm_i915_vm_bind_ext_uuid
669  *
670  * Used for registering metadata that will be attached to the vm
671  */
672 struct prelim_drm_i915_vm_bind_ext_uuid {
673 #define PRELIM_I915_VM_BIND_EXT_UUID	(PRELIM_I915_USER_EXT | 1)
674 	struct i915_user_extension base;
675 	__u32 uuid_handle; /* Handle to the registered UUID resource. */
676 };
677 
678 /**
679  * Do a debug event read for a debugger connection.
680  *
681  * This ioctl is available in debug version 1.
682  */
683 #define PRELIM_I915_DEBUG_IOCTL_READ_EVENT _IO('j', 0x0)
684 #define PRELIM_I915_DEBUG_IOCTL_READ_UUID  _IOWR('j', 0x1, struct prelim_drm_i915_debug_read_uuid)
685 #define PRELIM_I915_DEBUG_IOCTL_VM_OPEN  _IOW('j', 0x2, struct prelim_drm_i915_debug_vm_open)
686 #define PRELIM_I915_DEBUG_IOCTL_EU_CONTROL _IOWR('j', 0x3, struct prelim_drm_i915_debug_eu_control)
687 #define PRELIM_I915_DEBUG_IOCTL_ACK_EVENT _IOW('j', 0x4, struct prelim_drm_i915_debug_event_ack)
688 
689 struct prelim_drm_i915_debug_event {
690 	__u32 type;
691 #define PRELIM_DRM_I915_DEBUG_EVENT_NONE     0
692 #define PRELIM_DRM_I915_DEBUG_EVENT_READ     1
693 #define PRELIM_DRM_I915_DEBUG_EVENT_CLIENT   2
694 #define PRELIM_DRM_I915_DEBUG_EVENT_CONTEXT  3
695 #define PRELIM_DRM_I915_DEBUG_EVENT_UUID     4
696 #define PRELIM_DRM_I915_DEBUG_EVENT_VM       5
697 #define PRELIM_DRM_I915_DEBUG_EVENT_VM_BIND  6
698 #define PRELIM_DRM_I915_DEBUG_EVENT_CONTEXT_PARAM 7
699 #define PRELIM_DRM_I915_DEBUG_EVENT_EU_ATTENTION 8
700 #define PRELIM_DRM_I915_DEBUG_EVENT_ENGINES 9
701 #define PRELIM_DRM_I915_DEBUG_EVENT_MAX_EVENT PRELIM_DRM_I915_DEBUG_EVENT_ENGINES
702 
703 	__u32 flags;
704 #define PRELIM_DRM_I915_DEBUG_EVENT_CREATE	(1 << 31)
705 #define PRELIM_DRM_I915_DEBUG_EVENT_DESTROY	(1 << 30)
706 #define PRELIM_DRM_I915_DEBUG_EVENT_STATE_CHANGE (1 << 29)
707 #define PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK	(1 << 28)
708 	__u64 seqno;
709 	__u64 size;
710 } __attribute__((packed));
711 
712 struct prelim_drm_i915_debug_event_client {
713 	struct prelim_drm_i915_debug_event base; /* .flags = CREATE/DESTROY */
714 
715 	__u64 handle; /* This is unique per debug connection */
716 } __attribute__((packed));
717 
718 struct prelim_drm_i915_debug_event_context {
719 	struct prelim_drm_i915_debug_event base;
720 
721 	__u64 client_handle;
722 	__u64 handle;
723 } __attribute__((packed));
724 
725 struct prelim_drm_i915_debugger_open_param {
726 	__u64 pid; /* input: Target process ID */
727 	__u32 flags;
728 #define PRELIM_DRM_I915_DEBUG_FLAG_FD_NONBLOCK	(1u << 31)
729 
730 	__u32 version;
731 	__u64 events;  /* input: event types to subscribe to */
732 	__u64 extensions; /* MBZ */
733 };
734 
735 struct prelim_drm_i915_debug_event_uuid {
736 	struct prelim_drm_i915_debug_event base;
737 	__u64 client_handle;
738 
739 	__u64 handle;
740 	__u64 class_handle; /* Can be filtered based on pre-defined classes */
741 	__u64 payload_size;
742 } __attribute__((packed));
743 
744 struct prelim_drm_i915_debug_event_vm {
745 	struct prelim_drm_i915_debug_event base;
746 	__u64 client_handle;
747 
748 	__u64 handle;
749 } __attribute__((packed));
750 
751 struct prelim_drm_i915_debug_event_vm_bind {
752 	struct prelim_drm_i915_debug_event base;
753 	__u64 client_handle;
754 
755 	__u64 vm_handle;
756 	__u64 va_start;
757 	__u64 va_length;
758 	__u32 num_uuids;
759 	__u32 flags;
760 	__u64 uuids[0];
761 } __attribute__((packed));
762 
763 struct prelim_drm_i915_debug_event_eu_attention {
764 	struct prelim_drm_i915_debug_event base;
765 	__u64 client_handle;
766 	__u64 ctx_handle;
767 	__u64 lrc_handle;
768 
769 	__u32 flags;
770 
771 	struct i915_engine_class_instance ci;
772 
773 	__u32 bitmask_size;
774 
775 	/**
776 	 * Bitmask of thread attentions starting from natural
777 	 * hardware order of slice=0,subslice=0,eu=0, 8 attention
778 	 * bits per eu.
779 	 *
780 	 * NOTE: For dual subslice GENs, the bitmask is for
781 	 * lockstepped EUs and not for logical EUs. This makes
782 	 * the bitmask includu only half of logical EU count
783 	 * provided by topology query as we only control the
784 	 * 'pair' instead of individual EUs.
785 	 */
786 
787 	__u8 bitmask[0];
788 } __attribute__((packed));
789 
790 struct prelim_drm_i915_debug_read_uuid {
791 	__u64 client_handle;
792 	__u64 handle;
793 	__u32 flags; /* MBZ */
794 	char uuid[36]; /* output */
795 	__u64 payload_ptr;
796 	__u64 payload_size;
797 } __attribute__((packed));
798 
799 struct prelim_drm_i915_debug_event_context_param {
800 	struct prelim_drm_i915_debug_event base;
801 	__u64 client_handle;
802 	__u64 ctx_handle;
803 	struct drm_i915_gem_context_param param;
804 } __attribute__((packed));
805 
806 struct prelim_drm_i915_debug_engine_info {
807 	struct i915_engine_class_instance engine;
808 	__u64 lrc_handle;
809 } __attribute__((packed));
810 
811 struct prelim_drm_i915_debug_event_engines {
812 	struct prelim_drm_i915_debug_event base;
813 	__u64 client_handle;
814 	__u64 ctx_handle;
815 	__u64 num_engines;
816 	struct prelim_drm_i915_debug_engine_info engines[0];
817 } __attribute__((packed));
818 
819 struct prelim_drm_i915_debug_vm_open {
820 	__u64 client_handle;
821 	__u64 handle; /* input: The target address space (ppGTT) */
822 	__u64 flags;
823 #define PRELIM_I915_DEBUG_VM_OPEN_READ_ONLY	O_RDONLY
824 #define PRELIM_I915_DEBUG_VM_OPEN_WRITE_ONLY	O_WRONLY
825 #define PRELIM_I915_DEBUG_VM_OPEN_READ_WRITE	O_RDWR
826 };
827 
828 struct prelim_drm_i915_debug_eu_control {
829 	__u64 client_handle;
830 	__u32 cmd;
831 #define PRELIM_I915_DEBUG_EU_THREADS_CMD_INTERRUPT_ALL 0
832 #define PRELIM_I915_DEBUG_EU_THREADS_CMD_STOPPED   1
833 #define PRELIM_I915_DEBUG_EU_THREADS_CMD_RESUME    2
834 #define PRELIM_I915_DEBUG_EU_THREADS_CMD_INTERRUPT 3
835 	__u32 flags;
836 	__u64 seqno;
837 
838 	struct i915_engine_class_instance ci;
839 	__u32 bitmask_size;
840 
841 	/**
842 	 * Bitmask of thread attentions starting from natural
843 	 * hardware order of slice=0,subslice=0,eu=0, 8 attention bits
844 	 * per eu.
845 	 *
846 	 * NOTE: For dual subslice GENs, the bitmask is for
847 	 * lockstepped EUs and not for logical EUs. This makes
848 	 * the bitmask includu only half of logical EU count
849 	 * provided by topology query as we only control the
850 	 * 'pair' instead of individual EUs.
851 	 */
852 	__u64 bitmask_ptr;
853 } __attribute__((packed));
854 
855 struct prelim_drm_i915_debug_event_ack {
856 	__u32 type;
857 	__u32 flags; /* MBZ */
858 	__u64 seqno;
859 } __attribute__((packed));
860 
861 enum prelim_drm_i915_gem_memory_class {
862 	PRELIM_I915_MEMORY_CLASS_SYSTEM = 0,
863 	PRELIM_I915_MEMORY_CLASS_DEVICE,
864 	PRELIM_I915_MEMORY_CLASS_NONE = -1
865 };
866 
867 /**
868  * struct prelim_drm_i915_memory_region_info
869  *
870  * Describes one region as known to the driver.
871  */
872 struct prelim_drm_i915_memory_region_info {
873 	/** class:instance pair encoding */
874 	struct prelim_drm_i915_gem_memory_class_instance region;
875 
876 	/** MBZ */
877 	__u32 rsvd0;
878 
879 	/** MBZ */
880 	__u64 caps;
881 
882 	/** MBZ */
883 	__u64 flags;
884 
885 	/** Memory probed by the driver (-1 = unknown) */
886 	__u64 probed_size;
887 
888 	/** Estimate of memory remaining (-1 = unknown) */
889 	__u64 unallocated_size;
890 
891 	/** MBZ */
892 	__u64 rsvd1[8];
893 };
894 
895 /**
896  * struct prelim_drm_i915_query_memory_regions
897  *
898  * Region info query enumerates all regions known to the driver by filling in
899  * an array of struct prelim_drm_i915_memory_region_info structures.
900  */
901 struct prelim_drm_i915_query_memory_regions {
902 	/** Number of supported regions */
903 	__u32 num_regions;
904 
905 	/** MBZ */
906 	__u32 rsvd[3];
907 
908 	/* Info about each supported region */
909 	struct prelim_drm_i915_memory_region_info regions[];
910 };
911 
912 /**
913  * struct prelim_drm_i915_query_distance_info
914  *
915  * Distance info query returns the distance of given (class, instance)
916  * engine to the memory region id passed by the user. If the distance
917  * is -1 it means region is unreachable.
918  */
919 struct prelim_drm_i915_query_distance_info {
920 	/** Engine for which distance is queried */
921 	struct i915_engine_class_instance engine;
922 
923 	/** Memory region to be used */
924 	struct prelim_drm_i915_gem_memory_class_instance region;
925 
926 	/** Distance to region from engine */
927 	__s32 distance;
928 
929 	/** Must be zero */
930 	__u32 rsvd[3];
931 };
932 
933 /**
934  * struct prelim_drm_i915_query_cs_cycles
935  *
936  * The query returns the command streamer cycles and the frequency that can be
937  * used to calculate the command streamer timestamp. In addition the query
938  * returns the cpu timestamp that indicates when the command streamer cycle
939  * count was captured.
940  */
941 struct prelim_drm_i915_query_cs_cycles {
942 	/** Engine for which command streamer cycles is queried. */
943 	struct i915_engine_class_instance engine;
944 
945 	/** Must be zero. */
946 	__u32 flags;
947 
948 	/**
949 	 * Command streamer cycles as read from the command streamer
950 	 * register at 0x358 offset.
951 	 */
952 	__u64 cs_cycles;
953 
954 	/** Frequency of the cs cycles in Hz. */
955 	__u64 cs_frequency;
956 
957 	/** CPU timestamp in nanoseconds. */
958 	__u64 cpu_timestamp;
959 
960 	/**
961 	 * Reference clock id for CPU timestamp. For definition, see
962 	 * clock_gettime(2) and perf_event_open(2). Supported clock ids are
963 	 * CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, CLOCK_REALTIME, CLOCK_BOOTTIME,
964 	 * CLOCK_TAI.
965 	 */
966 	__s32 clockid;
967 
968 	/** Must be zero. */
969 	__u32 rsvd;
970 };
971 
972 /**
973  * struct prelim_drm_i915_query_fabric_info
974  *
975  * With the given fabric id, query fabric info wrt the device.
976  * Higher bandwidth is better.  0 means no fabric.
977  * Latency is averaged latency (from all paths)
978  *
979  * fabric_id can be obtained from
980  *    /sys/class/drm/cardx/device/iaf.y/iaf_fabric_id
981  * Bandwidth is in Gigabits per second (max value of 8 * 4 * 90)
982  *    8 possible ports
983  *    4 lanes max per port
984  *   90 gigabits per lane
985  * Latency is in tenths of path length. 10 == 1 fabric link between src and dst
986  *   POR is max 1 link (zero hops).
987  */
988 struct prelim_drm_i915_query_fabric_info {
989 	__u32 fabric_id;
990 	__u16 bandwidth;
991 	__u16 latency;
992 };
993 
994 /**
995  * struct prelim_drm_i915_engine_info
996  *
997  * Describes one engine and it's capabilities as known to the driver.
998  */
999 struct prelim_drm_i915_engine_info {
1000 	/** Engine class and instance. */
1001 	struct i915_engine_class_instance engine;
1002 
1003 	/**
1004 	 * SW defined id that identifies the OA unit associated with this
1005 	 * engine. A value of U32_MAX means engine is not supported by OA. All
1006 	 * other values are valid and can be used to group engines into the
1007 	 * associated OA unit.
1008 	 */
1009 	__u32 oa_unit_id;
1010 
1011 	/** Engine flags. */
1012 	__u64 flags;
1013 #define PRELIM_I915_ENGINE_INFO_HAS_KNOWN_CAPABILITIES	(1ull << 63)
1014 #define PRELIM_I915_ENGINE_INFO_HAS_LOGICAL_INSTANCE	(1ull << 62)
1015 #define PRELIM_I915_ENGINE_INFO_HAS_OA_UNIT_ID		(1ull << 61)
1016 
1017 	/** Capabilities of this engine. */
1018 	__u64 capabilities;
1019 #define I915_VIDEO_CLASS_CAPABILITY_HEVC		(1 << 0)
1020 #define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC	(1 << 1)
1021 #define PRELIM_I915_VIDEO_CLASS_CAPABILITY_VDENC	(1ull << 63)
1022 #define PRELIM_I915_COPY_CLASS_CAP_BLOCK_COPY		(1ull << 63)
1023 	/*
1024 	 * The following are capabilties of the copy engines, while all engines
1025 	 * are functionally same, but engines with cap PRELIM_I915_COPY_CLASS_CAP_SATURATE_LINK
1026 	 * can saturate pcie and scaleup links faster than engines with
1027 	 * PRELIM_I915_COPY_CLASS_CAP_SATURATE_PCIE. Engines having the capability of
1028 	 * PRELIM_I915_COPY_CLASS_CAP_SATURATE_LMEM can operate at HBM speeds.
1029 	 */
1030 #define PRELIM_I915_COPY_CLASS_CAP_SATURATE_PCIE	(1ull << 62)
1031 #define PRELIM_I915_COPY_CLASS_CAP_SATURATE_LINK	(1ull << 61)
1032 #define PRELIM_I915_COPY_CLASS_CAP_SATURATE_LMEM	(1ull << 60)
1033 
1034 	/** All known capabilities for this engine class. */
1035 	__u64 known_capabilities;
1036 
1037 	/** Logical engine instance */
1038 	__u16 logical_instance;
1039 
1040 	/** Reserved fields. */
1041 	__u16 rsvd1[3];
1042 	__u64 rsvd2[2];
1043 };
1044 
1045 /**
1046  * struct drm_i915_query_engine_info
1047  *
1048  * Engine info query enumerates all engines known to the driver by filling in
1049  * an array of struct drm_i915_engine_info structures.
1050  */
1051 struct prelim_drm_i915_query_engine_info {
1052 	/** Number of struct drm_i915_engine_info structs following. */
1053 	__u32 num_engines;
1054 
1055 	/** MBZ */
1056 	__u32 rsvd[3];
1057 
1058 	/** Marker for drm_i915_engine_info structures. */
1059 	struct prelim_drm_i915_engine_info engines[];
1060 };
1061 
1062 /**
1063  * struct prelim_drm_i915_gem_vm_bind
1064  *
1065  * VA to object/buffer mapping to [un]bind.
1066  *
1067  * NOTE:
1068  * A vm_bind will hold a reference on the BO which is released
1069  * during corresponding vm_unbind or while closing the VM.
1070  * Hence closing the BO alone will not ensure BO is released.
1071  */
1072 struct prelim_drm_i915_gem_vm_bind {
1073 	/** vm to [un]bind **/
1074 	__u32 vm_id;
1075 
1076 	/** BO handle or file descriptor. Set 'fd' to -1 for system pages **/
1077 	union {
1078 		__u32 handle; /* For unbind, it is reserved and must be 0 */
1079 		__s32 fd;
1080 	};
1081 
1082 	/** VA start to [un]bind **/
1083 	__u64 start;
1084 
1085 	/** Offset in object to [un]bind **/
1086 	__u64 offset;
1087 
1088 	/** VA length to [un]bind **/
1089 	__u64 length;
1090 
1091 	/** Flags **/
1092 	__u64 flags;
1093 #define PRELIM_I915_GEM_VM_BIND_IMMEDIATE	(1ull << 63)
1094 #define PRELIM_I915_GEM_VM_BIND_READONLY	(1ull << 62)
1095 #define PRELIM_I915_GEM_VM_BIND_CAPTURE		(1ull << 61)
1096 #define PRELIM_I915_GEM_VM_BIND_MAKE_RESIDENT	(1ull << 60)
1097 #define PRELIM_I915_GEM_VM_BIND_FD		(1ull << 59)
1098 
1099 	__u64 extensions;
1100 };
1101 
1102 /**
1103  * struct prelim_drm_i915_gem_vm_advise
1104  *
1105  * Set attribute (hint) for an address range or whole buffer object.
1106  *
1107  * To apply attribute to whole buffer object, specify:  handle
1108  * To apply attribute to address range, specify:  vm_id, start, and length.
1109  */
1110 struct prelim_drm_i915_gem_vm_advise {
1111 	/** vm that contains address range (specified with start, length) */
1112 	__u32 vm_id;
1113 
1114 	/** BO handle to apply hint */
1115 	__u32 handle;
1116 
1117 	/** VA start of address range to apply hint */
1118 	__u64 start;
1119 
1120 	/** Length of range to apply attribute */
1121 	__u64 length;
1122 
1123 	/**
1124 	 * Attributes to apply to address range or buffer object
1125 	 *
1126 	 * ATOMIC_SYSTEM
1127 	 *      inform that atomic access is enabled for both CPU and GPU.
1128 	 *      For some platforms, this may be required for correctness
1129 	 *      and this hint will influence migration policy.
1130 	 * ATOMIC_DEVICE
1131 	 *      inform that atomic access is enabled for GPU devices. For
1132 	 *      some platforms, this may be required for correctness and
1133 	 *      this hint will influence migration policy.
1134 	 * ATOMIC_NONE
1135 	 *	clears above ATOMIC_SYSTEM / ATOMIC_DEVICE hint.
1136 	 * PREFERRED_LOCATION
1137 	 *	sets the preferred memory class and instance for this object's
1138 	 *	backing store.  This is a hint only and not guaranteed to be
1139 	 *	honored.  It is an error to choose a memory region that was not
1140 	 *	part of the original set of placements for the GEM object.
1141 	 *	If choosing a preferred location that is in conflict with the
1142 	 *	use of ATOMIC_SYSTEM or ATOMIC_DEVICE, the atomic hint will
1143 	 *	always be honored first.
1144 	 *	To clear the current preferred location, specify memory class
1145 	 *	as I915_MEMORY_CLASS_NONE.
1146 	 */
1147 	__u32 attribute;
1148 #define PRELIM_I915_VM_ADVISE				(1 << 16)
1149 #define PRELIM_I915_VM_ADVISE_ATOMIC_NONE		(PRELIM_I915_VM_ADVISE | 0)
1150 #define PRELIM_I915_VM_ADVISE_ATOMIC_SYSTEM		(PRELIM_I915_VM_ADVISE | 1)
1151 #define PRELIM_I915_VM_ADVISE_ATOMIC_DEVICE		(PRELIM_I915_VM_ADVISE | 2)
1152 #define PRELIM_I915_VM_ADVISE_PREFERRED_LOCATION	(PRELIM_I915_VM_ADVISE | 3)
1153 
1154 	/** Preferred location (memory region) for object backing */
1155 	struct prelim_drm_i915_gem_memory_class_instance region;
1156 
1157 	__u32 rsvd[2];
1158 };
1159 
1160 /**
1161  * struct prelim_drm_i915_gem_wait_user_fence
1162  *
1163  * Wait on user fence. User fence can be woken up either by,
1164  *    1. GPU context indicated by 'ctx_id', or,
1165  *    2. Kerrnel driver async worker upon PRELIM_I915_UFENCE_WAIT_SOFT.
1166  *       'ctx_id' is ignored when this flag is set.
1167  *
1168  * Wakeup when below condition is true.
1169  * (*addr & MASK) OP (VALUE & MASK)
1170  *
1171  */
1172 struct prelim_drm_i915_gem_wait_user_fence {
1173 	__u64 extensions;
1174 	__u64 addr;
1175 	__u32 ctx_id;
1176 	__u16 op;
1177 #define PRELIM_I915_UFENCE		(1 << 8)
1178 #define PRELIM_I915_UFENCE_WAIT_EQ	(PRELIM_I915_UFENCE | 0)
1179 #define PRELIM_I915_UFENCE_WAIT_NEQ	(PRELIM_I915_UFENCE | 1)
1180 #define PRELIM_I915_UFENCE_WAIT_GT	(PRELIM_I915_UFENCE | 2)
1181 #define PRELIM_I915_UFENCE_WAIT_GTE	(PRELIM_I915_UFENCE | 3)
1182 #define PRELIM_I915_UFENCE_WAIT_LT	(PRELIM_I915_UFENCE | 4)
1183 #define PRELIM_I915_UFENCE_WAIT_LTE	(PRELIM_I915_UFENCE | 5)
1184 #define PRELIM_I915_UFENCE_WAIT_BEFORE	(PRELIM_I915_UFENCE | 6)
1185 #define PRELIM_I915_UFENCE_WAIT_AFTER	(PRELIM_I915_UFENCE | 7)
1186 	__u16 flags;
1187 #define PRELIM_I915_UFENCE_WAIT_SOFT	(1 << 15)
1188 #define PRELIM_I915_UFENCE_WAIT_ABSTIME	(1 << 14)
1189 	__u64 value;
1190 	__u64 mask;
1191 #define PRELIM_I915_UFENCE_WAIT_U8     0xffu
1192 #define PRELIM_I915_UFENCE_WAIT_U16    0xffffu
1193 #define PRELIM_I915_UFENCE_WAIT_U32    0xfffffffful
1194 #define PRELIM_I915_UFENCE_WAIT_U64    0xffffffffffffffffull
1195 	__s64 timeout;
1196 };
1197 
1198 /*
1199  * This extension allows user to attach a pair of <addr, value> to an execbuf.
1200  * When that execbuf is finished by GPU HW, the value is written to addr.
1201  * So after execbuf is submitted, user can poll addr to know whether execbuf
1202  * has been finished or not. User space can also call i915_gem_wait_user_fence_ioctl
1203  * (with PRELIM_I915_UFENCE_WAIT_EQ operation) to wait for finishing of execbuf.
1204  * This ioctl can sleep so it is more efficient than a busy polling.
1205  * So this serves as synchronization purpose. It is similar to DRM_IOCTL_I915_GEM_WAIT,
1206  * which is prohibited by compute context. The method introduced here can be use for
1207  * both compute and non-compute context.
1208  */
1209 struct prelim_drm_i915_gem_execbuffer_ext_user_fence {
1210 #define PRELIM_DRM_I915_GEM_EXECBUFFER_EXT_USER_FENCE (PRELIM_I915_USER_EXT | 1)
1211 	struct i915_user_extension base;
1212 
1213 	/**
1214 	 * A virtual address mapped to current process's GPU address space.
1215 	 * addr has to be qword aligned. address has to be a a valid gpu
1216 	 * virtual address at the time of batch buffer completion.
1217 	 */
1218 	__u64 addr;
1219 
1220 	/**
1221 	 * value to be written to above address after execbuf finishes.
1222 	 */
1223 	__u64 value;
1224 	/**
1225 	 * for future extensions. Currently not used.
1226 	 */
1227 	__u64 rsvd;
1228 };
1229 
1230 /* Deprecated in favor of prelim_drm_i915_vm_bind_ext_user_fence */
1231 struct prelim_drm_i915_vm_bind_ext_sync_fence {
1232 #define PRELIM_I915_VM_BIND_EXT_SYNC_FENCE     (PRELIM_I915_USER_EXT | 0)
1233 	struct i915_user_extension base;
1234 	__u64 addr;
1235 	__u64 val;
1236 };
1237 
1238 struct prelim_drm_i915_vm_bind_ext_user_fence {
1239 #define PRELIM_I915_VM_BIND_EXT_USER_FENCE     (PRELIM_I915_USER_EXT | 3)
1240 	struct i915_user_extension base;
1241 	__u64 addr;
1242 	__u64 val;
1243 	__u64 rsvd;
1244 };
1245 
1246 struct prelim_drm_i915_gem_vm_control {
1247 #define PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH	(1 << 16)
1248 #define PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT	(1 << 17)
1249 #define PRELIM_I915_VM_CREATE_FLAGS_USE_VM_BIND		(1 << 18)
1250 #define PRELIM_I915_VM_CREATE_FLAGS_UNKNOWN		(~(GENMASK(18, 16)))
1251 };
1252 
1253 struct prelim_drm_i915_gem_vm_region_ext {
1254 #define PRELIM_I915_GEM_VM_CONTROL_EXT_REGION	(PRELIM_I915_USER_EXT | 0)
1255 	struct i915_user_extension base;
1256 	/* memory region: to find gt to create vm on */
1257 	struct prelim_drm_i915_gem_memory_class_instance region;
1258 	__u32 pad;
1259 };
1260 
1261 struct prelim_drm_i915_vm_bind_ext_set_pat {
1262 #define PRELIM_I915_VM_BIND_EXT_SET_PAT	(PRELIM_I915_USER_EXT | 2)
1263        struct i915_user_extension base;
1264        __u64 pat_index;
1265 };
1266 
1267 /**
1268  * struct prelim_drm_i915_gem_clos_reserve
1269  *
1270  * Allows clients to request reservation of one free CLOS, to use in subsequent
1271  * Cache Reservations.
1272  *
1273  */
1274 struct prelim_drm_i915_gem_clos_reserve {
1275 	__u16 clos_index;
1276 	__u16 pad16;
1277 };
1278 
1279 /**
1280  * struct prelim_drm_i915_gem_clos_free
1281  *
1282  * Free off a previously reserved CLOS set. Any corresponding Cache Reservations
1283  * that are active for the CLOS are automatically dropped and returned to the
1284  * Shared set.
1285  *
1286  * The clos_index indicates the CLOS set which is being released and must
1287  * correspond to a CLOS index previously reserved.
1288  *
1289  */
1290 struct prelim_drm_i915_gem_clos_free {
1291 	__u16 clos_index;
1292 	__u16 pad16;
1293 };
1294 
1295 /**
1296  * struct prelim_drm_i915_gem_cache_reserve
1297  *
1298  * Allows clients to request, or release, reservation of one or more cache ways,
1299  * within a previously reserved CLOS set.
1300  *
1301  * If num_ways = 0, i915 will drop any existing Reservation for the specified
1302  * clos_index and cache_level. The requested clos_index and cache_level Waymasks
1303  * will then track the Shared set once again.
1304  *
1305  * Otherwise, the requested number of Ways will be removed from the Shared set
1306  * for the requested cache level, and assigned to the Cache and CLOS specified
1307  * by cache_level/clos_index.
1308  *
1309  */
1310 struct prelim_drm_i915_gem_cache_reserve {
1311 	__u16 clos_index;
1312 	__u16 cache_level; /* e.g. 3 for L3 */
1313 	__u16 num_ways;
1314 	__u16 pad16;
1315 };
1316 
1317 /**
1318  * struct prelim_drm_i915_gem_vm_prefetch
1319  *
1320  * Prefetch an address range to a memory region.
1321  */
1322 struct prelim_drm_i915_gem_vm_prefetch {
1323 	/** Memory region to prefetch to **/
1324 	__u32 region;
1325 
1326 	/** Reserved **/
1327 	__u32 rsvd;
1328 
1329 	/** VA start to prefetch **/
1330 	__u64 start;
1331 
1332 	/** VA length to prefetch **/
1333 	__u64 length;
1334 };
1335 
1336 struct prelim_drm_i915_gem_vm_param {
1337 	__u32 vm_id;
1338 	__u32 rsvd;
1339 
1340 #define PRELIM_I915_VM_PARAM		(1ull << 63)
1341 #define PRELIM_I915_GEM_VM_PARAM_SVM	(1 << 16)
1342 	__u64 param;
1343 
1344 	__u64 value;
1345 };
1346 
1347 #endif /* __I915_DRM_PRELIM_H__ */
1348