vpu_jsm_api.h 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (c) 2020-2024, Intel Corporation.
  4. */
  5. /**
  6. * @file
  7. * @brief JSM shared definitions
  8. *
  9. * @ingroup Jsm
  10. * @brief JSM shared definitions
  11. * @{
  12. */
  13. #ifndef VPU_JSM_API_H
  14. #define VPU_JSM_API_H
  15. /*
  16. * Major version changes that break backward compatibility
  17. */
  18. #define VPU_JSM_API_VER_MAJOR 3
  19. /*
  20. * Minor version changes when API backward compatibility is preserved.
  21. */
  22. #define VPU_JSM_API_VER_MINOR 25
  23. /*
  24. * API header changed (field names, documentation, formatting) but API itself has not been changed
  25. */
  26. #define VPU_JSM_API_VER_PATCH 0
  27. /*
  28. * Index in the API version table
  29. */
  30. #define VPU_JSM_API_VER_INDEX 4
  31. /*
  32. * Number of Priority Bands for Hardware Scheduling
  33. * Bands: Idle(0), Normal(1), Focus(2), RealTime(3)
  34. */
  35. #define VPU_HWS_NUM_PRIORITY_BANDS 4
  36. /* Max number of impacted contexts that can be dealt with the engine reset command */
  37. #define VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS 3
  38. /*
  39. * Pack the API structures to enforce binary compatibility
  40. * Align to 8 bytes for optimal performance
  41. */
  42. #pragma pack(push, 8)
  43. /*
  44. * Engine indexes.
  45. */
  46. #define VPU_ENGINE_COMPUTE 0
  47. #define VPU_ENGINE_COPY 1
  48. #define VPU_ENGINE_NB 2
  49. /*
  50. * VPU status values.
  51. */
  52. #define VPU_JSM_STATUS_SUCCESS 0x0U
  53. #define VPU_JSM_STATUS_PARSING_ERR 0x1U
  54. #define VPU_JSM_STATUS_PROCESSING_ERR 0x2U
  55. #define VPU_JSM_STATUS_PREEMPTED 0x3U
  56. #define VPU_JSM_STATUS_ABORTED 0x4U
  57. #define VPU_JSM_STATUS_USER_CTX_VIOL_ERR 0x5U
  58. #define VPU_JSM_STATUS_GLOBAL_CTX_VIOL_ERR 0x6U
  59. #define VPU_JSM_STATUS_MVNCI_WRONG_INPUT_FORMAT 0x7U
  60. #define VPU_JSM_STATUS_MVNCI_UNSUPPORTED_NETWORK_ELEMENT 0x8U
  61. #define VPU_JSM_STATUS_MVNCI_INVALID_HANDLE 0x9U
  62. #define VPU_JSM_STATUS_MVNCI_OUT_OF_RESOURCES 0xAU
  63. #define VPU_JSM_STATUS_MVNCI_NOT_IMPLEMENTED 0xBU
  64. #define VPU_JSM_STATUS_MVNCI_INTERNAL_ERROR 0xCU
  65. /* Job status returned when the job was preempted mid-inference */
  66. #define VPU_JSM_STATUS_PREEMPTED_MID_INFERENCE 0xDU
  67. #define VPU_JSM_STATUS_MVNCI_CONTEXT_VIOLATION_HW 0xEU
  68. /*
  69. * Host <-> VPU IPC channels.
  70. * ASYNC commands use a high priority channel, other messages use low-priority ones.
  71. */
  72. #define VPU_IPC_CHAN_ASYNC_CMD 0
  73. #define VPU_IPC_CHAN_GEN_CMD 10
  74. #define VPU_IPC_CHAN_JOB_RET 11
  75. /*
  76. * Job flags bit masks.
  77. */
  78. enum {
  79. /*
  80. * Null submission mask.
  81. * When set, batch buffer's commands are not processed but returned as
  82. * successful immediately, except fences and timestamps.
  83. * When cleared, batch buffer's commands are processed normally.
  84. * Used for testing and profiling purposes.
  85. */
  86. VPU_JOB_FLAGS_NULL_SUBMISSION_MASK = (1 << 0U),
  87. /*
  88. * Inline command mask.
  89. * When set, the object in job queue is an inline command (see struct vpu_inline_cmd below).
  90. * When cleared, the object in job queue is a job (see struct vpu_job_queue_entry below).
  91. */
  92. VPU_JOB_FLAGS_INLINE_CMD_MASK = (1 << 1U),
  93. /*
  94. * VPU private data mask.
  95. * Reserved for the VPU to store private data about the job (or inline command)
  96. * while being processed.
  97. */
  98. VPU_JOB_FLAGS_PRIVATE_DATA_MASK = 0xFFFF0000U
  99. };
  100. /*
  101. * Job queue flags bit masks.
  102. */
  103. enum {
  104. /*
  105. * No job done notification mask.
  106. * When set, indicates that no job done notification should be sent for any
  107. * job from this queue. When cleared, indicates that job done notification
  108. * should be sent for every job completed from this queue.
  109. */
  110. VPU_JOB_QUEUE_FLAGS_NO_JOB_DONE_MASK = (1 << 0U),
  111. /*
  112. * Native fence usage mask.
  113. * When set, indicates that job queue uses native fences (as inline commands
  114. * in job queue). Such queues may also use legacy fences (as commands in batch buffers).
  115. * When cleared, indicates the job queue only uses legacy fences.
  116. * NOTE: For queues using native fences, VPU expects that all jobs in the queue
  117. * are immediately followed by an inline command object. This object is expected
  118. * to be a fence signal command in most cases, but can also be a NOP in case the host
  119. * does not need per-job fence signalling. Other inline commands objects can be
  120. * inserted between "job and inline command" pairs.
  121. */
  122. VPU_JOB_QUEUE_FLAGS_USE_NATIVE_FENCE_MASK = (1 << 1U),
  123. /*
  124. * Enable turbo mode for testing NPU performance; not recommended for regular usage.
  125. */
  126. VPU_JOB_QUEUE_FLAGS_TURBO_MODE = (1 << 2U)
  127. };
  128. /*
  129. * Max length (including trailing NULL char) of trace entity name (e.g., the
  130. * name of a logging destination or a loggable HW component).
  131. */
  132. #define VPU_TRACE_ENTITY_NAME_MAX_LEN 32
  133. /*
  134. * Max length (including trailing NULL char) of a dyndbg command.
  135. *
  136. * NOTE: 96 is used so that the size of 'struct vpu_ipc_msg' in the JSM API is
  137. * 128 bytes (multiple of 64 bytes, the cache line size).
  138. */
  139. #define VPU_DYNDBG_CMD_MAX_LEN 96
  140. /*
  141. * For HWS command queue scheduling, we can prioritise command queues inside the
  142. * same process with a relative in-process priority. Valid values for relative
  143. * priority are given below - max and min.
  144. */
  145. #define VPU_HWS_COMMAND_QUEUE_MAX_IN_PROCESS_PRIORITY 7
  146. #define VPU_HWS_COMMAND_QUEUE_MIN_IN_PROCESS_PRIORITY -7
  147. /*
  148. * For HWS priority scheduling, we can have multiple realtime priority bands.
  149. * They are numbered 0 to a MAX.
  150. */
  151. #define VPU_HWS_MAX_REALTIME_PRIORITY_LEVEL 31U
  152. /*
  153. * vpu_jsm_engine_reset_context flag definitions
  154. */
  155. #define VPU_ENGINE_RESET_CONTEXT_FLAG_COLLATERAL_DAMAGE_MASK BIT(0)
  156. #define VPU_ENGINE_RESET_CONTEXT_HANG_PRIMARY_CAUSE 0
  157. #define VPU_ENGINE_RESET_CONTEXT_COLLATERAL_DAMAGE 1
  158. /*
  159. * Invalid command queue handle identifier. Applies to cmdq_id and cmdq_group
  160. * in this API.
  161. */
  162. #define VPU_HWS_INVALID_CMDQ_HANDLE 0ULL
  163. /*
  164. * Inline commands types.
  165. */
  166. /*
  167. * NOP.
  168. * VPU does nothing other than consuming the inline command object.
  169. */
  170. #define VPU_INLINE_CMD_TYPE_NOP 0x0
  171. /*
  172. * Fence wait.
  173. * VPU waits for the fence current value to reach monitored value.
  174. * Fence wait operations are executed upon job dispatching. While waiting for
  175. * the fence to be satisfied, VPU blocks fetching of the next objects in the queue.
  176. * Jobs present in the queue prior to the fence wait object may be processed
  177. * concurrently.
  178. */
  179. #define VPU_INLINE_CMD_TYPE_FENCE_WAIT 0x1
  180. /*
  181. * Fence signal.
  182. * VPU sets the fence current value to the provided value. If new current value
  183. * is equal to or higher than monitored value, VPU sends fence signalled notification
  184. * to the host. Fence signal operations are executed upon completion of all the jobs
  185. * present in the queue prior to them, and in-order relative to each other in the queue.
  186. * But jobs in-between them may be processed concurrently and may complete out-of-order.
  187. */
  188. #define VPU_INLINE_CMD_TYPE_FENCE_SIGNAL 0x2
  189. /*
  190. * Job scheduling priority bands for both hardware scheduling and OS scheduling.
  191. */
  192. enum vpu_job_scheduling_priority_band {
  193. VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE = 0,
  194. VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL = 1,
  195. VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS = 2,
  196. VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME = 3,
  197. VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT = 4,
  198. };
  199. /*
  200. * Job format.
  201. * Jobs defines the actual workloads to be executed by a given engine.
  202. */
  203. struct vpu_job_queue_entry {
  204. /**< Address of VPU commands batch buffer */
  205. u64 batch_buf_addr;
  206. /**< Job ID */
  207. u32 job_id;
  208. /**< Flags bit field, see VPU_JOB_FLAGS_* above */
  209. u32 flags;
  210. /**
  211. * Doorbell ring timestamp taken by KMD from SoC's global system clock, in
  212. * microseconds. NPU can convert this value to its own fixed clock's timebase,
  213. * to match other profiling timestamps.
  214. */
  215. u64 doorbell_timestamp;
  216. /**< Extra id for job tracking, used only in the firmware perf traces */
  217. u64 host_tracking_id;
  218. /**< Address of the primary preemption buffer to use for this job */
  219. u64 primary_preempt_buf_addr;
  220. /**< Size of the primary preemption buffer to use for this job */
  221. u32 primary_preempt_buf_size;
  222. /**< Size of secondary preemption buffer to use for this job */
  223. u32 secondary_preempt_buf_size;
  224. /**< Address of secondary preemption buffer to use for this job */
  225. u64 secondary_preempt_buf_addr;
  226. u64 reserved_0;
  227. };
  228. /*
  229. * Inline command format.
  230. * Inline commands are the commands executed at scheduler level (typically,
  231. * synchronization directives). Inline command and job objects must be of
  232. * the same size and have flags field at same offset.
  233. */
  234. struct vpu_inline_cmd {
  235. u64 reserved_0;
  236. /* Inline command type, see VPU_INLINE_CMD_TYPE_* defines. */
  237. u32 type;
  238. /* Flags bit field, see VPU_JOB_FLAGS_* above. */
  239. u32 flags;
  240. /* Inline command payload. Depends on inline command type. */
  241. union {
  242. /* Fence (wait and signal) commands' payload. */
  243. struct {
  244. /* Fence object handle. */
  245. u64 fence_handle;
  246. /* User VA of the current fence value. */
  247. u64 current_value_va;
  248. /* User VA of the monitored fence value (read-only). */
  249. u64 monitored_value_va;
  250. /* Value to wait for or write in fence location. */
  251. u64 value;
  252. /* User VA of the log buffer in which to add log entry on completion. */
  253. u64 log_buffer_va;
  254. } fence;
  255. /* Other commands do not have a payload. */
  256. /* Payload definition for future inline commands can be inserted here. */
  257. u64 reserved_1[6];
  258. } payload;
  259. };
  260. /*
  261. * Job queue slots can be populated either with job objects or inline command objects.
  262. */
  263. union vpu_jobq_slot {
  264. struct vpu_job_queue_entry job;
  265. struct vpu_inline_cmd inline_cmd;
  266. };
  267. /*
  268. * Job queue control registers.
  269. */
  270. struct vpu_job_queue_header {
  271. u32 engine_idx;
  272. u32 head;
  273. u32 tail;
  274. u32 flags;
  275. /* Set to 1 to indicate priority_band field is valid */
  276. u32 priority_band_valid;
  277. /*
  278. * Priority for the work of this job queue, valid only if the HWS is NOT used
  279. * and the `priority_band_valid` is set to 1. It is applied only during
  280. * the VPU_JSM_MSG_REGISTER_DB message processing.
  281. * The device firmware might use the `priority_band` to optimize the power
  282. * management logic, but it will not affect the order of jobs.
  283. * Available priority bands: @see enum vpu_job_scheduling_priority_band
  284. */
  285. u32 priority_band;
  286. /* Inside realtime band assigns a further priority, limited to 0..31 range */
  287. u32 realtime_priority_level;
  288. u32 reserved_0[9];
  289. };
  290. /*
  291. * Job queue format.
  292. */
  293. struct vpu_job_queue {
  294. struct vpu_job_queue_header header;
  295. union vpu_jobq_slot slot[];
  296. };
  297. /**
  298. * Logging entity types.
  299. *
  300. * This enum defines the different types of entities involved in logging.
  301. */
  302. enum vpu_trace_entity_type {
  303. /** Logging destination (entity where logs can be stored / printed). */
  304. VPU_TRACE_ENTITY_TYPE_DESTINATION = 1,
  305. /** Loggable HW component (HW entity that can be logged). */
  306. VPU_TRACE_ENTITY_TYPE_HW_COMPONENT = 2,
  307. };
  308. /*
  309. * HWS specific log buffer header details.
  310. * Total size is 32 bytes.
  311. */
  312. struct vpu_hws_log_buffer_header {
  313. /* Written by VPU after adding a log entry. Initialised by host to 0. */
  314. u32 first_free_entry_index;
  315. /* Incremented by VPU every time the VPU writes the 0th entry; initialised by host to 0. */
  316. u32 wraparound_count;
  317. /*
  318. * This is the number of buffers that can be stored in the log buffer provided by the host.
  319. * It is written by host before passing buffer to VPU. VPU should consider it read-only.
  320. */
  321. u64 num_of_entries;
  322. u64 reserved[2];
  323. };
  324. /*
  325. * HWS specific log buffer entry details.
  326. * Total size is 32 bytes.
  327. */
  328. struct vpu_hws_log_buffer_entry {
  329. /* VPU timestamp must be an invariant timer tick (not impacted by DVFS) */
  330. u64 vpu_timestamp;
  331. /*
  332. * Operation type:
  333. * 0 - context state change
  334. * 1 - queue new work
  335. * 2 - queue unwait sync object
  336. * 3 - queue no more work
  337. * 4 - queue wait sync object
  338. */
  339. u32 operation_type;
  340. u32 reserved;
  341. /* Operation data depends on operation type */
  342. u64 operation_data[2];
  343. };
  344. /* Native fence log buffer types. */
  345. enum vpu_hws_native_fence_log_type {
  346. VPU_HWS_NATIVE_FENCE_LOG_TYPE_WAITS = 1,
  347. VPU_HWS_NATIVE_FENCE_LOG_TYPE_SIGNALS = 2
  348. };
  349. /* HWS native fence log buffer header. */
  350. struct vpu_hws_native_fence_log_header {
  351. union {
  352. struct {
  353. /* Index of the first free entry in buffer. */
  354. u32 first_free_entry_idx;
  355. /* Incremented each time NPU wraps around the buffer to write next entry. */
  356. u32 wraparound_count;
  357. };
  358. /* Field allowing atomic update of both fields above. */
  359. u64 atomic_wraparound_and_entry_idx;
  360. };
  361. /* Log buffer type, see enum vpu_hws_native_fence_log_type. */
  362. u64 type;
  363. /* Allocated number of entries in the log buffer. */
  364. u64 entry_nb;
  365. u64 reserved[2];
  366. };
  367. /* Native fence log operation types. */
  368. enum vpu_hws_native_fence_log_op {
  369. VPU_HWS_NATIVE_FENCE_LOG_OP_SIGNAL_EXECUTED = 0,
  370. VPU_HWS_NATIVE_FENCE_LOG_OP_WAIT_UNBLOCKED = 1
  371. };
  372. /* HWS native fence log entry. */
  373. struct vpu_hws_native_fence_log_entry {
  374. /* Newly signaled/unblocked fence value. */
  375. u64 fence_value;
  376. /* Native fence object handle to which this operation belongs. */
  377. u64 fence_handle;
  378. /* Operation type, see enum vpu_hws_native_fence_log_op. */
  379. u64 op_type;
  380. u64 reserved_0;
  381. /*
  382. * VPU_HWS_NATIVE_FENCE_LOG_OP_WAIT_UNBLOCKED only: Timestamp at which fence
  383. * wait was started (in NPU SysTime).
  384. */
  385. u64 fence_wait_start_ts;
  386. u64 reserved_1;
  387. /* Timestamp at which fence operation was completed (in NPU SysTime). */
  388. u64 fence_end_ts;
  389. };
  390. /* Native fence log buffer. */
  391. struct vpu_hws_native_fence_log_buffer {
  392. struct vpu_hws_native_fence_log_header header;
  393. struct vpu_hws_native_fence_log_entry entry[];
  394. };
  395. /*
  396. * Host <-> VPU IPC messages types.
  397. */
  398. enum vpu_ipc_msg_type {
  399. VPU_JSM_MSG_UNKNOWN = 0xFFFFFFFF,
  400. /* IPC Host -> Device, Async commands */
  401. VPU_JSM_MSG_ASYNC_CMD = 0x1100,
  402. VPU_JSM_MSG_ENGINE_RESET = VPU_JSM_MSG_ASYNC_CMD,
  403. /**
  404. * Preempt engine. The NPU stops (preempts) all the jobs currently
  405. * executing on the target engine making the engine become idle and ready to
  406. * execute new jobs.
  407. * NOTE: The NPU does not remove unstarted jobs (if any) from job queues of
  408. * the target engine, but it stops processing them (until the queue doorbell
  409. * is rung again); the host is responsible to reset the job queue, either
  410. * after preemption or when resubmitting jobs to the queue.
  411. */
  412. VPU_JSM_MSG_ENGINE_PREEMPT = 0x1101,
  413. VPU_JSM_MSG_REGISTER_DB = 0x1102,
  414. VPU_JSM_MSG_UNREGISTER_DB = 0x1103,
  415. VPU_JSM_MSG_QUERY_ENGINE_HB = 0x1104,
  416. VPU_JSM_MSG_GET_POWER_LEVEL_COUNT = 0x1105,
  417. VPU_JSM_MSG_GET_POWER_LEVEL = 0x1106,
  418. VPU_JSM_MSG_SET_POWER_LEVEL = 0x1107,
  419. /* @deprecated */
  420. VPU_JSM_MSG_METRIC_STREAMER_OPEN = 0x1108,
  421. /* @deprecated */
  422. VPU_JSM_MSG_METRIC_STREAMER_CLOSE = 0x1109,
  423. /** Configure logging (used to modify configuration passed in boot params). */
  424. VPU_JSM_MSG_TRACE_SET_CONFIG = 0x110a,
  425. /** Return current logging configuration. */
  426. VPU_JSM_MSG_TRACE_GET_CONFIG = 0x110b,
  427. /**
  428. * Get masks of destinations and HW components supported by the firmware
  429. * (may vary between HW generations and FW compile
  430. * time configurations)
  431. */
  432. VPU_JSM_MSG_TRACE_GET_CAPABILITY = 0x110c,
  433. /** Get the name of a destination or HW component. */
  434. VPU_JSM_MSG_TRACE_GET_NAME = 0x110d,
  435. /**
  436. * Release resource associated with host ssid . All jobs that belong to the host_ssid
  437. * aborted and removed from internal scheduling queues. All doorbells assigned
  438. * to the host_ssid are unregistered and any internal FW resources belonging to
  439. * the host_ssid are released.
  440. */
  441. VPU_JSM_MSG_SSID_RELEASE = 0x110e,
  442. /**
  443. * Start collecting metric data.
  444. * @see vpu_jsm_metric_streamer_start
  445. */
  446. VPU_JSM_MSG_METRIC_STREAMER_START = 0x110f,
  447. /**
  448. * Stop collecting metric data. This command will return success if it is called
  449. * for a metric stream that has already been stopped or was never started.
  450. * @see vpu_jsm_metric_streamer_stop
  451. */
  452. VPU_JSM_MSG_METRIC_STREAMER_STOP = 0x1110,
  453. /**
  454. * Update current and next buffer for metric data collection. This command can
  455. * also be used to request information about the number of collected samples
  456. * and the amount of data written to the buffer.
  457. * @see vpu_jsm_metric_streamer_update
  458. */
  459. VPU_JSM_MSG_METRIC_STREAMER_UPDATE = 0x1111,
  460. /**
  461. * Request description of selected metric groups and metric counters within
  462. * each group. The VPU will write the description of groups and counters to
  463. * the buffer specified in the command structure.
  464. * @see vpu_jsm_metric_streamer_start
  465. */
  466. VPU_JSM_MSG_METRIC_STREAMER_INFO = 0x1112,
  467. /** Control command: Priority band setup */
  468. VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP = 0x1113,
  469. /** Control command: Create command queue */
  470. VPU_JSM_MSG_CREATE_CMD_QUEUE = 0x1114,
  471. /** Control command: Destroy command queue */
  472. VPU_JSM_MSG_DESTROY_CMD_QUEUE = 0x1115,
  473. /** Control command: Set context scheduling properties */
  474. VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES = 0x1116,
  475. /*
  476. * Register a doorbell to notify VPU of new work. The doorbell may later be
  477. * deallocated or reassigned to another context.
  478. */
  479. VPU_JSM_MSG_HWS_REGISTER_DB = 0x1117,
  480. /** Control command: Log buffer setting */
  481. VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG = 0x1118,
  482. /* Control command: Suspend command queue. */
  483. VPU_JSM_MSG_HWS_SUSPEND_CMDQ = 0x1119,
  484. /* Control command: Resume command queue */
  485. VPU_JSM_MSG_HWS_RESUME_CMDQ = 0x111a,
  486. /* Control command: Resume engine after reset */
  487. VPU_JSM_MSG_HWS_ENGINE_RESUME = 0x111b,
  488. /* Control command: Enable survivability/DCT mode */
  489. VPU_JSM_MSG_DCT_ENABLE = 0x111c,
  490. /* Control command: Disable survivability/DCT mode */
  491. VPU_JSM_MSG_DCT_DISABLE = 0x111d,
  492. /**
  493. * Dump VPU state. To be used for debug purposes only.
  494. * NOTE: Please introduce new ASYNC commands before this one. *
  495. */
  496. VPU_JSM_MSG_STATE_DUMP = 0x11FF,
  497. /* IPC Host -> Device, General commands */
  498. VPU_JSM_MSG_GENERAL_CMD = 0x1200,
  499. VPU_JSM_MSG_BLOB_DEINIT_DEPRECATED = VPU_JSM_MSG_GENERAL_CMD,
  500. /**
  501. * Control dyndbg behavior by executing a dyndbg command; equivalent to
  502. * Linux command: `echo '<dyndbg_cmd>' > <debugfs>/dynamic_debug/control`.
  503. */
  504. VPU_JSM_MSG_DYNDBG_CONTROL = 0x1201,
  505. /**
  506. * Perform the save procedure for the D0i3 entry
  507. */
  508. VPU_JSM_MSG_PWR_D0I3_ENTER = 0x1202,
  509. /* IPC Device -> Host, Job completion */
  510. VPU_JSM_MSG_JOB_DONE = 0x2100,
  511. /* IPC Device -> Host, Fence signalled */
  512. VPU_JSM_MSG_NATIVE_FENCE_SIGNALLED = 0x2101,
  513. /* IPC Device -> Host, Async command completion */
  514. VPU_JSM_MSG_ASYNC_CMD_DONE = 0x2200,
  515. VPU_JSM_MSG_ENGINE_RESET_DONE = VPU_JSM_MSG_ASYNC_CMD_DONE,
  516. VPU_JSM_MSG_ENGINE_PREEMPT_DONE = 0x2201,
  517. VPU_JSM_MSG_REGISTER_DB_DONE = 0x2202,
  518. VPU_JSM_MSG_UNREGISTER_DB_DONE = 0x2203,
  519. VPU_JSM_MSG_QUERY_ENGINE_HB_DONE = 0x2204,
  520. VPU_JSM_MSG_GET_POWER_LEVEL_COUNT_DONE = 0x2205,
  521. VPU_JSM_MSG_GET_POWER_LEVEL_DONE = 0x2206,
  522. VPU_JSM_MSG_SET_POWER_LEVEL_DONE = 0x2207,
  523. /* @deprecated */
  524. VPU_JSM_MSG_METRIC_STREAMER_OPEN_DONE = 0x2208,
  525. /* @deprecated */
  526. VPU_JSM_MSG_METRIC_STREAMER_CLOSE_DONE = 0x2209,
  527. /** Response to VPU_JSM_MSG_TRACE_SET_CONFIG. */
  528. VPU_JSM_MSG_TRACE_SET_CONFIG_RSP = 0x220a,
  529. /** Response to VPU_JSM_MSG_TRACE_GET_CONFIG. */
  530. VPU_JSM_MSG_TRACE_GET_CONFIG_RSP = 0x220b,
  531. /** Response to VPU_JSM_MSG_TRACE_GET_CAPABILITY. */
  532. VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP = 0x220c,
  533. /** Response to VPU_JSM_MSG_TRACE_GET_NAME. */
  534. VPU_JSM_MSG_TRACE_GET_NAME_RSP = 0x220d,
  535. /** Response to VPU_JSM_MSG_SSID_RELEASE. */
  536. VPU_JSM_MSG_SSID_RELEASE_DONE = 0x220e,
  537. /**
  538. * Response to VPU_JSM_MSG_METRIC_STREAMER_START.
  539. * VPU will return an error result if metric collection cannot be started,
  540. * e.g. when the specified metric mask is invalid.
  541. * @see vpu_jsm_metric_streamer_done
  542. */
  543. VPU_JSM_MSG_METRIC_STREAMER_START_DONE = 0x220f,
  544. /**
  545. * Response to VPU_JSM_MSG_METRIC_STREAMER_STOP.
  546. * Returns information about collected metric data.
  547. * @see vpu_jsm_metric_streamer_done
  548. */
  549. VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE = 0x2210,
  550. /**
  551. * Response to VPU_JSM_MSG_METRIC_STREAMER_UPDATE.
  552. * Returns information about collected metric data.
  553. * @see vpu_jsm_metric_streamer_done
  554. */
  555. VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE = 0x2211,
  556. /**
  557. * Response to VPU_JSM_MSG_METRIC_STREAMER_INFO.
  558. * Returns a description of the metric groups and metric counters.
  559. * @see vpu_jsm_metric_streamer_done
  560. */
  561. VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE = 0x2212,
  562. /**
  563. * Asynchronous event sent from the VPU to the host either when the current
  564. * metric buffer is full or when the VPU has collected a multiple of
  565. * @notify_sample_count samples as indicated through the start command
  566. * (VPU_JSM_MSG_METRIC_STREAMER_START). Returns information about collected
  567. * metric data.
  568. * @see vpu_jsm_metric_streamer_done
  569. */
  570. VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION = 0x2213,
  571. /** Response to control command: Priority band setup */
  572. VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP = 0x2214,
  573. /** Response to control command: Create command queue */
  574. VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP = 0x2215,
  575. /** Response to control command: Destroy command queue */
  576. VPU_JSM_MSG_DESTROY_CMD_QUEUE_RSP = 0x2216,
  577. /** Response to control command: Set context scheduling properties */
  578. VPU_JSM_MSG_SET_CONTEXT_SCHED_PROPERTIES_RSP = 0x2217,
  579. /** Response to control command: Log buffer setting */
  580. VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP = 0x2218,
  581. /* IPC Device -> Host, HWS notify index entry of log buffer written */
  582. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION = 0x2219,
  583. /* IPC Device -> Host, HWS completion of a context suspend request */
  584. VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE = 0x221a,
  585. /* Response to control command: Resume command queue */
  586. VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP = 0x221b,
  587. /* Response to control command: Resume engine command response */
  588. VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE = 0x221c,
  589. /* Response to control command: Enable survivability/DCT mode */
  590. VPU_JSM_MSG_DCT_ENABLE_DONE = 0x221d,
  591. /* Response to control command: Disable survivability/DCT mode */
  592. VPU_JSM_MSG_DCT_DISABLE_DONE = 0x221e,
  593. /**
  594. * Response to state dump control command.
  595. * NOTE: Please introduce new ASYNC responses before this one. *
  596. */
  597. VPU_JSM_MSG_STATE_DUMP_RSP = 0x22FF,
  598. /* IPC Device -> Host, General command completion */
  599. VPU_JSM_MSG_GENERAL_CMD_DONE = 0x2300,
  600. VPU_JSM_MSG_BLOB_DEINIT_DONE = VPU_JSM_MSG_GENERAL_CMD_DONE,
  601. /** Response to VPU_JSM_MSG_DYNDBG_CONTROL. */
  602. VPU_JSM_MSG_DYNDBG_CONTROL_RSP = 0x2301,
  603. /**
  604. * Acknowledgment of completion of the save procedure initiated by
  605. * VPU_JSM_MSG_PWR_D0I3_ENTER
  606. */
  607. VPU_JSM_MSG_PWR_D0I3_ENTER_DONE = 0x2302,
  608. };
  609. enum vpu_ipc_msg_status { VPU_JSM_MSG_FREE, VPU_JSM_MSG_ALLOCATED };
  610. /*
  611. * Host <-> LRT IPC message payload definitions
  612. */
  613. struct vpu_ipc_msg_payload_engine_reset {
  614. /* Engine to be reset. */
  615. u32 engine_idx;
  616. /* Reserved */
  617. u32 reserved_0;
  618. };
  619. struct vpu_ipc_msg_payload_engine_preempt {
  620. /* Engine to be preempted. */
  621. u32 engine_idx;
  622. /* ID of the preemption request. */
  623. u32 preempt_id;
  624. };
  625. /*
  626. * @brief Register doorbell command structure.
  627. * This structure supports doorbell registration for only OS scheduling.
  628. * @see VPU_JSM_MSG_REGISTER_DB
  629. */
  630. struct vpu_ipc_msg_payload_register_db {
  631. /* Index of the doorbell to register. */
  632. u32 db_idx;
  633. /* Reserved */
  634. u32 reserved_0;
  635. /* Virtual address in Global GTT pointing to the start of job queue. */
  636. u64 jobq_base;
  637. /* Size of the job queue in bytes. */
  638. u32 jobq_size;
  639. /* Host sub-stream ID for the context assigned to the doorbell. */
  640. u32 host_ssid;
  641. };
  642. /**
  643. * @brief Unregister doorbell command structure.
  644. * Request structure to unregister a doorbell for both HW and OS scheduling.
  645. * @see VPU_JSM_MSG_UNREGISTER_DB
  646. */
  647. struct vpu_ipc_msg_payload_unregister_db {
  648. /* Index of the doorbell to unregister. */
  649. u32 db_idx;
  650. /* Reserved */
  651. u32 reserved_0;
  652. };
  653. struct vpu_ipc_msg_payload_query_engine_hb {
  654. /* Engine to return heartbeat value. */
  655. u32 engine_idx;
  656. /* Reserved */
  657. u32 reserved_0;
  658. };
  659. struct vpu_ipc_msg_payload_power_level {
  660. /**
  661. * Requested power level. The power level value is in the
  662. * range [0, power_level_count-1] where power_level_count
  663. * is the number of available power levels as returned by
  664. * the get power level count command. A power level of 0
  665. * corresponds to the maximum possible power level, while
  666. * power_level_count-1 corresponds to the minimum possible
  667. * power level. Values outside of this range are not
  668. * considered to be valid.
  669. */
  670. u32 power_level;
  671. /* Reserved */
  672. u32 reserved_0;
  673. };
  674. struct vpu_ipc_msg_payload_ssid_release {
  675. /* Host sub-stream ID for the context to be released. */
  676. u32 host_ssid;
  677. /* Reserved */
  678. u32 reserved_0;
  679. };
  680. /**
  681. * @brief Metric streamer start command structure.
  682. * This structure is also used with VPU_JSM_MSG_METRIC_STREAMER_INFO to request metric
  683. * groups and metric counters description from the firmware.
  684. * @see VPU_JSM_MSG_METRIC_STREAMER_START
  685. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  686. */
  687. struct vpu_jsm_metric_streamer_start {
  688. /**
  689. * Bitmask to select the desired metric groups.
  690. * A metric group can belong only to one metric streamer instance at a time.
  691. * Since each metric streamer instance has a unique set of metric groups, it
  692. * can also identify a metric streamer instance if more than one instance was
  693. * started. If the VPU device does not support multiple metric streamer instances,
  694. * then VPU_JSM_MSG_METRIC_STREAMER_START will return an error even if the second
  695. * instance has different groups to the first.
  696. */
  697. u64 metric_group_mask;
  698. /** Sampling rate in nanoseconds. */
  699. u64 sampling_rate;
  700. /**
  701. * If > 0 the VPU will send a VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION message
  702. * after every @notify_sample_count samples is collected or dropped by the VPU.
  703. * If set to UINT_MAX the VPU will only generate a notification when the metric
  704. * buffer is full. If set to 0 the VPU will never generate a notification.
  705. */
  706. u32 notify_sample_count;
  707. u32 reserved_0;
  708. /**
  709. * Address and size of the buffer where the VPU will write metric data. The
  710. * VPU writes all counters from enabled metric groups one after another. If
  711. * there is no space left to write data at the next sample period the VPU
  712. * will switch to the next buffer (@see next_buffer_addr) and will optionally
  713. * send a notification to the host driver if @notify_sample_count is non-zero.
  714. * If @next_buffer_addr is NULL the VPU will stop collecting metric data.
  715. */
  716. u64 buffer_addr;
  717. u64 buffer_size;
  718. /**
  719. * Address and size of the next buffer to write metric data to after the initial
  720. * buffer is full. If the address is NULL the VPU will stop collecting metric
  721. * data.
  722. */
  723. u64 next_buffer_addr;
  724. u64 next_buffer_size;
  725. };
  726. /**
  727. * @brief Metric streamer stop command structure.
  728. * @see VPU_JSM_MSG_METRIC_STREAMER_STOP
  729. */
  730. struct vpu_jsm_metric_streamer_stop {
  731. /** Bitmask to select the desired metric groups. */
  732. u64 metric_group_mask;
  733. };
  734. /**
  735. * Provide VPU FW with buffers to write metric data.
  736. * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE
  737. */
  738. struct vpu_jsm_metric_streamer_update {
  739. /** Metric group mask that identifies metric streamer instance. */
  740. u64 metric_group_mask;
  741. /**
  742. * Address and size of the buffer where the VPU will write metric data. If
  743. * the buffer address is 0 or same as the currently used buffer the VPU will
  744. * continue writing metric data to the current buffer. In this case the
  745. * buffer size is ignored and the size of the current buffer is unchanged.
  746. * If the address is non-zero and differs from the current buffer address the
  747. * VPU will immediately switch data collection to the new buffer.
  748. */
  749. u64 buffer_addr;
  750. u64 buffer_size;
  751. /**
  752. * Address and size of the next buffer to write metric data after the initial
  753. * buffer is full. If the address is NULL the VPU will stop collecting metric
  754. * data but will continue to record dropped samples.
  755. *
  756. * Note that there is a hazard possible if both buffer_addr and the next_buffer_addr
  757. * are non-zero in same update request. It is the host's responsibility to ensure
  758. * that both addresses make sense even if the VPU just switched to writing samples
  759. * from the current to the next buffer.
  760. */
  761. u64 next_buffer_addr;
  762. u64 next_buffer_size;
  763. };
  764. struct vpu_ipc_msg_payload_job_done {
  765. /* Engine to which the job was submitted. */
  766. u32 engine_idx;
  767. /* Index of the doorbell to which the job was submitted */
  768. u32 db_idx;
  769. /* ID of the completed job */
  770. u32 job_id;
  771. /* Status of the completed job */
  772. u32 job_status;
  773. /* Host SSID */
  774. u32 host_ssid;
  775. /* Zero Padding */
  776. u32 reserved_0;
  777. /* Command queue id */
  778. u64 cmdq_id;
  779. };
  780. /*
  781. * Notification message upon native fence signalling.
  782. * @see VPU_JSM_MSG_NATIVE_FENCE_SIGNALLED
  783. */
  784. struct vpu_ipc_msg_payload_native_fence_signalled {
  785. /* Engine ID. */
  786. u32 engine_idx;
  787. /* Host SSID. */
  788. u32 host_ssid;
  789. /* CMDQ ID */
  790. u64 cmdq_id;
  791. /* Fence object handle. */
  792. u64 fence_handle;
  793. };
  794. struct vpu_jsm_engine_reset_context {
  795. /* Host SSID */
  796. u32 host_ssid;
  797. /* Zero Padding */
  798. u32 reserved_0;
  799. /* Command queue id */
  800. u64 cmdq_id;
  801. /* See VPU_ENGINE_RESET_CONTEXT_* defines */
  802. u64 flags;
  803. };
  804. struct vpu_ipc_msg_payload_engine_reset_done {
  805. /* Engine ordinal */
  806. u32 engine_idx;
  807. /* Number of impacted contexts */
  808. u32 num_impacted_contexts;
  809. /* Array of impacted command queue ids and their flags */
  810. struct vpu_jsm_engine_reset_context
  811. impacted_contexts[VPU_MAX_ENGINE_RESET_IMPACTED_CONTEXTS];
  812. };
  813. struct vpu_ipc_msg_payload_engine_preempt_done {
  814. /* Engine preempted. */
  815. u32 engine_idx;
  816. /* ID of the preemption request. */
  817. u32 preempt_id;
  818. };
  819. /**
  820. * Response structure for register doorbell command for both OS
  821. * and HW scheduling.
  822. * @see VPU_JSM_MSG_REGISTER_DB
  823. * @see VPU_JSM_MSG_HWS_REGISTER_DB
  824. */
  825. struct vpu_ipc_msg_payload_register_db_done {
  826. /* Index of the registered doorbell. */
  827. u32 db_idx;
  828. /* Reserved */
  829. u32 reserved_0;
  830. };
  831. /**
  832. * Response structure for unregister doorbell command for both OS
  833. * and HW scheduling.
  834. * @see VPU_JSM_MSG_UNREGISTER_DB
  835. */
  836. struct vpu_ipc_msg_payload_unregister_db_done {
  837. /* Index of the unregistered doorbell. */
  838. u32 db_idx;
  839. /* Reserved */
  840. u32 reserved_0;
  841. };
  842. struct vpu_ipc_msg_payload_query_engine_hb_done {
  843. /* Engine returning heartbeat value. */
  844. u32 engine_idx;
  845. /* Reserved */
  846. u32 reserved_0;
  847. /* Heartbeat value. */
  848. u64 heartbeat;
  849. };
  850. struct vpu_ipc_msg_payload_get_power_level_count_done {
  851. /**
  852. * Number of supported power levels. The maximum possible
  853. * value of power_level_count is 16 but this may vary across
  854. * implementations.
  855. */
  856. u32 power_level_count;
  857. /* Reserved */
  858. u32 reserved_0;
  859. /**
  860. * Power consumption limit for each supported power level in
  861. * [0-100%] range relative to power level 0.
  862. */
  863. u8 power_limit[16];
  864. };
  865. /* HWS priority band setup request / response */
  866. struct vpu_ipc_msg_payload_hws_priority_band_setup {
  867. /*
  868. * Grace period in 100ns units when preempting another priority band for
  869. * this priority band
  870. */
  871. u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
  872. /*
  873. * Default quantum in 100ns units for scheduling across processes
  874. * within a priority band
  875. */
  876. u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
  877. /*
  878. * Default grace period in 100ns units for processes that preempt each
  879. * other within a priority band
  880. */
  881. u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
  882. /*
  883. * For normal priority band, specifies the target VPU percentage
  884. * in situations when it's starved by the focus band.
  885. */
  886. u32 normal_band_percentage;
  887. /* Reserved */
  888. u32 reserved_0;
  889. };
  890. /*
  891. * @brief HWS create command queue request.
  892. * Host will create a command queue via this command.
  893. * Note: Cmdq group is a handle of an object which
  894. * may contain one or more command queues.
  895. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
  896. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
  897. */
  898. struct vpu_ipc_msg_payload_hws_create_cmdq {
  899. /* Process id */
  900. u64 process_id;
  901. /* Host SSID */
  902. u32 host_ssid;
  903. /* Engine for which queue is being created */
  904. u32 engine_idx;
  905. /* Cmdq group: only used for HWS logging of state changes */
  906. u64 cmdq_group;
  907. /* Command queue id */
  908. u64 cmdq_id;
  909. /* Command queue base */
  910. u64 cmdq_base;
  911. /* Command queue size */
  912. u32 cmdq_size;
  913. /* Zero padding */
  914. u32 reserved_0;
  915. };
  916. /*
  917. * @brief HWS create command queue response.
  918. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE
  919. * @see VPU_JSM_MSG_CREATE_CMD_QUEUE_RSP
  920. */
  921. struct vpu_ipc_msg_payload_hws_create_cmdq_rsp {
  922. /* Process id */
  923. u64 process_id;
  924. /* Host SSID */
  925. u32 host_ssid;
  926. /* Engine for which queue is being created */
  927. u32 engine_idx;
  928. /* Command queue group */
  929. u64 cmdq_group;
  930. /* Command queue id */
  931. u64 cmdq_id;
  932. };
  933. /* HWS destroy command queue request / response */
  934. struct vpu_ipc_msg_payload_hws_destroy_cmdq {
  935. /* Host SSID */
  936. u32 host_ssid;
  937. /* Zero Padding */
  938. u32 reserved;
  939. /* Command queue id */
  940. u64 cmdq_id;
  941. };
  942. /* HWS set context scheduling properties request / response */
  943. struct vpu_ipc_msg_payload_hws_set_context_sched_properties {
  944. /* Host SSID */
  945. u32 host_ssid;
  946. /* Zero Padding */
  947. u32 reserved_0;
  948. /* Command queue id */
  949. u64 cmdq_id;
  950. /*
  951. * Priority band to assign to work of this context.
  952. * Available priority bands: @see enum vpu_job_scheduling_priority_band
  953. */
  954. u32 priority_band;
  955. /* Inside realtime band assigns a further priority */
  956. u32 realtime_priority_level;
  957. /* Priority relative to other contexts in the same process */
  958. s32 in_process_priority;
  959. /* Zero padding / Reserved */
  960. u32 reserved_1;
  961. /* Context quantum relative to other contexts of same priority in the same process */
  962. u64 context_quantum;
  963. /* Grace period when preempting context of the same priority within the same process */
  964. u64 grace_period_same_priority;
  965. /* Grace period when preempting context of a lower priority within the same process */
  966. u64 grace_period_lower_priority;
  967. };
  968. /*
  969. * @brief Register doorbell command structure.
  970. * This structure supports doorbell registration for both HW and OS scheduling.
  971. * Note: Queue base and size are added here so that the same structure can be used for
  972. * OS scheduling and HW scheduling. For OS scheduling, cmdq_id will be ignored
  973. * and cmdq_base and cmdq_size will be used. For HW scheduling, cmdq_base and cmdq_size will be
  974. * ignored and cmdq_id is used.
  975. * @see VPU_JSM_MSG_HWS_REGISTER_DB
  976. */
  977. struct vpu_jsm_hws_register_db {
  978. /* Index of the doorbell to register. */
  979. u32 db_id;
  980. /* Host sub-stream ID for the context assigned to the doorbell. */
  981. u32 host_ssid;
  982. /* ID of the command queue associated with the doorbell. */
  983. u64 cmdq_id;
  984. /* Virtual address pointing to the start of command queue. */
  985. u64 cmdq_base;
  986. /* Size of the command queue in bytes. */
  987. u64 cmdq_size;
  988. };
  989. /*
  990. * @brief Structure to set another buffer to be used for scheduling-related logging.
  991. * The size of the logging buffer and the number of entries is defined as part of the
  992. * buffer itself as described next.
  993. * The log buffer received from the host is made up of;
  994. * - header: 32 bytes in size, as shown in 'struct vpu_hws_log_buffer_header'.
  995. * The header contains the number of log entries in the buffer.
  996. * - log entry: 0 to n-1, each log entry is 32 bytes in size, as shown in
  997. * 'struct vpu_hws_log_buffer_entry'.
  998. * The entry contains the VPU timestamp, operation type and data.
  999. * The host should provide the notify index value of log buffer to VPU. This is a
  1000. * value defined within the log buffer and when written to will generate the
  1001. * scheduling log notification.
  1002. * The host should set engine_idx and vpu_log_buffer_va to 0 to disable logging
  1003. * for a particular engine.
  1004. * VPU will handle one log buffer for each of supported engines.
  1005. * VPU should allow the logging to consume one host_ssid.
  1006. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
  1007. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP
  1008. * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  1009. */
  1010. struct vpu_ipc_msg_payload_hws_set_scheduling_log {
  1011. /* Engine ordinal */
  1012. u32 engine_idx;
  1013. /* Host SSID */
  1014. u32 host_ssid;
  1015. /*
  1016. * VPU log buffer virtual address.
  1017. * Set to 0 to disable logging for this engine.
  1018. */
  1019. u64 vpu_log_buffer_va;
  1020. /*
  1021. * Notify index of log buffer. VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  1022. * is generated when an event log is written to this index.
  1023. */
  1024. u64 notify_index;
  1025. /*
  1026. * Field is now deprecated, will be removed when KMD is updated to support removal
  1027. */
  1028. u32 enable_extra_events;
  1029. /* Zero Padding */
  1030. u32 reserved_0;
  1031. };
  1032. /*
  1033. * @brief The scheduling log notification is generated by VPU when it writes
  1034. * an event into the log buffer at the notify_index. VPU notifies host with
  1035. * VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION. This is an asynchronous
  1036. * message from VPU to host.
  1037. * @see VPU_JSM_MSG_HWS_SCHEDULING_LOG_NOTIFICATION
  1038. * @see VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG
  1039. */
  1040. struct vpu_ipc_msg_payload_hws_scheduling_log_notification {
  1041. /* Engine ordinal */
  1042. u32 engine_idx;
  1043. /* Zero Padding */
  1044. u32 reserved_0;
  1045. };
  1046. /*
  1047. * @brief HWS suspend command queue request and done structure.
  1048. * Host will request the suspend of contexts and VPU will;
  1049. * - Suspend all work on this context
  1050. * - Preempt any running work
  1051. * - Asynchronously perform the above and return success immediately once
  1052. * all items above are started successfully
  1053. * - Notify the host of completion of these operations via
  1054. * VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
  1055. * - Reject any other context operations on a context with an in-flight
  1056. * suspend request running
  1057. * Same structure used when VPU notifies host of completion of a context suspend
  1058. * request. The ids and suspend fence value reported in this command will match
  1059. * the one in the request from the host to suspend the context. Once suspend is
  1060. * complete, VPU will not access any data relating to this command queue until
  1061. * it is resumed.
  1062. * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ
  1063. * @see VPU_JSM_MSG_HWS_SUSPEND_CMDQ_DONE
  1064. */
  1065. struct vpu_ipc_msg_payload_hws_suspend_cmdq {
  1066. /* Host SSID */
  1067. u32 host_ssid;
  1068. /* Zero Padding */
  1069. u32 reserved_0;
  1070. /* Command queue id */
  1071. u64 cmdq_id;
  1072. /*
  1073. * Suspend fence value - reported by the VPU suspend context
  1074. * completed once suspend is complete.
  1075. */
  1076. u64 suspend_fence_value;
  1077. };
  1078. /*
  1079. * @brief HWS Resume command queue request / response structure.
  1080. * Host will request the resume of a context;
  1081. * - VPU will resume all work on this context
  1082. * - Scheduler will allow this context to be scheduled
  1083. * @see VPU_JSM_MSG_HWS_RESUME_CMDQ
  1084. * @see VPU_JSM_MSG_HWS_RESUME_CMDQ_RSP
  1085. */
  1086. struct vpu_ipc_msg_payload_hws_resume_cmdq {
  1087. /* Host SSID */
  1088. u32 host_ssid;
  1089. /* Zero Padding */
  1090. u32 reserved_0;
  1091. /* Command queue id */
  1092. u64 cmdq_id;
  1093. };
  1094. /*
  1095. * @brief HWS Resume engine request / response structure.
  1096. * After a HWS engine reset, all scheduling is stopped on VPU until a engine resume.
  1097. * Host shall send this command to resume scheduling of any valid queue.
  1098. * @see VPU_JSM_MSG_HWS_RESUME_ENGINE
  1099. * @see VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE
  1100. */
  1101. struct vpu_ipc_msg_payload_hws_resume_engine {
  1102. /* Engine to be resumed */
  1103. u32 engine_idx;
  1104. /* Reserved */
  1105. u32 reserved_0;
  1106. };
  1107. /**
  1108. * Payload for VPU_JSM_MSG_TRACE_SET_CONFIG[_RSP] and
  1109. * VPU_JSM_MSG_TRACE_GET_CONFIG_RSP messages.
  1110. *
  1111. * The payload is interpreted differently depending on the type of message:
  1112. *
  1113. * - For VPU_JSM_MSG_TRACE_SET_CONFIG, the payload specifies the desired
  1114. * logging configuration to be set.
  1115. *
  1116. * - For VPU_JSM_MSG_TRACE_SET_CONFIG_RSP, the payload reports the logging
  1117. * configuration that was set after a VPU_JSM_MSG_TRACE_SET_CONFIG request.
  1118. * The host can compare this payload with the one it sent in the
  1119. * VPU_JSM_MSG_TRACE_SET_CONFIG request to check whether or not the
  1120. * configuration was set as desired.
  1121. *
  1122. * - VPU_JSM_MSG_TRACE_GET_CONFIG_RSP, the payload reports the current logging
  1123. * configuration.
  1124. */
  1125. struct vpu_ipc_msg_payload_trace_config {
  1126. /**
  1127. * Logging level (currently set or to be set); see 'mvLog_t' enum for
  1128. * acceptable values. The specified logging level applies to all
  1129. * destinations and HW components
  1130. */
  1131. u32 trace_level;
  1132. /**
  1133. * Bitmask of logging destinations (currently enabled or to be enabled);
  1134. * bitwise OR of values defined in logging_destination enum.
  1135. */
  1136. u32 trace_destination_mask;
  1137. /**
  1138. * Bitmask of loggable HW components (currently enabled or to be enabled);
  1139. * bitwise OR of values defined in loggable_hw_component enum.
  1140. */
  1141. u64 trace_hw_component_mask;
  1142. u64 reserved_0; /**< Reserved for future extensions. */
  1143. };
  1144. /**
  1145. * Payload for VPU_JSM_MSG_TRACE_GET_CAPABILITY_RSP messages.
  1146. */
  1147. struct vpu_ipc_msg_payload_trace_capability_rsp {
  1148. u32 trace_destination_mask; /**< Bitmask of supported logging destinations. */
  1149. u32 reserved_0;
  1150. u64 trace_hw_component_mask; /**< Bitmask of supported loggable HW components. */
  1151. u64 reserved_1; /**< Reserved for future extensions. */
  1152. };
  1153. /**
  1154. * Payload for VPU_JSM_MSG_TRACE_GET_NAME requests.
  1155. */
  1156. struct vpu_ipc_msg_payload_trace_get_name {
  1157. /**
  1158. * The type of the entity to query name for; see logging_entity_type for
  1159. * possible values.
  1160. */
  1161. u32 entity_type;
  1162. u32 reserved_0;
  1163. /**
  1164. * The ID of the entity to query name for; possible values depends on the
  1165. * entity type.
  1166. */
  1167. u64 entity_id;
  1168. };
  1169. /**
  1170. * Payload for VPU_JSM_MSG_TRACE_GET_NAME_RSP responses.
  1171. */
  1172. struct vpu_ipc_msg_payload_trace_get_name_rsp {
  1173. /**
  1174. * The type of the entity whose name was queried; see logging_entity_type
  1175. * for possible values.
  1176. */
  1177. u32 entity_type;
  1178. u32 reserved_0;
  1179. /**
  1180. * The ID of the entity whose name was queried; possible values depends on
  1181. * the entity type.
  1182. */
  1183. u64 entity_id;
  1184. /** Reserved for future extensions. */
  1185. u64 reserved_1;
  1186. /** The name of the entity. */
  1187. char entity_name[VPU_TRACE_ENTITY_NAME_MAX_LEN];
  1188. };
  1189. /**
  1190. * Data sent from the VPU to the host in all metric streamer response messages
  1191. * and in asynchronous notification.
  1192. * @see VPU_JSM_MSG_METRIC_STREAMER_START_DONE
  1193. * @see VPU_JSM_MSG_METRIC_STREAMER_STOP_DONE
  1194. * @see VPU_JSM_MSG_METRIC_STREAMER_UPDATE_DONE
  1195. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO_DONE
  1196. * @see VPU_JSM_MSG_METRIC_STREAMER_NOTIFICATION
  1197. */
  1198. struct vpu_jsm_metric_streamer_done {
  1199. /** Metric group mask that identifies metric streamer instance. */
  1200. u64 metric_group_mask;
  1201. /**
  1202. * Size in bytes of single sample - total size of all enabled counters.
  1203. * Some VPU implementations may align sample_size to more than 8 bytes.
  1204. */
  1205. u32 sample_size;
  1206. u32 reserved_0;
  1207. /**
  1208. * Number of samples collected since the metric streamer was started.
  1209. * This will be 0 if the metric streamer was not started.
  1210. */
  1211. u32 samples_collected;
  1212. /**
  1213. * Number of samples dropped since the metric streamer was started. This
  1214. * is incremented every time the metric streamer is not able to write
  1215. * collected samples because the current buffer is full and there is no
  1216. * next buffer to switch to.
  1217. */
  1218. u32 samples_dropped;
  1219. /** Address of the buffer that contains the latest metric data. */
  1220. u64 buffer_addr;
  1221. /**
  1222. * Number of bytes written into the metric data buffer. In response to the
  1223. * VPU_JSM_MSG_METRIC_STREAMER_INFO request this field contains the size of
  1224. * all group and counter descriptors. The size is updated even if the buffer
  1225. * in the request was NULL or too small to hold descriptors of all counters
  1226. */
  1227. u64 bytes_written;
  1228. };
  1229. /**
  1230. * Metric group description placed in the metric buffer after successful completion
  1231. * of the VPU_JSM_MSG_METRIC_STREAMER_INFO command. This is followed by one or more
  1232. * @vpu_jsm_metric_counter_descriptor records.
  1233. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  1234. */
  1235. struct vpu_jsm_metric_group_descriptor {
  1236. /**
  1237. * Offset to the next metric group (8-byte aligned). If this offset is 0 this
  1238. * is the last descriptor. The value of metric_info_size must be greater than
  1239. * or equal to sizeof(struct vpu_jsm_metric_group_descriptor) + name_string_size
  1240. * + description_string_size and must be 8-byte aligned.
  1241. */
  1242. u32 next_metric_group_info_offset;
  1243. /**
  1244. * Offset to the first metric counter description record (8-byte aligned).
  1245. * @see vpu_jsm_metric_counter_descriptor
  1246. */
  1247. u32 next_metric_counter_info_offset;
  1248. /** Index of the group. This corresponds to bit index in metric_group_mask. */
  1249. u32 group_id;
  1250. /** Number of counters in the metric group. */
  1251. u32 num_counters;
  1252. /** Data size for all counters, must be a multiple of 8 bytes.*/
  1253. u32 metric_group_data_size;
  1254. /**
  1255. * Metric group domain number. Cannot use multiple, simultaneous metric groups
  1256. * from the same domain.
  1257. */
  1258. u32 domain;
  1259. /**
  1260. * Counter name string size. The string must include a null termination character.
  1261. * The FW may use a fixed size name or send a different name for each counter.
  1262. * If the VPU uses fixed size strings, all characters from the end of the name
  1263. * to the of the fixed size character array must be zeroed.
  1264. */
  1265. u32 name_string_size;
  1266. /** Counter description string size, @see name_string_size */
  1267. u32 description_string_size;
  1268. u64 reserved_0;
  1269. /**
  1270. * Right after this structure, the VPU writes name and description of
  1271. * the metric group.
  1272. */
  1273. };
  1274. /**
  1275. * Metric counter description, placed in the buffer after vpu_jsm_metric_group_descriptor.
  1276. * @see VPU_JSM_MSG_METRIC_STREAMER_INFO
  1277. */
  1278. struct vpu_jsm_metric_counter_descriptor {
  1279. /**
  1280. * Offset to the next counter in a group (8-byte aligned). If this offset is
  1281. * 0 this is the last counter in the group.
  1282. */
  1283. u32 next_metric_counter_info_offset;
  1284. /**
  1285. * Offset to the counter data from the start of samples in this metric group.
  1286. * Note that metric_data_offset % metric_data_size must be 0.
  1287. */
  1288. u32 metric_data_offset;
  1289. /** Size of the metric counter data in bytes. */
  1290. u32 metric_data_size;
  1291. /** Metric type, see Level Zero API for definitions. */
  1292. u32 tier;
  1293. /** Metric type, see set_metric_type_t for definitions. */
  1294. u32 metric_type;
  1295. /** Metric type, see set_value_type_t for definitions. */
  1296. u32 metric_value_type;
  1297. /**
  1298. * Counter name string size. The string must include a null termination character.
  1299. * The FW may use a fixed size name or send a different name for each counter.
  1300. * If the VPU uses fixed size strings, all characters from the end of the name
  1301. * to the of the fixed size character array must be zeroed.
  1302. */
  1303. u32 name_string_size;
  1304. /** Counter description string size, @see name_string_size */
  1305. u32 description_string_size;
  1306. /** Counter component name string size, @see name_string_size */
  1307. u32 component_string_size;
  1308. /** Counter string size, @see name_string_size */
  1309. u32 units_string_size;
  1310. u64 reserved_0;
  1311. /**
  1312. * Right after this structure, the VPU writes name, description
  1313. * component and unit strings.
  1314. */
  1315. };
  1316. /**
  1317. * Payload for VPU_JSM_MSG_DYNDBG_CONTROL requests.
  1318. *
  1319. * VPU_JSM_MSG_DYNDBG_CONTROL are used to control the VPU FW Dynamic Debug
  1320. * feature, which allows developers to selectively enable / disable MVLOG_DEBUG
  1321. * messages. This is equivalent to the Dynamic Debug functionality provided by
  1322. * Linux
  1323. * (https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html)
  1324. * The host can control Dynamic Debug behavior by sending dyndbg commands, which
  1325. * have the same syntax as Linux
  1326. * dyndbg commands.
  1327. *
  1328. * NOTE: in order for MVLOG_DEBUG messages to be actually printed, the host
  1329. * still has to set the logging level to MVLOG_DEBUG, using the
  1330. * VPU_JSM_MSG_TRACE_SET_CONFIG command.
  1331. *
  1332. * The host can see the current dynamic debug configuration by executing a
  1333. * special 'show' command. The dyndbg configuration will be printed to the
  1334. * configured logging destination using MVLOG_INFO logging level.
  1335. */
  1336. struct vpu_ipc_msg_payload_dyndbg_control {
  1337. /**
  1338. * Dyndbg command (same format as Linux dyndbg); must be a NULL-terminated
  1339. * string.
  1340. */
  1341. char dyndbg_cmd[VPU_DYNDBG_CMD_MAX_LEN];
  1342. };
  1343. /**
  1344. * Payload for VPU_JSM_MSG_PWR_D0I3_ENTER
  1345. *
  1346. * This is a bi-directional payload.
  1347. */
  1348. struct vpu_ipc_msg_payload_pwr_d0i3_enter {
  1349. /**
  1350. * 0: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is not sent to the host driver
  1351. * The driver will poll for D0i2 Idle state transitions.
  1352. * 1: VPU_JSM_MSG_PWR_D0I3_ENTER_DONE is sent after VPU state save is complete
  1353. */
  1354. u32 send_response;
  1355. u32 reserved_0;
  1356. };
  1357. /**
  1358. * Payload for VPU_JSM_MSG_DCT_ENABLE message.
  1359. *
  1360. * Default values for DCT active/inactive times are 5.3ms and 30ms respectively,
  1361. * corresponding to a 85% duty cycle. This payload allows the host to tune these
  1362. * values according to application requirements.
  1363. */
  1364. struct vpu_ipc_msg_payload_pwr_dct_control {
  1365. /** Duty cycle active time in microseconds */
  1366. u32 dct_active_us;
  1367. /** Duty cycle inactive time in microseconds */
  1368. u32 dct_inactive_us;
  1369. };
  1370. /*
  1371. * Payloads union, used to define complete message format.
  1372. */
  1373. union vpu_ipc_msg_payload {
  1374. struct vpu_ipc_msg_payload_engine_reset engine_reset;
  1375. struct vpu_ipc_msg_payload_engine_preempt engine_preempt;
  1376. struct vpu_ipc_msg_payload_register_db register_db;
  1377. struct vpu_ipc_msg_payload_unregister_db unregister_db;
  1378. struct vpu_ipc_msg_payload_query_engine_hb query_engine_hb;
  1379. struct vpu_ipc_msg_payload_power_level power_level;
  1380. struct vpu_jsm_metric_streamer_start metric_streamer_start;
  1381. struct vpu_jsm_metric_streamer_stop metric_streamer_stop;
  1382. struct vpu_jsm_metric_streamer_update metric_streamer_update;
  1383. struct vpu_ipc_msg_payload_ssid_release ssid_release;
  1384. struct vpu_jsm_hws_register_db hws_register_db;
  1385. struct vpu_ipc_msg_payload_job_done job_done;
  1386. struct vpu_ipc_msg_payload_native_fence_signalled native_fence_signalled;
  1387. struct vpu_ipc_msg_payload_engine_reset_done engine_reset_done;
  1388. struct vpu_ipc_msg_payload_engine_preempt_done engine_preempt_done;
  1389. struct vpu_ipc_msg_payload_register_db_done register_db_done;
  1390. struct vpu_ipc_msg_payload_unregister_db_done unregister_db_done;
  1391. struct vpu_ipc_msg_payload_query_engine_hb_done query_engine_hb_done;
  1392. struct vpu_ipc_msg_payload_get_power_level_count_done get_power_level_count_done;
  1393. struct vpu_jsm_metric_streamer_done metric_streamer_done;
  1394. struct vpu_ipc_msg_payload_trace_config trace_config;
  1395. struct vpu_ipc_msg_payload_trace_capability_rsp trace_capability;
  1396. struct vpu_ipc_msg_payload_trace_get_name trace_get_name;
  1397. struct vpu_ipc_msg_payload_trace_get_name_rsp trace_get_name_rsp;
  1398. struct vpu_ipc_msg_payload_dyndbg_control dyndbg_control;
  1399. struct vpu_ipc_msg_payload_hws_priority_band_setup hws_priority_band_setup;
  1400. struct vpu_ipc_msg_payload_hws_create_cmdq hws_create_cmdq;
  1401. struct vpu_ipc_msg_payload_hws_create_cmdq_rsp hws_create_cmdq_rsp;
  1402. struct vpu_ipc_msg_payload_hws_destroy_cmdq hws_destroy_cmdq;
  1403. struct vpu_ipc_msg_payload_hws_set_context_sched_properties
  1404. hws_set_context_sched_properties;
  1405. struct vpu_ipc_msg_payload_hws_set_scheduling_log hws_set_scheduling_log;
  1406. struct vpu_ipc_msg_payload_hws_scheduling_log_notification hws_scheduling_log_notification;
  1407. struct vpu_ipc_msg_payload_hws_suspend_cmdq hws_suspend_cmdq;
  1408. struct vpu_ipc_msg_payload_hws_resume_cmdq hws_resume_cmdq;
  1409. struct vpu_ipc_msg_payload_hws_resume_engine hws_resume_engine;
  1410. struct vpu_ipc_msg_payload_pwr_d0i3_enter pwr_d0i3_enter;
  1411. struct vpu_ipc_msg_payload_pwr_dct_control pwr_dct_control;
  1412. };
  1413. /*
  1414. * Host <-> LRT IPC message base structure.
  1415. *
  1416. * NOTE: All instances of this object must be aligned on a 64B boundary
  1417. * to allow proper handling of VPU cache operations.
  1418. */
  1419. struct vpu_jsm_msg {
  1420. /* Reserved */
  1421. u64 reserved_0;
  1422. /* Message type, see vpu_ipc_msg_type enum. */
  1423. u32 type;
  1424. /* Buffer status, see vpu_ipc_msg_status enum. */
  1425. u32 status;
  1426. /*
  1427. * Request ID, provided by the host in a request message and passed
  1428. * back by VPU in the response message.
  1429. */
  1430. u32 request_id;
  1431. /* Request return code set by the VPU, see VPU_JSM_STATUS_* defines. */
  1432. u32 result;
  1433. u64 reserved_1;
  1434. /* Message payload depending on message type, see vpu_ipc_msg_payload union. */
  1435. union vpu_ipc_msg_payload payload;
  1436. };
  1437. #pragma pack(pop)
  1438. #endif
  1439. ///@}