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 0
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
46 /** Pack the API structures for now, once alignment issues are fixed this can be removed */
52 #define VPU_ENGINE_COMPUTE 0
53 #define VPU_ENGINE_COPY 1
54 #define VPU_ENGINE_NB 2
59 #define VPU_JSM_STATUS_SUCCESS 0x0U
60 #define VPU_JSM_STATUS_PARSING_ERR 0x1U
61 #define VPU_JSM_STATUS_PROCESSING_ERR 0x2U
62 #define VPU_JSM_STATUS_PREEMPTED 0x3U
63 #define VPU_JSM_STATUS_ABORTED 0x4U
64 #define VPU_JSM_STATUS_USER_CTX_VIOL_ERR 0x5U
65 #define VPU_JSM_STATUS_GLOBAL_CTX_VIOL_ERR 0x6U
66 #define VPU_JSM_STATUS_MVNCI_WRONG_INPUT_FORMAT 0x7U
67 #define VPU_JSM_STATUS_MVNCI_UNSUPPORTED_NETWORK_ELEMENT 0x8U
68 #define VPU_JSM_STATUS_MVNCI_INVALID_HANDLE 0x9U
69 #define VPU_JSM_STATUS_MVNCI_OUT_OF_RESOURCES 0xAU
70 #define VPU_JSM_STATUS_MVNCI_NOT_IMPLEMENTED 0xBU
71 #define VPU_JSM_STATUS_MVNCI_INTERNAL_ERROR 0xCU
72 /* Job status returned when the job was preempted mid-inference */
73 #define VPU_JSM_STATUS_PREEMPTED_MID_INFERENCE 0xDU
76 * Host <-> VPU IPC channels.
77 * ASYNC commands use a high priority channel, other messages use low-priority ones.
79 #define VPU_IPC_CHAN_ASYNC_CMD 0
80 #define VPU_IPC_CHAN_GEN_CMD 10
81 #define VPU_IPC_CHAN_JOB_RET 11
84 * Job flags bit masks.
86 #define VPU_JOB_FLAGS_NULL_SUBMISSION_MASK 0x00000001
87 #define VPU_JOB_FLAGS_PRIVATE_DATA_MASK 0xFF000000
90 * Sizes of the reserved areas in jobs, in bytes.
92 #define VPU_JOB_RESERVED_BYTES 8
95 * Sizes of the reserved areas in job queues, in bytes.
97 #define VPU_JOB_QUEUE_RESERVED_BYTES 52
100 * Max length (including trailing NULL char) of trace entity name (e.g., the
101 * name of a logging destination or a loggable HW component).
103 #define VPU_TRACE_ENTITY_NAME_MAX_LEN 32
106 * Max length (including trailing NULL char) of a dyndbg command.
108 * NOTE: 96 is used so that the size of 'struct vpu_ipc_msg' in the JSM API is
109 * 128 bytes (multiple of 64 bytes, the cache line size).
111 #define VPU_DYNDBG_CMD_MAX_LEN 96
114 * For HWS command queue scheduling, we can prioritise command queues inside the
115 * same process with a relative in-process priority. Valid values for relative
116 * priority are given below - max and min.
118 #define VPU_HWS_COMMAND_QUEUE_MAX_IN_PROCESS_PRIORITY 7
119 #define VPU_HWS_COMMAND_QUEUE_MIN_IN_PROCESS_PRIORITY -7
122 * For HWS priority scheduling, we can have multiple realtime priority bands.
123 * They are numbered 0 to a MAX.
125 #define VPU_HWS_MAX_REALTIME_PRIORITY_LEVEL 31U
130 struct vpu_job_queue_entry {
131 u64 batch_buf_addr; /**< Address of VPU commands batch buffer */
132 u32 job_id; /**< Job ID */
133 u32 flags; /**< Flags bit field, see VPU_JOB_FLAGS_* above */
134 u64 root_page_table_addr; /**< Address of root page table to use for this job */
135 u64 root_page_table_update_counter; /**< Page tables update events counter */
136 u64 primary_preempt_buf_addr;
137 /**< Address of the primary preemption buffer to use for this job */
138 u32 primary_preempt_buf_size;
139 /**< Size of the primary preemption buffer to use for this job */
140 u32 secondary_preempt_buf_size;
141 /**< Size of secondary preemption buffer to use for this job */
142 u64 secondary_preempt_buf_addr;
143 /**< Address of secondary preemption buffer to use for this job */
144 u8 reserved_0[VPU_JOB_RESERVED_BYTES];
148 * Job queue control registers.
150 struct vpu_job_queue_header {
154 u8 reserved_0[VPU_JOB_QUEUE_RESERVED_BYTES];
160 struct vpu_job_queue {
161 struct vpu_job_queue_header header;
162 struct vpu_job_queue_entry job[];
166 * Logging entity types.
168 * This enum defines the different types of entities involved in logging.
170 enum vpu_trace_entity_type {
171 /** Logging destination (entity where logs can be stored / printed). */
172 VPU_TRACE_ENTITY_TYPE_DESTINATION = 1,
173 /** Loggable HW component (HW entity that can be logged). */
174 VPU_TRACE_ENTITY_TYPE_HW_COMPONENT = 2,
178 * HWS specific log buffer header details.
179 * Total size is 32 bytes.
181 struct vpu_hws_log_buffer_header {
182 /* Written by VPU after adding a log entry. Initialised by host to 0. */
183 u32 first_free_entry_index;
184 /* Incremented by VPU every time the VPU overwrites the 0th entry;
185 * initialised by host to 0.
187 u32 wraparound_count;
189 * This is the number of buffers that can be stored in the log buffer provided by the host.
190 * It is written by host before passing buffer to VPU. VPU should consider it read-only.
197 * HWS specific log buffer entry details.
198 * Total size is 32 bytes.
200 struct vpu_hws_log_buffer_entry {
201 /* VPU timestamp must be an invariant timer tick (not impacted by DVFS) */
205 * 0 - context state change
207 * 2 - queue unwait sync object
208 * 3 - queue no more work
209 * 4 - queue wait sync object
213 /* Operation data depends on operation type */
214 u64 operation_data[2];
218 * Host <-> VPU IPC messages types.
220 enum vpu_ipc_msg_type {
221 VPU_JSM_MSG_UNKNOWN = 0xFFFFFFFF,
222 /* IPC Host -> Device, Async commands */
223 VPU_JSM_MSG_ASYNC_CMD = 0x1100,
224 VPU_JSM_MSG_ENGINE_RESET = VPU_JSM_MSG_ASYNC_CMD,
225 VPU_JSM_MSG_ENGINE_PREEMPT = 0x1101,
226 VPU_JSM_MSG_REGISTER_DB = 0x1102,
227 VPU_JSM_MSG_UNREGISTER_DB = 0x1103,
228 VPU_JSM_MSG_QUERY_ENGINE_HB = 0x1104,
229 VPU_JSM_MSG_GET_POWER_LEVEL_COUNT = 0x1105,
230 VPU_JSM_MSG_GET_POWER_LEVEL = 0x1106,
231 VPU_JSM_MSG_SET_POWER_LEVEL = 0x1107,
233 VPU_JSM_MSG_METRIC_STREAMER_OPEN = 0x1108,
235 VPU_JSM_MSG_METRIC_STREAMER_CLOSE = 0x1109,
236 /** Configure logging (used to modify configuration passed in boot params). */
237 VPU_JSM_MSG_TRACE_SET_CONFIG = 0x110a,
238 /** Return current logging configuration. */
239 VPU_JSM_MSG_TRACE_GET_CONFIG = 0x110b,
241 * Get masks of destinations and HW components supported by the firmware
242 * (may vary between HW generations and FW compile
243 * time configurations)
245 VPU_JSM_MSG_TRACE_GET_CAPABILITY = 0x110c,
246 /** Get the name of a destination or HW component. */
247 VPU_JSM_MSG_TRACE_GET_NAME = 0x110d,
249 * Release resource associated with host ssid . All jobs that belong to the host_ssid
250 * aborted and removed from internal scheduling queues. All doorbells assigned
251 * to the host_ssid are unregistered and any internal FW resources belonging to
252 * the host_ssid are released.
254 VPU_JSM_MSG_SSID_RELEASE = 0x110e,
256 * Start collecting metric data.
257 * @see vpu_jsm_metric_streamer_start
259 VPU_JSM_MSG_METRIC_STREAMER_START = 0x110f,
261 * Stop collecting metric data. This command will return success if it is called
262 * for a metric stream that has already been stopped or was never started.
263 * @see vpu_jsm_metric_streamer_stop
265 VPU_JSM_MSG_METRIC_STREAMER_STOP = 0x1110,
267 * Update current and next buffer for metric data collection. This command can
268 * also be used to request information about the number of collected samples
269 * and the amount of data written to the buffer.
270 * @see vpu_jsm_metric_streamer_update
272 VPU_JSM_MSG_METRIC_STREAMER_UPDATE = 0x1111,
274 * Request description of selected metric groups and metric counters within
275 * each group. The VPU will write the description of groups and counters to
276 * the buffer specified in the command structure.
277 * @see vpu_jsm_metric_streamer_start
279 VPU_JSM_MSG_METRIC_STREAMER_INFO = 0x1112,
280 /** Control command: Priority band setup */
281 VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP = 0x1113,
282 /** Control command: Create command queue */
283 VPU_JSM_MSG_CREATE_CMD_QUEUE = 0x1114,
284 /** Control command: Destroy command queue */
285 VPU_JSM_MSG_DESTROY_CMD_QUEUE = 0x1115,
286 /** Control command: Set context scheduling properties */
287 VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES = 0x1116,
289 * Register a doorbell to notify VPU of new work. The doorbell may later be
290 * deallocated or reassigned to another context.
292 VPU_JSM_MSG_HWS_REGISTER_DB = 0x1117,
293 /** Control command: Log buffer setting */
294 VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG = 0x1118,
295 /* Control command: Suspend command queue. */
296 VPU_JSM_MSG_HWS_SUSPEND_CMDQ = 0x1119,
297 /* Control command: Resume command queue */
298 VPU_JSM_MSG_HWS_RESUME_CMDQ = 0x111a,
299 /* Control command: Resume engine after reset */
300 VPU_JSM_MSG_HWS_ENGINE_RESUME = 0x111b,
301 /* Control command: Enable survivability/DCT mode */
302 VPU_JSM_MSG_DCT_ENABLE = 0x111c,
303 /* Control command: Disable survivability/DCT mode */
304 VPU_JSM_MSG_DCT_DISABLE = 0x111d,
306 * Dump VPU state. To be used for debug purposes only.
307 * NOTE: Please introduce new ASYNC commands before this one. *
309 VPU_JSM_MSG_STATE_DUMP = 0x11FF,
310 /* IPC Host -> Device, General commands */
311 VPU_JSM_MSG_GENERAL_CMD = 0x1200,
312 VPU_JSM_MSG_BLOB_DEINIT = VPU_JSM_MSG_GENERAL_CMD,
314 * Control dyndbg behavior by executing a dyndbg command; equivalent to
315 * Linux command: `echo '<dyndbg_cmd>' > <debugfs>/dynamic_debug/control`.
317 VPU_JSM_MSG_DYNDBG_CONTROL = 0x1201,
319 * Perform the save procedure for the D0i3 entry
321 VPU_JSM_MSG_PWR_D0I3_ENTER = 0x1202,
322 /* IPC Device -> Host, Job completion */
323 VPU_JSM_MSG_JOB_DONE = 0x2100,
324 /* IPC Device -> Host, Async command completion */
325 VPU_JSM_MSG_ASYNC_CMD_DONE = 0x2200,
326 VPU_JSM_MSG_ENGINE_RESET_DONE = VPU_JSM_MSG_ASYNC_CMD_DONE,
327 VPU_JSM_MSG_ENGINE_PREEMPT_DONE = 0x2201,
328 VPU_JSM_MSG_REGISTER_DB_DONE = 0x2202,
329 VPU_JSM_MSG_UNREGISTER_DB_DONE = 0x2203,
330 VPU_JSM_MSG_QUERY_ENGINE_HB_DONE = 0x2204,
331 VPU_JSM_MSG_GET_POWER_LEVEL_COUNT_DONE = 0x2205,
332 VPU_JSM_MSG_GET_POWER_LEVEL_DONE = 0x2206,
333 VPU_JSM_MSG_SET_POWER_LEVEL_DONE = 0x2207,
335 VPU_JSM_MSG_METRIC_STREAMER_OPEN_DONE = 0x2208,
337 VPU_JSM_MSG_METRIC_STREAMER_CLOSE_DONE = 0x2209,
338 /** Response to VPU_JSM_MSG_TRACE_SET_CONFIG. */
339 VPU_JSM_MSG_TRACE_SET_CONFIG_RSP = 0x220a,
340 /** Response to VPU_JSM_MSG_TRACE_GET_CONFIG. */
341 VPU_JSM_MSG_TRACE_GET_CONFIG_RSP = 0x220b,
342 /** Response to VPU_JSM_MSG_TRACE_GET_CAPABILITY. */
343 VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP = 0x220c,
344 /** Response to VPU_JSM_MSG_TRACE_GET_NAME. */
345 VPU_JSM_MSG_TRACE_GET_NAME_RSP = 0x220d,
346 /** Response to VPU_JSM_MSG_SSID_RELEASE. */
347 VPU_JSM_MSG_SSID_RELEASE_DONE = 0x220e,
349 * Response to VPU_JSM_MSG_METRIC_STREAMER_START.
350 * VPU will return an error result if metric collection cannot be started,
351 * e.g. when the specified metric mask is invalid.
352 * @see vpu_jsm_metric_streamer_done
354 VPU_JSM_MSG_METRIC_STREAMER_START_DONE = 0x220f,
356 * Response to VPU_JSM_MSG_METRIC_STREAMER_STOP.
357 * Returns information about collected metric data.
358 * @see vpu_jsm_metric_streamer_done
360 VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE = 0x2210,
362 * Response to VPU_JSM_MSG_METRIC_STREAMER_UPDATE.
363 * Returns information about collected metric data.
364 * @see vpu_jsm_metric_streamer_done
366 VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE = 0x2211,
368 * Response to VPU_JSM_MSG_METRIC_STREAMER_INFO.
369 * Returns a description of the metric groups and metric counters.
370 * @see vpu_jsm_metric_streamer_done
372 VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE = 0x2212,
374 * Asynchronous event sent from the VPU to the host either when the current
375 * metric buffer is full or when the VPU has collected a multiple of
376 * @notify_sample_count samples as indicated through the start command
377 * (VPU_JSM_MSG_METRIC_STREAMER_START). Returns information about collected
379 * @see vpu_jsm_metric_streamer_done
381 VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION = 0x2213,
382 /** Response to control command: Priority band setup */
383 VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP = 0x2214,
384 /** Response to control command: Create command queue */
385 VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP = 0x2215,
386 /** Response to control command: Destroy command queue */
387 VPU_JSM_MSG_DESTROY_CMD_QUEUE_RSP = 0x2216,
388 /** Response to control command: Set context scheduling properties */
389 VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES_RSP = 0x2217,
390 /** Response to control command: Log buffer setting */
391 VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP = 0x2218,
392 /* IPC Device -> Host, HWS notify index entry of log buffer written */
393 VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION = 0x2219,
394 /* IPC Device -> Host, HWS completion of a context suspend request */
395 VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE = 0x221a,
396 /* Response to control command: Resume command queue */
397 VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP = 0x221b,
398 /* Response to control command: Resume engine command response */
399 VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE = 0x221c,
400 /* Response to control command: Enable survivability/DCT mode */
401 VPU_JSM_MSG_DCT_ENABLE_DONE = 0x221d,
402 /* Response to control command: Disable survivability/DCT mode */
403 VPU_JSM_MSG_DCT_DISABLE_DONE = 0x221e,
405 * Response to state dump control command.
406 * NOTE: Please introduce new ASYNC responses before this one. *
408 VPU_JSM_MSG_STATE_DUMP_RSP = 0x22FF,
409 /* IPC Device -> Host, General command completion */
410 VPU_JSM_MSG_GENERAL_CMD_DONE = 0x2300,
411 VPU_JSM_MSG_BLOB_DEINIT_DONE = VPU_JSM_MSG_GENERAL_CMD_DONE,
412 /** Response to VPU_JSM_MSG_DYNDBG_CONTROL. */
413 VPU_JSM_MSG_DYNDBG_CONTROL_RSP = 0x2301,
415 * Acknowledgment of completion of the save procedure initiated by
416 * VPU_JSM_MSG_PWR_D0I3_ENTER
418 VPU_JSM_MSG_PWR_D0I3_ENTER_DONE = 0x2302,
421 enum vpu_ipc_msg_status { VPU_JSM_MSG_FREE, VPU_JSM_MSG_ALLOCATED };
424 * Host <-> LRT IPC message payload definitions
426 struct vpu_ipc_msg_payload_engine_reset {
427 /* Engine to be reset. */
433 struct vpu_ipc_msg_payload_engine_preempt {
434 /* Engine to be preempted. */
436 /* ID of the preemption request. */
441 * @brief Register doorbell command structure.
442 * This structure supports doorbell registration for only OS scheduling.
443 * @see VPU_JSM_MSG_REGISTER_DB
445 struct vpu_ipc_msg_payload_register_db {
446 /* Index of the doorbell to register. */
450 /* Virtual address in Global GTT pointing to the start of job queue. */
452 /* Size of the job queue in bytes. */
454 /* Host sub-stream ID for the context assigned to the doorbell. */
459 * @brief Unregister doorbell command structure.
460 * Request structure to unregister a doorbell for both HW and OS scheduling.
461 * @see VPU_JSM_MSG_UNREGISTER_DB
463 struct vpu_ipc_msg_payload_unregister_db {
464 /* Index of the doorbell to unregister. */
470 struct vpu_ipc_msg_payload_query_engine_hb {
471 /* Engine to return heartbeat value. */
477 struct vpu_ipc_msg_payload_power_level {
479 * Requested power level. The power level value is in the
480 * range [0, power_level_count-1] where power_level_count
481 * is the number of available power levels as returned by
482 * the get power level count command. A power level of 0
483 * corresponds to the maximum possible power level, while
484 * power_level_count-1 corresponds to the minimum possible
485 * power level. Values outside of this range are not
486 * considered to be valid.
493 struct vpu_ipc_msg_payload_ssid_release {
494 /* Host sub-stream ID for the context to be released. */
501 * @brief Metric streamer start command structure.
502 * This structure is also used with VPU_JSM_MSG_METRIC_STREAMER_INFO to request metric
503 * groups and metric counters description from the firmware.
504 * @see VPU_JSM_MSG_METRIC_STREAMER_START
505 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
507 struct vpu_jsm_metric_streamer_start {
509 * Bitmask to select the desired metric groups.
510 * A metric group can belong only to one metric streamer instance at a time.
511 * Since each metric streamer instance has a unique set of metric groups, it
512 * can also identify a metric streamer instance if more than one instance was
513 * started. If the VPU device does not support multiple metric streamer instances,
514 * then VPU_JSM_MSG_METRIC_STREAMER_START will return an error even if the second
515 * instance has different groups to the first.
517 u64 metric_group_mask;
518 /** Sampling rate in nanoseconds. */
521 * If > 0 the VPU will send a VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION message
522 * after every @notify_sample_count samples is collected or dropped by the VPU.
523 * If set to UINT_MAX the VPU will only generate a notification when the metric
524 * buffer is full. If set to 0 the VPU will never generate a notification.
526 u32 notify_sample_count;
529 * Address and size of the buffer where the VPU will write metric data. The
530 * VPU writes all counters from enabled metric groups one after another. If
531 * there is no space left to write data at the next sample period the VPU
532 * will switch to the next buffer (@see next_buffer_addr) and will optionally
533 * send a notification to the host driver if @notify_sample_count is non-zero.
534 * If @next_buffer_addr is NULL the VPU will stop collecting metric data.
539 * Address and size of the next buffer to write metric data to after the initial
540 * buffer is full. If the address is NULL the VPU will stop collecting metric
543 u64 next_buffer_addr;
544 u64 next_buffer_size;
548 * @brief Metric streamer stop command structure.
549 * @see VPU_JSM_MSG_METRIC_STREAMER_STOP
551 struct vpu_jsm_metric_streamer_stop {
552 /** Bitmask to select the desired metric groups. */
553 u64 metric_group_mask;
557 * Provide VPU FW with buffers to write metric data.
558 * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE
560 struct vpu_jsm_metric_streamer_update {
561 /** Metric group mask that identifies metric streamer instance. */
562 u64 metric_group_mask;
564 * Address and size of the buffer where the VPU will write metric data. If
565 * the buffer address is 0 or same as the currently used buffer the VPU will
566 * continue writing metric data to the current buffer. In this case the
567 * buffer size is ignored and the size of the current buffer is unchanged.
568 * If the address is non-zero and differs from the current buffer address the
569 * VPU will immediately switch data collection to the new buffer.
574 * Address and size of the next buffer to write metric data after the initial
575 * buffer is full. If the address is NULL the VPU will stop collecting metric
576 * data but will continue to record dropped samples.
578 * Note that there is a hazard possible if both buffer_addr and the next_buffer_addr
579 * are non-zero in same update request. It is the host's responsibility to ensure
580 * that both addresses make sense even if the VPU just switched to writing samples
581 * from the current to the next buffer.
583 u64 next_buffer_addr;
584 u64 next_buffer_size;
587 struct vpu_ipc_msg_payload_blob_deinit {
588 /* 64-bit unique ID for the blob to be de-initialized. */
592 struct vpu_ipc_msg_payload_job_done {
593 /* Engine to which the job was submitted. */
595 /* Index of the doorbell to which the job was submitted */
597 /* ID of the completed job */
599 /* Status of the completed job */
605 /* Command queue id */
609 struct vpu_jsm_engine_reset_context {
614 /* Command queue id */
616 /* Flags: 0: cause of hang; 1: collateral damage of reset */
620 struct vpu_ipc_msg_payload_engine_reset_done {
623 /* Number of impacted contexts */
624 u32 num_impacted_contexts;
625 /* Array of impacted command queue ids and their flags */
626 struct vpu_jsm_engine_reset_context
627 impacted_contexts[VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS];
630 struct vpu_ipc_msg_payload_engine_preempt_done {
631 /* Engine preempted. */
633 /* ID of the preemption request. */
638 * Response structure for register doorbell command for both OS
640 * @see VPU_JSM_MSG_REGISTER_DB
641 * @see VPU_JSM_MSG_HWS_REGISTER_DB
643 struct vpu_ipc_msg_payload_register_db_done {
644 /* Index of the registered doorbell. */
651 * Response structure for unregister doorbell command for both OS
653 * @see VPU_JSM_MSG_UNREGISTER_DB
655 struct vpu_ipc_msg_payload_unregister_db_done {
656 /* Index of the unregistered doorbell. */
662 struct vpu_ipc_msg_payload_query_engine_hb_done {
663 /* Engine returning heartbeat value. */
667 /* Heartbeat value. */
671 struct vpu_ipc_msg_payload_get_power_level_count_done {
673 * Number of supported power levels. The maximum possible
674 * value of power_level_count is 16 but this may vary across
677 u32 power_level_count;
681 * Power consumption limit for each supported power level in
682 * [0-100%] range relative to power level 0.
687 struct vpu_ipc_msg_payload_blob_deinit_done {
688 /* 64-bit unique ID for the blob de-initialized. */
692 /* HWS priority band setup request / response */
693 struct vpu_ipc_msg_payload_hws_priority_band_setup {
695 * Grace period in 100ns units when preempting another priority band for
698 u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
700 * Default quantum in 100ns units for scheduling across processes
701 * within a priority band
703 u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
705 * Default grace period in 100ns units for processes that preempt each
706 * other within a priority band
708 u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
710 * For normal priority band, specifies the target VPU percentage
711 * in situations when it's starved by the focus band.
713 u32 normal_band_percentage;
719 * @brief HWS create command queue request.
720 * Host will create a command queue via this command.
721 * Note: Cmdq group is a handle of an object which
722 * may contain one or more command queues.
723 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
724 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
726 struct vpu_ipc_msg_payload_hws_create_cmdq {
731 /* Engine for which queue is being created */
734 * Cmdq group may be set to 0 or equal to
735 * cmdq_id while each priority band contains
736 * only single engine instances.
739 /* Command queue id */
741 /* Command queue base */
743 /* Command queue size */
750 * @brief HWS create command queue response.
751 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
752 * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
754 struct vpu_ipc_msg_payload_hws_create_cmdq_rsp {
759 /* Engine for which queue is being created */
761 /* Command queue group */
763 /* Command queue id */
767 /* HWS destroy command queue request / response */
768 struct vpu_ipc_msg_payload_hws_destroy_cmdq {
773 /* Command queue id */
777 /* HWS set context scheduling properties request / response */
778 struct vpu_ipc_msg_payload_hws_set_context_sched_properties {
783 /* Command queue id */
785 /* Priority band to assign to work of this context */
787 /* Inside realtime band assigns a further priority */
788 u32 realtime_priority_level;
789 /* Priority relative to other contexts in the same process */
790 s32 in_process_priority;
791 /* Zero padding / Reserved */
793 /* Context quantum relative to other contexts of same priority in the same process */
795 /* Grace period when preempting context of the same priority within the same process */
796 u64 grace_period_same_priority;
797 /* Grace period when preempting context of a lower priority within the same process */
798 u64 grace_period_lower_priority;
802 * @brief Register doorbell command structure.
803 * This structure supports doorbell registration for both HW and OS scheduling.
804 * Note: Queue base and size are added here so that the same structure can be used for
805 * OS scheduling and HW scheduling. For OS scheduling, cmdq_id will be ignored
806 * and cmdq_base and cmdq_size will be used. For HW scheduling, cmdq_base and cmdq_size will be
807 * ignored and cmdq_id is used.
808 * @see VPU_JSM_MSG_HWS_REGISTER_DB
810 struct vpu_jsm_hws_register_db {
811 /* Index of the doorbell to register. */
813 /* Host sub-stream ID for the context assigned to the doorbell. */
815 /* ID of the command queue associated with the doorbell. */
817 /* Virtual address pointing to the start of command queue. */
819 /* Size of the command queue in bytes. */
824 * @brief Structure to set another buffer to be used for scheduling-related logging.
825 * The size of the logging buffer and the number of entries is defined as part of the
826 * buffer itself as described next.
827 * The log buffer received from the host is made up of;
828 * - header: 32 bytes in size, as shown in 'struct vpu_hws_log_buffer_header'.
829 * The header contains the number of log entries in the buffer.
830 * - log entry: 0 to n-1, each log entry is 32 bytes in size, as shown in
831 * 'struct vpu_hws_log_buffer_entry'.
832 * The entry contains the VPU timestamp, operation type and data.
833 * The host should provide the notify index value of log buffer to VPU. This is a
834 * value defined within the log buffer and when written to will generate the
835 * scheduling log notification.
836 * The host should set engine_idx and vpu_log_buffer_va to 0 to disable logging
837 * for a particular engine.
838 * VPU will handle one log buffer for each of supported engines.
839 * VPU should allow the logging to consume one host_ssid.
840 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
841 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP
842 * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
844 struct vpu_ipc_msg_payload_hws_set_scheduling_log {
850 * VPU log buffer virtual address.
851 * Set to 0 to disable logging for this engine.
853 u64 vpu_log_buffer_va;
855 * Notify index of log buffer. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
856 * is generated when an event log is written to this index.
862 * @brief The scheduling log notification is generated by VPU when it writes
863 * an event into the log buffer at the notify_index. VPU notifies host with
864 * VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION. This is an asynchronous
865 * message from VPU to host.
866 * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
867 * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
869 struct vpu_ipc_msg_payload_hws_scheduling_log_notification {
877 * @brief HWS suspend command queue request and done structure.
878 * Host will request the suspend of contexts and VPU will;
879 * - Suspend all work on this context
880 * - Preempt any running work
881 * - Asynchronously perform the above and return success immediately once
882 * all items above are started successfully
883 * - Notify the host of completion of these operations via
884 * VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
885 * - Reject any other context operations on a context with an in-flight
886 * suspend request running
887 * Same structure used when VPU notifies host of completion of a context suspend
888 * request. The ids and suspend fence value reported in this command will match
889 * the one in the request from the host to suspend the context. Once suspend is
890 * complete, VPU will not access any data relating to this command queue until
892 * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ
893 * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
895 struct vpu_ipc_msg_payload_hws_suspend_cmdq {
900 /* Command queue id */
903 * Suspend fence value - reported by the VPU suspend context
904 * completed once suspend is complete.
906 u64 suspend_fence_value;
910 * @brief HWS Resume command queue request / response structure.
911 * Host will request the resume of a context;
912 * - VPU will resume all work on this context
913 * - Scheduler will allow this context to be scheduled
914 * @see VPU_JSM_MSG_HWS_RESUME_CMDQ
915 * @see VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP
917 struct vpu_ipc_msg_payload_hws_resume_cmdq {
922 /* Command queue id */
927 * @brief HWS Resume engine request / response structure.
928 * After a HWS engine reset, all scheduling is stopped on VPU until a engine resume.
929 * Host shall send this command to resume scheduling of any valid queue.
930 * @see VPU_JSM_MSG_HWS_RESUME_ENGINE
931 * @see VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE
933 struct vpu_ipc_msg_payload_hws_resume_engine {
934 /* Engine to be resumed */
941 * Payload for VPU_JSM_MSG_TRACE_SET_CONFIG[_RSP] and
942 * VPU_JSM_MSG_TRACE_GET_CONFIG_RSP messages.
944 * The payload is interpreted differently depending on the type of message:
946 * - For VPU_JSM_MSG_TRACE_SET_CONFIG, the payload specifies the desired
947 * logging configuration to be set.
949 * - For VPU_JSM_MSG_TRACE_SET_CONFIG_RSP, the payload reports the logging
950 * configuration that was set after a VPU_JSM_MSG_TRACE_SET_CONFIG request.
951 * The host can compare this payload with the one it sent in the
952 * VPU_JSM_MSG_TRACE_SET_CONFIG request to check whether or not the
953 * configuration was set as desired.
955 * - VPU_JSM_MSG_TRACE_GET_CONFIG_RSP, the payload reports the current logging
958 struct vpu_ipc_msg_payload_trace_config {
960 * Logging level (currently set or to be set); see 'mvLog_t' enum for
961 * acceptable values. The specified logging level applies to all
962 * destinations and HW components
966 * Bitmask of logging destinations (currently enabled or to be enabled);
967 * bitwise OR of values defined in logging_destination enum.
969 u32 trace_destination_mask;
971 * Bitmask of loggable HW components (currently enabled or to be enabled);
972 * bitwise OR of values defined in loggable_hw_component enum.
974 u64 trace_hw_component_mask;
975 u64 reserved_0; /**< Reserved for future extensions. */
979 * Payload for VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP messages.
981 struct vpu_ipc_msg_payload_trace_capability_rsp {
982 u32 trace_destination_mask; /**< Bitmask of supported logging destinations. */
984 u64 trace_hw_component_mask; /**< Bitmask of supported loggable HW components. */
985 u64 reserved_1; /**< Reserved for future extensions. */
989 * Payload for VPU_JSM_MSG_TRACE_GET_NAME requests.
991 struct vpu_ipc_msg_payload_trace_get_name {
993 * The type of the entity to query name for; see logging_entity_type for
999 * The ID of the entity to query name for; possible values depends on the
1006 * Payload for VPU_JSM_MSG_TRACE_GET_NAME_RSP responses.
1008 struct vpu_ipc_msg_payload_trace_get_name_rsp {
1010 * The type of the entity whose name was queried; see logging_entity_type
1011 * for possible values.
1016 * The ID of the entity whose name was queried; possible values depends on
1020 /** Reserved for future extensions. */
1022 /** The name of the entity. */
1023 char entity_name[VPU_TRACE_ENTITY_NAME_MAX_LEN];
1027 * Data sent from the VPU to the host in all metric streamer response messages
1028 * and in asynchronous notification.
1029 * @see VPU_JSM_MSG_METRIC_STREAMER_START_DONE
1030 * @see VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE
1031 * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE
1032 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE
1033 * @see VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION
1035 struct vpu_jsm_metric_streamer_done {
1036 /** Metric group mask that identifies metric streamer instance. */
1037 u64 metric_group_mask;
1039 * Size in bytes of single sample - total size of all enabled counters.
1040 * Some VPU implementations may align sample_size to more than 8 bytes.
1045 * Number of samples collected since the metric streamer was started.
1046 * This will be 0 if the metric streamer was not started.
1048 u32 samples_collected;
1050 * Number of samples dropped since the metric streamer was started. This
1051 * is incremented every time the metric streamer is not able to write
1052 * collected samples because the current buffer is full and there is no
1053 * next buffer to switch to.
1055 u32 samples_dropped;
1056 /** Address of the buffer that contains the latest metric data. */
1059 * Number of bytes written into the metric data buffer. In response to the
1060 * VPU_JSM_MSG_METRIC_STREAMER_INFO request this field contains the size of
1061 * all group and counter descriptors. The size is updated even if the buffer
1062 * in the request was NULL or too small to hold descriptors of all counters
1068 * Metric group description placed in the metric buffer after successful completion
1069 * of the VPU_JSM_MSG_METRIC_STREAMER_INFO command. This is followed by one or more
1070 * @vpu_jsm_metric_counter_descriptor records.
1071 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
1073 struct vpu_jsm_metric_group_descriptor {
1075 * Offset to the next metric group (8-byte aligned). If this offset is 0 this
1076 * is the last descriptor. The value of metric_info_size must be greater than
1077 * or equal to sizeof(struct vpu_jsm_metric_group_descriptor) + name_string_size
1078 * + description_string_size and must be 8-byte aligned.
1080 u32 next_metric_group_info_offset;
1082 * Offset to the first metric counter description record (8-byte aligned).
1083 * @see vpu_jsm_metric_counter_descriptor
1085 u32 next_metric_counter_info_offset;
1086 /** Index of the group. This corresponds to bit index in metric_group_mask. */
1088 /** Number of counters in the metric group. */
1090 /** Data size for all counters, must be a multiple of 8 bytes.*/
1091 u32 metric_group_data_size;
1093 * Metric group domain number. Cannot use multiple, simultaneous metric groups
1094 * from the same domain.
1098 * Counter name string size. The string must include a null termination character.
1099 * The FW may use a fixed size name or send a different name for each counter.
1100 * If the VPU uses fixed size strings, all characters from the end of the name
1101 * to the of the fixed size character array must be zeroed.
1103 u32 name_string_size;
1104 /** Counter description string size, @see name_string_size */
1105 u32 description_string_size;
1108 * Right after this structure, the VPU writes name and description of
1114 * Metric counter description, placed in the buffer after vpu_jsm_metric_group_descriptor.
1115 * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
1117 struct vpu_jsm_metric_counter_descriptor {
1119 * Offset to the next counter in a group (8-byte aligned). If this offset is
1120 * 0 this is the last counter in the group.
1122 u32 next_metric_counter_info_offset;
1124 * Offset to the counter data from the start of samples in this metric group.
1125 * Note that metric_data_offset % metric_data_size must be 0.
1127 u32 metric_data_offset;
1128 /** Size of the metric counter data in bytes. */
1129 u32 metric_data_size;
1130 /** Metric type, see Level Zero API for definitions. */
1132 /** Metric type, see set_metric_type_t for definitions. */
1134 /** Metric type, see set_value_type_t for definitions. */
1135 u32 metric_value_type;
1137 * Counter name string size. The string must include a null termination character.
1138 * The FW may use a fixed size name or send a different name for each counter.
1139 * If the VPU uses fixed size strings, all characters from the end of the name
1140 * to the of the fixed size character array must be zeroed.
1142 u32 name_string_size;
1143 /** Counter description string size, @see name_string_size */
1144 u32 description_string_size;
1145 /** Counter component name string size, @see name_string_size */
1146 u32 component_string_size;
1147 /** Counter string size, @see name_string_size */
1148 u32 units_string_size;
1151 * Right after this structure, the VPU writes name, description
1152 * component and unit strings.
1157 * Payload for VPU_JSM_MSG_DYNDBG_CONTROL requests.
1159 * VPU_JSM_MSG_DYNDBG_CONTROL are used to control the VPU FW Dynamic Debug
1160 * feature, which allows developers to selectively enable / disable MVLOG_DEBUG
1161 * messages. This is equivalent to the Dynamic Debug functionality provided by
1163 * (https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html)
1164 * The host can control Dynamic Debug behavior by sending dyndbg commands, which
1165 * have the same syntax as Linux
1168 * NOTE: in order for MVLOG_DEBUG messages to be actually printed, the host
1169 * still has to set the logging level to MVLOG_DEBUG, using the
1170 * VPU_JSM_MSG_TRACE_SET_CONFIG command.
1172 * The host can see the current dynamic debug configuration by executing a
1173 * special 'show' command. The dyndbg configuration will be printed to the
1174 * configured logging destination using MVLOG_INFO logging level.
1176 struct vpu_ipc_msg_payload_dyndbg_control {
1178 * Dyndbg command (same format as Linux dyndbg); must be a NULL-terminated
1181 char dyndbg_cmd[VPU_DYNDBG_CMD_MAX_LEN];
1185 * Payload for VPU_JSM_MSG_PWR_D0I3_ENTER
1187 * This is a bi-directional payload.
1189 struct vpu_ipc_msg_payload_pwr_d0i3_enter {
1191 * 0: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is not sent to the host driver
1192 * The driver will poll for D0i2 Idle state transitions.
1193 * 1: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is sent after VPU state save is complete
1200 * Payload for VPU_JSM_MSG_DCT_ENABLE message.
1202 * Default values for DCT active/inactive times are 5.3ms and 30ms respectively,
1203 * corresponding to a 85% duty cycle. This payload allows the host to tune these
1204 * values according to application requirements.
1206 struct vpu_ipc_msg_payload_pwr_dct_control {
1207 /** Duty cycle active time in microseconds */
1209 /** Duty cycle inactive time in microseconds */
1210 u32 dct_inactive_us;
1214 * Payloads union, used to define complete message format.
1216 union vpu_ipc_msg_payload {
1217 struct vpu_ipc_msg_payload_engine_reset engine_reset;
1218 struct vpu_ipc_msg_payload_engine_preempt engine_preempt;
1219 struct vpu_ipc_msg_payload_register_db register_db;
1220 struct vpu_ipc_msg_payload_unregister_db unregister_db;
1221 struct vpu_ipc_msg_payload_query_engine_hb query_engine_hb;
1222 struct vpu_ipc_msg_payload_power_level power_level;
1223 struct vpu_jsm_metric_streamer_start metric_streamer_start;
1224 struct vpu_jsm_metric_streamer_stop metric_streamer_stop;
1225 struct vpu_jsm_metric_streamer_update metric_streamer_update;
1226 struct vpu_ipc_msg_payload_blob_deinit blob_deinit;
1227 struct vpu_ipc_msg_payload_ssid_release ssid_release;
1228 struct vpu_jsm_hws_register_db hws_register_db;
1229 struct vpu_ipc_msg_payload_job_done job_done;
1230 struct vpu_ipc_msg_payload_engine_reset_done engine_reset_done;
1231 struct vpu_ipc_msg_payload_engine_preempt_done engine_preempt_done;
1232 struct vpu_ipc_msg_payload_register_db_done register_db_done;
1233 struct vpu_ipc_msg_payload_unregister_db_done unregister_db_done;
1234 struct vpu_ipc_msg_payload_query_engine_hb_done query_engine_hb_done;
1235 struct vpu_ipc_msg_payload_get_power_level_count_done get_power_level_count_done;
1236 struct vpu_jsm_metric_streamer_done metric_streamer_done;
1237 struct vpu_ipc_msg_payload_blob_deinit_done blob_deinit_done;
1238 struct vpu_ipc_msg_payload_trace_config trace_config;
1239 struct vpu_ipc_msg_payload_trace_capability_rsp trace_capability;
1240 struct vpu_ipc_msg_payload_trace_get_name trace_get_name;
1241 struct vpu_ipc_msg_payload_trace_get_name_rsp trace_get_name_rsp;
1242 struct vpu_ipc_msg_payload_dyndbg_control dyndbg_control;
1243 struct vpu_ipc_msg_payload_hws_priority_band_setup hws_priority_band_setup;
1244 struct vpu_ipc_msg_payload_hws_create_cmdq hws_create_cmdq;
1245 struct vpu_ipc_msg_payload_hws_create_cmdq_rsp hws_create_cmdq_rsp;
1246 struct vpu_ipc_msg_payload_hws_destroy_cmdq hws_destroy_cmdq;
1247 struct vpu_ipc_msg_payload_hws_set_context_sched_properties
1248 hws_set_context_sched_properties;
1249 struct vpu_ipc_msg_payload_hws_set_scheduling_log hws_set_scheduling_log;
1250 struct vpu_ipc_msg_payload_hws_scheduling_log_notification hws_scheduling_log_notification;
1251 struct vpu_ipc_msg_payload_hws_suspend_cmdq hws_suspend_cmdq;
1252 struct vpu_ipc_msg_payload_hws_resume_cmdq hws_resume_cmdq;
1253 struct vpu_ipc_msg_payload_hws_resume_engine hws_resume_engine;
1254 struct vpu_ipc_msg_payload_pwr_d0i3_enter pwr_d0i3_enter;
1255 struct vpu_ipc_msg_payload_pwr_dct_control pwr_dct_control;
1259 * Host <-> LRT IPC message base structure.
1261 * NOTE: All instances of this object must be aligned on a 64B boundary
1262 * to allow proper handling of VPU cache operations.
1264 struct vpu_jsm_msg {
1267 /* Message type, see vpu_ipc_msg_type enum. */
1269 /* Buffer status, see vpu_ipc_msg_status enum. */
1272 * Request ID, provided by the host in a request message and passed
1273 * back by VPU in the response message.
1276 /* Request return code set by the VPU, see VPU_JSM_STATUS_* defines. */
1279 /* Message payload depending on message type, see vpu_ipc_msg_payload union. */
1280 union vpu_ipc_msg_payload payload;