amdxdna_accel.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (C) 2022-2024, Advanced Micro Devices, Inc.
  4. */
  5. #ifndef _AMDXDNA_ACCEL_H_
  6. #define _AMDXDNA_ACCEL_H_
  7. #include <linux/stddef.h>
  8. #include "drm.h"
  9. #if defined(__cplusplus)
  10. extern "C" {
  11. #endif
  12. #define AMDXDNA_INVALID_CMD_HANDLE (~0UL)
  13. #define AMDXDNA_INVALID_ADDR (~0UL)
  14. #define AMDXDNA_INVALID_CTX_HANDLE 0
  15. #define AMDXDNA_INVALID_BO_HANDLE 0
  16. #define AMDXDNA_INVALID_FENCE_HANDLE 0
  17. /*
  18. * Define hardware context priority
  19. */
  20. #define AMDXDNA_QOS_REALTIME_PRIORITY 0x100
  21. #define AMDXDNA_QOS_HIGH_PRIORITY 0x180
  22. #define AMDXDNA_QOS_NORMAL_PRIORITY 0x200
  23. #define AMDXDNA_QOS_LOW_PRIORITY 0x280
  24. enum amdxdna_device_type {
  25. AMDXDNA_DEV_TYPE_UNKNOWN = -1,
  26. AMDXDNA_DEV_TYPE_KMQ,
  27. };
  28. enum amdxdna_drm_ioctl_id {
  29. DRM_AMDXDNA_CREATE_HWCTX,
  30. DRM_AMDXDNA_DESTROY_HWCTX,
  31. DRM_AMDXDNA_CONFIG_HWCTX,
  32. DRM_AMDXDNA_CREATE_BO,
  33. DRM_AMDXDNA_GET_BO_INFO,
  34. DRM_AMDXDNA_SYNC_BO,
  35. DRM_AMDXDNA_EXEC_CMD,
  36. DRM_AMDXDNA_GET_INFO,
  37. DRM_AMDXDNA_SET_STATE,
  38. DRM_AMDXDNA_GET_ARRAY = 10,
  39. };
  40. /**
  41. * struct qos_info - QoS information for driver.
  42. * @gops: Giga operations per second.
  43. * @fps: Frames per second.
  44. * @dma_bandwidth: DMA bandwidtha.
  45. * @latency: Frame response latency.
  46. * @frame_exec_time: Frame execution time.
  47. * @priority: Request priority.
  48. *
  49. * User program can provide QoS hints to driver.
  50. */
  51. struct amdxdna_qos_info {
  52. __u32 gops;
  53. __u32 fps;
  54. __u32 dma_bandwidth;
  55. __u32 latency;
  56. __u32 frame_exec_time;
  57. __u32 priority;
  58. };
  59. /**
  60. * struct amdxdna_drm_create_hwctx - Create hardware context.
  61. * @ext: MBZ.
  62. * @ext_flags: MBZ.
  63. * @qos_p: Address of QoS info.
  64. * @umq_bo: BO handle for user mode queue(UMQ).
  65. * @log_buf_bo: BO handle for log buffer.
  66. * @max_opc: Maximum operations per cycle.
  67. * @num_tiles: Number of AIE tiles.
  68. * @mem_size: Size of AIE tile memory.
  69. * @umq_doorbell: Returned offset of doorbell associated with UMQ.
  70. * @handle: Returned hardware context handle.
  71. * @syncobj_handle: Returned syncobj handle for command completion.
  72. */
  73. struct amdxdna_drm_create_hwctx {
  74. __u64 ext;
  75. __u64 ext_flags;
  76. __u64 qos_p;
  77. __u32 umq_bo;
  78. __u32 log_buf_bo;
  79. __u32 max_opc;
  80. __u32 num_tiles;
  81. __u32 mem_size;
  82. __u32 umq_doorbell;
  83. __u32 handle;
  84. __u32 syncobj_handle;
  85. };
  86. /**
  87. * struct amdxdna_drm_destroy_hwctx - Destroy hardware context.
  88. * @handle: Hardware context handle.
  89. * @pad: MBZ.
  90. */
  91. struct amdxdna_drm_destroy_hwctx {
  92. __u32 handle;
  93. __u32 pad;
  94. };
  95. /**
  96. * struct amdxdna_cu_config - configuration for one CU
  97. * @cu_bo: CU configuration buffer bo handle.
  98. * @cu_func: Function of a CU.
  99. * @pad: MBZ.
  100. */
  101. struct amdxdna_cu_config {
  102. __u32 cu_bo;
  103. __u8 cu_func;
  104. __u8 pad[3];
  105. };
  106. /**
  107. * struct amdxdna_hwctx_param_config_cu - configuration for CUs in hardware context
  108. * @num_cus: Number of CUs to configure.
  109. * @pad: MBZ.
  110. * @cu_configs: Array of CU configurations of struct amdxdna_cu_config.
  111. */
  112. struct amdxdna_hwctx_param_config_cu {
  113. __u16 num_cus;
  114. __u16 pad[3];
  115. struct amdxdna_cu_config cu_configs[] __counted_by(num_cus);
  116. };
  117. enum amdxdna_drm_config_hwctx_param {
  118. DRM_AMDXDNA_HWCTX_CONFIG_CU,
  119. DRM_AMDXDNA_HWCTX_ASSIGN_DBG_BUF,
  120. DRM_AMDXDNA_HWCTX_REMOVE_DBG_BUF,
  121. };
  122. /**
  123. * struct amdxdna_drm_config_hwctx - Configure hardware context.
  124. * @handle: hardware context handle.
  125. * @param_type: Value in enum amdxdna_drm_config_hwctx_param. Specifies the
  126. * structure passed in via param_val.
  127. * @param_val: A structure specified by the param_type struct member.
  128. * @param_val_size: Size of the parameter buffer pointed to by the param_val.
  129. * If param_val is not a pointer, driver can ignore this.
  130. * @pad: MBZ.
  131. *
  132. * Note: if the param_val is a pointer pointing to a buffer, the maximum size
  133. * of the buffer is 4KiB(PAGE_SIZE).
  134. */
  135. struct amdxdna_drm_config_hwctx {
  136. __u32 handle;
  137. __u32 param_type;
  138. __u64 param_val;
  139. __u32 param_val_size;
  140. __u32 pad;
  141. };
  142. enum amdxdna_bo_type {
  143. AMDXDNA_BO_INVALID = 0,
  144. AMDXDNA_BO_SHMEM,
  145. AMDXDNA_BO_DEV_HEAP,
  146. AMDXDNA_BO_DEV,
  147. AMDXDNA_BO_CMD,
  148. };
  149. /**
  150. * struct amdxdna_drm_va_entry
  151. * @vaddr: Virtual address.
  152. * @len: Size of entry.
  153. */
  154. struct amdxdna_drm_va_entry {
  155. __u64 vaddr;
  156. __u64 len;
  157. };
  158. /**
  159. * struct amdxdna_drm_va_tbl
  160. * @dmabuf_fd: The fd of dmabuf.
  161. * @num_entries: Number of va entries.
  162. * @va_entries: Array of va entries.
  163. *
  164. * The input can be either a dmabuf fd or a virtual address entry table.
  165. * When dmabuf_fd is used, num_entries must be zero.
  166. */
  167. struct amdxdna_drm_va_tbl {
  168. __s32 dmabuf_fd;
  169. __u32 num_entries;
  170. struct amdxdna_drm_va_entry va_entries[];
  171. };
  172. /**
  173. * struct amdxdna_drm_create_bo - Create a buffer object.
  174. * @flags: Buffer flags. MBZ.
  175. * @vaddr: User VA of buffer if applied. MBZ.
  176. * @size: Size in bytes.
  177. * @type: Buffer type.
  178. * @handle: Returned DRM buffer object handle.
  179. */
  180. struct amdxdna_drm_create_bo {
  181. __u64 flags;
  182. __u64 vaddr;
  183. __u64 size;
  184. __u32 type;
  185. __u32 handle;
  186. };
  187. /**
  188. * struct amdxdna_drm_get_bo_info - Get buffer object information.
  189. * @ext: MBZ.
  190. * @ext_flags: MBZ.
  191. * @handle: DRM buffer object handle.
  192. * @pad: MBZ.
  193. * @map_offset: Returned DRM fake offset for mmap().
  194. * @vaddr: Returned user VA of buffer. 0 in case user needs mmap().
  195. * @xdna_addr: Returned XDNA device virtual address.
  196. */
  197. struct amdxdna_drm_get_bo_info {
  198. __u64 ext;
  199. __u64 ext_flags;
  200. __u32 handle;
  201. __u32 pad;
  202. __u64 map_offset;
  203. __u64 vaddr;
  204. __u64 xdna_addr;
  205. };
  206. /**
  207. * struct amdxdna_drm_sync_bo - Sync buffer object.
  208. * @handle: Buffer object handle.
  209. * @direction: Direction of sync, can be from device or to device.
  210. * @offset: Offset in the buffer to sync.
  211. * @size: Size in bytes.
  212. */
  213. struct amdxdna_drm_sync_bo {
  214. __u32 handle;
  215. #define SYNC_DIRECT_TO_DEVICE 0U
  216. #define SYNC_DIRECT_FROM_DEVICE 1U
  217. __u32 direction;
  218. __u64 offset;
  219. __u64 size;
  220. };
  221. enum amdxdna_cmd_type {
  222. AMDXDNA_CMD_SUBMIT_EXEC_BUF = 0,
  223. AMDXDNA_CMD_SUBMIT_DEPENDENCY,
  224. AMDXDNA_CMD_SUBMIT_SIGNAL,
  225. };
  226. /**
  227. * struct amdxdna_drm_exec_cmd - Execute command.
  228. * @ext: MBZ.
  229. * @ext_flags: MBZ.
  230. * @hwctx: Hardware context handle.
  231. * @type: One of command type in enum amdxdna_cmd_type.
  232. * @cmd_handles: Array of command handles or the command handle itself
  233. * in case of just one.
  234. * @args: Array of arguments for all command handles.
  235. * @cmd_count: Number of command handles in the cmd_handles array.
  236. * @arg_count: Number of arguments in the args array.
  237. * @seq: Returned sequence number for this command.
  238. */
  239. struct amdxdna_drm_exec_cmd {
  240. __u64 ext;
  241. __u64 ext_flags;
  242. __u32 hwctx;
  243. __u32 type;
  244. __u64 cmd_handles;
  245. __u64 args;
  246. __u32 cmd_count;
  247. __u32 arg_count;
  248. __u64 seq;
  249. };
  250. /**
  251. * struct amdxdna_drm_query_aie_status - Query the status of the AIE hardware
  252. * @buffer: The user space buffer that will return the AIE status.
  253. * @buffer_size: The size of the user space buffer.
  254. * @cols_filled: A bitmap of AIE columns whose data has been returned in the buffer.
  255. */
  256. struct amdxdna_drm_query_aie_status {
  257. __u64 buffer; /* out */
  258. __u32 buffer_size; /* in */
  259. __u32 cols_filled; /* out */
  260. };
  261. /**
  262. * struct amdxdna_drm_query_aie_version - Query the version of the AIE hardware
  263. * @major: The major version number.
  264. * @minor: The minor version number.
  265. */
  266. struct amdxdna_drm_query_aie_version {
  267. __u32 major; /* out */
  268. __u32 minor; /* out */
  269. };
  270. /**
  271. * struct amdxdna_drm_query_aie_tile_metadata - Query the metadata of AIE tile (core, mem, shim)
  272. * @row_count: The number of rows.
  273. * @row_start: The starting row number.
  274. * @dma_channel_count: The number of dma channels.
  275. * @lock_count: The number of locks.
  276. * @event_reg_count: The number of events.
  277. * @pad: Structure padding.
  278. */
  279. struct amdxdna_drm_query_aie_tile_metadata {
  280. __u16 row_count;
  281. __u16 row_start;
  282. __u16 dma_channel_count;
  283. __u16 lock_count;
  284. __u16 event_reg_count;
  285. __u16 pad[3];
  286. };
  287. /**
  288. * struct amdxdna_drm_query_aie_metadata - Query the metadata of the AIE hardware
  289. * @col_size: The size of a column in bytes.
  290. * @cols: The total number of columns.
  291. * @rows: The total number of rows.
  292. * @version: The version of the AIE hardware.
  293. * @core: The metadata for all core tiles.
  294. * @mem: The metadata for all mem tiles.
  295. * @shim: The metadata for all shim tiles.
  296. */
  297. struct amdxdna_drm_query_aie_metadata {
  298. __u32 col_size;
  299. __u16 cols;
  300. __u16 rows;
  301. struct amdxdna_drm_query_aie_version version;
  302. struct amdxdna_drm_query_aie_tile_metadata core;
  303. struct amdxdna_drm_query_aie_tile_metadata mem;
  304. struct amdxdna_drm_query_aie_tile_metadata shim;
  305. };
  306. /**
  307. * struct amdxdna_drm_query_clock - Metadata for a clock
  308. * @name: The clock name.
  309. * @freq_mhz: The clock frequency.
  310. * @pad: Structure padding.
  311. */
  312. struct amdxdna_drm_query_clock {
  313. __u8 name[16];
  314. __u32 freq_mhz;
  315. __u32 pad;
  316. };
  317. /**
  318. * struct amdxdna_drm_query_clock_metadata - Query metadata for clocks
  319. * @mp_npu_clock: The metadata for MP-NPU clock.
  320. * @h_clock: The metadata for H clock.
  321. */
  322. struct amdxdna_drm_query_clock_metadata {
  323. struct amdxdna_drm_query_clock mp_npu_clock;
  324. struct amdxdna_drm_query_clock h_clock;
  325. };
  326. enum amdxdna_sensor_type {
  327. AMDXDNA_SENSOR_TYPE_POWER
  328. };
  329. /**
  330. * struct amdxdna_drm_query_sensor - The data for single sensor.
  331. * @label: The name for a sensor.
  332. * @input: The current value of the sensor.
  333. * @max: The maximum value possible for the sensor.
  334. * @average: The average value of the sensor.
  335. * @highest: The highest recorded sensor value for this driver load for the sensor.
  336. * @status: The sensor status.
  337. * @units: The sensor units.
  338. * @unitm: Translates value member variables into the correct unit via (pow(10, unitm) * value).
  339. * @type: The sensor type from enum amdxdna_sensor_type.
  340. * @pad: Structure padding.
  341. */
  342. struct amdxdna_drm_query_sensor {
  343. __u8 label[64];
  344. __u32 input;
  345. __u32 max;
  346. __u32 average;
  347. __u32 highest;
  348. __u8 status[64];
  349. __u8 units[16];
  350. __s8 unitm;
  351. __u8 type;
  352. __u8 pad[6];
  353. };
  354. /**
  355. * struct amdxdna_drm_query_hwctx - The data for single context.
  356. * @context_id: The ID for this context.
  357. * @start_col: The starting column for the partition assigned to this context.
  358. * @num_col: The number of columns in the partition assigned to this context.
  359. * @pad: Structure padding.
  360. * @pid: The Process ID of the process that created this context.
  361. * @command_submissions: The number of commands submitted to this context.
  362. * @command_completions: The number of commands completed by this context.
  363. * @migrations: The number of times this context has been moved to a different partition.
  364. * @preemptions: The number of times this context has been preempted by another context in the
  365. * same partition.
  366. * @errors: The errors for this context.
  367. */
  368. struct amdxdna_drm_query_hwctx {
  369. __u32 context_id;
  370. __u32 start_col;
  371. __u32 num_col;
  372. __u32 pad;
  373. __s64 pid;
  374. __u64 command_submissions;
  375. __u64 command_completions;
  376. __u64 migrations;
  377. __u64 preemptions;
  378. __u64 errors;
  379. };
  380. enum amdxdna_power_mode_type {
  381. POWER_MODE_DEFAULT, /* Fallback to calculated DPM */
  382. POWER_MODE_LOW, /* Set frequency to lowest DPM */
  383. POWER_MODE_MEDIUM, /* Set frequency to medium DPM */
  384. POWER_MODE_HIGH, /* Set frequency to highest DPM */
  385. POWER_MODE_TURBO, /* Maximum power */
  386. };
  387. /**
  388. * struct amdxdna_drm_get_power_mode - Get the configured power mode
  389. * @power_mode: The mode type from enum amdxdna_power_mode_type
  390. * @pad: Structure padding.
  391. */
  392. struct amdxdna_drm_get_power_mode {
  393. __u8 power_mode;
  394. __u8 pad[7];
  395. };
  396. /**
  397. * struct amdxdna_drm_query_firmware_version - Query the firmware version
  398. * @major: The major version number
  399. * @minor: The minor version number
  400. * @patch: The patch level version number
  401. * @build: The build ID
  402. */
  403. struct amdxdna_drm_query_firmware_version {
  404. __u32 major; /* out */
  405. __u32 minor; /* out */
  406. __u32 patch; /* out */
  407. __u32 build; /* out */
  408. };
  409. enum amdxdna_drm_get_param {
  410. DRM_AMDXDNA_QUERY_AIE_STATUS,
  411. DRM_AMDXDNA_QUERY_AIE_METADATA,
  412. DRM_AMDXDNA_QUERY_AIE_VERSION,
  413. DRM_AMDXDNA_QUERY_CLOCK_METADATA,
  414. DRM_AMDXDNA_QUERY_SENSORS,
  415. DRM_AMDXDNA_QUERY_HW_CONTEXTS,
  416. DRM_AMDXDNA_QUERY_FIRMWARE_VERSION = 8,
  417. DRM_AMDXDNA_GET_POWER_MODE,
  418. DRM_AMDXDNA_QUERY_TELEMETRY,
  419. DRM_AMDXDNA_GET_FORCE_PREEMPT_STATE,
  420. DRM_AMDXDNA_QUERY_RESOURCE_INFO,
  421. DRM_AMDXDNA_GET_FRAME_BOUNDARY_PREEMPT_STATE,
  422. };
  423. /**
  424. * struct amdxdna_drm_get_resource_info - Get resource information
  425. */
  426. struct amdxdna_drm_get_resource_info {
  427. /** @npu_clk_max: max H-Clocks */
  428. __u64 npu_clk_max;
  429. /** @npu_tops_max: max TOPs */
  430. __u64 npu_tops_max;
  431. /** @npu_task_max: max number of tasks */
  432. __u64 npu_task_max;
  433. /** @npu_tops_curr: current TOPs */
  434. __u64 npu_tops_curr;
  435. /** @npu_task_curr: current number of tasks */
  436. __u64 npu_task_curr;
  437. };
  438. /**
  439. * struct amdxdna_drm_attribute_state - State of an attribute
  440. */
  441. struct amdxdna_drm_attribute_state {
  442. /** @state: enabled or disabled */
  443. __u8 state;
  444. /** @pad: MBZ */
  445. __u8 pad[7];
  446. };
  447. /**
  448. * struct amdxdna_drm_query_telemetry_header - Telemetry data header
  449. */
  450. struct amdxdna_drm_query_telemetry_header {
  451. /** @major: Firmware telemetry interface major version number */
  452. __u32 major;
  453. /** @minor: Firmware telemetry interface minor version number */
  454. __u32 minor;
  455. /** @type: Telemetry query type */
  456. __u32 type;
  457. /** @map_num_elements: Total number of elements in the map table */
  458. __u32 map_num_elements;
  459. /** @map: Element map */
  460. __u32 map[];
  461. };
  462. /**
  463. * struct amdxdna_drm_get_info - Get some information from the AIE hardware.
  464. * @param: Value in enum amdxdna_drm_get_param. Specifies the structure passed in the buffer.
  465. * @buffer_size: Size of the input buffer. Size needed/written by the kernel.
  466. * @buffer: A structure specified by the param struct member.
  467. */
  468. struct amdxdna_drm_get_info {
  469. __u32 param; /* in */
  470. __u32 buffer_size; /* in/out */
  471. __u64 buffer; /* in/out */
  472. };
  473. #define AMDXDNA_HWCTX_STATE_IDLE 0
  474. #define AMDXDNA_HWCTX_STATE_ACTIVE 1
  475. /**
  476. * struct amdxdna_drm_hwctx_entry - The hardware context array entry
  477. */
  478. struct amdxdna_drm_hwctx_entry {
  479. /** @context_id: Context ID. */
  480. __u32 context_id;
  481. /** @start_col: Start AIE array column assigned to context. */
  482. __u32 start_col;
  483. /** @num_col: Number of AIE array columns assigned to context. */
  484. __u32 num_col;
  485. /** @hwctx_id: The real hardware context id. */
  486. __u32 hwctx_id;
  487. /** @pid: ID of process which created this context. */
  488. __s64 pid;
  489. /** @command_submissions: Number of commands submitted. */
  490. __u64 command_submissions;
  491. /** @command_completions: Number of commands completed. */
  492. __u64 command_completions;
  493. /** @migrations: Number of times been migrated. */
  494. __u64 migrations;
  495. /** @preemptions: Number of times been preempted. */
  496. __u64 preemptions;
  497. /** @errors: Number of errors happened. */
  498. __u64 errors;
  499. /** @priority: Context priority. */
  500. __u64 priority;
  501. /** @heap_usage: Usage of device heap buffer. */
  502. __u64 heap_usage;
  503. /** @suspensions: Number of times been suspended. */
  504. __u64 suspensions;
  505. /**
  506. * @state: Context state.
  507. * %AMDXDNA_HWCTX_STATE_IDLE
  508. * %AMDXDNA_HWCTX_STATE_ACTIVE
  509. */
  510. __u32 state;
  511. /** @pasid: PASID been bound. */
  512. __u32 pasid;
  513. /** @gops: Giga operations per second. */
  514. __u32 gops;
  515. /** @fps: Frames per second. */
  516. __u32 fps;
  517. /** @dma_bandwidth: DMA bandwidth. */
  518. __u32 dma_bandwidth;
  519. /** @latency: Frame response latency. */
  520. __u32 latency;
  521. /** @frame_exec_time: Frame execution time. */
  522. __u32 frame_exec_time;
  523. /** @txn_op_idx: Index of last control code executed. */
  524. __u32 txn_op_idx;
  525. /** @ctx_pc: Program counter. */
  526. __u32 ctx_pc;
  527. /** @fatal_error_type: Fatal error type if context crashes. */
  528. __u32 fatal_error_type;
  529. /** @fatal_error_exception_type: Firmware exception type. */
  530. __u32 fatal_error_exception_type;
  531. /** @fatal_error_exception_pc: Firmware exception program counter. */
  532. __u32 fatal_error_exception_pc;
  533. /** @fatal_error_app_module: Exception module name. */
  534. __u32 fatal_error_app_module;
  535. /** @pad: Structure pad. */
  536. __u32 pad;
  537. };
  538. /**
  539. * struct amdxdna_async_error - XDNA async error structure
  540. */
  541. struct amdxdna_async_error {
  542. /** @err_code: Error code. */
  543. __u64 err_code;
  544. /** @ts_us: Timestamp. */
  545. __u64 ts_us;
  546. /** @ex_err_code: Extra error code */
  547. __u64 ex_err_code;
  548. };
  549. #define DRM_AMDXDNA_HW_CONTEXT_ALL 0
  550. #define DRM_AMDXDNA_HW_LAST_ASYNC_ERR 2
  551. /**
  552. * struct amdxdna_drm_get_array - Get information array.
  553. */
  554. struct amdxdna_drm_get_array {
  555. /**
  556. * @param:
  557. *
  558. * Supported params:
  559. *
  560. * %DRM_AMDXDNA_HW_CONTEXT_ALL:
  561. * Returns all created hardware contexts.
  562. */
  563. __u32 param;
  564. /**
  565. * @element_size:
  566. *
  567. * Specifies maximum element size and returns the actual element size.
  568. */
  569. __u32 element_size;
  570. /**
  571. * @num_element:
  572. *
  573. * Specifies maximum number of elements and returns the actual number
  574. * of elements.
  575. */
  576. __u32 num_element; /* in/out */
  577. /** @pad: MBZ */
  578. __u32 pad;
  579. /**
  580. * @buffer:
  581. *
  582. * Specifies the match conditions and returns the matched information
  583. * array.
  584. */
  585. __u64 buffer;
  586. };
  587. enum amdxdna_drm_set_param {
  588. DRM_AMDXDNA_SET_POWER_MODE,
  589. DRM_AMDXDNA_WRITE_AIE_MEM,
  590. DRM_AMDXDNA_WRITE_AIE_REG,
  591. DRM_AMDXDNA_SET_FORCE_PREEMPT,
  592. DRM_AMDXDNA_SET_FRAME_BOUNDARY_PREEMPT,
  593. };
  594. /**
  595. * struct amdxdna_drm_set_state - Set the state of the AIE hardware.
  596. * @param: Value in enum amdxdna_drm_set_param.
  597. * @buffer_size: Size of the input param.
  598. * @buffer: Pointer to the input param.
  599. */
  600. struct amdxdna_drm_set_state {
  601. __u32 param; /* in */
  602. __u32 buffer_size; /* in */
  603. __u64 buffer; /* in */
  604. };
  605. /**
  606. * struct amdxdna_drm_set_power_mode - Set the power mode of the AIE hardware
  607. * @power_mode: The sensor type from enum amdxdna_power_mode_type
  608. * @pad: MBZ.
  609. */
  610. struct amdxdna_drm_set_power_mode {
  611. __u8 power_mode;
  612. __u8 pad[7];
  613. };
  614. #define DRM_IOCTL_AMDXDNA_CREATE_HWCTX \
  615. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_CREATE_HWCTX, \
  616. struct amdxdna_drm_create_hwctx)
  617. #define DRM_IOCTL_AMDXDNA_DESTROY_HWCTX \
  618. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_DESTROY_HWCTX, \
  619. struct amdxdna_drm_destroy_hwctx)
  620. #define DRM_IOCTL_AMDXDNA_CONFIG_HWCTX \
  621. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_CONFIG_HWCTX, \
  622. struct amdxdna_drm_config_hwctx)
  623. #define DRM_IOCTL_AMDXDNA_CREATE_BO \
  624. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_CREATE_BO, \
  625. struct amdxdna_drm_create_bo)
  626. #define DRM_IOCTL_AMDXDNA_GET_BO_INFO \
  627. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_GET_BO_INFO, \
  628. struct amdxdna_drm_get_bo_info)
  629. #define DRM_IOCTL_AMDXDNA_SYNC_BO \
  630. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_SYNC_BO, \
  631. struct amdxdna_drm_sync_bo)
  632. #define DRM_IOCTL_AMDXDNA_EXEC_CMD \
  633. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_EXEC_CMD, \
  634. struct amdxdna_drm_exec_cmd)
  635. #define DRM_IOCTL_AMDXDNA_GET_INFO \
  636. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_GET_INFO, \
  637. struct amdxdna_drm_get_info)
  638. #define DRM_IOCTL_AMDXDNA_SET_STATE \
  639. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_SET_STATE, \
  640. struct amdxdna_drm_set_state)
  641. #define DRM_IOCTL_AMDXDNA_GET_ARRAY \
  642. DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_GET_ARRAY, \
  643. struct amdxdna_drm_get_array)
  644. #if defined(__cplusplus)
  645. } /* extern c end */
  646. #endif
  647. #endif /* _AMDXDNA_ACCEL_H_ */