1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
3 * Copyright (C) 2020-2024 Intel Corporation
6 #ifndef __UAPI_IVPU_DRM_H__
7 #define __UAPI_IVPU_DRM_H__
11 #if defined(__cplusplus)
15 #define DRM_IVPU_GET_PARAM 0x00
16 #define DRM_IVPU_SET_PARAM 0x01
17 #define DRM_IVPU_BO_CREATE 0x02
18 #define DRM_IVPU_BO_INFO 0x03
19 #define DRM_IVPU_SUBMIT 0x05
20 #define DRM_IVPU_BO_WAIT 0x06
21 #define DRM_IVPU_METRIC_STREAMER_START 0x07
22 #define DRM_IVPU_METRIC_STREAMER_STOP 0x08
23 #define DRM_IVPU_METRIC_STREAMER_GET_DATA 0x09
24 #define DRM_IVPU_METRIC_STREAMER_GET_INFO 0x0a
26 #define DRM_IOCTL_IVPU_GET_PARAM \
27 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_GET_PARAM, struct drm_ivpu_param)
29 #define DRM_IOCTL_IVPU_SET_PARAM \
30 DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SET_PARAM, struct drm_ivpu_param)
32 #define DRM_IOCTL_IVPU_BO_CREATE \
33 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE, struct drm_ivpu_bo_create)
35 #define DRM_IOCTL_IVPU_BO_INFO \
36 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_INFO, struct drm_ivpu_bo_info)
38 #define DRM_IOCTL_IVPU_SUBMIT \
39 DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SUBMIT, struct drm_ivpu_submit)
41 #define DRM_IOCTL_IVPU_BO_WAIT \
42 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_WAIT, struct drm_ivpu_bo_wait)
44 #define DRM_IOCTL_IVPU_METRIC_STREAMER_START \
45 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_START, \
46 struct drm_ivpu_metric_streamer_start)
48 #define DRM_IOCTL_IVPU_METRIC_STREAMER_STOP \
49 DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_STOP, \
50 struct drm_ivpu_metric_streamer_stop)
52 #define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA \
53 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_DATA, \
54 struct drm_ivpu_metric_streamer_get_data)
56 #define DRM_IOCTL_IVPU_METRIC_STREAMER_GET_INFO \
57 DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_METRIC_STREAMER_GET_INFO, \
58 struct drm_ivpu_metric_streamer_get_data)
63 * VPU contexts have private virtual address space, job queues and priority.
64 * Each context is identified by an unique ID. Context is created on open().
67 #define DRM_IVPU_PARAM_DEVICE_ID 0
68 #define DRM_IVPU_PARAM_DEVICE_REVISION 1
69 #define DRM_IVPU_PARAM_PLATFORM_TYPE 2
70 #define DRM_IVPU_PARAM_CORE_CLOCK_RATE 3
71 #define DRM_IVPU_PARAM_NUM_CONTEXTS 4
72 #define DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS 5
73 #define DRM_IVPU_PARAM_CONTEXT_PRIORITY 6 /* Deprecated */
74 #define DRM_IVPU_PARAM_CONTEXT_ID 7
75 #define DRM_IVPU_PARAM_FW_API_VERSION 8
76 #define DRM_IVPU_PARAM_ENGINE_HEARTBEAT 9
77 #define DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID 10
78 #define DRM_IVPU_PARAM_TILE_CONFIG 11
79 #define DRM_IVPU_PARAM_SKU 12
80 #define DRM_IVPU_PARAM_CAPABILITIES 13
82 #define DRM_IVPU_PLATFORM_TYPE_SILICON 0
84 /* Deprecated, use DRM_IVPU_JOB_PRIORITY */
85 #define DRM_IVPU_CONTEXT_PRIORITY_IDLE 0
86 #define DRM_IVPU_CONTEXT_PRIORITY_NORMAL 1
87 #define DRM_IVPU_CONTEXT_PRIORITY_FOCUS 2
88 #define DRM_IVPU_CONTEXT_PRIORITY_REALTIME 3
90 #define DRM_IVPU_JOB_PRIORITY_DEFAULT 0
91 #define DRM_IVPU_JOB_PRIORITY_IDLE 1
92 #define DRM_IVPU_JOB_PRIORITY_NORMAL 2
93 #define DRM_IVPU_JOB_PRIORITY_FOCUS 3
94 #define DRM_IVPU_JOB_PRIORITY_REALTIME 4
97 * DRM_IVPU_CAP_METRIC_STREAMER
99 * Metric streamer support. Provides sampling of various hardware performance
100 * metrics like DMA bandwidth and cache miss/hits. Can be used for profiling.
102 #define DRM_IVPU_CAP_METRIC_STREAMER 1
104 * DRM_IVPU_CAP_DMA_MEMORY_RANGE
106 * Driver has capability to allocate separate memory range
107 * accessible by hardware DMA.
109 #define DRM_IVPU_CAP_DMA_MEMORY_RANGE 2
112 * struct drm_ivpu_param - Get/Set VPU parameters
114 struct drm_ivpu_param {
120 * %DRM_IVPU_PARAM_DEVICE_ID:
121 * PCI Device ID of the VPU device (read-only)
123 * %DRM_IVPU_PARAM_DEVICE_REVISION:
124 * VPU device revision (read-only)
126 * %DRM_IVPU_PARAM_PLATFORM_TYPE:
127 * Returns %DRM_IVPU_PLATFORM_TYPE_SILICON on real hardware or device specific
128 * platform type when executing on a simulator or emulator (read-only)
130 * %DRM_IVPU_PARAM_CORE_CLOCK_RATE:
131 * Current PLL frequency (read-only)
133 * %DRM_IVPU_PARAM_NUM_CONTEXTS:
134 * Maximum number of simultaneously existing contexts (read-only)
136 * %DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS:
137 * Lowest VPU virtual address available in the current context (read-only)
139 * %DRM_IVPU_PARAM_CONTEXT_ID:
140 * Current context ID, always greater than 0 (read-only)
142 * %DRM_IVPU_PARAM_FW_API_VERSION:
143 * Firmware API version array (read-only)
145 * %DRM_IVPU_PARAM_ENGINE_HEARTBEAT:
146 * Heartbeat value from an engine (read-only).
147 * Engine ID (i.e. DRM_IVPU_ENGINE_COMPUTE) is given via index.
149 * %DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID:
150 * Device-unique inference ID (read-only)
152 * %DRM_IVPU_PARAM_TILE_CONFIG:
153 * VPU tile configuration (read-only)
155 * %DRM_IVPU_PARAM_SKU:
156 * VPU SKU ID (read-only)
158 * %DRM_IVPU_PARAM_CAPABILITIES:
159 * Supported capabilities (read-only)
163 /** @index: Index for params that have multiple instances */
166 /** @value: Param value */
170 #define DRM_IVPU_BO_SHAVE_MEM 0x00000001
171 #define DRM_IVPU_BO_HIGH_MEM DRM_IVPU_BO_SHAVE_MEM
172 #define DRM_IVPU_BO_MAPPABLE 0x00000002
173 #define DRM_IVPU_BO_DMA_MEM 0x00000004
175 #define DRM_IVPU_BO_CACHED 0x00000000
176 #define DRM_IVPU_BO_UNCACHED 0x00010000
177 #define DRM_IVPU_BO_WC 0x00020000
178 #define DRM_IVPU_BO_CACHE_MASK 0x00030000
180 #define DRM_IVPU_BO_FLAGS \
181 (DRM_IVPU_BO_HIGH_MEM | \
182 DRM_IVPU_BO_MAPPABLE | \
183 DRM_IVPU_BO_DMA_MEM | \
184 DRM_IVPU_BO_CACHE_MASK)
187 * struct drm_ivpu_bo_create - Create BO backed by SHMEM
189 * Create GEM buffer object allocated in SHMEM memory.
191 struct drm_ivpu_bo_create {
192 /** @size: The size in bytes of the allocated memory */
200 * %DRM_IVPU_BO_HIGH_MEM:
202 * Allocate VPU address from >4GB range.
203 * Buffer object with vpu address >4GB can be always accessed by the
204 * VPU DMA engine, but some HW generation may not be able to access
205 * this memory from then firmware running on the VPU management processor.
206 * Suitable for input, output and some scratch buffers.
208 * %DRM_IVPU_BO_MAPPABLE:
210 * Buffer object can be mapped using mmap().
212 * %DRM_IVPU_BO_CACHED:
214 * Allocated BO will be cached on host side (WB) and snooped on the VPU side.
215 * This is the default caching mode.
217 * %DRM_IVPU_BO_UNCACHED:
219 * Not supported. Use DRM_IVPU_BO_WC instead.
223 * Allocated BO will use write combining buffer for writes but reads will be
228 /** @handle: Returned GEM object handle */
231 /** @vpu_addr: Returned VPU virtual address */
236 * struct drm_ivpu_bo_info - Query buffer object info
238 struct drm_ivpu_bo_info {
239 /** @handle: Handle of the queried BO */
242 /** @flags: Returned flags used to create the BO */
245 /** @vpu_addr: Returned VPU virtual address */
251 * Returned offset to be used in mmap(). 0 in case the BO is not mappable.
255 /** @size: Returned GEM object size, aligned to PAGE_SIZE */
259 /* drm_ivpu_submit engines */
260 #define DRM_IVPU_ENGINE_COMPUTE 0
261 #define DRM_IVPU_ENGINE_COPY 1 /* Deprecated */
264 * struct drm_ivpu_submit - Submit commands to the VPU
266 * Execute a single command buffer on a given VPU engine.
267 * Handles to all referenced buffer objects have to be provided in @buffers_ptr.
269 * User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.
271 struct drm_ivpu_submit {
275 * A pointer to an u32 array of GEM handles of the BOs required for this job.
276 * The number of elements in the array must be equal to the value given by @buffer_count.
278 * The first BO is the command buffer. The rest of array has to contain all
279 * BOs referenced from the command buffer.
283 /** @buffer_count: Number of elements in the @buffers_ptr */
287 * @engine: Select the engine this job should be executed on
289 * %DRM_IVPU_ENGINE_COMPUTE:
291 * Performs Deep Learning Neural Compute Inference Operations
295 /** @flags: Reserved for future use - must be zero */
301 * Offset inside the first buffer in @buffers_ptr containing commands
302 * to be executed. The offset has to be 8-byte aligned.
304 __u32 commands_offset;
309 * Priority to be set for related job command queue, can be one of the following:
310 * %DRM_IVPU_JOB_PRIORITY_DEFAULT
311 * %DRM_IVPU_JOB_PRIORITY_IDLE
312 * %DRM_IVPU_JOB_PRIORITY_NORMAL
313 * %DRM_IVPU_JOB_PRIORITY_FOCUS
314 * %DRM_IVPU_JOB_PRIORITY_REALTIME
319 /* drm_ivpu_bo_wait job status codes */
320 #define DRM_IVPU_JOB_STATUS_SUCCESS 0
321 #define DRM_IVPU_JOB_STATUS_ABORTED 256
324 * struct drm_ivpu_bo_wait - Wait for BO to become inactive
326 * Blocks until a given buffer object becomes inactive.
327 * With @timeout_ms set to 0 returns immediately.
329 struct drm_ivpu_bo_wait {
330 /** @handle: Handle to the buffer object to be waited on */
333 /** @flags: Reserved for future use - must be zero */
336 /** @timeout_ns: Absolute timeout in nanoseconds (may be zero) */
342 * Job status code which is updated after the job is completed.
343 * &DRM_IVPU_JOB_STATUS_SUCCESS or device specific error otherwise.
344 * Valid only if @handle points to a command buffer.
348 /** @pad: Padding - must be zero */
353 * struct drm_ivpu_metric_streamer_start - Start collecting metric data
355 struct drm_ivpu_metric_streamer_start {
356 /** @metric_group_mask: Indicates metric streamer instance */
357 __u64 metric_group_mask;
358 /** @sampling_period_ns: Sampling period in nanoseconds */
359 __u64 sampling_period_ns;
361 * @read_period_samples:
363 * Number of samples after which user space will try to read the data.
364 * Reading the data after significantly longer period may cause data loss.
366 __u32 read_period_samples;
367 /** @sample_size: Returned size of a single sample in bytes */
369 /** @max_data_size: Returned max @data_size from %DRM_IOCTL_IVPU_METRIC_STREAMER_GET_DATA */
374 * struct drm_ivpu_metric_streamer_get_data - Copy collected metric data
376 struct drm_ivpu_metric_streamer_get_data {
377 /** @metric_group_mask: Indicates metric streamer instance */
378 __u64 metric_group_mask;
379 /** @buffer_ptr: A pointer to a destination for the copied data */
381 /** @buffer_size: Size of the destination buffer */
384 * @data_size: Returned size of copied metric data
386 * If the @buffer_size is zero, returns the amount of data ready to be copied.
392 * struct drm_ivpu_metric_streamer_stop - Stop collecting metric data
394 struct drm_ivpu_metric_streamer_stop {
395 /** @metric_group_mask: Indicates metric streamer instance */
396 __u64 metric_group_mask;
399 #if defined(__cplusplus)
403 #endif /* __UAPI_IVPU_DRM_H__ */