blob: 55aff047b1b1a22b21fe2b2ab67591568adc7da6 [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
24#define KFD_IOCTL_MINOR_VERSION 1
25struct 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};
29#define KFD_IOC_QUEUE_TYPE_COMPUTE 0
30#define KFD_IOC_QUEUE_TYPE_SDMA 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080031#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2
32#define KFD_MAX_QUEUE_PERCENTAGE 100
33#define KFD_MAX_QUEUE_PRIORITY 15
34struct kfd_ioctl_create_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080035 __u64 ring_base_address;
36 __u64 write_pointer_address;
37 __u64 read_pointer_address;
38 __u64 doorbell_offset;
39 __u32 ring_size;
40 __u32 gpu_id;
41 __u32 queue_type;
42 __u32 queue_percentage;
43 __u32 queue_priority;
44 __u32 queue_id;
45 __u64 eop_buffer_address;
46 __u64 eop_buffer_size;
47 __u64 ctx_save_restore_address;
Christopher Ferris76a1d452018-06-27 14:12:29 -070048 __u32 ctx_save_restore_size;
49 __u32 ctl_stack_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -080050};
51struct kfd_ioctl_destroy_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080052 __u32 queue_id;
53 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080054};
55struct kfd_ioctl_update_queue_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080056 __u64 ring_base_address;
57 __u32 queue_id;
58 __u32 ring_size;
59 __u32 queue_percentage;
60 __u32 queue_priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -080061};
Christopher Ferris9ce28842018-10-25 12:11:39 -070062struct kfd_ioctl_set_cu_mask_args {
63 __u32 queue_id;
64 __u32 num_cu_mask;
65 __u64 cu_mask_ptr;
66};
Christopher Ferris05d08e92016-02-04 13:16:38 -080067#define KFD_IOC_CACHE_POLICY_COHERENT 0
68#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080069struct kfd_ioctl_set_memory_policy_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080070 __u64 alternate_aperture_base;
71 __u64 alternate_aperture_size;
72 __u32 gpu_id;
73 __u32 default_policy;
74 __u32 alternate_policy;
75 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080076};
Christopher Ferris05d08e92016-02-04 13:16:38 -080077struct kfd_ioctl_get_clock_counters_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -080078 __u64 gpu_clock_counter;
79 __u64 cpu_clock_counter;
80 __u64 system_clock_counter;
81 __u64 system_clock_freq;
82 __u32 gpu_id;
83 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080084};
Christopher Ferris05d08e92016-02-04 13:16:38 -080085struct kfd_process_device_apertures {
Christopher Ferris1308ad32017-11-14 17:32:13 -080086 __u64 lds_base;
87 __u64 lds_limit;
88 __u64 scratch_base;
89 __u64 scratch_limit;
90 __u64 gpuvm_base;
91 __u64 gpuvm_limit;
92 __u32 gpu_id;
93 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080094};
Christopher Ferris76a1d452018-06-27 14:12:29 -070095#define NUM_OF_SUPPORTED_GPUS 7
Christopher Ferris05d08e92016-02-04 13:16:38 -080096struct kfd_ioctl_get_process_apertures_args {
Christopher Ferris05d08e92016-02-04 13:16:38 -080097 struct kfd_process_device_apertures process_apertures[NUM_OF_SUPPORTED_GPUS];
Christopher Ferris1308ad32017-11-14 17:32:13 -080098 __u32 num_of_nodes;
99 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700101struct kfd_ioctl_get_process_apertures_new_args {
102 __u64 kfd_process_device_apertures_ptr;
103 __u32 num_of_nodes;
104 __u32 pad;
105};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106#define MAX_ALLOWED_NUM_POINTS 100
107#define MAX_ALLOWED_AW_BUFF_SIZE 4096
108#define MAX_ALLOWED_WAC_BUFF_SIZE 128
109struct kfd_ioctl_dbg_register_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800110 __u32 gpu_id;
111 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800112};
113struct kfd_ioctl_dbg_unregister_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800114 __u32 gpu_id;
115 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800116};
117struct kfd_ioctl_dbg_address_watch_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800118 __u64 content_ptr;
119 __u32 gpu_id;
120 __u32 buf_size_in_bytes;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800122struct kfd_ioctl_dbg_wave_control_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800123 __u64 content_ptr;
124 __u32 gpu_id;
125 __u32 buf_size_in_bytes;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126};
127#define KFD_IOC_EVENT_SIGNAL 0
128#define KFD_IOC_EVENT_NODECHANGE 1
129#define KFD_IOC_EVENT_DEVICESTATECHANGE 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800130#define KFD_IOC_EVENT_HW_EXCEPTION 3
131#define KFD_IOC_EVENT_SYSTEM_EVENT 4
132#define KFD_IOC_EVENT_DEBUG_EVENT 5
133#define KFD_IOC_EVENT_PROFILE_EVENT 6
Christopher Ferris05d08e92016-02-04 13:16:38 -0800134#define KFD_IOC_EVENT_QUEUE_EVENT 7
135#define KFD_IOC_EVENT_MEMORY 8
136#define KFD_IOC_WAIT_RESULT_COMPLETE 0
137#define KFD_IOC_WAIT_RESULT_TIMEOUT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800138#define KFD_IOC_WAIT_RESULT_FAIL 2
Christopher Ferris934ec942018-01-31 15:29:16 -0800139#define KFD_SIGNAL_EVENT_LIMIT 4096
Christopher Ferris9ce28842018-10-25 12:11:39 -0700140#define KFD_HW_EXCEPTION_WHOLE_GPU_RESET 0
141#define KFD_HW_EXCEPTION_PER_ENGINE_RESET 1
142#define KFD_HW_EXCEPTION_GPU_HANG 0
143#define KFD_HW_EXCEPTION_ECC 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800144struct kfd_ioctl_create_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800145 __u64 event_page_offset;
146 __u32 event_trigger_data;
147 __u32 event_type;
148 __u32 auto_reset;
149 __u32 node_id;
150 __u32 event_id;
151 __u32 event_slot_index;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800152};
153struct kfd_ioctl_destroy_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800154 __u32 event_id;
155 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800156};
157struct kfd_ioctl_set_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800158 __u32 event_id;
159 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800160};
161struct kfd_ioctl_reset_event_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800162 __u32 event_id;
163 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800164};
165struct kfd_memory_exception_failure {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800166 __u32 NotPresent;
167 __u32 ReadOnly;
168 __u32 NoExecute;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700169 __u32 imprecise;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800170};
171struct kfd_hsa_memory_exception_data {
172 struct kfd_memory_exception_failure failure;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800173 __u64 va;
174 __u32 gpu_id;
175 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800176};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700177struct kfd_hsa_hw_exception_data {
178 uint32_t reset_type;
179 uint32_t reset_cause;
180 uint32_t memory_lost;
181 uint32_t gpu_id;
182};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800183struct kfd_event_data {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800184 union {
185 struct kfd_hsa_memory_exception_data memory_exception_data;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700186 struct kfd_hsa_hw_exception_data hw_exception_data;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800187 };
Christopher Ferris1308ad32017-11-14 17:32:13 -0800188 __u64 kfd_event_data_ext;
189 __u32 event_id;
190 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800191};
192struct kfd_ioctl_wait_events_args {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800193 __u64 events_ptr;
194 __u32 num_events;
195 __u32 wait_for_all;
196 __u32 timeout;
197 __u32 wait_result;
198};
199struct kfd_ioctl_set_scratch_backing_va_args {
Christopher Ferris934ec942018-01-31 15:29:16 -0800200 __u64 va_addr;
201 __u32 gpu_id;
202 __u32 pad;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800203};
204struct kfd_ioctl_get_tile_config_args {
Christopher Ferris934ec942018-01-31 15:29:16 -0800205 __u64 tile_config_ptr;
206 __u64 macro_tile_config_ptr;
207 __u32 num_tile_configs;
208 __u32 num_macro_tile_configs;
209 __u32 gpu_id;
210 __u32 gb_addr_config;
211 __u32 num_banks;
212 __u32 num_ranks;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800213};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700214struct kfd_ioctl_set_trap_handler_args {
215 __u64 tba_addr;
216 __u64 tma_addr;
217 __u32 gpu_id;
218 __u32 pad;
219};
220struct kfd_ioctl_acquire_vm_args {
221 __u32 drm_fd;
222 __u32 gpu_id;
223};
224#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
225#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
226#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
227#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
228#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31)
229#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30)
230#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
231#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
232#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
233#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 26)
234struct kfd_ioctl_alloc_memory_of_gpu_args {
235 __u64 va_addr;
236 __u64 size;
237 __u64 handle;
238 __u64 mmap_offset;
239 __u32 gpu_id;
240 __u32 flags;
241};
242struct kfd_ioctl_free_memory_of_gpu_args {
243 __u64 handle;
244};
245struct kfd_ioctl_map_memory_to_gpu_args {
246 __u64 handle;
247 __u64 device_ids_array_ptr;
248 __u32 n_devices;
249 __u32 n_success;
250};
251struct kfd_ioctl_unmap_memory_from_gpu_args {
252 __u64 handle;
253 __u64 device_ids_array_ptr;
254 __u32 n_devices;
255 __u32 n_success;
256};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800257#define AMDKFD_IOCTL_BASE 'K'
258#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800259#define AMDKFD_IOR(nr,type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
260#define AMDKFD_IOW(nr,type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
261#define AMDKFD_IOWR(nr,type) _IOWR(AMDKFD_IOCTL_BASE, nr, type)
262#define AMDKFD_IOC_GET_VERSION AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800263#define AMDKFD_IOC_CREATE_QUEUE AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
264#define AMDKFD_IOC_DESTROY_QUEUE AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
265#define AMDKFD_IOC_SET_MEMORY_POLICY AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
266#define AMDKFD_IOC_GET_CLOCK_COUNTERS AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800267#define AMDKFD_IOC_GET_PROCESS_APERTURES AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
268#define AMDKFD_IOC_UPDATE_QUEUE AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
269#define AMDKFD_IOC_CREATE_EVENT AMDKFD_IOWR(0x08, struct kfd_ioctl_create_event_args)
270#define AMDKFD_IOC_DESTROY_EVENT AMDKFD_IOW(0x09, struct kfd_ioctl_destroy_event_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800271#define AMDKFD_IOC_SET_EVENT AMDKFD_IOW(0x0A, struct kfd_ioctl_set_event_args)
272#define AMDKFD_IOC_RESET_EVENT AMDKFD_IOW(0x0B, struct kfd_ioctl_reset_event_args)
273#define AMDKFD_IOC_WAIT_EVENTS AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
274#define AMDKFD_IOC_DBG_REGISTER AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800275#define AMDKFD_IOC_DBG_UNREGISTER AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
276#define AMDKFD_IOC_DBG_ADDRESS_WATCH AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
277#define AMDKFD_IOC_DBG_WAVE_CONTROL AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800278#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
279#define AMDKFD_IOC_GET_TILE_CONFIG AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700280#define AMDKFD_IOC_SET_TRAP_HANDLER AMDKFD_IOW(0x13, struct kfd_ioctl_set_trap_handler_args)
281#define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW AMDKFD_IOWR(0x14, struct kfd_ioctl_get_process_apertures_new_args)
282#define AMDKFD_IOC_ACQUIRE_VM AMDKFD_IOW(0x15, struct kfd_ioctl_acquire_vm_args)
283#define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args)
284#define AMDKFD_IOC_FREE_MEMORY_OF_GPU AMDKFD_IOW(0x17, struct kfd_ioctl_free_memory_of_gpu_args)
285#define AMDKFD_IOC_MAP_MEMORY_TO_GPU AMDKFD_IOWR(0x18, struct kfd_ioctl_map_memory_to_gpu_args)
286#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 -0700287#define AMDKFD_IOC_SET_CU_MASK AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800288#define AMDKFD_COMMAND_START 0x01
Christopher Ferris9ce28842018-10-25 12:11:39 -0700289#define AMDKFD_COMMAND_END 0x1B
Christopher Ferris05d08e92016-02-04 13:16:38 -0800290#endif