blob: 109418250397fd78ea92390e0b521f0d85710082 [file] [log] [blame]
Christopher Ferris05d08e92016-02-04 13:16:38 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef KFD_IOCTL_H_INCLUDED
20#define KFD_IOCTL_H_INCLUDED
Christopher Ferris1308ad32017-11-14 17:32:13 -080021#include <drm/drm.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080022#include <linux/ioctl.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080023#define KFD_IOCTL_MAJOR_VERSION 1
Christopher Ferris8666d042023-09-06 14:55:31 -070024#define KFD_IOCTL_MINOR_VERSION 14
Christopher Ferris05d08e92016-02-04 13:16:38 -080025struct kfd_ioctl_get_version_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080026 __u32 major_version;
27 __u32 minor_version;
Christopher Ferris05d08e92016-02-04 13:16:38 -080028};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -070029#define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0
30#define KFD_IOC_QUEUE_TYPE_SDMA 0x1
31#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2
32#define KFD_IOC_QUEUE_TYPE_SDMA_XGMI 0x3
Christopher Ferris05d08e92016-02-04 13:16:38 -080033#define KFD_MAX_QUEUE_PERCENTAGE 100
34#define KFD_MAX_QUEUE_PRIORITY 15
35struct kfd_ioctl_create_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080036 __u64 ring_base_address;
37 __u64 write_pointer_address;
38 __u64 read_pointer_address;
39 __u64 doorbell_offset;
40 __u32 ring_size;
41 __u32 gpu_id;
42 __u32 queue_type;
43 __u32 queue_percentage;
44 __u32 queue_priority;
45 __u32 queue_id;
46 __u64 eop_buffer_address;
47 __u64 eop_buffer_size;
48 __u64 ctx_save_restore_address;
Christopher Ferris76a1d452018-06-27 14:12:29 -070049 __u32 ctx_save_restore_size;
50 __u32 ctl_stack_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -080051};
52struct kfd_ioctl_destroy_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080053 __u32 queue_id;
54 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080055};
56struct kfd_ioctl_update_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080057 __u64 ring_base_address;
58 __u32 queue_id;
59 __u32 ring_size;
60 __u32 queue_percentage;
61 __u32 queue_priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -080062};
Christopher Ferris9ce28842018-10-25 12:11:39 -070063struct kfd_ioctl_set_cu_mask_args {
64 __u32 queue_id;
65 __u32 num_cu_mask;
66 __u64 cu_mask_ptr;
67};
Christopher Ferris86a48372019-01-10 14:14:59 -080068struct kfd_ioctl_get_queue_wave_state_args {
69 __u64 ctl_stack_address;
70 __u32 ctl_stack_used_size;
71 __u32 save_area_used_size;
72 __u32 queue_id;
73 __u32 pad;
74};
Christopher Ferris7447a1c2022-10-04 18:24:44 -070075struct kfd_ioctl_get_available_memory_args {
76 __u64 available;
77 __u32 gpu_id;
78 __u32 pad;
79};
Christopher Ferris8666d042023-09-06 14:55:31 -070080struct kfd_dbg_device_info_entry {
81 __u64 exception_status;
82 __u64 lds_base;
83 __u64 lds_limit;
84 __u64 scratch_base;
85 __u64 scratch_limit;
86 __u64 gpuvm_base;
87 __u64 gpuvm_limit;
88 __u32 gpu_id;
89 __u32 location_id;
90 __u32 vendor_id;
91 __u32 device_id;
92 __u32 revision_id;
93 __u32 subsystem_vendor_id;
94 __u32 subsystem_device_id;
95 __u32 fw_version;
96 __u32 gfx_target_version;
97 __u32 simd_count;
98 __u32 max_waves_per_simd;
99 __u32 array_count;
100 __u32 simd_arrays_per_engine;
101 __u32 num_xcc;
102 __u32 capability;
103 __u32 debug_prop;
104};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105#define KFD_IOC_CACHE_POLICY_COHERENT 0
106#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800107struct kfd_ioctl_set_memory_policy_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800108 __u64 alternate_aperture_base;
109 __u64 alternate_aperture_size;
110 __u32 gpu_id;
111 __u32 default_policy;
112 __u32 alternate_policy;
113 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800114};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800115struct kfd_ioctl_get_clock_counters_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800116 __u64 gpu_clock_counter;
117 __u64 cpu_clock_counter;
118 __u64 system_clock_counter;
119 __u64 system_clock_freq;
120 __u32 gpu_id;
121 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800122};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800123struct kfd_process_device_apertures {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800124 __u64 lds_base;
125 __u64 lds_limit;
126 __u64 scratch_base;
127 __u64 scratch_limit;
128 __u64 gpuvm_base;
129 __u64 gpuvm_limit;
130 __u32 gpu_id;
131 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800132};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700133#define NUM_OF_SUPPORTED_GPUS 7
Christopher Ferris05d08e92016-02-04 13:16:38 -0800134struct kfd_ioctl_get_process_apertures_args {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800135 struct kfd_process_device_apertures process_apertures[NUM_OF_SUPPORTED_GPUS];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800136 __u32 num_of_nodes;
137 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800138};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700139struct kfd_ioctl_get_process_apertures_new_args {
140 __u64 kfd_process_device_apertures_ptr;
141 __u32 num_of_nodes;
142 __u32 pad;
143};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800144#define MAX_ALLOWED_NUM_POINTS 100
145#define MAX_ALLOWED_AW_BUFF_SIZE 4096
146#define MAX_ALLOWED_WAC_BUFF_SIZE 128
147struct kfd_ioctl_dbg_register_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800148 __u32 gpu_id;
149 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800150};
151struct kfd_ioctl_dbg_unregister_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800152 __u32 gpu_id;
153 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800154};
155struct kfd_ioctl_dbg_address_watch_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800156 __u64 content_ptr;
157 __u32 gpu_id;
158 __u32 buf_size_in_bytes;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800159};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800160struct kfd_ioctl_dbg_wave_control_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800161 __u64 content_ptr;
162 __u32 gpu_id;
163 __u32 buf_size_in_bytes;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800164};
Christopher Ferris10a76e62022-06-08 13:31:52 -0700165#define KFD_INVALID_FD 0xffffffff
Christopher Ferris05d08e92016-02-04 13:16:38 -0800166#define KFD_IOC_EVENT_SIGNAL 0
167#define KFD_IOC_EVENT_NODECHANGE 1
168#define KFD_IOC_EVENT_DEVICESTATECHANGE 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800169#define KFD_IOC_EVENT_HW_EXCEPTION 3
170#define KFD_IOC_EVENT_SYSTEM_EVENT 4
171#define KFD_IOC_EVENT_DEBUG_EVENT 5
172#define KFD_IOC_EVENT_PROFILE_EVENT 6
Christopher Ferris05d08e92016-02-04 13:16:38 -0800173#define KFD_IOC_EVENT_QUEUE_EVENT 7
174#define KFD_IOC_EVENT_MEMORY 8
175#define KFD_IOC_WAIT_RESULT_COMPLETE 0
176#define KFD_IOC_WAIT_RESULT_TIMEOUT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800177#define KFD_IOC_WAIT_RESULT_FAIL 2
Christopher Ferris934ec942018-01-31 15:29:16 -0800178#define KFD_SIGNAL_EVENT_LIMIT 4096
Christopher Ferris9ce28842018-10-25 12:11:39 -0700179#define KFD_HW_EXCEPTION_WHOLE_GPU_RESET 0
180#define KFD_HW_EXCEPTION_PER_ENGINE_RESET 1
181#define KFD_HW_EXCEPTION_GPU_HANG 0
182#define KFD_HW_EXCEPTION_ECC 1
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700183#define KFD_MEM_ERR_NO_RAS 0
184#define KFD_MEM_ERR_SRAM_ECC 1
185#define KFD_MEM_ERR_POISON_CONSUMED 2
186#define KFD_MEM_ERR_GPU_HANG 3
Christopher Ferris05d08e92016-02-04 13:16:38 -0800187struct kfd_ioctl_create_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800188 __u64 event_page_offset;
189 __u32 event_trigger_data;
190 __u32 event_type;
191 __u32 auto_reset;
192 __u32 node_id;
193 __u32 event_id;
194 __u32 event_slot_index;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800195};
196struct kfd_ioctl_destroy_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800197 __u32 event_id;
198 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800199};
200struct kfd_ioctl_set_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800201 __u32 event_id;
202 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800203};
204struct kfd_ioctl_reset_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800205 __u32 event_id;
206 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800207};
208struct kfd_memory_exception_failure {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800209 __u32 NotPresent;
210 __u32 ReadOnly;
211 __u32 NoExecute;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700212 __u32 imprecise;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800213};
214struct kfd_hsa_memory_exception_data {
215 struct kfd_memory_exception_failure failure;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800216 __u64 va;
217 __u32 gpu_id;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700218 __u32 ErrorType;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800219};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700220struct kfd_hsa_hw_exception_data {
Christopher Ferris86a48372019-01-10 14:14:59 -0800221 __u32 reset_type;
222 __u32 reset_cause;
223 __u32 memory_lost;
224 __u32 gpu_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700225};
Christopher Ferris8666d042023-09-06 14:55:31 -0700226struct kfd_hsa_signal_event_data {
227 __u64 last_event_age;
228};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800229struct kfd_event_data {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800230 union {
231 struct kfd_hsa_memory_exception_data memory_exception_data;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700232 struct kfd_hsa_hw_exception_data hw_exception_data;
Christopher Ferris8666d042023-09-06 14:55:31 -0700233 struct kfd_hsa_signal_event_data signal_event_data;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800234 };
Christopher Ferris1308ad32017-11-14 17:32:13 -0800235 __u64 kfd_event_data_ext;
236 __u32 event_id;
237 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800238};
239struct kfd_ioctl_wait_events_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800240 __u64 events_ptr;
241 __u32 num_events;
242 __u32 wait_for_all;
243 __u32 timeout;
244 __u32 wait_result;
245};
246struct kfd_ioctl_set_scratch_backing_va_args {
Christopher Ferris934ec942018-01-31 15:29:16 -0800247 __u64 va_addr;
248 __u32 gpu_id;
249 __u32 pad;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800250};
251struct kfd_ioctl_get_tile_config_args {
Christopher Ferris934ec942018-01-31 15:29:16 -0800252 __u64 tile_config_ptr;
253 __u64 macro_tile_config_ptr;
254 __u32 num_tile_configs;
255 __u32 num_macro_tile_configs;
256 __u32 gpu_id;
257 __u32 gb_addr_config;
258 __u32 num_banks;
259 __u32 num_ranks;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800260};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700261struct kfd_ioctl_set_trap_handler_args {
262 __u64 tba_addr;
263 __u64 tma_addr;
264 __u32 gpu_id;
265 __u32 pad;
266};
267struct kfd_ioctl_acquire_vm_args {
268 __u32 drm_fd;
269 __u32 gpu_id;
270};
271#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
272#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
273#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
274#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700275#define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700276#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31)
277#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30)
278#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
279#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
280#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
281#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 26)
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000282#define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED (1 << 25)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700283struct kfd_ioctl_alloc_memory_of_gpu_args {
284 __u64 va_addr;
285 __u64 size;
286 __u64 handle;
287 __u64 mmap_offset;
288 __u32 gpu_id;
289 __u32 flags;
290};
291struct kfd_ioctl_free_memory_of_gpu_args {
292 __u64 handle;
293};
294struct kfd_ioctl_map_memory_to_gpu_args {
295 __u64 handle;
296 __u64 device_ids_array_ptr;
297 __u32 n_devices;
298 __u32 n_success;
299};
300struct kfd_ioctl_unmap_memory_from_gpu_args {
301 __u64 handle;
302 __u64 device_ids_array_ptr;
303 __u32 n_devices;
304 __u32 n_success;
305};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700306struct kfd_ioctl_alloc_queue_gws_args {
307 __u32 queue_id;
308 __u32 num_gws;
309 __u32 first_gws;
310 __u32 pad;
311};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800312struct kfd_ioctl_get_dmabuf_info_args {
313 __u64 size;
314 __u64 metadata_ptr;
315 __u32 metadata_size;
316 __u32 gpu_id;
317 __u32 flags;
318 __u32 dmabuf_fd;
319};
320struct kfd_ioctl_import_dmabuf_args {
321 __u64 va_addr;
322 __u64 handle;
323 __u32 gpu_id;
324 __u32 dmabuf_fd;
325};
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700326struct kfd_ioctl_export_dmabuf_args {
327 __u64 handle;
328 __u32 flags;
329 __u32 dmabuf_fd;
330};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800331enum kfd_smi_event {
332 KFD_SMI_EVENT_NONE = 0,
333 KFD_SMI_EVENT_VMFAULT = 1,
334 KFD_SMI_EVENT_THERMAL_THROTTLE = 2,
335 KFD_SMI_EVENT_GPU_PRE_RESET = 3,
336 KFD_SMI_EVENT_GPU_POST_RESET = 4,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700337 KFD_SMI_EVENT_MIGRATE_START = 5,
338 KFD_SMI_EVENT_MIGRATE_END = 6,
339 KFD_SMI_EVENT_PAGE_FAULT_START = 7,
340 KFD_SMI_EVENT_PAGE_FAULT_END = 8,
341 KFD_SMI_EVENT_QUEUE_EVICTION = 9,
342 KFD_SMI_EVENT_QUEUE_RESTORE = 10,
343 KFD_SMI_EVENT_UNMAP_FROM_GPU = 11,
344 KFD_SMI_EVENT_ALL_PROCESS = 64
345};
346enum KFD_MIGRATE_TRIGGERS {
347 KFD_MIGRATE_TRIGGER_PREFETCH,
348 KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU,
349 KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU,
350 KFD_MIGRATE_TRIGGER_TTM_EVICTION
351};
352enum KFD_QUEUE_EVICTION_TRIGGERS {
353 KFD_QUEUE_EVICTION_TRIGGER_SVM,
354 KFD_QUEUE_EVICTION_TRIGGER_USERPTR,
355 KFD_QUEUE_EVICTION_TRIGGER_TTM,
356 KFD_QUEUE_EVICTION_TRIGGER_SUSPEND,
357 KFD_QUEUE_EVICTION_CRIU_CHECKPOINT,
358 KFD_QUEUE_EVICTION_CRIU_RESTORE
359};
360enum KFD_SVM_UNMAP_TRIGGERS {
361 KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY,
362 KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRATE,
363 KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800364};
365#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
Christopher Ferris10a76e62022-06-08 13:31:52 -0700366#define KFD_SMI_EVENT_MSG_SIZE 96
Christopher Ferris25c18d42020-10-14 17:42:58 -0700367struct kfd_ioctl_smi_events_args {
368 __u32 gpuid;
369 __u32 anon_fd;
370};
Christopher Ferris10a76e62022-06-08 13:31:52 -0700371enum kfd_criu_op {
372 KFD_CRIU_OP_PROCESS_INFO,
373 KFD_CRIU_OP_CHECKPOINT,
374 KFD_CRIU_OP_UNPAUSE,
375 KFD_CRIU_OP_RESTORE,
376 KFD_CRIU_OP_RESUME,
377};
378struct kfd_ioctl_criu_args {
379 __u64 devices;
380 __u64 bos;
381 __u64 priv_data;
382 __u64 priv_data_size;
383 __u32 num_devices;
384 __u32 num_bos;
385 __u32 num_objects;
386 __u32 pid;
387 __u32 op;
388};
389struct kfd_criu_device_bucket {
390 __u32 user_gpu_id;
391 __u32 actual_gpu_id;
392 __u32 drm_fd;
393 __u32 pad;
394};
395struct kfd_criu_bo_bucket {
396 __u64 addr;
397 __u64 size;
398 __u64 offset;
399 __u64 restored_offset;
400 __u32 gpu_id;
401 __u32 alloc_flags;
402 __u32 dmabuf_fd;
403 __u32 pad;
404};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700405enum kfd_mmio_remap {
406 KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL = 0,
407 KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,
408};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000409#define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000001
410#define KFD_IOCTL_SVM_FLAG_COHERENT 0x00000002
411#define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL 0x00000004
412#define KFD_IOCTL_SVM_FLAG_GPU_RO 0x00000008
413#define KFD_IOCTL_SVM_FLAG_GPU_EXEC 0x00000010
414#define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY 0x00000020
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700415#define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED 0x00000040
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000416enum kfd_ioctl_svm_op {
417 KFD_IOCTL_SVM_OP_SET_ATTR,
418 KFD_IOCTL_SVM_OP_GET_ATTR
419};
420enum kfd_ioctl_svm_location {
421 KFD_IOCTL_SVM_LOCATION_SYSMEM = 0,
422 KFD_IOCTL_SVM_LOCATION_UNDEFINED = 0xffffffff
423};
424enum kfd_ioctl_svm_attr_type {
425 KFD_IOCTL_SVM_ATTR_PREFERRED_LOC,
426 KFD_IOCTL_SVM_ATTR_PREFETCH_LOC,
427 KFD_IOCTL_SVM_ATTR_ACCESS,
428 KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE,
429 KFD_IOCTL_SVM_ATTR_NO_ACCESS,
430 KFD_IOCTL_SVM_ATTR_SET_FLAGS,
431 KFD_IOCTL_SVM_ATTR_CLR_FLAGS,
432 KFD_IOCTL_SVM_ATTR_GRANULARITY
433};
434struct kfd_ioctl_svm_attribute {
435 __u32 type;
436 __u32 value;
437};
438struct kfd_ioctl_svm_args {
439 __u64 start_addr;
440 __u64 size;
441 __u32 op;
442 __u32 nattr;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700443 struct kfd_ioctl_svm_attribute attrs[];
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000444};
445struct kfd_ioctl_set_xnack_mode_args {
446 __s32 xnack_enabled;
447};
Christopher Ferris8666d042023-09-06 14:55:31 -0700448enum kfd_dbg_trap_override_mode {
449 KFD_DBG_TRAP_OVERRIDE_OR = 0,
450 KFD_DBG_TRAP_OVERRIDE_REPLACE = 1
451};
452enum kfd_dbg_trap_mask {
453 KFD_DBG_TRAP_MASK_FP_INVALID = 1,
454 KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL = 2,
455 KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO = 4,
456 KFD_DBG_TRAP_MASK_FP_OVERFLOW = 8,
457 KFD_DBG_TRAP_MASK_FP_UNDERFLOW = 16,
458 KFD_DBG_TRAP_MASK_FP_INEXACT = 32,
459 KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO = 64,
460 KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH = 128,
461 KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION = 256,
462 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START = (1 << 30),
463 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END = (1 << 31)
464};
465enum kfd_dbg_trap_wave_launch_mode {
466 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL = 0,
467 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT = 1,
468 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG = 3
469};
470enum kfd_dbg_trap_address_watch_mode {
471 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ = 0,
472 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREAD = 1,
473 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC = 2,
474 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL = 3
475};
476enum kfd_dbg_trap_flags {
477 KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP = 1,
478};
479enum kfd_dbg_trap_exception_code {
480 EC_NONE = 0,
481 EC_QUEUE_WAVE_ABORT = 1,
482 EC_QUEUE_WAVE_TRAP = 2,
483 EC_QUEUE_WAVE_MATH_ERROR = 3,
484 EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION = 4,
485 EC_QUEUE_WAVE_MEMORY_VIOLATION = 5,
486 EC_QUEUE_WAVE_APERTURE_VIOLATION = 6,
487 EC_QUEUE_PACKET_DISPATCH_DIM_INVALID = 16,
488 EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID = 17,
489 EC_QUEUE_PACKET_DISPATCH_CODE_INVALID = 18,
490 EC_QUEUE_PACKET_RESERVED = 19,
491 EC_QUEUE_PACKET_UNSUPPORTED = 20,
492 EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID = 21,
493 EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID = 22,
494 EC_QUEUE_PACKET_VENDOR_UNSUPPORTED = 23,
495 EC_QUEUE_PREEMPTION_ERROR = 30,
496 EC_QUEUE_NEW = 31,
497 EC_DEVICE_QUEUE_DELETE = 32,
498 EC_DEVICE_MEMORY_VIOLATION = 33,
499 EC_DEVICE_RAS_ERROR = 34,
500 EC_DEVICE_FATAL_HALT = 35,
501 EC_DEVICE_NEW = 36,
502 EC_PROCESS_RUNTIME = 48,
503 EC_PROCESS_DEVICE_REMOVE = 49,
504 EC_MAX
505};
506#define KFD_EC_MASK(ecode) (1ULL << (ecode - 1))
507#define KFD_EC_MASK_QUEUE (KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) | KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) | KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) | KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) | KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) | KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED) | KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR) | KFD_EC_MASK(EC_QUEUE_NEW))
508#define KFD_EC_MASK_DEVICE (KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) | KFD_EC_MASK(EC_DEVICE_RAS_ERROR) | KFD_EC_MASK(EC_DEVICE_FATAL_HALT) | KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) | KFD_EC_MASK(EC_DEVICE_NEW))
509#define KFD_EC_MASK_PROCESS (KFD_EC_MASK(EC_PROCESS_RUNTIME) | KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE))
510#define KFD_DBG_EC_TYPE_IS_QUEUE(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
511#define KFD_DBG_EC_TYPE_IS_DEVICE(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
512#define KFD_DBG_EC_TYPE_IS_PROCESS(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
513enum kfd_dbg_runtime_state {
514 DEBUG_RUNTIME_STATE_DISABLED = 0,
515 DEBUG_RUNTIME_STATE_ENABLED = 1,
516 DEBUG_RUNTIME_STATE_ENABLED_BUSY = 2,
517 DEBUG_RUNTIME_STATE_ENABLED_ERROR = 3
518};
519struct kfd_runtime_info {
520 __u64 r_debug;
521 __u32 runtime_state;
522 __u32 ttmp_setup;
523};
524#define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK 1
525#define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK 2
526struct kfd_ioctl_runtime_enable_args {
527 __u64 r_debug;
528 __u32 mode_mask;
529 __u32 capabilities_mask;
530};
531struct kfd_queue_snapshot_entry {
532 __u64 exception_status;
533 __u64 ring_base_address;
534 __u64 write_pointer_address;
535 __u64 read_pointer_address;
536 __u64 ctx_save_restore_address;
537 __u32 queue_id;
538 __u32 gpu_id;
539 __u32 ring_size;
540 __u32 queue_type;
541 __u32 ctx_save_restore_area_size;
542 __u32 reserved;
543};
544#define KFD_DBG_QUEUE_ERROR_BIT 30
545#define KFD_DBG_QUEUE_INVALID_BIT 31
546#define KFD_DBG_QUEUE_ERROR_MASK (1 << KFD_DBG_QUEUE_ERROR_BIT)
547#define KFD_DBG_QUEUE_INVALID_MASK (1 << KFD_DBG_QUEUE_INVALID_BIT)
548struct kfd_context_save_area_header {
549 struct {
550 __u32 control_stack_offset;
551 __u32 control_stack_size;
552 __u32 wave_state_offset;
553 __u32 wave_state_size;
554 } wave_state;
555 __u32 debug_offset;
556 __u32 debug_size;
557 __u64 err_payload_addr;
558 __u32 err_event_id;
559 __u32 reserved1;
560};
561enum kfd_dbg_trap_operations {
562 KFD_IOC_DBG_TRAP_ENABLE = 0,
563 KFD_IOC_DBG_TRAP_DISABLE = 1,
564 KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT = 2,
565 KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED = 3,
566 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE = 4,
567 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE = 5,
568 KFD_IOC_DBG_TRAP_SUSPEND_QUEUES = 6,
569 KFD_IOC_DBG_TRAP_RESUME_QUEUES = 7,
570 KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH = 8,
571 KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH = 9,
572 KFD_IOC_DBG_TRAP_SET_FLAGS = 10,
573 KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT = 11,
574 KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO = 12,
575 KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT = 13,
576 KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT = 14
577};
578struct kfd_ioctl_dbg_trap_enable_args {
579 __u64 exception_mask;
580 __u64 rinfo_ptr;
581 __u32 rinfo_size;
582 __u32 dbg_fd;
583};
584struct kfd_ioctl_dbg_trap_send_runtime_event_args {
585 __u64 exception_mask;
586 __u32 gpu_id;
587 __u32 queue_id;
588};
589struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args {
590 __u64 exception_mask;
591};
592struct kfd_ioctl_dbg_trap_set_wave_launch_override_args {
593 __u32 override_mode;
594 __u32 enable_mask;
595 __u32 support_request_mask;
596 __u32 pad;
597};
598struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args {
599 __u32 launch_mode;
600 __u32 pad;
601};
602struct kfd_ioctl_dbg_trap_suspend_queues_args {
603 __u64 exception_mask;
604 __u64 queue_array_ptr;
605 __u32 num_queues;
606 __u32 grace_period;
607};
608struct kfd_ioctl_dbg_trap_resume_queues_args {
609 __u64 queue_array_ptr;
610 __u32 num_queues;
611 __u32 pad;
612};
613struct kfd_ioctl_dbg_trap_set_node_address_watch_args {
614 __u64 address;
615 __u32 mode;
616 __u32 mask;
617 __u32 gpu_id;
618 __u32 id;
619};
620struct kfd_ioctl_dbg_trap_clear_node_address_watch_args {
621 __u32 gpu_id;
622 __u32 id;
623};
624struct kfd_ioctl_dbg_trap_set_flags_args {
625 __u32 flags;
626 __u32 pad;
627};
628struct kfd_ioctl_dbg_trap_query_debug_event_args {
629 __u64 exception_mask;
630 __u32 gpu_id;
631 __u32 queue_id;
632};
633struct kfd_ioctl_dbg_trap_query_exception_info_args {
634 __u64 info_ptr;
635 __u32 info_size;
636 __u32 source_id;
637 __u32 exception_code;
638 __u32 clear_exception;
639};
640struct kfd_ioctl_dbg_trap_queue_snapshot_args {
641 __u64 exception_mask;
642 __u64 snapshot_buf_ptr;
643 __u32 num_queues;
644 __u32 entry_size;
645};
646struct kfd_ioctl_dbg_trap_device_snapshot_args {
647 __u64 exception_mask;
648 __u64 snapshot_buf_ptr;
649 __u32 num_devices;
650 __u32 entry_size;
651};
652struct kfd_ioctl_dbg_trap_args {
653 __u32 pid;
654 __u32 op;
655 union {
656 struct kfd_ioctl_dbg_trap_enable_args enable;
657 struct kfd_ioctl_dbg_trap_send_runtime_event_args send_runtime_event;
658 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args set_exceptions_enabled;
659 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args launch_override;
660 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args launch_mode;
661 struct kfd_ioctl_dbg_trap_suspend_queues_args suspend_queues;
662 struct kfd_ioctl_dbg_trap_resume_queues_args resume_queues;
663 struct kfd_ioctl_dbg_trap_set_node_address_watch_args set_node_address_watch;
664 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args clear_node_address_watch;
665 struct kfd_ioctl_dbg_trap_set_flags_args set_flags;
666 struct kfd_ioctl_dbg_trap_query_debug_event_args query_debug_event;
667 struct kfd_ioctl_dbg_trap_query_exception_info_args query_exception_info;
668 struct kfd_ioctl_dbg_trap_queue_snapshot_args queue_snapshot;
669 struct kfd_ioctl_dbg_trap_device_snapshot_args device_snapshot;
670 };
671};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800672#define AMDKFD_IOCTL_BASE 'K'
673#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800674#define AMDKFD_IOR(nr,type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
675#define AMDKFD_IOW(nr,type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
676#define AMDKFD_IOWR(nr,type) _IOWR(AMDKFD_IOCTL_BASE, nr, type)
677#define AMDKFD_IOC_GET_VERSION AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800678#define AMDKFD_IOC_CREATE_QUEUE AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
679#define AMDKFD_IOC_DESTROY_QUEUE AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
680#define AMDKFD_IOC_SET_MEMORY_POLICY AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
681#define AMDKFD_IOC_GET_CLOCK_COUNTERS AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800682#define AMDKFD_IOC_GET_PROCESS_APERTURES AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
683#define AMDKFD_IOC_UPDATE_QUEUE AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
684#define AMDKFD_IOC_CREATE_EVENT AMDKFD_IOWR(0x08, struct kfd_ioctl_create_event_args)
685#define AMDKFD_IOC_DESTROY_EVENT AMDKFD_IOW(0x09, struct kfd_ioctl_destroy_event_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800686#define AMDKFD_IOC_SET_EVENT AMDKFD_IOW(0x0A, struct kfd_ioctl_set_event_args)
687#define AMDKFD_IOC_RESET_EVENT AMDKFD_IOW(0x0B, struct kfd_ioctl_reset_event_args)
688#define AMDKFD_IOC_WAIT_EVENTS AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700689#define AMDKFD_IOC_DBG_REGISTER_DEPRECATED AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
690#define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
691#define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECATED AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
692#define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATED AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800693#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
694#define AMDKFD_IOC_GET_TILE_CONFIG AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700695#define AMDKFD_IOC_SET_TRAP_HANDLER AMDKFD_IOW(0x13, struct kfd_ioctl_set_trap_handler_args)
696#define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW AMDKFD_IOWR(0x14, struct kfd_ioctl_get_process_apertures_new_args)
697#define AMDKFD_IOC_ACQUIRE_VM AMDKFD_IOW(0x15, struct kfd_ioctl_acquire_vm_args)
698#define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args)
699#define AMDKFD_IOC_FREE_MEMORY_OF_GPU AMDKFD_IOW(0x17, struct kfd_ioctl_free_memory_of_gpu_args)
700#define AMDKFD_IOC_MAP_MEMORY_TO_GPU AMDKFD_IOWR(0x18, struct kfd_ioctl_map_memory_to_gpu_args)
701#define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU AMDKFD_IOWR(0x19, struct kfd_ioctl_unmap_memory_from_gpu_args)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700702#define AMDKFD_IOC_SET_CU_MASK AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
Christopher Ferris86a48372019-01-10 14:14:59 -0800703#define AMDKFD_IOC_GET_QUEUE_WAVE_STATE AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800704#define AMDKFD_IOC_GET_DMABUF_INFO AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args)
705#define AMDKFD_IOC_IMPORT_DMABUF AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700706#define AMDKFD_IOC_ALLOC_QUEUE_GWS AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
Christopher Ferris25c18d42020-10-14 17:42:58 -0700707#define AMDKFD_IOC_SMI_EVENTS AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000708#define AMDKFD_IOC_SVM AMDKFD_IOWR(0x20, struct kfd_ioctl_svm_args)
709#define AMDKFD_IOC_SET_XNACK_MODE AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700710#define AMDKFD_IOC_CRIU_OP AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_args)
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700711#define AMDKFD_IOC_AVAILABLE_MEMORY AMDKFD_IOWR(0x23, struct kfd_ioctl_get_available_memory_args)
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700712#define AMDKFD_IOC_EXPORT_DMABUF AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args)
Christopher Ferris8666d042023-09-06 14:55:31 -0700713#define AMDKFD_IOC_RUNTIME_ENABLE AMDKFD_IOWR(0x25, struct kfd_ioctl_runtime_enable_args)
714#define AMDKFD_IOC_DBG_TRAP AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800715#define AMDKFD_COMMAND_START 0x01
Christopher Ferris8666d042023-09-06 14:55:31 -0700716#define AMDKFD_COMMAND_END 0x27
Christopher Ferris05d08e92016-02-04 13:16:38 -0800717#endif