1 /* SPDX-License-Identifier: MIT */
3 * Copyright (c) 2020-2023, Intel Corporation.
8 * @brief JSM shared definitions
11 * @brief JSM shared definitions
18 * Major version changes that break backward compatibility
20 #define VPU_JSM_API_VER_MAJOR 3
23 * Minor version changes when API backward compatibility is preserved.
25 #define VPU_JSM_API_VER_MINOR 15
28 * API header changed (field names, documentation, formatting) but API itself has not been changed
30 #define VPU_JSM_API_VER_PATCH 6
33 * Index in the API version table
35 #define VPU_JSM_API_VER_INDEX 4
38 * Number of Priority Bands for Hardware Scheduling
39 * Bands: RealTime, Focus, Normal, Idle
41 #define VPU_HWS_NUM_PRIORITY_BANDS 4
43 /* Max number of impacted contexts that can be dealt with the engine reset command */
44 #define VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS 3
47 * Pack the API structures to enforce binary compatibility
48 * Align to 8 bytes for optimal performance
55 #define VPU_ENGINE_COMPUTE 0
56 #define VPU_ENGINE_COPY 1
57 #define VPU_ENGINE_NB 2
62 #define VPU_JSM_STATUS_SUCCESS 0x0U
63 #define VPU_JSM_STATUS_PARSING_ERR 0x1U
64 #define VPU_JSM_STATUS_PROCESSING_ERR 0x2U
65 #define VPU_JSM_STATUS_PREEMPTED 0x3U
66 #define VPU_JSM_STATUS_ABORTED 0x4U
67 #define VPU_JSM_STATUS_USER_CTX_VIOL_ERR 0x5U
68 #define VPU_JSM_STATUS_GLOBAL_CTX_VIOL_ERR 0x6U
69 #define VPU_JSM_STATUS_MVNCI_WRONG_INPUT_FORMAT 0x7U
70 #define VPU_JSM_STATUS_MVNCI_UNSUPPORTED_NETWORK_ELEMENT 0x8U
71 #define VPU_JSM_STATUS_MVNCI_INVALID_HANDLE 0x9U
72 #define VPU_JSM_STATUS_MVNCI_OUT_OF_RESOURCES 0xAU
73 #define VPU_JSM_STATUS_MVNCI_NOT_IMPLEMENTED 0xBU
74 #define VPU_JSM_STATUS_MVNCI_INTERNAL_ERROR 0xCU
75 /* Job status returned when the job was preempted mid-inference */
76 #define VPU_JSM_STATUS_PREEMPTED_MID_INFERENCE 0xDU
79 * Host <-> VPU IPC channels.
80 * ASYNC commands use a high priority channel, other messages use low-priority ones.
82 #define VPU_IPC_CHAN_ASYNC_CMD 0
83 #define VPU_IPC_CHAN_GEN_CMD 10
84 #define VPU_IPC_CHAN_JOB_RET 11
87 * Job flags bit masks.
89 #define VPU_JOB_FLAGS_NULL_SUBMISSION_MASK 0x00000001
90 #define VPU_JOB_FLAGS_PRIVATE_DATA_MASK 0xFF000000
93 * Sizes of the reserved areas in jobs, in bytes.
95 #define VPU_JOB_RESERVED_BYTES 8
98 * Sizes of the reserved areas in job queues, in bytes.
100 #define VPU_JOB_QUEUE_RESERVED_BYTES 52
103 * Max length (including trailing NULL char) of trace entity name (e.g., the
104 * name of a logging destination or a loggable HW component).
106 #define VPU_TRACE_ENTITY_NAME_MAX_LEN 32
109 * Max length (including trailing NULL char) of a dyndbg command.
111 * NOTE: 96 is used so that the size of 'struct vpu_ipc_msg' in the JSM API is
112 * 128 bytes (multiple of 64 bytes, the cache line size).
114 #define VPU_DYNDBG_CMD_MAX_LEN 96
117 * For HWS command queue scheduling, we can prioritise command queues inside the
118 * same process with a relative in-process priority. Valid values for relative
119 * priority are given below - max and min.
121 #define VPU_HWS_COMMAND_QUEUE_MAX_IN_PROCESS_PRIORITY 7
122 #define VPU_HWS_COMMAND_QUEUE_MIN_IN_PROCESS_PRIORITY -7
125 * For HWS priority scheduling, we can have multiple realtime priority bands.
126 * They are numbered 0 to a MAX.
128 #define VPU_HWS_MAX_REALTIME_PRIORITY_LEVEL 31U
131 * vpu_jsm_engine_reset_context flag definitions
133 #define VPU_ENGINE_RESET_CONTEXT_FLAG_COLLATERAL_DAMAGE_MASK BIT(0)
134 #define VPU_ENGINE_RESET_CONTEXT_HANG_PRIMARY_CAUSE 0
135 #define VPU_ENGINE_RESET_CONTEXT_COLLATERAL_DAMAGE 1
138 * Invalid command queue handle identifier. Applies to cmdq_id and cmdq_group
141 #define VPU_HWS_INVALID_CMDQ_HANDLE 0ULL
146 struct vpu_job_queue_entry {
147 u64 batch_buf_addr; /**< Address of VPU commands batch buffer */
148 u32 job_id; /**< Job ID */
149 u32 flags; /**< Flags bit field, see VPU_JOB_FLAGS_* above */
150 u64 root_page_table_addr; /**< Address of root page table to use for this job */
151 u64 root_page_table_update_counter; /**< Page tables update events counter */
152 u64 primary_preempt_buf_addr;
153 /**< Address of the primary preemption buffer to use for this job */
154 u32 primary_preempt_buf_size;
155 /**< Size of the primary preemption buffer to use for this job */
156 u32 secondary_preempt_buf_size;
157 /**< Size of secondary preemption buffer to use for this job */
158 u64 secondary_preempt_buf_addr;
159 /**< Address of secondary preemption buffer to use for this job */
160 u8 reserved_0[VPU_JOB_RESERVED_BYTES];
164 * Job queue control registers.
166 struct vpu_job_queue_header {
170 u8 reserved_0[VPU_JOB_QUEUE_RESERVED_BYTES];
176 struct vpu_job_queue {
177 struct vpu_job_queue_header header;
178 struct vpu_job_queue_entry job[];
182 * Logging entity types.
184 * This enum defines the different types of entities involved in logging.
186 enum vpu_trace_entity_type {
187 /** Logging destination (entity where logs can be stored / printed). */
188 VPU_TRACE_ENTITY_TYPE_DESTINATION = 1,
189 /** Loggable HW component (HW entity that can be logged). */
190 VPU_TRACE_ENTITY_TYPE_HW_COMPONENT = 2,
194 * HWS specific log buffer header details.
195 * Total size is 32 bytes.
197 struct vpu_hws_log_buffer_header {
198 /* Written by VPU after adding a log entry. Initialised by host to 0. */
199 u32 first_free_entry_index;
200 /* Incremented by VPU every time the VPU overwrites the 0th entry;
201 * initialised by host to 0.
203 u32 wraparound_count;
205 * This is the number of buffers that can be stored in the log buffer provided by the host.
206 * It is written by host before passing buffer to VPU. VPU should consider it read-only.
213 * HWS specific log buffer entry details.
214 * Total size is 32 bytes.
216 struct vpu_hws_log_buffer_entry {
217 /* VPU timestamp must be an invariant timer tick (not impacted by DVFS) */
221 * 0 - context state change
223 * 2 - queue unwait sync object
224 * 3 - queue no more work
225 * 4 - queue wait sync object
229 /* Operation data depends on operation type */
230 u64 operation_data[2];
234 * Host <-> VPU IPC messages types.
236 enum vpu_ipc_msg_type {
237 VPU_JSM_MSG_UNKNOWN = 0xFFFFFFFF,
238 /* IPC Host -> Device, Async commands */
239 VPU_JSM_MSG_ASYNC_CMD = 0x1100,
240 VPU_JSM_MSG_ENGINE_RESET = VPU_JSM_MSG_ASYNC_CMD,
241 VPU_JSM_MSG_ENGINE_PREEMPT = 0x1101,
242 VPU_JSM_MSG_REGISTER_DB = 0x1102,
243 VPU_JSM_MSG_UNREGISTER_DB = 0x1103,
244 VPU_JSM_MSG_QUERY_ENGINE_HB = 0x1104,
245 VPU_JSM_MSG_GET_POWER_LEVEL_COUNT = 0x1105,
246 VPU_JSM_MSG_GET_POWER_LEVEL = 0x1106,
247 VPU_JSM_MSG_SET_POWER_LEVEL = 0x1107,
249 VPU_JSM_MSG_METRIC_STREAMER_OPEN = 0x1108,
251 VPU_JSM_MSG_METRIC_STREAMER_CLOSE = 0x1109,
252 /** Configure logging (used to modify configuration passed in boot params). */
253 VPU_JSM_MSG_TRACE_SET_CONFIG = 0x110a,
254 /** Return current logging configuration. */
255 VPU_JSM_MSG_TRACE_GET_CONFIG = 0x110b,
257 * Get masks of destinations and HW components supported by the firmware
258 * (may vary between HW generations and FW compile
259 * time configurations)
261 VPU_JSM_MSG_TRACE_GET_CAPABILITY = 0x110c,
262 /** Get the name of a destination or HW component. */
263 VPU_JSM_MSG_TRACE_GET_NAME = 0x110d,
265 * Release resource associated with host ssid . All jobs that belong to the host_ssid
266 * aborted and removed from internal scheduling queues. All doorbells assigned
267 * to the host_ssid are unregistered and any internal FW resources belonging to
268 * the host_ssid are released.
270 VPU_JSM_MSG_SSID_RELEASE = 0x110e,
272 * Start collecting metric data.
273 * @see vpu_jsm_metric_streamer_start
275 VPU_JSM_MSG_METRIC_STREAMER_START = 0x110f,
277 * Stop collecting metric data. This command will return success if it is called
278 * for a metric stream that has already been stopped or was never started.
279 * @see vpu_jsm_metric_streamer_stop
281 VPU_JSM_MSG_METRIC_STREAMER_STOP = 0x1110,
283 * Update current and next buffer for metric data collection. This command can
284 * also be used to request information about the number of collected samples
285 * and the amount of data written to the buffer.
286 * @see vpu_jsm_metric_streamer_update
288 VPU_JSM_MSG_METRIC_STREAMER_UPDATE = 0x1111,
290 * Request description of selected metric groups and metric counters within
291 * each group. The VPU will write the description of groups and counters to
292 * the buffer specified in the command structure.
293 * @see vpu_jsm_metric_streamer_start
295 VPU_JSM_MSG_METRIC_STREAMER_INFO = 0x1112,
296 /** Control command: Priority band setup */
297 VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP = 0x1113,
298 /** Control command: Create command queue */
299 VPU_JSM_MSG_CREATE_CMD_QUEUE = 0x1114,
300 /** Control command: Destroy command queue */
301 VPU_JSM_MSG_DESTROY_CMD_QUEUE = 0x1115,
302 /** Control command: Set context scheduling properties */
303 VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES = 0x1116,
305 * Register a doorbell to notify VPU of new work. The doorbell may later be
306 * deallocated or reassigned to another context.
308 VPU_JSM_MSG_HWS_REGISTER_DB = 0x1117,
309 /** Control command: Log buffer setting */
310 VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG = 0x1118,
311 /* Control command: Suspend command queue. */
312 VPU_JSM_MSG_HWS_SUSPEND_CMDQ = 0x1119,
313 /* Control command: Resume command queue */
314 VPU_JSM_MSG_HWS_RESUME_CMDQ = 0x111a,
315 /* Control command: Resume engine after reset */
316 VPU_JSM_MSG_HWS_ENGINE_RESUME = 0x111b,
317 /* Control command: Enable survivability/DCT mode */
318 VPU_JSM_MSG_DCT_ENABLE = 0x111c,
319 /* Control command: Disable survivability/DCT mode */
320 VPU_JSM_MSG_DCT_DISABLE = 0x111d,
322 * Dump VPU state. To be used for debug purposes only.
323 * NOTE: Please introduce new ASYNC commands before this one. *
325 VPU_JSM_MSG_STATE_DUMP = 0x11FF,
326 /* IPC Host -> Device, General commands */
327 VPU_JSM_MSG_GENERAL_CMD = 0x1200,
328 VPU_JSM_MSG_BLOB_DEINIT = VPU_JSM_MSG_GENERAL_CMD,
330 * Control dyndbg behavior by executing a dyndbg command; equivalent to
331 * Linux command: `echo '<dyndbg_cmd>' > <debugfs>/dynamic_debug/control`.
333 VPU_JSM_MSG_DYNDBG_CONTROL = 0x1201,
335 * Perform the save procedure for the D0i3 entry
337 VPU_JSM_MSG_PWR_D0I3_ENTER = 0x1202,
338 /* IPC Device -> Host, Job completion */
339 VPU_JSM_MSG_JOB_DONE = 0x2100,
340 /* IPC Device -> Host, Async command completion */
341 VPU_JSM_MSG_ASYNC_CMD_DONE = 0x2200,
342 VPU_JSM_MSG_ENGINE_RESET_DONE = VPU_JSM_MSG_ASYNC_CMD_DONE,
343 VPU_JSM_MSG_ENGINE_PREEMPT_DONE = 0x2201,
344 VPU_JSM_MSG_REGISTER_DB_DONE = 0x2202,
345 VPU_JSM_MSG_UNREGISTER_DB_DONE = 0x2203,
346 VPU_JSM_MSG_QUERY_ENGINE_HB_DONE = 0x2204,
347 VPU_JSM_MSG_GET_POWER_LEVEL_COUNT_DONE = 0x2205,
348 VPU_JSM_MSG_GET_POWER_LEVEL_DONE = 0x2206,
349 VPU_JSM_MSG_SET_POWER_LEVEL_DONE = 0x2207,
351 VPU_JSM_MSG_METRIC_STREAMER_OPEN_DONE = 0x2208,
353 VPU_JSM_MSG_METRIC_STREAMER_CLOSE_DONE = 0x2209,
354 /** Response to VPU_JSM_MSG_TRACE_SET_CONFIG. */
355 VPU_JSM_MSG_TRACE_SET_CONFIG_RSP = 0x220a,
356 /** Response to VPU_JSM_MSG_TRACE_GET_CONFIG. */
357 VPU_JSM_MSG_TRACE_GET_CONFIG_RSP = 0x220b,
358 /** Response to VPU_JSM_MSG_TRACE_GET_CAPABILITY. */
359 VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP = 0x220c,
360 /** Response to VPU_JSM_MSG_TRACE_GET_NAME. */
361 VPU_JSM_MSG_TRACE_GET_NAME_RSP = 0x220d,
362 /** Response to VPU_JSM_MSG_SSID_RELEASE. */
363 VPU_JSM_MSG_SSID_RELEASE_DONE = 0x220e,
365 * Response to VPU_JSM_MSG_METRIC_STREAMER_START.
366 * VPU will return an error result if metric collection cannot be started,
367 * e.g. when the specified metric mask is invalid.
368 * @see vpu_jsm_metric_streamer_done
370 VPU_JSM_MSG_METRIC_STREAMER_START_DONE = 0x220f,
372 * Response to VPU_JSM_MSG_METRIC_STREAMER_STOP.
373 * Returns information about collected metric data.
374 * @see vpu_jsm_metric_streamer_done
376 VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE = 0x2210,
378 * Response to VPU_JSM_MSG_METRIC_STREAMER_UPDATE.
379 * Returns information about collected metric data.
380 * @see vpu_jsm_metric_streamer_done
382 VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE = 0x2211,
384 * Response to VPU_JSM_MSG_METRIC_STREAMER_INFO.
385 * Returns a description of the metric groups and metric counters.
386 * @see vpu_jsm_metric_streamer_done
388 VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE = 0x2212,
390 * Asynchronous event sent from the VPU to the host either when the current
391 * metric buffer is full or when the VPU has collected a multiple of
392 * @notify_sample_count samples as indicated through the start command
393 * (VPU_JSM_MSG_METRIC_STREAMER_START). Returns information about collected
395 * @see vpu_jsm_metric_streamer_done
397 VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION = 0x2213,
398 /** Response to control command: Priority band setup */
399 VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP = 0x2214,
400 /** Response to control command: Create command queue */
401 VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP = 0x2215,
402 /** Response to control command: Destroy command queue */
403 VPU_JSM_MSG_DESTROY_CMD_QUEUE_RSP = 0x2216,
404 /** Response to control command: Set context scheduling properties */
405 VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES_RSP = 0x2217,
406 /** Response to control command: Log buffer setting */
407 VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP = 0x2218,
408 /* IPC Device -> Host, HWS notify index entry of log buffer written */
409 VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION = 0x2219,
410 /* IPC Device -> Host, HWS completion of a context suspend request */
411 VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE = 0x221a,
412 /* Response to control command: Resume command queue */
413 VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP = 0x221b,
414 /* Response to control command: Resume engine command response */
415 VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE = 0x221c,
416 /* Response to control command: Enable survivability/DCT mode */
417 VPU_JSM_MSG_DCT_ENABLE_DONE = 0x221d,
418 /* Response to control command: Disable survivability/DCT mode */
419 VPU_JSM_MSG_DCT_DISABLE_DONE = 0x221e,
421 * Response to state dump control command.
422 * NOTE: Please introduce new ASYNC responses before this one. *
424 VPU_JSM_MSG_STATE_DUMP_RSP = 0x22FF,
425 /* IPC Device -> Host, General command completion */
426 VPU_JSM_MSG_GENERAL_CMD_DONE = 0x2300,
427 VPU_JSM_MSG_BLOB_DEINIT_DONE = VPU_JSM_MSG_GENERAL_CMD_DONE,
428 /** Response to VPU_JSM_MSG_DYNDBG_CONTROL. */
429 VPU_JSM_MSG_DYNDBG_CONTROL_RSP = 0x2301,
431 * Acknowledgment of completion of the save procedure initiated by
432 * VPU_JSM_MSG_PWR_D0I3_ENTER
434 VPU_JSM_MSG_PWR_D0I3_ENTER_DONE = 0x2302,
437 enum vpu_ipc_msg_status { VPU_JSM_MSG_FREE, VPU_JSM_MSG_ALLOCATED };
440 * Host <-> LRT IPC message payload definitions
442 struct vpu_ipc_msg_payload_engine_reset {
443 /* Engine to be reset. */
449 struct vpu_ipc_msg_payload_engine_preempt {
450 /* Engine to be preempted. */
452 /* ID of the preemption request. */
457 * @brief Register doorbell command structure.
458 * This structure supports doorbell registration for only OS scheduling.
459 * @see VPU_JSM_MSG_REGISTER_DB
461 struct vpu_ipc_msg_payload_register_db {
462 /* Index of the doorbell to register. */
466 /* Virtual address in Global GTT pointing to the start of job queue. */
468 /* Size of the job queue in bytes. */
470 /* Host sub-stream ID for the context assigned to the doorbell. */
475 * @brief Unregister doorbell command structure.
476 * Request structure to unregister a doorbell for both HW and OS scheduling.
477 * @see VPU_JSM_MSG_UNREGISTER_DB
479 struct vpu_ipc_msg_payload_unregister_db {
480 /* Index of the doorbell to unregister. */
486 struct vpu_ipc_msg_payload_query_engine_hb {
487 /* Engine to return heartbeat value. */
493 struct vpu_ipc_msg_payload_power_level {
495 * Requested power level. The power level value is in the
496 * range [0, power_level_count-1] where power_level_count
497 * is the number of available power levels as returned by
498 * the get power level count command. A power level of 0
499 * corresponds to the maximum possible power level, while
500 * power_level_count-1 corresponds to the minimum possible
501 * power level. Values outside of this range are not
502 * considered to be valid.
509 struct vpu_ipc_msg_payload_ssid_release {
510 /* Host sub-stream ID for the context to be released. */
517 * @brief Metric streamer start command structure.
518 * This structure is also used with VPU_JSM_MSG_METRIC_STREAMER_INFO to request metric
519 * groups and metric counters description from the firmware.
520 * @see VPU_JSM_MSG_METRIC_STREAMER_START
521 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
523 struct vpu_jsm_metric_streamer_start {
525 * Bitmask to select the desired metric groups.
526 * A metric group can belong only to one metric streamer instance at a time.
527 * Since each metric streamer instance has a unique set of metric groups, it
528 * can also identify a metric streamer instance if more than one instance was
529 * started. If the VPU device does not support multiple metric streamer instances,
530 * then VPU_JSM_MSG_METRIC_STREAMER_START will return an error even if the second
531 * instance has different groups to the first.
533 u64 metric_group_mask;
534 /** Sampling rate in nanoseconds. */
537 * If > 0 the VPU will send a VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION message
538 * after every @notify_sample_count samples is collected or dropped by the VPU.
539 * If set to UINT_MAX the VPU will only generate a notification when the metric
540 * buffer is full. If set to 0 the VPU will never generate a notification.
542 u32 notify_sample_count;
545 * Address and size of the buffer where the VPU will write metric data. The
546 * VPU writes all counters from enabled metric groups one after another. If
547 * there is no space left to write data at the next sample period the VPU
548 * will switch to the next buffer (@see next_buffer_addr) and will optionally
549 * send a notification to the host driver if @notify_sample_count is non-zero.
550 * If @next_buffer_addr is NULL the VPU will stop collecting metric data.
555 * Address and size of the next buffer to write metric data to after the initial
556 * buffer is full. If the address is NULL the VPU will stop collecting metric
559 u64 next_buffer_addr;
560 u64 next_buffer_size;
564 * @brief Metric streamer stop command structure.
565 * @see VPU_JSM_MSG_METRIC_STREAMER_STOP
567 struct vpu_jsm_metric_streamer_stop {
568 /** Bitmask to select the desired metric groups. */
569 u64 metric_group_mask;
573 * Provide VPU FW with buffers to write metric data.
574 * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE
576 struct vpu_jsm_metric_streamer_update {
577 /** Metric group mask that identifies metric streamer instance. */
578 u64 metric_group_mask;
580 * Address and size of the buffer where the VPU will write metric data. If
581 * the buffer address is 0 or same as the currently used buffer the VPU will
582 * continue writing metric data to the current buffer. In this case the
583 * buffer size is ignored and the size of the current buffer is unchanged.
584 * If the address is non-zero and differs from the current buffer address the
585 * VPU will immediately switch data collection to the new buffer.
590 * Address and size of the next buffer to write metric data after the initial
591 * buffer is full. If the address is NULL the VPU will stop collecting metric
592 * data but will continue to record dropped samples.
594 * Note that there is a hazard possible if both buffer_addr and the next_buffer_addr
595 * are non-zero in same update request. It is the host's responsibility to ensure
596 * that both addresses make sense even if the VPU just switched to writing samples
597 * from the current to the next buffer.
599 u64 next_buffer_addr;
600 u64 next_buffer_size;
603 struct vpu_ipc_msg_payload_blob_deinit {
604 /* 64-bit unique ID for the blob to be de-initialized. */
608 struct vpu_ipc_msg_payload_job_done {
609 /* Engine to which the job was submitted. */
611 /* Index of the doorbell to which the job was submitted */
613 /* ID of the completed job */
615 /* Status of the completed job */
621 /* Command queue id */
625 struct vpu_jsm_engine_reset_context {
630 /* Command queue id */
632 /* See VPU_ENGINE_RESET_CONTEXT_* defines */
636 struct vpu_ipc_msg_payload_engine_reset_done {
639 /* Number of impacted contexts */
640 u32 num_impacted_contexts;
641 /* Array of impacted command queue ids and their flags */
642 struct vpu_jsm_engine_reset_context
643 impacted_contexts[VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS];
646 struct vpu_ipc_msg_payload_engine_preempt_done {
647 /* Engine preempted. */
649 /* ID of the preemption request. */
654 * Response structure for register doorbell command for both OS
656 * @see VPU_JSM_MSG_REGISTER_DB
657 * @see VPU_JSM_MSG_HWS_REGISTER_DB
659 struct vpu_ipc_msg_payload_register_db_done {
660 /* Index of the registered doorbell. */
667 * Response structure for unregister doorbell command for both OS
669 * @see VPU_JSM_MSG_UNREGISTER_DB
671 struct vpu_ipc_msg_payload_unregister_db_done {
672 /* Index of the unregistered doorbell. */
678 struct vpu_ipc_msg_payload_query_engine_hb_done {
679 /* Engine returning heartbeat value. */
683 /* Heartbeat value. */
687 struct vpu_ipc_msg_payload_get_power_level_count_done {
689 * Number of supported power levels. The maximum possible
690 * value of power_level_count is 16 but this may vary across
693 u32 power_level_count;
697 * Power consumption limit for each supported power level in
698 * [0-100%] range relative to power level 0.
703 struct vpu_ipc_msg_payload_blob_deinit_done {
704 /* 64-bit unique ID for the blob de-initialized. */
708 /* HWS priority band setup request / response */
709 struct vpu_ipc_msg_payload_hws_priority_band_setup {
711 * Grace period in 100ns units when preempting another priority band for
714 u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
716 * Default quantum in 100ns units for scheduling across processes
717 * within a priority band
719 u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
721 * Default grace period in 100ns units for processes that preempt each
722 * other within a priority band
724 u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
726 * For normal priority band, specifies the target VPU percentage
727 * in situations when it's starved by the focus band.
729 u32 normal_band_percentage;
735 * @brief HWS create command queue request.
736 * Host will create a command queue via this command.
737 * Note: Cmdq group is a handle of an object which
738 * may contain one or more command queues.
739 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
740 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
742 struct vpu_ipc_msg_payload_hws_create_cmdq {
747 /* Engine for which queue is being created */
749 /* Cmdq group: only used for HWS logging of state changes */
751 /* Command queue id */
753 /* Command queue base */
755 /* Command queue size */
762 * @brief HWS create command queue response.
763 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
764 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
766 struct vpu_ipc_msg_payload_hws_create_cmdq_rsp {
771 /* Engine for which queue is being created */
773 /* Command queue group */
775 /* Command queue id */
779 /* HWS destroy command queue request / response */
780 struct vpu_ipc_msg_payload_hws_destroy_cmdq {
785 /* Command queue id */
789 /* HWS set context scheduling properties request / response */
790 struct vpu_ipc_msg_payload_hws_set_context_sched_properties {
795 /* Command queue id */
797 /* Priority band to assign to work of this context */
799 /* Inside realtime band assigns a further priority */
800 u32 realtime_priority_level;
801 /* Priority relative to other contexts in the same process */
802 s32 in_process_priority;
803 /* Zero padding / Reserved */
805 /* Context quantum relative to other contexts of same priority in the same process */
807 /* Grace period when preempting context of the same priority within the same process */
808 u64 grace_period_same_priority;
809 /* Grace period when preempting context of a lower priority within the same process */
810 u64 grace_period_lower_priority;
814 * @brief Register doorbell command structure.
815 * This structure supports doorbell registration for both HW and OS scheduling.
816 * Note: Queue base and size are added here so that the same structure can be used for
817 * OS scheduling and HW scheduling. For OS scheduling, cmdq_id will be ignored
818 * and cmdq_base and cmdq_size will be used. For HW scheduling, cmdq_base and cmdq_size will be
819 * ignored and cmdq_id is used.
820 * @see VPU_JSM_MSG_HWS_REGISTER_DB
822 struct vpu_jsm_hws_register_db {
823 /* Index of the doorbell to register. */
825 /* Host sub-stream ID for the context assigned to the doorbell. */
827 /* ID of the command queue associated with the doorbell. */
829 /* Virtual address pointing to the start of command queue. */
831 /* Size of the command queue in bytes. */
836 * @brief Structure to set another buffer to be used for scheduling-related logging.
837 * The size of the logging buffer and the number of entries is defined as part of the
838 * buffer itself as described next.
839 * The log buffer received from the host is made up of;
840 * - header: 32 bytes in size, as shown in 'struct vpu_hws_log_buffer_header'.
841 * The header contains the number of log entries in the buffer.
842 * - log entry: 0 to n-1, each log entry is 32 bytes in size, as shown in
843 * 'struct vpu_hws_log_buffer_entry'.
844 * The entry contains the VPU timestamp, operation type and data.
845 * The host should provide the notify index value of log buffer to VPU. This is a
846 * value defined within the log buffer and when written to will generate the
847 * scheduling log notification.
848 * The host should set engine_idx and vpu_log_buffer_va to 0 to disable logging
849 * for a particular engine.
850 * VPU will handle one log buffer for each of supported engines.
851 * VPU should allow the logging to consume one host_ssid.
852 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
853 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP
854 * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
856 struct vpu_ipc_msg_payload_hws_set_scheduling_log {
862 * VPU log buffer virtual address.
863 * Set to 0 to disable logging for this engine.
865 u64 vpu_log_buffer_va;
867 * Notify index of log buffer. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
868 * is generated when an event log is written to this index.
874 * @brief The scheduling log notification is generated by VPU when it writes
875 * an event into the log buffer at the notify_index. VPU notifies host with
876 * VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION. This is an asynchronous
877 * message from VPU to host.
878 * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
879 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
881 struct vpu_ipc_msg_payload_hws_scheduling_log_notification {
889 * @brief HWS suspend command queue request and done structure.
890 * Host will request the suspend of contexts and VPU will;
891 * - Suspend all work on this context
892 * - Preempt any running work
893 * - Asynchronously perform the above and return success immediately once
894 * all items above are started successfully
895 * - Notify the host of completion of these operations via
896 * VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
897 * - Reject any other context operations on a context with an in-flight
898 * suspend request running
899 * Same structure used when VPU notifies host of completion of a context suspend
900 * request. The ids and suspend fence value reported in this command will match
901 * the one in the request from the host to suspend the context. Once suspend is
902 * complete, VPU will not access any data relating to this command queue until
904 * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ
905 * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
907 struct vpu_ipc_msg_payload_hws_suspend_cmdq {
912 /* Command queue id */
915 * Suspend fence value - reported by the VPU suspend context
916 * completed once suspend is complete.
918 u64 suspend_fence_value;
922 * @brief HWS Resume command queue request / response structure.
923 * Host will request the resume of a context;
924 * - VPU will resume all work on this context
925 * - Scheduler will allow this context to be scheduled
926 * @see VPU_JSM_MSG_HWS_RESUME_CMDQ
927 * @see VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP
929 struct vpu_ipc_msg_payload_hws_resume_cmdq {
934 /* Command queue id */
939 * @brief HWS Resume engine request / response structure.
940 * After a HWS engine reset, all scheduling is stopped on VPU until a engine resume.
941 * Host shall send this command to resume scheduling of any valid queue.
942 * @see VPU_JSM_MSG_HWS_RESUME_ENGINE
943 * @see VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE
945 struct vpu_ipc_msg_payload_hws_resume_engine {
946 /* Engine to be resumed */
953 * Payload for VPU_JSM_MSG_TRACE_SET_CONFIG[_RSP] and
954 * VPU_JSM_MSG_TRACE_GET_CONFIG_RSP messages.
956 * The payload is interpreted differently depending on the type of message:
958 * - For VPU_JSM_MSG_TRACE_SET_CONFIG, the payload specifies the desired
959 * logging configuration to be set.
961 * - For VPU_JSM_MSG_TRACE_SET_CONFIG_RSP, the payload reports the logging
962 * configuration that was set after a VPU_JSM_MSG_TRACE_SET_CONFIG request.
963 * The host can compare this payload with the one it sent in the
964 * VPU_JSM_MSG_TRACE_SET_CONFIG request to check whether or not the
965 * configuration was set as desired.
967 * - VPU_JSM_MSG_TRACE_GET_CONFIG_RSP, the payload reports the current logging
970 struct vpu_ipc_msg_payload_trace_config {
972 * Logging level (currently set or to be set); see 'mvLog_t' enum for
973 * acceptable values. The specified logging level applies to all
974 * destinations and HW components
978 * Bitmask of logging destinations (currently enabled or to be enabled);
979 * bitwise OR of values defined in logging_destination enum.
981 u32 trace_destination_mask;
983 * Bitmask of loggable HW components (currently enabled or to be enabled);
984 * bitwise OR of values defined in loggable_hw_component enum.
986 u64 trace_hw_component_mask;
987 u64 reserved_0; /**< Reserved for future extensions. */
991 * Payload for VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP messages.
993 struct vpu_ipc_msg_payload_trace_capability_rsp {
994 u32 trace_destination_mask; /**< Bitmask of supported logging destinations. */
996 u64 trace_hw_component_mask; /**< Bitmask of supported loggable HW components. */
997 u64 reserved_1; /**< Reserved for future extensions. */
1001 * Payload for VPU_JSM_MSG_TRACE_GET_NAME requests.
1003 struct vpu_ipc_msg_payload_trace_get_name {
1005 * The type of the entity to query name for; see logging_entity_type for
1011 * The ID of the entity to query name for; possible values depends on the
1018 * Payload for VPU_JSM_MSG_TRACE_GET_NAME_RSP responses.
1020 struct vpu_ipc_msg_payload_trace_get_name_rsp {
1022 * The type of the entity whose name was queried; see logging_entity_type
1023 * for possible values.
1028 * The ID of the entity whose name was queried; possible values depends on
1032 /** Reserved for future extensions. */
1034 /** The name of the entity. */
1035 char entity_name[VPU_TRACE_ENTITY_NAME_MAX_LEN];
1039 * Data sent from the VPU to the host in all metric streamer response messages
1040 * and in asynchronous notification.
1041 * @see VPU_JSM_MSG_METRIC_STREAMER_START_DONE
1042 * @see VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE
1043 * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE
1044 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE
1045 * @see VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION
1047 struct vpu_jsm_metric_streamer_done {
1048 /** Metric group mask that identifies metric streamer instance. */
1049 u64 metric_group_mask;
1051 * Size in bytes of single sample - total size of all enabled counters.
1052 * Some VPU implementations may align sample_size to more than 8 bytes.
1057 * Number of samples collected since the metric streamer was started.
1058 * This will be 0 if the metric streamer was not started.
1060 u32 samples_collected;
1062 * Number of samples dropped since the metric streamer was started. This
1063 * is incremented every time the metric streamer is not able to write
1064 * collected samples because the current buffer is full and there is no
1065 * next buffer to switch to.
1067 u32 samples_dropped;
1068 /** Address of the buffer that contains the latest metric data. */
1071 * Number of bytes written into the metric data buffer. In response to the
1072 * VPU_JSM_MSG_METRIC_STREAMER_INFO request this field contains the size of
1073 * all group and counter descriptors. The size is updated even if the buffer
1074 * in the request was NULL or too small to hold descriptors of all counters
1080 * Metric group description placed in the metric buffer after successful completion
1081 * of the VPU_JSM_MSG_METRIC_STREAMER_INFO command. This is followed by one or more
1082 * @vpu_jsm_metric_counter_descriptor records.
1083 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
1085 struct vpu_jsm_metric_group_descriptor {
1087 * Offset to the next metric group (8-byte aligned). If this offset is 0 this
1088 * is the last descriptor. The value of metric_info_size must be greater than
1089 * or equal to sizeof(struct vpu_jsm_metric_group_descriptor) + name_string_size
1090 * + description_string_size and must be 8-byte aligned.
1092 u32 next_metric_group_info_offset;
1094 * Offset to the first metric counter description record (8-byte aligned).
1095 * @see vpu_jsm_metric_counter_descriptor
1097 u32 next_metric_counter_info_offset;
1098 /** Index of the group. This corresponds to bit index in metric_group_mask. */
1100 /** Number of counters in the metric group. */
1102 /** Data size for all counters, must be a multiple of 8 bytes.*/
1103 u32 metric_group_data_size;
1105 * Metric group domain number. Cannot use multiple, simultaneous metric groups
1106 * from the same domain.
1110 * Counter name string size. The string must include a null termination character.
1111 * The FW may use a fixed size name or send a different name for each counter.
1112 * If the VPU uses fixed size strings, all characters from the end of the name
1113 * to the of the fixed size character array must be zeroed.
1115 u32 name_string_size;
1116 /** Counter description string size, @see name_string_size */
1117 u32 description_string_size;
1120 * Right after this structure, the VPU writes name and description of
1126 * Metric counter description, placed in the buffer after vpu_jsm_metric_group_descriptor.
1127 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
1129 struct vpu_jsm_metric_counter_descriptor {
1131 * Offset to the next counter in a group (8-byte aligned). If this offset is
1132 * 0 this is the last counter in the group.
1134 u32 next_metric_counter_info_offset;
1136 * Offset to the counter data from the start of samples in this metric group.
1137 * Note that metric_data_offset % metric_data_size must be 0.
1139 u32 metric_data_offset;
1140 /** Size of the metric counter data in bytes. */
1141 u32 metric_data_size;
1142 /** Metric type, see Level Zero API for definitions. */
1144 /** Metric type, see set_metric_type_t for definitions. */
1146 /** Metric type, see set_value_type_t for definitions. */
1147 u32 metric_value_type;
1149 * Counter name string size. The string must include a null termination character.
1150 * The FW may use a fixed size name or send a different name for each counter.
1151 * If the VPU uses fixed size strings, all characters from the end of the name
1152 * to the of the fixed size character array must be zeroed.
1154 u32 name_string_size;
1155 /** Counter description string size, @see name_string_size */
1156 u32 description_string_size;
1157 /** Counter component name string size, @see name_string_size */
1158 u32 component_string_size;
1159 /** Counter string size, @see name_string_size */
1160 u32 units_string_size;
1163 * Right after this structure, the VPU writes name, description
1164 * component and unit strings.
1169 * Payload for VPU_JSM_MSG_DYNDBG_CONTROL requests.
1171 * VPU_JSM_MSG_DYNDBG_CONTROL are used to control the VPU FW Dynamic Debug
1172 * feature, which allows developers to selectively enable / disable MVLOG_DEBUG
1173 * messages. This is equivalent to the Dynamic Debug functionality provided by
1175 * (https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html)
1176 * The host can control Dynamic Debug behavior by sending dyndbg commands, which
1177 * have the same syntax as Linux
1180 * NOTE: in order for MVLOG_DEBUG messages to be actually printed, the host
1181 * still has to set the logging level to MVLOG_DEBUG, using the
1182 * VPU_JSM_MSG_TRACE_SET_CONFIG command.
1184 * The host can see the current dynamic debug configuration by executing a
1185 * special 'show' command. The dyndbg configuration will be printed to the
1186 * configured logging destination using MVLOG_INFO logging level.
1188 struct vpu_ipc_msg_payload_dyndbg_control {
1190 * Dyndbg command (same format as Linux dyndbg); must be a NULL-terminated
1193 char dyndbg_cmd[VPU_DYNDBG_CMD_MAX_LEN];
1197 * Payload for VPU_JSM_MSG_PWR_D0I3_ENTER
1199 * This is a bi-directional payload.
1201 struct vpu_ipc_msg_payload_pwr_d0i3_enter {
1203 * 0: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is not sent to the host driver
1204 * The driver will poll for D0i2 Idle state transitions.
1205 * 1: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is sent after VPU state save is complete
1212 * Payload for VPU_JSM_MSG_DCT_ENABLE message.
1214 * Default values for DCT active/inactive times are 5.3ms and 30ms respectively,
1215 * corresponding to a 85% duty cycle. This payload allows the host to tune these
1216 * values according to application requirements.
1218 struct vpu_ipc_msg_payload_pwr_dct_control {
1219 /** Duty cycle active time in microseconds */
1221 /** Duty cycle inactive time in microseconds */
1222 u32 dct_inactive_us;
1226 * Payloads union, used to define complete message format.
1228 union vpu_ipc_msg_payload {
1229 struct vpu_ipc_msg_payload_engine_reset engine_reset;
1230 struct vpu_ipc_msg_payload_engine_preempt engine_preempt;
1231 struct vpu_ipc_msg_payload_register_db register_db;
1232 struct vpu_ipc_msg_payload_unregister_db unregister_db;
1233 struct vpu_ipc_msg_payload_query_engine_hb query_engine_hb;
1234 struct vpu_ipc_msg_payload_power_level power_level;
1235 struct vpu_jsm_metric_streamer_start metric_streamer_start;
1236 struct vpu_jsm_metric_streamer_stop metric_streamer_stop;
1237 struct vpu_jsm_metric_streamer_update metric_streamer_update;
1238 struct vpu_ipc_msg_payload_blob_deinit blob_deinit;
1239 struct vpu_ipc_msg_payload_ssid_release ssid_release;
1240 struct vpu_jsm_hws_register_db hws_register_db;
1241 struct vpu_ipc_msg_payload_job_done job_done;
1242 struct vpu_ipc_msg_payload_engine_reset_done engine_reset_done;
1243 struct vpu_ipc_msg_payload_engine_preempt_done engine_preempt_done;
1244 struct vpu_ipc_msg_payload_register_db_done register_db_done;
1245 struct vpu_ipc_msg_payload_unregister_db_done unregister_db_done;
1246 struct vpu_ipc_msg_payload_query_engine_hb_done query_engine_hb_done;
1247 struct vpu_ipc_msg_payload_get_power_level_count_done get_power_level_count_done;
1248 struct vpu_jsm_metric_streamer_done metric_streamer_done;
1249 struct vpu_ipc_msg_payload_blob_deinit_done blob_deinit_done;
1250 struct vpu_ipc_msg_payload_trace_config trace_config;
1251 struct vpu_ipc_msg_payload_trace_capability_rsp trace_capability;
1252 struct vpu_ipc_msg_payload_trace_get_name trace_get_name;
1253 struct vpu_ipc_msg_payload_trace_get_name_rsp trace_get_name_rsp;
1254 struct vpu_ipc_msg_payload_dyndbg_control dyndbg_control;
1255 struct vpu_ipc_msg_payload_hws_priority_band_setup hws_priority_band_setup;
1256 struct vpu_ipc_msg_payload_hws_create_cmdq hws_create_cmdq;
1257 struct vpu_ipc_msg_payload_hws_create_cmdq_rsp hws_create_cmdq_rsp;
1258 struct vpu_ipc_msg_payload_hws_destroy_cmdq hws_destroy_cmdq;
1259 struct vpu_ipc_msg_payload_hws_set_context_sched_properties
1260 hws_set_context_sched_properties;
1261 struct vpu_ipc_msg_payload_hws_set_scheduling_log hws_set_scheduling_log;
1262 struct vpu_ipc_msg_payload_hws_scheduling_log_notification hws_scheduling_log_notification;
1263 struct vpu_ipc_msg_payload_hws_suspend_cmdq hws_suspend_cmdq;
1264 struct vpu_ipc_msg_payload_hws_resume_cmdq hws_resume_cmdq;
1265 struct vpu_ipc_msg_payload_hws_resume_engine hws_resume_engine;
1266 struct vpu_ipc_msg_payload_pwr_d0i3_enter pwr_d0i3_enter;
1267 struct vpu_ipc_msg_payload_pwr_dct_control pwr_dct_control;
1271 * Host <-> LRT IPC message base structure.
1273 * NOTE: All instances of this object must be aligned on a 64B boundary
1274 * to allow proper handling of VPU cache operations.
1276 struct vpu_jsm_msg {
1279 /* Message type, see vpu_ipc_msg_type enum. */
1281 /* Buffer status, see vpu_ipc_msg_status enum. */
1284 * Request ID, provided by the host in a request message and passed
1285 * back by VPU in the response message.
1288 /* Request return code set by the VPU, see VPU_JSM_STATUS_* defines. */
1291 /* Message payload depending on message type, see vpu_ipc_msg_payload union. */
1292 union vpu_ipc_msg_payload payload;