2 * Copyright 2014 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef KFD_IOCTL_H_INCLUDED
24 #define KFD_IOCTL_H_INCLUDED
27 #include <linux/ioctl.h>
30 * - 1.1 - initial version
31 * - 1.3 - Add SMI events support
32 * - 1.4 - Indicate new SRAM EDC bit in device properties
34 * - 1.6 - Query clear flags in SVM get_attr API
35 * - 1.7 - Checkpoint Restore (CRIU) API
36 * - 1.8 - CRIU - Support for SDMA transfers with GTT BOs
37 * - 1.9 - Add available memory ioctl
38 * - 1.10 - Add SMI profiler event log
39 * - 1.11 - Add unified memory for ctx save/restore area
40 * - 1.12 - Add DMA buf export ioctl
41 * - 1.13 - Add debugger API
42 * - 1.14 - Update kfd_event_data
43 * - 1.15 - Enable managing mappings in compute VMs with GEM_VA ioctl
44 * - 1.16 - Add contiguous VRAM allocation flag
45 * - 1.17 - Add SDMA queue creation with target SDMA engine ID
47 #define KFD_IOCTL_MAJOR_VERSION 1
48 #define KFD_IOCTL_MINOR_VERSION 17
50 struct kfd_ioctl_get_version_args
{
51 __u32 major_version
; /* from KFD */
52 __u32 minor_version
; /* from KFD */
55 /* For kfd_ioctl_create_queue_args.queue_type. */
56 #define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0
57 #define KFD_IOC_QUEUE_TYPE_SDMA 0x1
58 #define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2
59 #define KFD_IOC_QUEUE_TYPE_SDMA_XGMI 0x3
60 #define KFD_IOC_QUEUE_TYPE_SDMA_BY_ENG_ID 0x4
62 #define KFD_MAX_QUEUE_PERCENTAGE 100
63 #define KFD_MAX_QUEUE_PRIORITY 15
65 struct kfd_ioctl_create_queue_args
{
66 __u64 ring_base_address
; /* to KFD */
67 __u64 write_pointer_address
; /* from KFD */
68 __u64 read_pointer_address
; /* from KFD */
69 __u64 doorbell_offset
; /* from KFD */
71 __u32 ring_size
; /* to KFD */
72 __u32 gpu_id
; /* to KFD */
73 __u32 queue_type
; /* to KFD */
74 __u32 queue_percentage
; /* to KFD */
75 __u32 queue_priority
; /* to KFD */
76 __u32 queue_id
; /* from KFD */
78 __u64 eop_buffer_address
; /* to KFD */
79 __u64 eop_buffer_size
; /* to KFD */
80 __u64 ctx_save_restore_address
; /* to KFD */
81 __u32 ctx_save_restore_size
; /* to KFD */
82 __u32 ctl_stack_size
; /* to KFD */
83 __u32 sdma_engine_id
; /* to KFD */
87 struct kfd_ioctl_destroy_queue_args
{
88 __u32 queue_id
; /* to KFD */
92 struct kfd_ioctl_update_queue_args
{
93 __u64 ring_base_address
; /* to KFD */
95 __u32 queue_id
; /* to KFD */
96 __u32 ring_size
; /* to KFD */
97 __u32 queue_percentage
; /* to KFD */
98 __u32 queue_priority
; /* to KFD */
101 struct kfd_ioctl_set_cu_mask_args
{
102 __u32 queue_id
; /* to KFD */
103 __u32 num_cu_mask
; /* to KFD */
104 __u64 cu_mask_ptr
; /* to KFD */
107 struct kfd_ioctl_get_queue_wave_state_args
{
108 __u64 ctl_stack_address
; /* to KFD */
109 __u32 ctl_stack_used_size
; /* from KFD */
110 __u32 save_area_used_size
; /* from KFD */
111 __u32 queue_id
; /* to KFD */
115 struct kfd_ioctl_get_available_memory_args
{
116 __u64 available
; /* from KFD */
117 __u32 gpu_id
; /* to KFD */
121 struct kfd_dbg_device_info_entry
{
122 __u64 exception_status
;
134 __u32 subsystem_vendor_id
;
135 __u32 subsystem_device_id
;
137 __u32 gfx_target_version
;
139 __u32 max_waves_per_simd
;
141 __u32 simd_arrays_per_engine
;
147 /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
148 #define KFD_IOC_CACHE_POLICY_COHERENT 0
149 #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
151 struct kfd_ioctl_set_memory_policy_args
{
152 __u64 alternate_aperture_base
; /* to KFD */
153 __u64 alternate_aperture_size
; /* to KFD */
155 __u32 gpu_id
; /* to KFD */
156 __u32 default_policy
; /* to KFD */
157 __u32 alternate_policy
; /* to KFD */
162 * All counters are monotonic. They are used for profiling of compute jobs.
163 * The profiling is done by userspace.
165 * In case of GPU reset, the counter should not be affected.
168 struct kfd_ioctl_get_clock_counters_args
{
169 __u64 gpu_clock_counter
; /* from KFD */
170 __u64 cpu_clock_counter
; /* from KFD */
171 __u64 system_clock_counter
; /* from KFD */
172 __u64 system_clock_freq
; /* from KFD */
174 __u32 gpu_id
; /* to KFD */
178 struct kfd_process_device_apertures
{
179 __u64 lds_base
; /* from KFD */
180 __u64 lds_limit
; /* from KFD */
181 __u64 scratch_base
; /* from KFD */
182 __u64 scratch_limit
; /* from KFD */
183 __u64 gpuvm_base
; /* from KFD */
184 __u64 gpuvm_limit
; /* from KFD */
185 __u32 gpu_id
; /* from KFD */
190 * AMDKFD_IOC_GET_PROCESS_APERTURES is deprecated. Use
191 * AMDKFD_IOC_GET_PROCESS_APERTURES_NEW instead, which supports an
192 * unlimited number of GPUs.
194 #define NUM_OF_SUPPORTED_GPUS 7
195 struct kfd_ioctl_get_process_apertures_args
{
196 struct kfd_process_device_apertures
197 process_apertures
[NUM_OF_SUPPORTED_GPUS
];/* from KFD */
199 /* from KFD, should be in the range [1 - NUM_OF_SUPPORTED_GPUS] */
204 struct kfd_ioctl_get_process_apertures_new_args
{
205 /* User allocated. Pointer to struct kfd_process_device_apertures
206 * filled in by Kernel
208 __u64 kfd_process_device_apertures_ptr
;
209 /* to KFD - indicates amount of memory present in
210 * kfd_process_device_apertures_ptr
211 * from KFD - Number of entries filled by KFD.
217 #define MAX_ALLOWED_NUM_POINTS 100
218 #define MAX_ALLOWED_AW_BUFF_SIZE 4096
219 #define MAX_ALLOWED_WAC_BUFF_SIZE 128
221 struct kfd_ioctl_dbg_register_args
{
222 __u32 gpu_id
; /* to KFD */
226 struct kfd_ioctl_dbg_unregister_args
{
227 __u32 gpu_id
; /* to KFD */
231 struct kfd_ioctl_dbg_address_watch_args
{
232 __u64 content_ptr
; /* a pointer to the actual content */
233 __u32 gpu_id
; /* to KFD */
234 __u32 buf_size_in_bytes
; /*including gpu_id and buf_size */
237 struct kfd_ioctl_dbg_wave_control_args
{
238 __u64 content_ptr
; /* a pointer to the actual content */
239 __u32 gpu_id
; /* to KFD */
240 __u32 buf_size_in_bytes
; /*including gpu_id and buf_size */
243 #define KFD_INVALID_FD 0xffffffff
245 /* Matching HSA_EVENTTYPE */
246 #define KFD_IOC_EVENT_SIGNAL 0
247 #define KFD_IOC_EVENT_NODECHANGE 1
248 #define KFD_IOC_EVENT_DEVICESTATECHANGE 2
249 #define KFD_IOC_EVENT_HW_EXCEPTION 3
250 #define KFD_IOC_EVENT_SYSTEM_EVENT 4
251 #define KFD_IOC_EVENT_DEBUG_EVENT 5
252 #define KFD_IOC_EVENT_PROFILE_EVENT 6
253 #define KFD_IOC_EVENT_QUEUE_EVENT 7
254 #define KFD_IOC_EVENT_MEMORY 8
256 #define KFD_IOC_WAIT_RESULT_COMPLETE 0
257 #define KFD_IOC_WAIT_RESULT_TIMEOUT 1
258 #define KFD_IOC_WAIT_RESULT_FAIL 2
260 #define KFD_SIGNAL_EVENT_LIMIT 4096
262 /* For kfd_event_data.hw_exception_data.reset_type. */
263 #define KFD_HW_EXCEPTION_WHOLE_GPU_RESET 0
264 #define KFD_HW_EXCEPTION_PER_ENGINE_RESET 1
266 /* For kfd_event_data.hw_exception_data.reset_cause. */
267 #define KFD_HW_EXCEPTION_GPU_HANG 0
268 #define KFD_HW_EXCEPTION_ECC 1
270 /* For kfd_hsa_memory_exception_data.ErrorType */
271 #define KFD_MEM_ERR_NO_RAS 0
272 #define KFD_MEM_ERR_SRAM_ECC 1
273 #define KFD_MEM_ERR_POISON_CONSUMED 2
274 #define KFD_MEM_ERR_GPU_HANG 3
276 struct kfd_ioctl_create_event_args
{
277 __u64 event_page_offset
; /* from KFD */
278 __u32 event_trigger_data
; /* from KFD - signal events only */
279 __u32 event_type
; /* to KFD */
280 __u32 auto_reset
; /* to KFD */
281 __u32 node_id
; /* to KFD - only valid for certain
283 __u32 event_id
; /* from KFD */
284 __u32 event_slot_index
; /* from KFD */
287 struct kfd_ioctl_destroy_event_args
{
288 __u32 event_id
; /* to KFD */
292 struct kfd_ioctl_set_event_args
{
293 __u32 event_id
; /* to KFD */
297 struct kfd_ioctl_reset_event_args
{
298 __u32 event_id
; /* to KFD */
302 struct kfd_memory_exception_failure
{
303 __u32 NotPresent
; /* Page not present or supervisor privilege */
304 __u32 ReadOnly
; /* Write access to a read-only page */
305 __u32 NoExecute
; /* Execute access to a page marked NX */
306 __u32 imprecise
; /* Can't determine the exact fault address */
309 /* memory exception data */
310 struct kfd_hsa_memory_exception_data
{
311 struct kfd_memory_exception_failure failure
;
314 __u32 ErrorType
; /* 0 = no RAS error,
316 * 2 = Link_SYNFLOOD (poison),
317 * 3 = GPU hang (not attributable to a specific cause),
318 * other values reserved
322 /* hw exception data */
323 struct kfd_hsa_hw_exception_data
{
330 /* hsa signal event data */
331 struct kfd_hsa_signal_event_data
{
332 __u64 last_event_age
; /* to and from KFD */
336 struct kfd_event_data
{
339 struct kfd_hsa_memory_exception_data memory_exception_data
;
340 struct kfd_hsa_hw_exception_data hw_exception_data
;
341 /* To and From KFD */
342 struct kfd_hsa_signal_event_data signal_event_data
;
344 __u64 kfd_event_data_ext
; /* pointer to an extension structure
345 for future exception types */
346 __u32 event_id
; /* to KFD */
350 struct kfd_ioctl_wait_events_args
{
351 __u64 events_ptr
; /* pointed to struct
352 kfd_event_data array, to KFD */
353 __u32 num_events
; /* to KFD */
354 __u32 wait_for_all
; /* to KFD */
355 __u32 timeout
; /* to KFD */
356 __u32 wait_result
; /* from KFD */
359 struct kfd_ioctl_set_scratch_backing_va_args
{
360 __u64 va_addr
; /* to KFD */
361 __u32 gpu_id
; /* to KFD */
365 struct kfd_ioctl_get_tile_config_args
{
366 /* to KFD: pointer to tile array */
367 __u64 tile_config_ptr
;
368 /* to KFD: pointer to macro tile array */
369 __u64 macro_tile_config_ptr
;
370 /* to KFD: array size allocated by user mode
371 * from KFD: array size filled by kernel
373 __u32 num_tile_configs
;
374 /* to KFD: array size allocated by user mode
375 * from KFD: array size filled by kernel
377 __u32 num_macro_tile_configs
;
379 __u32 gpu_id
; /* to KFD */
380 __u32 gb_addr_config
; /* from KFD */
381 __u32 num_banks
; /* from KFD */
382 __u32 num_ranks
; /* from KFD */
383 /* struct size can be extended later if needed
384 * without breaking ABI compatibility
388 struct kfd_ioctl_set_trap_handler_args
{
389 __u64 tba_addr
; /* to KFD */
390 __u64 tma_addr
; /* to KFD */
391 __u32 gpu_id
; /* to KFD */
395 struct kfd_ioctl_acquire_vm_args
{
396 __u32 drm_fd
; /* to KFD */
397 __u32 gpu_id
; /* to KFD */
400 /* Allocation flags: memory types */
401 #define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
402 #define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
403 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
404 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
405 #define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4)
406 /* Allocation flags: attributes/access options */
407 #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31)
408 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30)
409 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
410 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
411 #define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
412 #define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 26)
413 #define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED (1 << 25)
414 #define KFD_IOC_ALLOC_MEM_FLAGS_EXT_COHERENT (1 << 24)
415 #define KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS (1 << 23)
417 /* Allocate memory for later SVM (shared virtual memory) mapping.
419 * @va_addr: virtual address of the memory to be allocated
420 * all later mappings on all GPUs will use this address
421 * @size: size in bytes
422 * @handle: buffer handle returned to user mode, used to refer to
423 * this allocation for mapping, unmapping and freeing
424 * @mmap_offset: for CPU-mapping the allocation by mmapping a render node
425 * for userptrs this is overloaded to specify the CPU address
426 * @gpu_id: device identifier
427 * @flags: memory type and attributes. See KFD_IOC_ALLOC_MEM_FLAGS above
429 struct kfd_ioctl_alloc_memory_of_gpu_args
{
430 __u64 va_addr
; /* to KFD */
431 __u64 size
; /* to KFD */
432 __u64 handle
; /* from KFD */
433 __u64 mmap_offset
; /* to KFD (userptr), from KFD (mmap offset) */
434 __u32 gpu_id
; /* to KFD */
438 /* Free memory allocated with kfd_ioctl_alloc_memory_of_gpu
440 * @handle: memory handle returned by alloc
442 struct kfd_ioctl_free_memory_of_gpu_args
{
443 __u64 handle
; /* to KFD */
446 /* Map memory to one or more GPUs
448 * @handle: memory handle returned by alloc
449 * @device_ids_array_ptr: array of gpu_ids (__u32 per device)
450 * @n_devices: number of devices in the array
451 * @n_success: number of devices mapped successfully
453 * @n_success returns information to the caller how many devices from
454 * the start of the array have mapped the buffer successfully. It can
455 * be passed into a subsequent retry call to skip those devices. For
456 * the first call the caller should initialize it to 0.
458 * If the ioctl completes with return code 0 (success), n_success ==
461 struct kfd_ioctl_map_memory_to_gpu_args
{
462 __u64 handle
; /* to KFD */
463 __u64 device_ids_array_ptr
; /* to KFD */
464 __u32 n_devices
; /* to KFD */
465 __u32 n_success
; /* to/from KFD */
468 /* Unmap memory from one or more GPUs
470 * same arguments as for mapping
472 struct kfd_ioctl_unmap_memory_from_gpu_args
{
473 __u64 handle
; /* to KFD */
474 __u64 device_ids_array_ptr
; /* to KFD */
475 __u32 n_devices
; /* to KFD */
476 __u32 n_success
; /* to/from KFD */
479 /* Allocate GWS for specific queue
481 * @queue_id: queue's id that GWS is allocated for
482 * @num_gws: how many GWS to allocate
483 * @first_gws: index of the first GWS allocated.
484 * only support contiguous GWS allocation
486 struct kfd_ioctl_alloc_queue_gws_args
{
487 __u32 queue_id
; /* to KFD */
488 __u32 num_gws
; /* to KFD */
489 __u32 first_gws
; /* from KFD */
493 struct kfd_ioctl_get_dmabuf_info_args
{
494 __u64 size
; /* from KFD */
495 __u64 metadata_ptr
; /* to KFD */
496 __u32 metadata_size
; /* to KFD (space allocated by user)
497 * from KFD (actual metadata size)
499 __u32 gpu_id
; /* from KFD */
500 __u32 flags
; /* from KFD (KFD_IOC_ALLOC_MEM_FLAGS) */
501 __u32 dmabuf_fd
; /* to KFD */
504 struct kfd_ioctl_import_dmabuf_args
{
505 __u64 va_addr
; /* to KFD */
506 __u64 handle
; /* from KFD */
507 __u32 gpu_id
; /* to KFD */
508 __u32 dmabuf_fd
; /* to KFD */
511 struct kfd_ioctl_export_dmabuf_args
{
512 __u64 handle
; /* to KFD */
513 __u32 flags
; /* to KFD */
514 __u32 dmabuf_fd
; /* from KFD */
518 * KFD SMI(System Management Interface) events
521 KFD_SMI_EVENT_NONE
= 0, /* not used */
522 KFD_SMI_EVENT_VMFAULT
= 1, /* event start counting at 1 */
523 KFD_SMI_EVENT_THERMAL_THROTTLE
= 2,
524 KFD_SMI_EVENT_GPU_PRE_RESET
= 3,
525 KFD_SMI_EVENT_GPU_POST_RESET
= 4,
526 KFD_SMI_EVENT_MIGRATE_START
= 5,
527 KFD_SMI_EVENT_MIGRATE_END
= 6,
528 KFD_SMI_EVENT_PAGE_FAULT_START
= 7,
529 KFD_SMI_EVENT_PAGE_FAULT_END
= 8,
530 KFD_SMI_EVENT_QUEUE_EVICTION
= 9,
531 KFD_SMI_EVENT_QUEUE_RESTORE
= 10,
532 KFD_SMI_EVENT_UNMAP_FROM_GPU
= 11,
535 * max event number, as a flag bit to get events from all processes,
536 * this requires super user permission, otherwise will not be able to
537 * receive event from any process. Without this flag to receive events
540 KFD_SMI_EVENT_ALL_PROCESS
= 64
543 /* The reason of the page migration event */
544 enum KFD_MIGRATE_TRIGGERS
{
545 KFD_MIGRATE_TRIGGER_PREFETCH
, /* Prefetch to GPU VRAM or system memory */
546 KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU
, /* GPU page fault recover */
547 KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU
, /* CPU page fault recover */
548 KFD_MIGRATE_TRIGGER_TTM_EVICTION
/* TTM eviction */
551 /* The reason of user queue evition event */
552 enum KFD_QUEUE_EVICTION_TRIGGERS
{
553 KFD_QUEUE_EVICTION_TRIGGER_SVM
, /* SVM buffer migration */
554 KFD_QUEUE_EVICTION_TRIGGER_USERPTR
, /* userptr movement */
555 KFD_QUEUE_EVICTION_TRIGGER_TTM
, /* TTM move buffer */
556 KFD_QUEUE_EVICTION_TRIGGER_SUSPEND
, /* GPU suspend */
557 KFD_QUEUE_EVICTION_CRIU_CHECKPOINT
, /* CRIU checkpoint */
558 KFD_QUEUE_EVICTION_CRIU_RESTORE
/* CRIU restore */
561 /* The reason of unmap buffer from GPU event */
562 enum KFD_SVM_UNMAP_TRIGGERS
{
563 KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY
, /* MMU notifier CPU buffer movement */
564 KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRATE
,/* MMU notifier page migration */
565 KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU
/* Unmap to free the buffer */
568 #define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
569 #define KFD_SMI_EVENT_MSG_SIZE 96
571 struct kfd_ioctl_smi_events_args
{
572 __u32 gpuid
; /* to KFD */
573 __u32 anon_fd
; /* from KFD */
577 * SVM event tracing via SMI system management interface
579 * Open event file descriptor
580 * use ioctl AMDKFD_IOC_SMI_EVENTS, pass in gpuid and return a anonymous file
581 * descriptor to receive SMI events.
582 * If calling with sudo permission, then file descriptor can be used to receive
583 * SVM events from all processes, otherwise, to only receive SVM events of same
586 * To enable the SVM event
587 * Write event file descriptor with KFD_SMI_EVENT_MASK_FROM_INDEX(event) bitmap
588 * mask to start record the event to the kfifo, use bitmap mask combination
589 * for multiple events. New event mask will overwrite the previous event mask.
590 * KFD_SMI_EVENT_MASK_FROM_INDEX(KFD_SMI_EVENT_ALL_PROCESS) bit requires sudo
591 * permisson to receive SVM events from all process.
593 * To receive the event
594 * Application can poll file descriptor to wait for the events, then read event
595 * from the file into a buffer. Each event is one line string message, starting
596 * with the event id, then the event specific information.
598 * To decode event information
599 * The following event format string macro can be used with sscanf to decode
600 * the specific event information.
601 * event triggers: the reason to generate the event, defined as enum for unmap,
602 * eviction and migrate events.
603 * node, from, to, prefetch_loc, preferred_loc: GPU ID, or 0 for system memory.
604 * addr: user mode address, in pages
606 * pid: the process ID to generate the event
607 * ns: timestamp in nanosecond-resolution, starts at system boot time but
608 * stops during suspend
609 * migrate_update: GPU page fault is recovered by 'M' for migrate, 'U' for update
610 * rw: 'W' for write page fault, 'R' for read page fault
611 * rescheduled: 'R' if the queue restore failed and rescheduled to try again
612 * error_code: migrate failure error code, 0 if no error
614 #define KFD_EVENT_FMT_UPDATE_GPU_RESET(reset_seq_num, reset_cause)\
615 "%x %s\n", (reset_seq_num), (reset_cause)
617 #define KFD_EVENT_FMT_THERMAL_THROTTLING(bitmask, counter)\
618 "%llx:%llx\n", (bitmask), (counter)
620 #define KFD_EVENT_FMT_VMFAULT(pid, task_name)\
621 "%x:%s\n", (pid), (task_name)
623 #define KFD_EVENT_FMT_PAGEFAULT_START(ns, pid, addr, node, rw)\
624 "%lld -%d @%lx(%x) %c\n", (ns), (pid), (addr), (node), (rw)
626 #define KFD_EVENT_FMT_PAGEFAULT_END(ns, pid, addr, node, migrate_update)\
627 "%lld -%d @%lx(%x) %c\n", (ns), (pid), (addr), (node), (migrate_update)
629 #define KFD_EVENT_FMT_MIGRATE_START(ns, pid, start, size, from, to, prefetch_loc,\
630 preferred_loc, migrate_trigger)\
631 "%lld -%d @%lx(%lx) %x->%x %x:%x %d\n", (ns), (pid), (start), (size),\
632 (from), (to), (prefetch_loc), (preferred_loc), (migrate_trigger)
634 #define KFD_EVENT_FMT_MIGRATE_END(ns, pid, start, size, from, to, migrate_trigger, error_code) \
635 "%lld -%d @%lx(%lx) %x->%x %d %d\n", (ns), (pid), (start), (size),\
636 (from), (to), (migrate_trigger), (error_code)
638 #define KFD_EVENT_FMT_QUEUE_EVICTION(ns, pid, node, evict_trigger)\
639 "%lld -%d %x %d\n", (ns), (pid), (node), (evict_trigger)
641 #define KFD_EVENT_FMT_QUEUE_RESTORE(ns, pid, node, rescheduled)\
642 "%lld -%d %x %c\n", (ns), (pid), (node), (rescheduled)
644 #define KFD_EVENT_FMT_UNMAP_FROM_GPU(ns, pid, addr, size, node, unmap_trigger)\
645 "%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\
646 (node), (unmap_trigger)
648 /**************************************************************************************************
649 * CRIU IOCTLs (Checkpoint Restore In Userspace)
651 * When checkpointing a process, the userspace application will perform:
652 * 1. PROCESS_INFO op to determine current process information. This pauses execution and evicts
654 * 2. CHECKPOINT op to checkpoint process contents (BOs, queues, events, svm-ranges)
655 * 3. UNPAUSE op to un-evict all the queues
657 * When restoring a process, the CRIU userspace application will perform:
659 * 1. RESTORE op to restore process contents
660 * 2. RESUME op to start the process
662 * Note: Queues are forced into an evicted state after a successful PROCESS_INFO. User
663 * application needs to perform an UNPAUSE operation after calling PROCESS_INFO.
667 KFD_CRIU_OP_PROCESS_INFO
,
668 KFD_CRIU_OP_CHECKPOINT
,
675 * kfd_ioctl_criu_args - Arguments perform CRIU operation
676 * @devices: [in/out] User pointer to memory location for devices information.
677 * This is an array of type kfd_criu_device_bucket.
678 * @bos: [in/out] User pointer to memory location for BOs information
679 * This is an array of type kfd_criu_bo_bucket.
680 * @priv_data: [in/out] User pointer to memory location for private data
681 * @priv_data_size: [in/out] Size of priv_data in bytes
682 * @num_devices: [in/out] Number of GPUs used by process. Size of @devices array.
683 * @num_bos [in/out] Number of BOs used by process. Size of @bos array.
684 * @num_objects: [in/out] Number of objects used by process. Objects are opaque to
686 * @pid: [in/out] PID of the process being checkpointed
687 * @op [in] Type of operation (kfd_criu_op)
689 * Return: 0 on success, -errno on failure
691 struct kfd_ioctl_criu_args
{
692 __u64 devices
; /* Used during ops: CHECKPOINT, RESTORE */
693 __u64 bos
; /* Used during ops: CHECKPOINT, RESTORE */
694 __u64 priv_data
; /* Used during ops: CHECKPOINT, RESTORE */
695 __u64 priv_data_size
; /* Used during ops: PROCESS_INFO, RESTORE */
696 __u32 num_devices
; /* Used during ops: PROCESS_INFO, RESTORE */
697 __u32 num_bos
; /* Used during ops: PROCESS_INFO, RESTORE */
698 __u32 num_objects
; /* Used during ops: PROCESS_INFO, RESTORE */
699 __u32 pid
; /* Used during ops: PROCESS_INFO, RESUME */
703 struct kfd_criu_device_bucket
{
710 struct kfd_criu_bo_bucket
{
714 __u64 restored_offset
; /* During restore, updated offset for BO */
715 __u32 gpu_id
; /* This is the user_gpu_id */
721 /* CRIU IOCTLs - END */
722 /**************************************************************************************************/
724 /* Register offset inside the remapped mmio page
726 enum kfd_mmio_remap
{
727 KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL
= 0,
728 KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL
= 4,
731 /* Guarantee host access to memory */
732 #define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000001
733 /* Fine grained coherency between all devices with access */
734 #define KFD_IOCTL_SVM_FLAG_COHERENT 0x00000002
735 /* Use any GPU in same hive as preferred device */
736 #define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL 0x00000004
737 /* GPUs only read, allows replication */
738 #define KFD_IOCTL_SVM_FLAG_GPU_RO 0x00000008
739 /* Allow execution on GPU */
740 #define KFD_IOCTL_SVM_FLAG_GPU_EXEC 0x00000010
741 /* GPUs mostly read, may allow similar optimizations as RO, but writes fault */
742 #define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY 0x00000020
743 /* Keep GPU memory mapping always valid as if XNACK is disable */
744 #define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED 0x00000040
745 /* Fine grained coherency between all devices using device-scope atomics */
746 #define KFD_IOCTL_SVM_FLAG_EXT_COHERENT 0x00000080
749 * kfd_ioctl_svm_op - SVM ioctl operations
751 * @KFD_IOCTL_SVM_OP_SET_ATTR: Modify one or more attributes
752 * @KFD_IOCTL_SVM_OP_GET_ATTR: Query one or more attributes
754 enum kfd_ioctl_svm_op
{
755 KFD_IOCTL_SVM_OP_SET_ATTR
,
756 KFD_IOCTL_SVM_OP_GET_ATTR
759 /** kfd_ioctl_svm_location - Enum for preferred and prefetch locations
761 * GPU IDs are used to specify GPUs as preferred and prefetch locations.
762 * Below definitions are used for system memory or for leaving the preferred
763 * location unspecified.
765 enum kfd_ioctl_svm_location
{
766 KFD_IOCTL_SVM_LOCATION_SYSMEM
= 0,
767 KFD_IOCTL_SVM_LOCATION_UNDEFINED
= 0xffffffff
771 * kfd_ioctl_svm_attr_type - SVM attribute types
773 * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC: gpuid of the preferred location, 0 for
775 * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC: gpuid of the prefetch location, 0 for
776 * system memory. Setting this triggers an
777 * immediate prefetch (migration).
778 * @KFD_IOCTL_SVM_ATTR_ACCESS:
779 * @KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE:
780 * @KFD_IOCTL_SVM_ATTR_NO_ACCESS: specify memory access for the gpuid given
781 * by the attribute value
782 * @KFD_IOCTL_SVM_ATTR_SET_FLAGS: bitmask of flags to set (see
783 * KFD_IOCTL_SVM_FLAG_...)
784 * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS: bitmask of flags to clear
785 * @KFD_IOCTL_SVM_ATTR_GRANULARITY: migration granularity
788 enum kfd_ioctl_svm_attr_type
{
789 KFD_IOCTL_SVM_ATTR_PREFERRED_LOC
,
790 KFD_IOCTL_SVM_ATTR_PREFETCH_LOC
,
791 KFD_IOCTL_SVM_ATTR_ACCESS
,
792 KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE
,
793 KFD_IOCTL_SVM_ATTR_NO_ACCESS
,
794 KFD_IOCTL_SVM_ATTR_SET_FLAGS
,
795 KFD_IOCTL_SVM_ATTR_CLR_FLAGS
,
796 KFD_IOCTL_SVM_ATTR_GRANULARITY
800 * kfd_ioctl_svm_attribute - Attributes as pairs of type and value
802 * The meaning of the @value depends on the attribute type.
804 * @type: attribute type (see enum @kfd_ioctl_svm_attr_type)
805 * @value: attribute value
807 struct kfd_ioctl_svm_attribute
{
813 * kfd_ioctl_svm_args - Arguments for SVM ioctl
815 * @op specifies the operation to perform (see enum
816 * @kfd_ioctl_svm_op). @start_addr and @size are common for all
819 * A variable number of attributes can be given in @attrs.
820 * @nattr specifies the number of attributes. New attributes can be
821 * added in the future without breaking the ABI. If unknown attributes
822 * are given, the function returns -EINVAL.
824 * @KFD_IOCTL_SVM_OP_SET_ATTR sets attributes for a virtual address
825 * range. It may overlap existing virtual address ranges. If it does,
826 * the existing ranges will be split such that the attribute changes
827 * only apply to the specified address range.
829 * @KFD_IOCTL_SVM_OP_GET_ATTR returns the intersection of attributes
830 * over all memory in the given range and returns the result as the
831 * attribute value. If different pages have different preferred or
832 * prefetch locations, 0xffffffff will be returned for
833 * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC or
834 * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC resepctively. For
835 * @KFD_IOCTL_SVM_ATTR_SET_FLAGS, flags of all pages will be
836 * aggregated by bitwise AND. That means, a flag will be set in the
837 * output, if that flag is set for all pages in the range. For
838 * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS, flags of all pages will be
839 * aggregated by bitwise NOR. That means, a flag will be set in the
840 * output, if that flag is clear for all pages in the range.
841 * The minimum migration granularity throughout the range will be
842 * returned for @KFD_IOCTL_SVM_ATTR_GRANULARITY.
844 * Querying of accessibility attributes works by initializing the
845 * attribute type to @KFD_IOCTL_SVM_ATTR_ACCESS and the value to the
846 * GPUID being queried. Multiple attributes can be given to allow
847 * querying multiple GPUIDs. The ioctl function overwrites the
848 * attribute type to indicate the access for the specified GPU.
850 struct kfd_ioctl_svm_args
{
855 /* Variable length array of attributes */
856 struct kfd_ioctl_svm_attribute attrs
[];
860 * kfd_ioctl_set_xnack_mode_args - Arguments for set_xnack_mode
862 * @xnack_enabled: [in/out] Whether to enable XNACK mode for this process
864 * @xnack_enabled indicates whether recoverable page faults should be
865 * enabled for the current process. 0 means disabled, positive means
866 * enabled, negative means leave unchanged. If enabled, virtual address
867 * translations on GFXv9 and later AMD GPUs can return XNACK and retry
868 * the access until a valid PTE is available. This is used to implement
869 * device page faults.
871 * On output, @xnack_enabled returns the (new) current mode (0 or
872 * positive). Therefore, a negative input value can be used to query
873 * the current mode without changing it.
875 * The XNACK mode fundamentally changes the way SVM managed memory works
876 * in the driver, with subtle effects on application performance and
879 * Enabling XNACK mode requires shader programs to be compiled
880 * differently. Furthermore, not all GPUs support changing the mode
881 * per-process. Therefore changing the mode is only allowed while no
882 * user mode queues exist in the process. This ensure that no shader
883 * code is running that may be compiled for the wrong mode. And GPUs
884 * that cannot change to the requested mode will prevent the XNACK
885 * mode from occurring. All GPUs used by the process must be in the
888 * GFXv8 or older GPUs do not support 48 bit virtual addresses or SVM.
889 * Therefore those GPUs are not considered for the XNACK mode switch.
891 * Return: 0 on success, -errno on failure
893 struct kfd_ioctl_set_xnack_mode_args
{
897 /* Wave launch override modes */
898 enum kfd_dbg_trap_override_mode
{
899 KFD_DBG_TRAP_OVERRIDE_OR
= 0,
900 KFD_DBG_TRAP_OVERRIDE_REPLACE
= 1
903 /* Wave launch overrides */
904 enum kfd_dbg_trap_mask
{
905 KFD_DBG_TRAP_MASK_FP_INVALID
= 1,
906 KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL
= 2,
907 KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO
= 4,
908 KFD_DBG_TRAP_MASK_FP_OVERFLOW
= 8,
909 KFD_DBG_TRAP_MASK_FP_UNDERFLOW
= 16,
910 KFD_DBG_TRAP_MASK_FP_INEXACT
= 32,
911 KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO
= 64,
912 KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH
= 128,
913 KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION
= 256,
914 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START
= (1 << 30),
915 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END
= (1 << 31)
918 /* Wave launch modes */
919 enum kfd_dbg_trap_wave_launch_mode
{
920 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL
= 0,
921 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT
= 1,
922 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG
= 3
925 /* Address watch modes */
926 enum kfd_dbg_trap_address_watch_mode
{
927 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ
= 0,
928 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREAD
= 1,
929 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC
= 2,
930 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL
= 3
933 /* Additional wave settings */
934 enum kfd_dbg_trap_flags
{
935 KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP
= 1,
936 KFD_DBG_TRAP_FLAG_SINGLE_ALU_OP
= 2,
939 /* Trap exceptions */
940 enum kfd_dbg_trap_exception_code
{
943 EC_QUEUE_WAVE_ABORT
= 1,
944 EC_QUEUE_WAVE_TRAP
= 2,
945 EC_QUEUE_WAVE_MATH_ERROR
= 3,
946 EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION
= 4,
947 EC_QUEUE_WAVE_MEMORY_VIOLATION
= 5,
948 EC_QUEUE_WAVE_APERTURE_VIOLATION
= 6,
949 EC_QUEUE_PACKET_DISPATCH_DIM_INVALID
= 16,
950 EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID
= 17,
951 EC_QUEUE_PACKET_DISPATCH_CODE_INVALID
= 18,
952 EC_QUEUE_PACKET_RESERVED
= 19,
953 EC_QUEUE_PACKET_UNSUPPORTED
= 20,
954 EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID
= 21,
955 EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID
= 22,
956 EC_QUEUE_PACKET_VENDOR_UNSUPPORTED
= 23,
957 EC_QUEUE_PREEMPTION_ERROR
= 30,
960 EC_DEVICE_QUEUE_DELETE
= 32,
961 EC_DEVICE_MEMORY_VIOLATION
= 33,
962 EC_DEVICE_RAS_ERROR
= 34,
963 EC_DEVICE_FATAL_HALT
= 35,
966 EC_PROCESS_RUNTIME
= 48,
967 EC_PROCESS_DEVICE_REMOVE
= 49,
971 /* Mask generated by ecode in kfd_dbg_trap_exception_code */
972 #define KFD_EC_MASK(ecode) (1ULL << (ecode - 1))
974 /* Masks for exception code type checks below */
975 #define KFD_EC_MASK_QUEUE (KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) | \
976 KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) | \
977 KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) | \
978 KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) | \
979 KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) | \
980 KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) | \
981 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | \
982 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | \
983 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | \
984 KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | \
985 KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | \
986 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | \
987 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | \
988 KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED) | \
989 KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR) | \
990 KFD_EC_MASK(EC_QUEUE_NEW))
991 #define KFD_EC_MASK_DEVICE (KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) | \
992 KFD_EC_MASK(EC_DEVICE_RAS_ERROR) | \
993 KFD_EC_MASK(EC_DEVICE_FATAL_HALT) | \
994 KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) | \
995 KFD_EC_MASK(EC_DEVICE_NEW))
996 #define KFD_EC_MASK_PROCESS (KFD_EC_MASK(EC_PROCESS_RUNTIME) | \
997 KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE))
998 #define KFD_EC_MASK_PACKET (KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | \
999 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | \
1000 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | \
1001 KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | \
1002 KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | \
1003 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | \
1004 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | \
1005 KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED))
1007 /* Checks for exception code types for KFD search */
1008 #define KFD_DBG_EC_IS_VALID(ecode) (ecode > EC_NONE && ecode < EC_MAX)
1009 #define KFD_DBG_EC_TYPE_IS_QUEUE(ecode) \
1010 (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
1011 #define KFD_DBG_EC_TYPE_IS_DEVICE(ecode) \
1012 (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
1013 #define KFD_DBG_EC_TYPE_IS_PROCESS(ecode) \
1014 (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
1015 #define KFD_DBG_EC_TYPE_IS_PACKET(ecode) \
1016 (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PACKET))
1019 /* Runtime enable states */
1020 enum kfd_dbg_runtime_state
{
1021 DEBUG_RUNTIME_STATE_DISABLED
= 0,
1022 DEBUG_RUNTIME_STATE_ENABLED
= 1,
1023 DEBUG_RUNTIME_STATE_ENABLED_BUSY
= 2,
1024 DEBUG_RUNTIME_STATE_ENABLED_ERROR
= 3
1027 /* Runtime enable status */
1028 struct kfd_runtime_info
{
1030 __u32 runtime_state
;
1034 /* Enable modes for runtime enable */
1035 #define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK 1
1036 #define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK 2
1039 * kfd_ioctl_runtime_enable_args - Arguments for runtime enable
1041 * Coordinates debug exception signalling and debug device enablement with runtime.
1043 * @r_debug - pointer to user struct for sharing information between ROCr and the debuggger
1044 * @mode_mask - mask to set mode
1045 * KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK - enable runtime for debugging, otherwise disable
1046 * KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK - enable trap temporary setup (ignore on disable)
1047 * @capabilities_mask - mask to notify runtime on what KFD supports
1049 * Return - 0 on SUCCESS.
1050 * - EBUSY if runtime enable call already pending.
1051 * - EEXIST if user queues already active prior to call.
1052 * If process is debug enabled, runtime enable will enable debug devices and
1053 * wait for debugger process to send runtime exception EC_PROCESS_RUNTIME
1054 * to unblock - see kfd_ioctl_dbg_trap_args.
1057 struct kfd_ioctl_runtime_enable_args
{
1060 __u32 capabilities_mask
;
1063 /* Queue information */
1064 struct kfd_queue_snapshot_entry
{
1065 __u64 exception_status
;
1066 __u64 ring_base_address
;
1067 __u64 write_pointer_address
;
1068 __u64 read_pointer_address
;
1069 __u64 ctx_save_restore_address
;
1074 __u32 ctx_save_restore_area_size
;
1078 /* Queue status return for suspend/resume */
1079 #define KFD_DBG_QUEUE_ERROR_BIT 30
1080 #define KFD_DBG_QUEUE_INVALID_BIT 31
1081 #define KFD_DBG_QUEUE_ERROR_MASK (1 << KFD_DBG_QUEUE_ERROR_BIT)
1082 #define KFD_DBG_QUEUE_INVALID_MASK (1 << KFD_DBG_QUEUE_INVALID_BIT)
1084 /* Context save area header information */
1085 struct kfd_context_save_area_header
{
1087 __u32 control_stack_offset
;
1088 __u32 control_stack_size
;
1089 __u32 wave_state_offset
;
1090 __u32 wave_state_size
;
1094 __u64 err_payload_addr
;
1102 * For specifics on usage and return values, see documentation per operation
1103 * below. Otherwise, generic error returns apply:
1104 * - ESRCH if the process to debug does not exist.
1106 * - EINVAL (with KFD_IOC_DBG_TRAP_ENABLE exempt) if operation
1107 * KFD_IOC_DBG_TRAP_ENABLE has not succeeded prior.
1108 * Also returns this error if GPU hardware scheduling is not supported.
1110 * - EPERM (with KFD_IOC_DBG_TRAP_DISABLE exempt) if target process is not
1111 * PTRACE_ATTACHED. KFD_IOC_DBG_TRAP_DISABLE is exempt to allow
1112 * clean up of debug mode as long as process is debug enabled.
1114 * - EACCES if any DBG_HW_OP (debug hardware operation) is requested when
1115 * AMDKFD_IOC_RUNTIME_ENABLE has not succeeded prior.
1117 * - ENODEV if any GPU does not support debugging on a DBG_HW_OP call.
1119 * - Other errors may be returned when a DBG_HW_OP occurs while the GPU
1120 * is in a fatal state.
1123 enum kfd_dbg_trap_operations
{
1124 KFD_IOC_DBG_TRAP_ENABLE
= 0,
1125 KFD_IOC_DBG_TRAP_DISABLE
= 1,
1126 KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT
= 2,
1127 KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED
= 3,
1128 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE
= 4, /* DBG_HW_OP */
1129 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE
= 5, /* DBG_HW_OP */
1130 KFD_IOC_DBG_TRAP_SUSPEND_QUEUES
= 6, /* DBG_HW_OP */
1131 KFD_IOC_DBG_TRAP_RESUME_QUEUES
= 7, /* DBG_HW_OP */
1132 KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH
= 8, /* DBG_HW_OP */
1133 KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH
= 9, /* DBG_HW_OP */
1134 KFD_IOC_DBG_TRAP_SET_FLAGS
= 10,
1135 KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT
= 11,
1136 KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO
= 12,
1137 KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT
= 13,
1138 KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT
= 14
1142 * kfd_ioctl_dbg_trap_enable_args
1144 * Arguments for KFD_IOC_DBG_TRAP_ENABLE.
1146 * Enables debug session for target process. Call @op KFD_IOC_DBG_TRAP_DISABLE in
1147 * kfd_ioctl_dbg_trap_args to disable debug session.
1149 * @exception_mask (IN) - exceptions to raise to the debugger
1150 * @rinfo_ptr (IN) - pointer to runtime info buffer (see kfd_runtime_info)
1151 * @rinfo_size (IN/OUT) - size of runtime info buffer in bytes
1152 * @dbg_fd (IN) - fd the KFD will nofify the debugger with of raised
1153 * exceptions set in exception_mask.
1155 * Generic errors apply (see kfd_dbg_trap_operations).
1156 * Return - 0 on SUCCESS.
1157 * Copies KFD saved kfd_runtime_info to @rinfo_ptr on enable.
1158 * Size of kfd_runtime saved by the KFD returned to @rinfo_size.
1159 * - EBADF if KFD cannot get a reference to dbg_fd.
1160 * - EFAULT if KFD cannot copy runtime info to rinfo_ptr.
1161 * - EINVAL if target process is already debug enabled.
1164 struct kfd_ioctl_dbg_trap_enable_args
{
1165 __u64 exception_mask
;
1172 * kfd_ioctl_dbg_trap_send_runtime_event_args
1175 * Arguments for KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT.
1176 * Raises exceptions to runtime.
1178 * @exception_mask (IN) - exceptions to raise to runtime
1179 * @gpu_id (IN) - target device id
1180 * @queue_id (IN) - target queue id
1182 * Generic errors apply (see kfd_dbg_trap_operations).
1183 * Return - 0 on SUCCESS.
1184 * - ENODEV if gpu_id not found.
1185 * If exception_mask contains EC_PROCESS_RUNTIME, unblocks pending
1186 * AMDKFD_IOC_RUNTIME_ENABLE call - see kfd_ioctl_runtime_enable_args.
1187 * All other exceptions are raised to runtime through err_payload_addr.
1188 * See kfd_context_save_area_header.
1190 struct kfd_ioctl_dbg_trap_send_runtime_event_args
{
1191 __u64 exception_mask
;
1197 * kfd_ioctl_dbg_trap_set_exceptions_enabled_args
1199 * Arguments for KFD_IOC_SET_EXCEPTIONS_ENABLED
1200 * Set new exceptions to be raised to the debugger.
1202 * @exception_mask (IN) - new exceptions to raise the debugger
1204 * Generic errors apply (see kfd_dbg_trap_operations).
1205 * Return - 0 on SUCCESS.
1207 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args
{
1208 __u64 exception_mask
;
1212 * kfd_ioctl_dbg_trap_set_wave_launch_override_args
1214 * Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE
1215 * Enable HW exceptions to raise trap.
1217 * @override_mode (IN) - see kfd_dbg_trap_override_mode
1218 * @enable_mask (IN/OUT) - reference kfd_dbg_trap_mask.
1219 * IN is the override modes requested to be enabled.
1220 * OUT is referenced in Return below.
1221 * @support_request_mask (IN/OUT) - reference kfd_dbg_trap_mask.
1222 * IN is the override modes requested for support check.
1223 * OUT is referenced in Return below.
1225 * Generic errors apply (see kfd_dbg_trap_operations).
1226 * Return - 0 on SUCCESS.
1227 * Previous enablement is returned in @enable_mask.
1228 * Actual override support is returned in @support_request_mask.
1229 * - EINVAL if override mode is not supported.
1230 * - EACCES if trap support requested is not actually supported.
1231 * i.e. enable_mask (IN) is not a subset of support_request_mask (OUT).
1232 * Otherwise it is considered a generic error (see kfd_dbg_trap_operations).
1234 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args
{
1235 __u32 override_mode
;
1237 __u32 support_request_mask
;
1242 * kfd_ioctl_dbg_trap_set_wave_launch_mode_args
1244 * Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE
1245 * Set wave launch mode.
1247 * @mode (IN) - see kfd_dbg_trap_wave_launch_mode
1249 * Generic errors apply (see kfd_dbg_trap_operations).
1250 * Return - 0 on SUCCESS.
1252 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args
{
1258 * kfd_ioctl_dbg_trap_suspend_queues_ags
1260 * Arguments for KFD_IOC_DBG_TRAP_SUSPEND_QUEUES
1263 * @exception_mask (IN) - raised exceptions to clear
1264 * @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1266 * @num_queues (IN) - number of queues to suspend in @queue_array_ptr
1267 * @grace_period (IN) - wave time allowance before preemption
1268 * per 1K GPU clock cycle unit
1270 * Generic errors apply (see kfd_dbg_trap_operations).
1271 * Destruction of a suspended queue is blocked until the queue is
1272 * resumed. This allows the debugger to access queue information and
1273 * the its context save area without running into a race condition on
1274 * queue destruction.
1275 * Automatically copies per queue context save area header information
1276 * into the save area base
1277 * (see kfd_queue_snapshot_entry and kfd_context_save_area_header).
1279 * Return - Number of queues suspended on SUCCESS.
1280 * . KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK masked
1281 * for each queue id in @queue_array_ptr array reports unsuccessful
1283 * KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1284 * KFD_DBG_QUEUE_INVALID_MASK = queue does not exist, is new or
1285 * is being destroyed.
1287 struct kfd_ioctl_dbg_trap_suspend_queues_args
{
1288 __u64 exception_mask
;
1289 __u64 queue_array_ptr
;
1295 * kfd_ioctl_dbg_trap_resume_queues_args
1297 * Arguments for KFD_IOC_DBG_TRAP_RESUME_QUEUES
1300 * @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1302 * @num_queues (IN) - number of queues to resume in @queue_array_ptr
1304 * Generic errors apply (see kfd_dbg_trap_operations).
1305 * Return - Number of queues resumed on SUCCESS.
1306 * KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK mask
1307 * for each queue id in @queue_array_ptr array reports unsuccessful
1309 * KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1310 * KFD_DBG_QUEUE_INVALID_MASK = queue does not exist.
1312 struct kfd_ioctl_dbg_trap_resume_queues_args
{
1313 __u64 queue_array_ptr
;
1319 * kfd_ioctl_dbg_trap_set_node_address_watch_args
1321 * Arguments for KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH
1322 * Sets address watch for device.
1324 * @address (IN) - watch address to set
1325 * @mode (IN) - see kfd_dbg_trap_address_watch_mode
1326 * @mask (IN) - watch address mask
1327 * @gpu_id (IN) - target gpu to set watch point
1328 * @id (OUT) - watch id allocated
1330 * Generic errors apply (see kfd_dbg_trap_operations).
1331 * Return - 0 on SUCCESS.
1332 * Allocated watch ID returned to @id.
1333 * - ENODEV if gpu_id not found.
1334 * - ENOMEM if watch IDs can be allocated
1336 struct kfd_ioctl_dbg_trap_set_node_address_watch_args
{
1345 * kfd_ioctl_dbg_trap_clear_node_address_watch_args
1347 * Arguments for KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH
1348 * Clear address watch for device.
1350 * @gpu_id (IN) - target device to clear watch point
1351 * @id (IN) - allocated watch id to clear
1353 * Generic errors apply (see kfd_dbg_trap_operations).
1354 * Return - 0 on SUCCESS.
1355 * - ENODEV if gpu_id not found.
1356 * - EINVAL if watch ID has not been allocated.
1358 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args
{
1364 * kfd_ioctl_dbg_trap_set_flags_args
1366 * Arguments for KFD_IOC_DBG_TRAP_SET_FLAGS
1367 * Sets flags for wave behaviour.
1369 * @flags (IN/OUT) - IN = flags to enable, OUT = flags previously enabled
1371 * Generic errors apply (see kfd_dbg_trap_operations).
1372 * Return - 0 on SUCCESS.
1373 * - EACCESS if any debug device does not allow flag options.
1375 struct kfd_ioctl_dbg_trap_set_flags_args
{
1381 * kfd_ioctl_dbg_trap_query_debug_event_args
1383 * Arguments for KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT
1385 * Find one or more raised exceptions. This function can return multiple
1386 * exceptions from a single queue or a single device with one call. To find
1387 * all raised exceptions, this function must be called repeatedly until it
1388 * returns -EAGAIN. Returned exceptions can optionally be cleared by
1389 * setting the corresponding bit in the @exception_mask input parameter.
1390 * However, clearing an exception prevents retrieving further information
1391 * about it with KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO.
1393 * @exception_mask (IN/OUT) - exception to clear (IN) and raised (OUT)
1394 * @gpu_id (OUT) - gpu id of exceptions raised
1395 * @queue_id (OUT) - queue id of exceptions raised
1397 * Generic errors apply (see kfd_dbg_trap_operations).
1398 * Return - 0 on raised exception found
1399 * Raised exceptions found are returned in @exception mask
1400 * with reported source id returned in @gpu_id or @queue_id.
1401 * - EAGAIN if no raised exception has been found
1403 struct kfd_ioctl_dbg_trap_query_debug_event_args
{
1404 __u64 exception_mask
;
1410 * kfd_ioctl_dbg_trap_query_exception_info_args
1412 * Arguments KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO
1413 * Get additional info on raised exception.
1415 * @info_ptr (IN) - pointer to exception info buffer to copy to
1416 * @info_size (IN/OUT) - exception info buffer size (bytes)
1417 * @source_id (IN) - target gpu or queue id
1418 * @exception_code (IN) - target exception
1419 * @clear_exception (IN) - clear raised @exception_code exception
1420 * (0 = false, 1 = true)
1422 * Generic errors apply (see kfd_dbg_trap_operations).
1423 * Return - 0 on SUCCESS.
1424 * If @exception_code is EC_DEVICE_MEMORY_VIOLATION, copy @info_size(OUT)
1425 * bytes of memory exception data to @info_ptr.
1426 * If @exception_code is EC_PROCESS_RUNTIME, copy saved
1427 * kfd_runtime_info to @info_ptr.
1428 * Actual required @info_ptr size (bytes) is returned in @info_size.
1430 struct kfd_ioctl_dbg_trap_query_exception_info_args
{
1434 __u32 exception_code
;
1435 __u32 clear_exception
;
1439 * kfd_ioctl_dbg_trap_get_queue_snapshot_args
1441 * Arguments KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT
1442 * Get queue information.
1444 * @exception_mask (IN) - exceptions raised to clear
1445 * @snapshot_buf_ptr (IN) - queue snapshot entry buffer (see kfd_queue_snapshot_entry)
1446 * @num_queues (IN/OUT) - number of queue snapshot entries
1447 * The debugger specifies the size of the array allocated in @num_queues.
1448 * KFD returns the number of queues that actually existed. If this is
1449 * larger than the size specified by the debugger, KFD will not overflow
1450 * the array allocated by the debugger.
1452 * @entry_size (IN/OUT) - size per entry in bytes
1453 * The debugger specifies sizeof(struct kfd_queue_snapshot_entry) in
1454 * @entry_size. KFD returns the number of bytes actually populated per
1455 * entry. The debugger should use the KFD_IOCTL_MINOR_VERSION to determine,
1456 * which fields in struct kfd_queue_snapshot_entry are valid. This allows
1457 * growing the ABI in a backwards compatible manner.
1458 * Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1459 * event that it's larger than actual kfd_queue_snapshot_entry.
1461 * Generic errors apply (see kfd_dbg_trap_operations).
1462 * Return - 0 on SUCCESS.
1463 * Copies @num_queues(IN) queue snapshot entries of size @entry_size(IN)
1464 * into @snapshot_buf_ptr if @num_queues(IN) > 0.
1465 * Otherwise return @num_queues(OUT) queue snapshot entries that exist.
1467 struct kfd_ioctl_dbg_trap_queue_snapshot_args
{
1468 __u64 exception_mask
;
1469 __u64 snapshot_buf_ptr
;
1475 * kfd_ioctl_dbg_trap_get_device_snapshot_args
1477 * Arguments for KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT
1478 * Get device information.
1480 * @exception_mask (IN) - exceptions raised to clear
1481 * @snapshot_buf_ptr (IN) - pointer to snapshot buffer (see kfd_dbg_device_info_entry)
1482 * @num_devices (IN/OUT) - number of debug devices to snapshot
1483 * The debugger specifies the size of the array allocated in @num_devices.
1484 * KFD returns the number of devices that actually existed. If this is
1485 * larger than the size specified by the debugger, KFD will not overflow
1486 * the array allocated by the debugger.
1488 * @entry_size (IN/OUT) - size per entry in bytes
1489 * The debugger specifies sizeof(struct kfd_dbg_device_info_entry) in
1490 * @entry_size. KFD returns the number of bytes actually populated. The
1491 * debugger should use KFD_IOCTL_MINOR_VERSION to determine, which fields
1492 * in struct kfd_dbg_device_info_entry are valid. This allows growing the
1493 * ABI in a backwards compatible manner.
1494 * Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1495 * event that it's larger than actual kfd_dbg_device_info_entry.
1497 * Generic errors apply (see kfd_dbg_trap_operations).
1498 * Return - 0 on SUCCESS.
1499 * Copies @num_devices(IN) device snapshot entries of size @entry_size(IN)
1500 * into @snapshot_buf_ptr if @num_devices(IN) > 0.
1501 * Otherwise return @num_devices(OUT) queue snapshot entries that exist.
1503 struct kfd_ioctl_dbg_trap_device_snapshot_args
{
1504 __u64 exception_mask
;
1505 __u64 snapshot_buf_ptr
;
1511 * kfd_ioctl_dbg_trap_args
1513 * Arguments to debug target process.
1515 * @pid - target process to debug
1516 * @op - debug operation (see kfd_dbg_trap_operations)
1518 * @op determines which union struct args to use.
1519 * Refer to kern docs for each kfd_ioctl_dbg_trap_*_args struct.
1521 struct kfd_ioctl_dbg_trap_args
{
1526 struct kfd_ioctl_dbg_trap_enable_args enable
;
1527 struct kfd_ioctl_dbg_trap_send_runtime_event_args send_runtime_event
;
1528 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args set_exceptions_enabled
;
1529 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args launch_override
;
1530 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args launch_mode
;
1531 struct kfd_ioctl_dbg_trap_suspend_queues_args suspend_queues
;
1532 struct kfd_ioctl_dbg_trap_resume_queues_args resume_queues
;
1533 struct kfd_ioctl_dbg_trap_set_node_address_watch_args set_node_address_watch
;
1534 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args clear_node_address_watch
;
1535 struct kfd_ioctl_dbg_trap_set_flags_args set_flags
;
1536 struct kfd_ioctl_dbg_trap_query_debug_event_args query_debug_event
;
1537 struct kfd_ioctl_dbg_trap_query_exception_info_args query_exception_info
;
1538 struct kfd_ioctl_dbg_trap_queue_snapshot_args queue_snapshot
;
1539 struct kfd_ioctl_dbg_trap_device_snapshot_args device_snapshot
;
1543 #define AMDKFD_IOCTL_BASE 'K'
1544 #define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
1545 #define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
1546 #define AMDKFD_IOW(nr, type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
1547 #define AMDKFD_IOWR(nr, type) _IOWR(AMDKFD_IOCTL_BASE, nr, type)
1549 #define AMDKFD_IOC_GET_VERSION \
1550 AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
1552 #define AMDKFD_IOC_CREATE_QUEUE \
1553 AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
1555 #define AMDKFD_IOC_DESTROY_QUEUE \
1556 AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
1558 #define AMDKFD_IOC_SET_MEMORY_POLICY \
1559 AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
1561 #define AMDKFD_IOC_GET_CLOCK_COUNTERS \
1562 AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
1564 #define AMDKFD_IOC_GET_PROCESS_APERTURES \
1565 AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
1567 #define AMDKFD_IOC_UPDATE_QUEUE \
1568 AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
1570 #define AMDKFD_IOC_CREATE_EVENT \
1571 AMDKFD_IOWR(0x08, struct kfd_ioctl_create_event_args)
1573 #define AMDKFD_IOC_DESTROY_EVENT \
1574 AMDKFD_IOW(0x09, struct kfd_ioctl_destroy_event_args)
1576 #define AMDKFD_IOC_SET_EVENT \
1577 AMDKFD_IOW(0x0A, struct kfd_ioctl_set_event_args)
1579 #define AMDKFD_IOC_RESET_EVENT \
1580 AMDKFD_IOW(0x0B, struct kfd_ioctl_reset_event_args)
1582 #define AMDKFD_IOC_WAIT_EVENTS \
1583 AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
1585 #define AMDKFD_IOC_DBG_REGISTER_DEPRECATED \
1586 AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
1588 #define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED \
1589 AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
1591 #define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECATED \
1592 AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
1594 #define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATED \
1595 AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
1597 #define AMDKFD_IOC_SET_SCRATCH_BACKING_VA \
1598 AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
1600 #define AMDKFD_IOC_GET_TILE_CONFIG \
1601 AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
1603 #define AMDKFD_IOC_SET_TRAP_HANDLER \
1604 AMDKFD_IOW(0x13, struct kfd_ioctl_set_trap_handler_args)
1606 #define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW \
1608 struct kfd_ioctl_get_process_apertures_new_args)
1610 #define AMDKFD_IOC_ACQUIRE_VM \
1611 AMDKFD_IOW(0x15, struct kfd_ioctl_acquire_vm_args)
1613 #define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU \
1614 AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args)
1616 #define AMDKFD_IOC_FREE_MEMORY_OF_GPU \
1617 AMDKFD_IOW(0x17, struct kfd_ioctl_free_memory_of_gpu_args)
1619 #define AMDKFD_IOC_MAP_MEMORY_TO_GPU \
1620 AMDKFD_IOWR(0x18, struct kfd_ioctl_map_memory_to_gpu_args)
1622 #define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU \
1623 AMDKFD_IOWR(0x19, struct kfd_ioctl_unmap_memory_from_gpu_args)
1625 #define AMDKFD_IOC_SET_CU_MASK \
1626 AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
1628 #define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \
1629 AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args)
1631 #define AMDKFD_IOC_GET_DMABUF_INFO \
1632 AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args)
1634 #define AMDKFD_IOC_IMPORT_DMABUF \
1635 AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
1637 #define AMDKFD_IOC_ALLOC_QUEUE_GWS \
1638 AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
1640 #define AMDKFD_IOC_SMI_EVENTS \
1641 AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
1643 #define AMDKFD_IOC_SVM AMDKFD_IOWR(0x20, struct kfd_ioctl_svm_args)
1645 #define AMDKFD_IOC_SET_XNACK_MODE \
1646 AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)
1648 #define AMDKFD_IOC_CRIU_OP \
1649 AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_args)
1651 #define AMDKFD_IOC_AVAILABLE_MEMORY \
1652 AMDKFD_IOWR(0x23, struct kfd_ioctl_get_available_memory_args)
1654 #define AMDKFD_IOC_EXPORT_DMABUF \
1655 AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args)
1657 #define AMDKFD_IOC_RUNTIME_ENABLE \
1658 AMDKFD_IOWR(0x25, struct kfd_ioctl_runtime_enable_args)
1660 #define AMDKFD_IOC_DBG_TRAP \
1661 AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args)
1663 #define AMDKFD_COMMAND_START 0x01
1664 #define AMDKFD_COMMAND_END 0x27