~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/uapi/linux/kfd_ioctl.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/uapi/linux/kfd_ioctl.h (Architecture alpha) and /include/uapi/linux/kfd_ioctl.h (Architecture sparc)


  1 /*                                                  1 /*
  2  * Copyright 2014 Advanced Micro Devices, Inc.      2  * Copyright 2014 Advanced Micro Devices, Inc.
  3  *                                                  3  *
  4  * Permission is hereby granted, free of charg      4  * Permission is hereby granted, free of charge, to any person obtaining a
  5  * copy of this software and associated docume      5  * copy of this software and associated documentation files (the "Software"),
  6  * to deal in the Software without restriction      6  * to deal in the Software without restriction, including without limitation
  7  * the rights to use, copy, modify, merge, pub      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8  * and/or sell copies of the Software, and to       8  * and/or sell copies of the Software, and to permit persons to whom the
  9  * Software is furnished to do so, subject to       9  * Software is furnished to do so, subject to the following conditions:
 10  *                                                 10  *
 11  * The above copyright notice and this permiss     11  * The above copyright notice and this permission notice shall be included in
 12  * all copies or substantial portions of the S     12  * all copies or substantial portions of the Software.
 13  *                                                 13  *
 14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W     14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W     15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINF     16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIA     17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CO     18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 19  * ARISING FROM, OUT OF OR IN CONNECTION WITH      19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 20  * OTHER DEALINGS IN THE SOFTWARE.                 20  * OTHER DEALINGS IN THE SOFTWARE.
 21  */                                                21  */
 22                                                    22 
 23 #ifndef KFD_IOCTL_H_INCLUDED                       23 #ifndef KFD_IOCTL_H_INCLUDED
 24 #define KFD_IOCTL_H_INCLUDED                       24 #define KFD_IOCTL_H_INCLUDED
 25                                                    25 
 26 #include <drm/drm.h>                               26 #include <drm/drm.h>
 27 #include <linux/ioctl.h>                           27 #include <linux/ioctl.h>
 28                                                    28 
 29 /*                                                 29 /*
 30  * - 1.1 - initial version                         30  * - 1.1 - initial version
 31  * - 1.3 - Add SMI events support                  31  * - 1.3 - Add SMI events support
 32  * - 1.4 - Indicate new SRAM EDC bit in device     32  * - 1.4 - Indicate new SRAM EDC bit in device properties
 33  * - 1.5 - Add SVM API                             33  * - 1.5 - Add SVM API
 34  * - 1.6 - Query clear flags in SVM get_attr A     34  * - 1.6 - Query clear flags in SVM get_attr API
 35  * - 1.7 - Checkpoint Restore (CRIU) API           35  * - 1.7 - Checkpoint Restore (CRIU) API
 36  * - 1.8 - CRIU - Support for SDMA transfers w     36  * - 1.8 - CRIU - Support for SDMA transfers with GTT BOs
 37  * - 1.9 - Add available memory ioctl              37  * - 1.9 - Add available memory ioctl
 38  * - 1.10 - Add SMI profiler event log             38  * - 1.10 - Add SMI profiler event log
 39  * - 1.11 - Add unified memory for ctx save/re     39  * - 1.11 - Add unified memory for ctx save/restore area
 40  * - 1.12 - Add DMA buf export ioctl               40  * - 1.12 - Add DMA buf export ioctl
 41  * - 1.13 - Add debugger API                       41  * - 1.13 - Add debugger API
 42  * - 1.14 - Update kfd_event_data                  42  * - 1.14 - Update kfd_event_data
 43  * - 1.15 - Enable managing mappings in comput     43  * - 1.15 - Enable managing mappings in compute VMs with GEM_VA ioctl
 44  * - 1.16 - Add contiguous VRAM allocation fla     44  * - 1.16 - Add contiguous VRAM allocation flag
 45  */                                                45  */
 46 #define KFD_IOCTL_MAJOR_VERSION 1                  46 #define KFD_IOCTL_MAJOR_VERSION 1
 47 #define KFD_IOCTL_MINOR_VERSION 16                 47 #define KFD_IOCTL_MINOR_VERSION 16
 48                                                    48 
 49 struct kfd_ioctl_get_version_args {                49 struct kfd_ioctl_get_version_args {
 50         __u32 major_version;    /* from KFD */     50         __u32 major_version;    /* from KFD */
 51         __u32 minor_version;    /* from KFD */     51         __u32 minor_version;    /* from KFD */
 52 };                                                 52 };
 53                                                    53 
 54 /* For kfd_ioctl_create_queue_args.queue_type.     54 /* For kfd_ioctl_create_queue_args.queue_type. */
 55 #define KFD_IOC_QUEUE_TYPE_COMPUTE                 55 #define KFD_IOC_QUEUE_TYPE_COMPUTE              0x0
 56 #define KFD_IOC_QUEUE_TYPE_SDMA                    56 #define KFD_IOC_QUEUE_TYPE_SDMA                 0x1
 57 #define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL             57 #define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL          0x2
 58 #define KFD_IOC_QUEUE_TYPE_SDMA_XGMI               58 #define KFD_IOC_QUEUE_TYPE_SDMA_XGMI            0x3
 59                                                    59 
 60 #define KFD_MAX_QUEUE_PERCENTAGE        100        60 #define KFD_MAX_QUEUE_PERCENTAGE        100
 61 #define KFD_MAX_QUEUE_PRIORITY          15         61 #define KFD_MAX_QUEUE_PRIORITY          15
 62                                                    62 
 63 struct kfd_ioctl_create_queue_args {               63 struct kfd_ioctl_create_queue_args {
 64         __u64 ring_base_address;        /* to      64         __u64 ring_base_address;        /* to KFD */
 65         __u64 write_pointer_address;    /* fro     65         __u64 write_pointer_address;    /* from KFD */
 66         __u64 read_pointer_address;     /* fro     66         __u64 read_pointer_address;     /* from KFD */
 67         __u64 doorbell_offset;  /* from KFD */     67         __u64 doorbell_offset;  /* from KFD */
 68                                                    68 
 69         __u32 ring_size;                /* to      69         __u32 ring_size;                /* to KFD */
 70         __u32 gpu_id;           /* to KFD */       70         __u32 gpu_id;           /* to KFD */
 71         __u32 queue_type;               /* to      71         __u32 queue_type;               /* to KFD */
 72         __u32 queue_percentage; /* to KFD */       72         __u32 queue_percentage; /* to KFD */
 73         __u32 queue_priority;   /* to KFD */       73         __u32 queue_priority;   /* to KFD */
 74         __u32 queue_id;         /* from KFD */     74         __u32 queue_id;         /* from KFD */
 75                                                    75 
 76         __u64 eop_buffer_address;       /* to      76         __u64 eop_buffer_address;       /* to KFD */
 77         __u64 eop_buffer_size;  /* to KFD */       77         __u64 eop_buffer_size;  /* to KFD */
 78         __u64 ctx_save_restore_address; /* to      78         __u64 ctx_save_restore_address; /* to KFD */
 79         __u32 ctx_save_restore_size;    /* to      79         __u32 ctx_save_restore_size;    /* to KFD */
 80         __u32 ctl_stack_size;           /* to      80         __u32 ctl_stack_size;           /* to KFD */
 81 };                                                 81 };
 82                                                    82 
 83 struct kfd_ioctl_destroy_queue_args {              83 struct kfd_ioctl_destroy_queue_args {
 84         __u32 queue_id;         /* to KFD */       84         __u32 queue_id;         /* to KFD */
 85         __u32 pad;                                 85         __u32 pad;
 86 };                                                 86 };
 87                                                    87 
 88 struct kfd_ioctl_update_queue_args {               88 struct kfd_ioctl_update_queue_args {
 89         __u64 ring_base_address;        /* to      89         __u64 ring_base_address;        /* to KFD */
 90                                                    90 
 91         __u32 queue_id;         /* to KFD */       91         __u32 queue_id;         /* to KFD */
 92         __u32 ring_size;                /* to      92         __u32 ring_size;                /* to KFD */
 93         __u32 queue_percentage; /* to KFD */       93         __u32 queue_percentage; /* to KFD */
 94         __u32 queue_priority;   /* to KFD */       94         __u32 queue_priority;   /* to KFD */
 95 };                                                 95 };
 96                                                    96 
 97 struct kfd_ioctl_set_cu_mask_args {                97 struct kfd_ioctl_set_cu_mask_args {
 98         __u32 queue_id;         /* to KFD */       98         __u32 queue_id;         /* to KFD */
 99         __u32 num_cu_mask;              /* to      99         __u32 num_cu_mask;              /* to KFD */
100         __u64 cu_mask_ptr;              /* to     100         __u64 cu_mask_ptr;              /* to KFD */
101 };                                                101 };
102                                                   102 
103 struct kfd_ioctl_get_queue_wave_state_args {      103 struct kfd_ioctl_get_queue_wave_state_args {
104         __u64 ctl_stack_address;        /* to     104         __u64 ctl_stack_address;        /* to KFD */
105         __u32 ctl_stack_used_size;      /* fro    105         __u32 ctl_stack_used_size;      /* from KFD */
106         __u32 save_area_used_size;      /* fro    106         __u32 save_area_used_size;      /* from KFD */
107         __u32 queue_id;                 /* to     107         __u32 queue_id;                 /* to KFD */
108         __u32 pad;                                108         __u32 pad;
109 };                                                109 };
110                                                   110 
111 struct kfd_ioctl_get_available_memory_args {      111 struct kfd_ioctl_get_available_memory_args {
112         __u64 available;        /* from KFD */    112         __u64 available;        /* from KFD */
113         __u32 gpu_id;           /* to KFD */      113         __u32 gpu_id;           /* to KFD */
114         __u32 pad;                                114         __u32 pad;
115 };                                                115 };
116                                                   116 
117 struct kfd_dbg_device_info_entry {                117 struct kfd_dbg_device_info_entry {
118         __u64 exception_status;                   118         __u64 exception_status;
119         __u64 lds_base;                           119         __u64 lds_base;
120         __u64 lds_limit;                          120         __u64 lds_limit;
121         __u64 scratch_base;                       121         __u64 scratch_base;
122         __u64 scratch_limit;                      122         __u64 scratch_limit;
123         __u64 gpuvm_base;                         123         __u64 gpuvm_base;
124         __u64 gpuvm_limit;                        124         __u64 gpuvm_limit;
125         __u32 gpu_id;                             125         __u32 gpu_id;
126         __u32 location_id;                        126         __u32 location_id;
127         __u32 vendor_id;                          127         __u32 vendor_id;
128         __u32 device_id;                          128         __u32 device_id;
129         __u32 revision_id;                        129         __u32 revision_id;
130         __u32 subsystem_vendor_id;                130         __u32 subsystem_vendor_id;
131         __u32 subsystem_device_id;                131         __u32 subsystem_device_id;
132         __u32 fw_version;                         132         __u32 fw_version;
133         __u32 gfx_target_version;                 133         __u32 gfx_target_version;
134         __u32 simd_count;                         134         __u32 simd_count;
135         __u32 max_waves_per_simd;                 135         __u32 max_waves_per_simd;
136         __u32 array_count;                        136         __u32 array_count;
137         __u32 simd_arrays_per_engine;             137         __u32 simd_arrays_per_engine;
138         __u32 num_xcc;                            138         __u32 num_xcc;
139         __u32 capability;                         139         __u32 capability;
140         __u32 debug_prop;                         140         __u32 debug_prop;
141 };                                                141 };
142                                                   142 
143 /* For kfd_ioctl_set_memory_policy_args.defaul    143 /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
144 #define KFD_IOC_CACHE_POLICY_COHERENT 0           144 #define KFD_IOC_CACHE_POLICY_COHERENT 0
145 #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1        145 #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
146                                                   146 
147 struct kfd_ioctl_set_memory_policy_args {         147 struct kfd_ioctl_set_memory_policy_args {
148         __u64 alternate_aperture_base;  /* to     148         __u64 alternate_aperture_base;  /* to KFD */
149         __u64 alternate_aperture_size;  /* to     149         __u64 alternate_aperture_size;  /* to KFD */
150                                                   150 
151         __u32 gpu_id;                   /* to     151         __u32 gpu_id;                   /* to KFD */
152         __u32 default_policy;           /* to     152         __u32 default_policy;           /* to KFD */
153         __u32 alternate_policy;         /* to     153         __u32 alternate_policy;         /* to KFD */
154         __u32 pad;                                154         __u32 pad;
155 };                                                155 };
156                                                   156 
157 /*                                                157 /*
158  * All counters are monotonic. They are used f    158  * All counters are monotonic. They are used for profiling of compute jobs.
159  * The profiling is done by userspace.            159  * The profiling is done by userspace.
160  *                                                160  *
161  * In case of GPU reset, the counter should no    161  * In case of GPU reset, the counter should not be affected.
162  */                                               162  */
163                                                   163 
164 struct kfd_ioctl_get_clock_counters_args {        164 struct kfd_ioctl_get_clock_counters_args {
165         __u64 gpu_clock_counter;        /* fro    165         __u64 gpu_clock_counter;        /* from KFD */
166         __u64 cpu_clock_counter;        /* fro    166         __u64 cpu_clock_counter;        /* from KFD */
167         __u64 system_clock_counter;     /* fro    167         __u64 system_clock_counter;     /* from KFD */
168         __u64 system_clock_freq;        /* fro    168         __u64 system_clock_freq;        /* from KFD */
169                                                   169 
170         __u32 gpu_id;           /* to KFD */      170         __u32 gpu_id;           /* to KFD */
171         __u32 pad;                                171         __u32 pad;
172 };                                                172 };
173                                                   173 
174 struct kfd_process_device_apertures {             174 struct kfd_process_device_apertures {
175         __u64 lds_base;         /* from KFD */    175         __u64 lds_base;         /* from KFD */
176         __u64 lds_limit;                /* fro    176         __u64 lds_limit;                /* from KFD */
177         __u64 scratch_base;             /* fro    177         __u64 scratch_base;             /* from KFD */
178         __u64 scratch_limit;            /* fro    178         __u64 scratch_limit;            /* from KFD */
179         __u64 gpuvm_base;               /* fro    179         __u64 gpuvm_base;               /* from KFD */
180         __u64 gpuvm_limit;              /* fro    180         __u64 gpuvm_limit;              /* from KFD */
181         __u32 gpu_id;           /* from KFD */    181         __u32 gpu_id;           /* from KFD */
182         __u32 pad;                                182         __u32 pad;
183 };                                                183 };
184                                                   184 
185 /*                                                185 /*
186  * AMDKFD_IOC_GET_PROCESS_APERTURES is depreca    186  * AMDKFD_IOC_GET_PROCESS_APERTURES is deprecated. Use
187  * AMDKFD_IOC_GET_PROCESS_APERTURES_NEW instea    187  * AMDKFD_IOC_GET_PROCESS_APERTURES_NEW instead, which supports an
188  * unlimited number of GPUs.                      188  * unlimited number of GPUs.
189  */                                               189  */
190 #define NUM_OF_SUPPORTED_GPUS 7                   190 #define NUM_OF_SUPPORTED_GPUS 7
191 struct kfd_ioctl_get_process_apertures_args {     191 struct kfd_ioctl_get_process_apertures_args {
192         struct kfd_process_device_apertures       192         struct kfd_process_device_apertures
193                         process_apertures[NUM_    193                         process_apertures[NUM_OF_SUPPORTED_GPUS];/* from KFD */
194                                                   194 
195         /* from KFD, should be in the range [1    195         /* from KFD, should be in the range [1 - NUM_OF_SUPPORTED_GPUS] */
196         __u32 num_of_nodes;                       196         __u32 num_of_nodes;
197         __u32 pad;                                197         __u32 pad;
198 };                                                198 };
199                                                   199 
200 struct kfd_ioctl_get_process_apertures_new_arg    200 struct kfd_ioctl_get_process_apertures_new_args {
201         /* User allocated. Pointer to struct k    201         /* User allocated. Pointer to struct kfd_process_device_apertures
202          * filled in by Kernel                    202          * filled in by Kernel
203          */                                       203          */
204         __u64 kfd_process_device_apertures_ptr    204         __u64 kfd_process_device_apertures_ptr;
205         /* to KFD - indicates amount of memory    205         /* to KFD - indicates amount of memory present in
206          *  kfd_process_device_apertures_ptr      206          *  kfd_process_device_apertures_ptr
207          * from KFD - Number of entries filled    207          * from KFD - Number of entries filled by KFD.
208          */                                       208          */
209         __u32 num_of_nodes;                       209         __u32 num_of_nodes;
210         __u32 pad;                                210         __u32 pad;
211 };                                                211 };
212                                                   212 
213 #define MAX_ALLOWED_NUM_POINTS    100             213 #define MAX_ALLOWED_NUM_POINTS    100
214 #define MAX_ALLOWED_AW_BUFF_SIZE 4096             214 #define MAX_ALLOWED_AW_BUFF_SIZE 4096
215 #define MAX_ALLOWED_WAC_BUFF_SIZE  128            215 #define MAX_ALLOWED_WAC_BUFF_SIZE  128
216                                                   216 
217 struct kfd_ioctl_dbg_register_args {              217 struct kfd_ioctl_dbg_register_args {
218         __u32 gpu_id;           /* to KFD */      218         __u32 gpu_id;           /* to KFD */
219         __u32 pad;                                219         __u32 pad;
220 };                                                220 };
221                                                   221 
222 struct kfd_ioctl_dbg_unregister_args {            222 struct kfd_ioctl_dbg_unregister_args {
223         __u32 gpu_id;           /* to KFD */      223         __u32 gpu_id;           /* to KFD */
224         __u32 pad;                                224         __u32 pad;
225 };                                                225 };
226                                                   226 
227 struct kfd_ioctl_dbg_address_watch_args {         227 struct kfd_ioctl_dbg_address_watch_args {
228         __u64 content_ptr;              /* a p    228         __u64 content_ptr;              /* a pointer to the actual content */
229         __u32 gpu_id;           /* to KFD */      229         __u32 gpu_id;           /* to KFD */
230         __u32 buf_size_in_bytes;        /*incl    230         __u32 buf_size_in_bytes;        /*including gpu_id and buf_size */
231 };                                                231 };
232                                                   232 
233 struct kfd_ioctl_dbg_wave_control_args {          233 struct kfd_ioctl_dbg_wave_control_args {
234         __u64 content_ptr;              /* a p    234         __u64 content_ptr;              /* a pointer to the actual content */
235         __u32 gpu_id;           /* to KFD */      235         __u32 gpu_id;           /* to KFD */
236         __u32 buf_size_in_bytes;        /*incl    236         __u32 buf_size_in_bytes;        /*including gpu_id and buf_size */
237 };                                                237 };
238                                                   238 
239 #define KFD_INVALID_FD     0xffffffff             239 #define KFD_INVALID_FD     0xffffffff
240                                                   240 
241 /* Matching HSA_EVENTTYPE */                      241 /* Matching HSA_EVENTTYPE */
242 #define KFD_IOC_EVENT_SIGNAL                      242 #define KFD_IOC_EVENT_SIGNAL                    0
243 #define KFD_IOC_EVENT_NODECHANGE                  243 #define KFD_IOC_EVENT_NODECHANGE                1
244 #define KFD_IOC_EVENT_DEVICESTATECHANGE           244 #define KFD_IOC_EVENT_DEVICESTATECHANGE         2
245 #define KFD_IOC_EVENT_HW_EXCEPTION                245 #define KFD_IOC_EVENT_HW_EXCEPTION              3
246 #define KFD_IOC_EVENT_SYSTEM_EVENT                246 #define KFD_IOC_EVENT_SYSTEM_EVENT              4
247 #define KFD_IOC_EVENT_DEBUG_EVENT                 247 #define KFD_IOC_EVENT_DEBUG_EVENT               5
248 #define KFD_IOC_EVENT_PROFILE_EVENT               248 #define KFD_IOC_EVENT_PROFILE_EVENT             6
249 #define KFD_IOC_EVENT_QUEUE_EVENT                 249 #define KFD_IOC_EVENT_QUEUE_EVENT               7
250 #define KFD_IOC_EVENT_MEMORY                      250 #define KFD_IOC_EVENT_MEMORY                    8
251                                                   251 
252 #define KFD_IOC_WAIT_RESULT_COMPLETE              252 #define KFD_IOC_WAIT_RESULT_COMPLETE            0
253 #define KFD_IOC_WAIT_RESULT_TIMEOUT               253 #define KFD_IOC_WAIT_RESULT_TIMEOUT             1
254 #define KFD_IOC_WAIT_RESULT_FAIL                  254 #define KFD_IOC_WAIT_RESULT_FAIL                2
255                                                   255 
256 #define KFD_SIGNAL_EVENT_LIMIT                    256 #define KFD_SIGNAL_EVENT_LIMIT                  4096
257                                                   257 
258 /* For kfd_event_data.hw_exception_data.reset_    258 /* For kfd_event_data.hw_exception_data.reset_type. */
259 #define KFD_HW_EXCEPTION_WHOLE_GPU_RESET          259 #define KFD_HW_EXCEPTION_WHOLE_GPU_RESET        0
260 #define KFD_HW_EXCEPTION_PER_ENGINE_RESET         260 #define KFD_HW_EXCEPTION_PER_ENGINE_RESET       1
261                                                   261 
262 /* For kfd_event_data.hw_exception_data.reset_    262 /* For kfd_event_data.hw_exception_data.reset_cause. */
263 #define KFD_HW_EXCEPTION_GPU_HANG       0         263 #define KFD_HW_EXCEPTION_GPU_HANG       0
264 #define KFD_HW_EXCEPTION_ECC            1         264 #define KFD_HW_EXCEPTION_ECC            1
265                                                   265 
266 /* For kfd_hsa_memory_exception_data.ErrorType    266 /* For kfd_hsa_memory_exception_data.ErrorType */
267 #define KFD_MEM_ERR_NO_RAS              0         267 #define KFD_MEM_ERR_NO_RAS              0
268 #define KFD_MEM_ERR_SRAM_ECC            1         268 #define KFD_MEM_ERR_SRAM_ECC            1
269 #define KFD_MEM_ERR_POISON_CONSUMED     2         269 #define KFD_MEM_ERR_POISON_CONSUMED     2
270 #define KFD_MEM_ERR_GPU_HANG            3         270 #define KFD_MEM_ERR_GPU_HANG            3
271                                                   271 
272 struct kfd_ioctl_create_event_args {              272 struct kfd_ioctl_create_event_args {
273         __u64 event_page_offset;        /* fro    273         __u64 event_page_offset;        /* from KFD */
274         __u32 event_trigger_data;       /* fro    274         __u32 event_trigger_data;       /* from KFD - signal events only */
275         __u32 event_type;               /* to     275         __u32 event_type;               /* to KFD */
276         __u32 auto_reset;               /* to     276         __u32 auto_reset;               /* to KFD */
277         __u32 node_id;          /* to KFD - on    277         __u32 node_id;          /* to KFD - only valid for certain
278                                                   278                                                         event types */
279         __u32 event_id;         /* from KFD */    279         __u32 event_id;         /* from KFD */
280         __u32 event_slot_index; /* from KFD */    280         __u32 event_slot_index; /* from KFD */
281 };                                                281 };
282                                                   282 
283 struct kfd_ioctl_destroy_event_args {             283 struct kfd_ioctl_destroy_event_args {
284         __u32 event_id;         /* to KFD */      284         __u32 event_id;         /* to KFD */
285         __u32 pad;                                285         __u32 pad;
286 };                                                286 };
287                                                   287 
288 struct kfd_ioctl_set_event_args {                 288 struct kfd_ioctl_set_event_args {
289         __u32 event_id;         /* to KFD */      289         __u32 event_id;         /* to KFD */
290         __u32 pad;                                290         __u32 pad;
291 };                                                291 };
292                                                   292 
293 struct kfd_ioctl_reset_event_args {               293 struct kfd_ioctl_reset_event_args {
294         __u32 event_id;         /* to KFD */      294         __u32 event_id;         /* to KFD */
295         __u32 pad;                                295         __u32 pad;
296 };                                                296 };
297                                                   297 
298 struct kfd_memory_exception_failure {             298 struct kfd_memory_exception_failure {
299         __u32 NotPresent;       /* Page not pr    299         __u32 NotPresent;       /* Page not present or supervisor privilege */
300         __u32 ReadOnly; /* Write access to a r    300         __u32 ReadOnly; /* Write access to a read-only page */
301         __u32 NoExecute;        /* Execute acc    301         __u32 NoExecute;        /* Execute access to a page marked NX */
302         __u32 imprecise;        /* Can't deter    302         __u32 imprecise;        /* Can't determine the  exact fault address */
303 };                                                303 };
304                                                   304 
305 /* memory exception data */                       305 /* memory exception data */
306 struct kfd_hsa_memory_exception_data {            306 struct kfd_hsa_memory_exception_data {
307         struct kfd_memory_exception_failure fa    307         struct kfd_memory_exception_failure failure;
308         __u64 va;                                 308         __u64 va;
309         __u32 gpu_id;                             309         __u32 gpu_id;
310         __u32 ErrorType; /* 0 = no RAS error,     310         __u32 ErrorType; /* 0 = no RAS error,
311                           * 1 = ECC_SRAM,         311                           * 1 = ECC_SRAM,
312                           * 2 = Link_SYNFLOOD     312                           * 2 = Link_SYNFLOOD (poison),
313                           * 3 = GPU hang (not     313                           * 3 = GPU hang (not attributable to a specific cause),
314                           * other values reser    314                           * other values reserved
315                           */                      315                           */
316 };                                                316 };
317                                                   317 
318 /* hw exception data */                           318 /* hw exception data */
319 struct kfd_hsa_hw_exception_data {                319 struct kfd_hsa_hw_exception_data {
320         __u32 reset_type;                         320         __u32 reset_type;
321         __u32 reset_cause;                        321         __u32 reset_cause;
322         __u32 memory_lost;                        322         __u32 memory_lost;
323         __u32 gpu_id;                             323         __u32 gpu_id;
324 };                                                324 };
325                                                   325 
326 /* hsa signal event data */                       326 /* hsa signal event data */
327 struct kfd_hsa_signal_event_data {                327 struct kfd_hsa_signal_event_data {
328         __u64 last_event_age;   /* to and from    328         __u64 last_event_age;   /* to and from KFD */
329 };                                                329 };
330                                                   330 
331 /* Event data */                                  331 /* Event data */
332 struct kfd_event_data {                           332 struct kfd_event_data {
333         union {                                   333         union {
334                 /* From KFD */                    334                 /* From KFD */
335                 struct kfd_hsa_memory_exceptio    335                 struct kfd_hsa_memory_exception_data memory_exception_data;
336                 struct kfd_hsa_hw_exception_da    336                 struct kfd_hsa_hw_exception_data hw_exception_data;
337                 /* To and From KFD */             337                 /* To and From KFD */
338                 struct kfd_hsa_signal_event_da    338                 struct kfd_hsa_signal_event_data signal_event_data;
339         };                                        339         };
340         __u64 kfd_event_data_ext;       /* poi    340         __u64 kfd_event_data_ext;       /* pointer to an extension structure
341                                            for    341                                            for future exception types */
342         __u32 event_id;         /* to KFD */      342         __u32 event_id;         /* to KFD */
343         __u32 pad;                                343         __u32 pad;
344 };                                                344 };
345                                                   345 
346 struct kfd_ioctl_wait_events_args {               346 struct kfd_ioctl_wait_events_args {
347         __u64 events_ptr;               /* poi    347         __u64 events_ptr;               /* pointed to struct
348                                            kfd    348                                            kfd_event_data array, to KFD */
349         __u32 num_events;               /* to     349         __u32 num_events;               /* to KFD */
350         __u32 wait_for_all;             /* to     350         __u32 wait_for_all;             /* to KFD */
351         __u32 timeout;          /* to KFD */      351         __u32 timeout;          /* to KFD */
352         __u32 wait_result;              /* fro    352         __u32 wait_result;              /* from KFD */
353 };                                                353 };
354                                                   354 
355 struct kfd_ioctl_set_scratch_backing_va_args {    355 struct kfd_ioctl_set_scratch_backing_va_args {
356         __u64 va_addr;  /* to KFD */              356         __u64 va_addr;  /* to KFD */
357         __u32 gpu_id;   /* to KFD */              357         __u32 gpu_id;   /* to KFD */
358         __u32 pad;                                358         __u32 pad;
359 };                                                359 };
360                                                   360 
361 struct kfd_ioctl_get_tile_config_args {           361 struct kfd_ioctl_get_tile_config_args {
362         /* to KFD: pointer to tile array */       362         /* to KFD: pointer to tile array */
363         __u64 tile_config_ptr;                    363         __u64 tile_config_ptr;
364         /* to KFD: pointer to macro tile array    364         /* to KFD: pointer to macro tile array */
365         __u64 macro_tile_config_ptr;              365         __u64 macro_tile_config_ptr;
366         /* to KFD: array size allocated by use    366         /* to KFD: array size allocated by user mode
367          * from KFD: array size filled by kern    367          * from KFD: array size filled by kernel
368          */                                       368          */
369         __u32 num_tile_configs;                   369         __u32 num_tile_configs;
370         /* to KFD: array size allocated by use    370         /* to KFD: array size allocated by user mode
371          * from KFD: array size filled by kern    371          * from KFD: array size filled by kernel
372          */                                       372          */
373         __u32 num_macro_tile_configs;             373         __u32 num_macro_tile_configs;
374                                                   374 
375         __u32 gpu_id;           /* to KFD */      375         __u32 gpu_id;           /* to KFD */
376         __u32 gb_addr_config;   /* from KFD */    376         __u32 gb_addr_config;   /* from KFD */
377         __u32 num_banks;                /* fro    377         __u32 num_banks;                /* from KFD */
378         __u32 num_ranks;                /* fro    378         __u32 num_ranks;                /* from KFD */
379         /* struct size can be extended later i    379         /* struct size can be extended later if needed
380          * without breaking ABI compatibility     380          * without breaking ABI compatibility
381          */                                       381          */
382 };                                                382 };
383                                                   383 
384 struct kfd_ioctl_set_trap_handler_args {          384 struct kfd_ioctl_set_trap_handler_args {
385         __u64 tba_addr;         /* to KFD */      385         __u64 tba_addr;         /* to KFD */
386         __u64 tma_addr;         /* to KFD */      386         __u64 tma_addr;         /* to KFD */
387         __u32 gpu_id;           /* to KFD */      387         __u32 gpu_id;           /* to KFD */
388         __u32 pad;                                388         __u32 pad;
389 };                                                389 };
390                                                   390 
391 struct kfd_ioctl_acquire_vm_args {                391 struct kfd_ioctl_acquire_vm_args {
392         __u32 drm_fd;   /* to KFD */              392         __u32 drm_fd;   /* to KFD */
393         __u32 gpu_id;   /* to KFD */              393         __u32 gpu_id;   /* to KFD */
394 };                                                394 };
395                                                   395 
396 /* Allocation flags: memory types */              396 /* Allocation flags: memory types */
397 #define KFD_IOC_ALLOC_MEM_FLAGS_VRAM              397 #define KFD_IOC_ALLOC_MEM_FLAGS_VRAM            (1 << 0)
398 #define KFD_IOC_ALLOC_MEM_FLAGS_GTT               398 #define KFD_IOC_ALLOC_MEM_FLAGS_GTT             (1 << 1)
399 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR           399 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR         (1 << 2)
400 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL          400 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL        (1 << 3)
401 #define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP        401 #define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP      (1 << 4)
402 /* Allocation flags: attributes/access options    402 /* Allocation flags: attributes/access options */
403 #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE          403 #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE        (1 << 31)
404 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE        404 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE      (1 << 30)
405 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC            405 #define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC          (1 << 29)
406 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE     406 #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE   (1 << 28)
407 #define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM     407 #define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM   (1 << 27)
408 #define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT          408 #define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT        (1 << 26)
409 #define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED          409 #define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED        (1 << 25)
410 #define KFD_IOC_ALLOC_MEM_FLAGS_EXT_COHERENT      410 #define KFD_IOC_ALLOC_MEM_FLAGS_EXT_COHERENT    (1 << 24)
411 #define KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS        411 #define KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS      (1 << 23)
412                                                   412 
413 /* Allocate memory for later SVM (shared virtu    413 /* Allocate memory for later SVM (shared virtual memory) mapping.
414  *                                                414  *
415  * @va_addr:     virtual address of the memory    415  * @va_addr:     virtual address of the memory to be allocated
416  *               all later mappings on all GPU    416  *               all later mappings on all GPUs will use this address
417  * @size:        size in bytes                    417  * @size:        size in bytes
418  * @handle:      buffer handle returned to use    418  * @handle:      buffer handle returned to user mode, used to refer to
419  *               this allocation for mapping,     419  *               this allocation for mapping, unmapping and freeing
420  * @mmap_offset: for CPU-mapping the allocatio    420  * @mmap_offset: for CPU-mapping the allocation by mmapping a render node
421  *               for userptrs this is overload    421  *               for userptrs this is overloaded to specify the CPU address
422  * @gpu_id:      device identifier                422  * @gpu_id:      device identifier
423  * @flags:       memory type and attributes. S    423  * @flags:       memory type and attributes. See KFD_IOC_ALLOC_MEM_FLAGS above
424  */                                               424  */
425 struct kfd_ioctl_alloc_memory_of_gpu_args {       425 struct kfd_ioctl_alloc_memory_of_gpu_args {
426         __u64 va_addr;          /* to KFD */      426         __u64 va_addr;          /* to KFD */
427         __u64 size;             /* to KFD */      427         __u64 size;             /* to KFD */
428         __u64 handle;           /* from KFD */    428         __u64 handle;           /* from KFD */
429         __u64 mmap_offset;      /* to KFD (use    429         __u64 mmap_offset;      /* to KFD (userptr), from KFD (mmap offset) */
430         __u32 gpu_id;           /* to KFD */      430         __u32 gpu_id;           /* to KFD */
431         __u32 flags;                              431         __u32 flags;
432 };                                                432 };
433                                                   433 
434 /* Free memory allocated with kfd_ioctl_alloc_    434 /* Free memory allocated with kfd_ioctl_alloc_memory_of_gpu
435  *                                                435  *
436  * @handle: memory handle returned by alloc       436  * @handle: memory handle returned by alloc
437  */                                               437  */
438 struct kfd_ioctl_free_memory_of_gpu_args {        438 struct kfd_ioctl_free_memory_of_gpu_args {
439         __u64 handle;           /* to KFD */      439         __u64 handle;           /* to KFD */
440 };                                                440 };
441                                                   441 
442 /* Map memory to one or more GPUs                 442 /* Map memory to one or more GPUs
443  *                                                443  *
444  * @handle:                memory handle retur    444  * @handle:                memory handle returned by alloc
445  * @device_ids_array_ptr:  array of gpu_ids (_    445  * @device_ids_array_ptr:  array of gpu_ids (__u32 per device)
446  * @n_devices:             number of devices i    446  * @n_devices:             number of devices in the array
447  * @n_success:             number of devices m    447  * @n_success:             number of devices mapped successfully
448  *                                                448  *
449  * @n_success returns information to the calle    449  * @n_success returns information to the caller how many devices from
450  * the start of the array have mapped the buff    450  * the start of the array have mapped the buffer successfully. It can
451  * be passed into a subsequent retry call to s    451  * be passed into a subsequent retry call to skip those devices. For
452  * the first call the caller should initialize    452  * the first call the caller should initialize it to 0.
453  *                                                453  *
454  * If the ioctl completes with return code 0 (    454  * If the ioctl completes with return code 0 (success), n_success ==
455  * n_devices.                                     455  * n_devices.
456  */                                               456  */
457 struct kfd_ioctl_map_memory_to_gpu_args {         457 struct kfd_ioctl_map_memory_to_gpu_args {
458         __u64 handle;                   /* to     458         __u64 handle;                   /* to KFD */
459         __u64 device_ids_array_ptr;     /* to     459         __u64 device_ids_array_ptr;     /* to KFD */
460         __u32 n_devices;                /* to     460         __u32 n_devices;                /* to KFD */
461         __u32 n_success;                /* to/    461         __u32 n_success;                /* to/from KFD */
462 };                                                462 };
463                                                   463 
464 /* Unmap memory from one or more GPUs             464 /* Unmap memory from one or more GPUs
465  *                                                465  *
466  * same arguments as for mapping                  466  * same arguments as for mapping
467  */                                               467  */
468 struct kfd_ioctl_unmap_memory_from_gpu_args {     468 struct kfd_ioctl_unmap_memory_from_gpu_args {
469         __u64 handle;                   /* to     469         __u64 handle;                   /* to KFD */
470         __u64 device_ids_array_ptr;     /* to     470         __u64 device_ids_array_ptr;     /* to KFD */
471         __u32 n_devices;                /* to     471         __u32 n_devices;                /* to KFD */
472         __u32 n_success;                /* to/    472         __u32 n_success;                /* to/from KFD */
473 };                                                473 };
474                                                   474 
475 /* Allocate GWS for specific queue                475 /* Allocate GWS for specific queue
476  *                                                476  *
477  * @queue_id:    queue's id that GWS is alloca    477  * @queue_id:    queue's id that GWS is allocated for
478  * @num_gws:     how many GWS to allocate         478  * @num_gws:     how many GWS to allocate
479  * @first_gws:   index of the first GWS alloca    479  * @first_gws:   index of the first GWS allocated.
480  *               only support contiguous GWS a    480  *               only support contiguous GWS allocation
481  */                                               481  */
482 struct kfd_ioctl_alloc_queue_gws_args {           482 struct kfd_ioctl_alloc_queue_gws_args {
483         __u32 queue_id;         /* to KFD */      483         __u32 queue_id;         /* to KFD */
484         __u32 num_gws;          /* to KFD */      484         __u32 num_gws;          /* to KFD */
485         __u32 first_gws;        /* from KFD */    485         __u32 first_gws;        /* from KFD */
486         __u32 pad;                                486         __u32 pad;
487 };                                                487 };
488                                                   488 
489 struct kfd_ioctl_get_dmabuf_info_args {           489 struct kfd_ioctl_get_dmabuf_info_args {
490         __u64 size;             /* from KFD */    490         __u64 size;             /* from KFD */
491         __u64 metadata_ptr;     /* to KFD */      491         __u64 metadata_ptr;     /* to KFD */
492         __u32 metadata_size;    /* to KFD (spa    492         __u32 metadata_size;    /* to KFD (space allocated by user)
493                                  * from KFD (a    493                                  * from KFD (actual metadata size)
494                                  */               494                                  */
495         __u32 gpu_id;   /* from KFD */            495         __u32 gpu_id;   /* from KFD */
496         __u32 flags;            /* from KFD (K    496         __u32 flags;            /* from KFD (KFD_IOC_ALLOC_MEM_FLAGS) */
497         __u32 dmabuf_fd;        /* to KFD */      497         __u32 dmabuf_fd;        /* to KFD */
498 };                                                498 };
499                                                   499 
500 struct kfd_ioctl_import_dmabuf_args {             500 struct kfd_ioctl_import_dmabuf_args {
501         __u64 va_addr;  /* to KFD */              501         __u64 va_addr;  /* to KFD */
502         __u64 handle;   /* from KFD */            502         __u64 handle;   /* from KFD */
503         __u32 gpu_id;   /* to KFD */              503         __u32 gpu_id;   /* to KFD */
504         __u32 dmabuf_fd;        /* to KFD */      504         __u32 dmabuf_fd;        /* to KFD */
505 };                                                505 };
506                                                   506 
507 struct kfd_ioctl_export_dmabuf_args {             507 struct kfd_ioctl_export_dmabuf_args {
508         __u64 handle;           /* to KFD */      508         __u64 handle;           /* to KFD */
509         __u32 flags;            /* to KFD */      509         __u32 flags;            /* to KFD */
510         __u32 dmabuf_fd;        /* from KFD */    510         __u32 dmabuf_fd;        /* from KFD */
511 };                                                511 };
512                                                   512 
513 /*                                                513 /*
514  * KFD SMI(System Management Interface) events    514  * KFD SMI(System Management Interface) events
515  */                                               515  */
516 enum kfd_smi_event {                              516 enum kfd_smi_event {
517         KFD_SMI_EVENT_NONE = 0, /* not used */    517         KFD_SMI_EVENT_NONE = 0, /* not used */
518         KFD_SMI_EVENT_VMFAULT = 1, /* event st    518         KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */
519         KFD_SMI_EVENT_THERMAL_THROTTLE = 2,       519         KFD_SMI_EVENT_THERMAL_THROTTLE = 2,
520         KFD_SMI_EVENT_GPU_PRE_RESET = 3,          520         KFD_SMI_EVENT_GPU_PRE_RESET = 3,
521         KFD_SMI_EVENT_GPU_POST_RESET = 4,         521         KFD_SMI_EVENT_GPU_POST_RESET = 4,
522         KFD_SMI_EVENT_MIGRATE_START = 5,          522         KFD_SMI_EVENT_MIGRATE_START = 5,
523         KFD_SMI_EVENT_MIGRATE_END = 6,            523         KFD_SMI_EVENT_MIGRATE_END = 6,
524         KFD_SMI_EVENT_PAGE_FAULT_START = 7,       524         KFD_SMI_EVENT_PAGE_FAULT_START = 7,
525         KFD_SMI_EVENT_PAGE_FAULT_END = 8,         525         KFD_SMI_EVENT_PAGE_FAULT_END = 8,
526         KFD_SMI_EVENT_QUEUE_EVICTION = 9,         526         KFD_SMI_EVENT_QUEUE_EVICTION = 9,
527         KFD_SMI_EVENT_QUEUE_RESTORE = 10,         527         KFD_SMI_EVENT_QUEUE_RESTORE = 10,
528         KFD_SMI_EVENT_UNMAP_FROM_GPU = 11,        528         KFD_SMI_EVENT_UNMAP_FROM_GPU = 11,
529                                                   529 
530         /*                                        530         /*
531          * max event number, as a flag bit to     531          * max event number, as a flag bit to get events from all processes,
532          * this requires super user permission    532          * this requires super user permission, otherwise will not be able to
533          * receive event from any process. Wit    533          * receive event from any process. Without this flag to receive events
534          * from same process.                     534          * from same process.
535          */                                       535          */
536         KFD_SMI_EVENT_ALL_PROCESS = 64            536         KFD_SMI_EVENT_ALL_PROCESS = 64
537 };                                                537 };
538                                                   538 
539 enum KFD_MIGRATE_TRIGGERS {                       539 enum KFD_MIGRATE_TRIGGERS {
540         KFD_MIGRATE_TRIGGER_PREFETCH,             540         KFD_MIGRATE_TRIGGER_PREFETCH,
541         KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU,        541         KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU,
542         KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU,        542         KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU,
543         KFD_MIGRATE_TRIGGER_TTM_EVICTION          543         KFD_MIGRATE_TRIGGER_TTM_EVICTION
544 };                                                544 };
545                                                   545 
546 enum KFD_QUEUE_EVICTION_TRIGGERS {                546 enum KFD_QUEUE_EVICTION_TRIGGERS {
547         KFD_QUEUE_EVICTION_TRIGGER_SVM,           547         KFD_QUEUE_EVICTION_TRIGGER_SVM,
548         KFD_QUEUE_EVICTION_TRIGGER_USERPTR,       548         KFD_QUEUE_EVICTION_TRIGGER_USERPTR,
549         KFD_QUEUE_EVICTION_TRIGGER_TTM,           549         KFD_QUEUE_EVICTION_TRIGGER_TTM,
550         KFD_QUEUE_EVICTION_TRIGGER_SUSPEND,       550         KFD_QUEUE_EVICTION_TRIGGER_SUSPEND,
551         KFD_QUEUE_EVICTION_CRIU_CHECKPOINT,       551         KFD_QUEUE_EVICTION_CRIU_CHECKPOINT,
552         KFD_QUEUE_EVICTION_CRIU_RESTORE           552         KFD_QUEUE_EVICTION_CRIU_RESTORE
553 };                                                553 };
554                                                   554 
555 enum KFD_SVM_UNMAP_TRIGGERS {                     555 enum KFD_SVM_UNMAP_TRIGGERS {
556         KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY,         556         KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY,
557         KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRA    557         KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRATE,
558         KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU      558         KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU
559 };                                                559 };
560                                                   560 
561 #define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL    561 #define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
562 #define KFD_SMI_EVENT_MSG_SIZE  96                562 #define KFD_SMI_EVENT_MSG_SIZE  96
563                                                   563 
564 struct kfd_ioctl_smi_events_args {                564 struct kfd_ioctl_smi_events_args {
565         __u32 gpuid;    /* to KFD */              565         __u32 gpuid;    /* to KFD */
566         __u32 anon_fd;  /* from KFD */            566         __u32 anon_fd;  /* from KFD */
567 };                                                567 };
568                                                   568 
569 /*********************************************    569 /**************************************************************************************************
570  * CRIU IOCTLs (Checkpoint Restore In Userspac    570  * CRIU IOCTLs (Checkpoint Restore In Userspace)
571  *                                                571  *
572  * When checkpointing a process, the userspace    572  * When checkpointing a process, the userspace application will perform:
573  * 1. PROCESS_INFO op to determine current pro    573  * 1. PROCESS_INFO op to determine current process information. This pauses execution and evicts
574  *    all the queues.                             574  *    all the queues.
575  * 2. CHECKPOINT op to checkpoint process cont    575  * 2. CHECKPOINT op to checkpoint process contents (BOs, queues, events, svm-ranges)
576  * 3. UNPAUSE op to un-evict all the queues       576  * 3. UNPAUSE op to un-evict all the queues
577  *                                                577  *
578  * When restoring a process, the CRIU userspac    578  * When restoring a process, the CRIU userspace application will perform:
579  *                                                579  *
580  * 1. RESTORE op to restore process contents      580  * 1. RESTORE op to restore process contents
581  * 2. RESUME op to start the process              581  * 2. RESUME op to start the process
582  *                                                582  *
583  * Note: Queues are forced into an evicted sta    583  * Note: Queues are forced into an evicted state after a successful PROCESS_INFO. User
584  * application needs to perform an UNPAUSE ope    584  * application needs to perform an UNPAUSE operation after calling PROCESS_INFO.
585  */                                               585  */
586                                                   586 
587 enum kfd_criu_op {                                587 enum kfd_criu_op {
588         KFD_CRIU_OP_PROCESS_INFO,                 588         KFD_CRIU_OP_PROCESS_INFO,
589         KFD_CRIU_OP_CHECKPOINT,                   589         KFD_CRIU_OP_CHECKPOINT,
590         KFD_CRIU_OP_UNPAUSE,                      590         KFD_CRIU_OP_UNPAUSE,
591         KFD_CRIU_OP_RESTORE,                      591         KFD_CRIU_OP_RESTORE,
592         KFD_CRIU_OP_RESUME,                       592         KFD_CRIU_OP_RESUME,
593 };                                                593 };
594                                                   594 
595 /**                                               595 /**
596  * kfd_ioctl_criu_args - Arguments perform CRI    596  * kfd_ioctl_criu_args - Arguments perform CRIU operation
597  * @devices:            [in/out] User pointer     597  * @devices:            [in/out] User pointer to memory location for devices information.
598  *                      This is an array of ty    598  *                      This is an array of type kfd_criu_device_bucket.
599  * @bos:                [in/out] User pointer     599  * @bos:                [in/out] User pointer to memory location for BOs information
600  *                      This is an array of ty    600  *                      This is an array of type kfd_criu_bo_bucket.
601  * @priv_data:          [in/out] User pointer     601  * @priv_data:          [in/out] User pointer to memory location for private data
602  * @priv_data_size:     [in/out] Size of priv_    602  * @priv_data_size:     [in/out] Size of priv_data in bytes
603  * @num_devices:        [in/out] Number of GPU    603  * @num_devices:        [in/out] Number of GPUs used by process. Size of @devices array.
604  * @num_bos             [in/out] Number of BOs    604  * @num_bos             [in/out] Number of BOs used by process. Size of @bos array.
605  * @num_objects:        [in/out] Number of obj    605  * @num_objects:        [in/out] Number of objects used by process. Objects are opaque to
606  *                               user applicat    606  *                               user application.
607  * @pid:                [in/out] PID of the pr    607  * @pid:                [in/out] PID of the process being checkpointed
608  * @op                  [in] Type of operation    608  * @op                  [in] Type of operation (kfd_criu_op)
609  *                                                609  *
610  * Return: 0 on success, -errno on failure        610  * Return: 0 on success, -errno on failure
611  */                                               611  */
612 struct kfd_ioctl_criu_args {                      612 struct kfd_ioctl_criu_args {
613         __u64 devices;          /* Used during    613         __u64 devices;          /* Used during ops: CHECKPOINT, RESTORE */
614         __u64 bos;              /* Used during    614         __u64 bos;              /* Used during ops: CHECKPOINT, RESTORE */
615         __u64 priv_data;        /* Used during    615         __u64 priv_data;        /* Used during ops: CHECKPOINT, RESTORE */
616         __u64 priv_data_size;   /* Used during    616         __u64 priv_data_size;   /* Used during ops: PROCESS_INFO, RESTORE */
617         __u32 num_devices;      /* Used during    617         __u32 num_devices;      /* Used during ops: PROCESS_INFO, RESTORE */
618         __u32 num_bos;          /* Used during    618         __u32 num_bos;          /* Used during ops: PROCESS_INFO, RESTORE */
619         __u32 num_objects;      /* Used during    619         __u32 num_objects;      /* Used during ops: PROCESS_INFO, RESTORE */
620         __u32 pid;              /* Used during    620         __u32 pid;              /* Used during ops: PROCESS_INFO, RESUME */
621         __u32 op;                                 621         __u32 op;
622 };                                                622 };
623                                                   623 
624 struct kfd_criu_device_bucket {                   624 struct kfd_criu_device_bucket {
625         __u32 user_gpu_id;                        625         __u32 user_gpu_id;
626         __u32 actual_gpu_id;                      626         __u32 actual_gpu_id;
627         __u32 drm_fd;                             627         __u32 drm_fd;
628         __u32 pad;                                628         __u32 pad;
629 };                                                629 };
630                                                   630 
631 struct kfd_criu_bo_bucket {                       631 struct kfd_criu_bo_bucket {
632         __u64 addr;                               632         __u64 addr;
633         __u64 size;                               633         __u64 size;
634         __u64 offset;                             634         __u64 offset;
635         __u64 restored_offset;    /* During re    635         __u64 restored_offset;    /* During restore, updated offset for BO */
636         __u32 gpu_id;             /* This is t    636         __u32 gpu_id;             /* This is the user_gpu_id */
637         __u32 alloc_flags;                        637         __u32 alloc_flags;
638         __u32 dmabuf_fd;                          638         __u32 dmabuf_fd;
639         __u32 pad;                                639         __u32 pad;
640 };                                                640 };
641                                                   641 
642 /* CRIU IOCTLs - END */                           642 /* CRIU IOCTLs - END */
643 /*********************************************    643 /**************************************************************************************************/
644                                                   644 
645 /* Register offset inside the remapped mmio pa    645 /* Register offset inside the remapped mmio page
646  */                                               646  */
647 enum kfd_mmio_remap {                             647 enum kfd_mmio_remap {
648         KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL = 0,    648         KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL = 0,
649         KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,    649         KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,
650 };                                                650 };
651                                                   651 
652 /* Guarantee host access to memory */             652 /* Guarantee host access to memory */
653 #define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000    653 #define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000001
654 /* Fine grained coherency between all devices     654 /* Fine grained coherency between all devices with access */
655 #define KFD_IOCTL_SVM_FLAG_COHERENT    0x00000    655 #define KFD_IOCTL_SVM_FLAG_COHERENT    0x00000002
656 /* Use any GPU in same hive as preferred devic    656 /* Use any GPU in same hive as preferred device */
657 #define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL  0x00000    657 #define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL  0x00000004
658 /* GPUs only read, allows replication */          658 /* GPUs only read, allows replication */
659 #define KFD_IOCTL_SVM_FLAG_GPU_RO      0x00000    659 #define KFD_IOCTL_SVM_FLAG_GPU_RO      0x00000008
660 /* Allow execution on GPU */                      660 /* Allow execution on GPU */
661 #define KFD_IOCTL_SVM_FLAG_GPU_EXEC    0x00000    661 #define KFD_IOCTL_SVM_FLAG_GPU_EXEC    0x00000010
662 /* GPUs mostly read, may allow similar optimiz    662 /* GPUs mostly read, may allow similar optimizations as RO, but writes fault */
663 #define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY        663 #define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY     0x00000020
664 /* Keep GPU memory mapping always valid as if     664 /* Keep GPU memory mapping always valid as if XNACK is disable */
665 #define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED      665 #define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED   0x00000040
666 /* Fine grained coherency between all devices     666 /* Fine grained coherency between all devices using device-scope atomics */
667 #define KFD_IOCTL_SVM_FLAG_EXT_COHERENT           667 #define KFD_IOCTL_SVM_FLAG_EXT_COHERENT        0x00000080
668                                                   668 
669 /**                                               669 /**
670  * kfd_ioctl_svm_op - SVM ioctl operations        670  * kfd_ioctl_svm_op - SVM ioctl operations
671  *                                                671  *
672  * @KFD_IOCTL_SVM_OP_SET_ATTR: Modify one or m    672  * @KFD_IOCTL_SVM_OP_SET_ATTR: Modify one or more attributes
673  * @KFD_IOCTL_SVM_OP_GET_ATTR: Query one or mo    673  * @KFD_IOCTL_SVM_OP_GET_ATTR: Query one or more attributes
674  */                                               674  */
675 enum kfd_ioctl_svm_op {                           675 enum kfd_ioctl_svm_op {
676         KFD_IOCTL_SVM_OP_SET_ATTR,                676         KFD_IOCTL_SVM_OP_SET_ATTR,
677         KFD_IOCTL_SVM_OP_GET_ATTR                 677         KFD_IOCTL_SVM_OP_GET_ATTR
678 };                                                678 };
679                                                   679 
680 /** kfd_ioctl_svm_location - Enum for preferre    680 /** kfd_ioctl_svm_location - Enum for preferred and prefetch locations
681  *                                                681  *
682  * GPU IDs are used to specify GPUs as preferr    682  * GPU IDs are used to specify GPUs as preferred and prefetch locations.
683  * Below definitions are used for system memor    683  * Below definitions are used for system memory or for leaving the preferred
684  * location unspecified.                          684  * location unspecified.
685  */                                               685  */
686 enum kfd_ioctl_svm_location {                     686 enum kfd_ioctl_svm_location {
687         KFD_IOCTL_SVM_LOCATION_SYSMEM = 0,        687         KFD_IOCTL_SVM_LOCATION_SYSMEM = 0,
688         KFD_IOCTL_SVM_LOCATION_UNDEFINED = 0xf    688         KFD_IOCTL_SVM_LOCATION_UNDEFINED = 0xffffffff
689 };                                                689 };
690                                                   690 
691 /**                                               691 /**
692  * kfd_ioctl_svm_attr_type - SVM attribute typ    692  * kfd_ioctl_svm_attr_type - SVM attribute types
693  *                                                693  *
694  * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC: gpuid of    694  * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC: gpuid of the preferred location, 0 for
695  *                                    system m    695  *                                    system memory
696  * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC: gpuid of     696  * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC: gpuid of the prefetch location, 0 for
697  *                                   system me    697  *                                   system memory. Setting this triggers an
698  *                                   immediate    698  *                                   immediate prefetch (migration).
699  * @KFD_IOCTL_SVM_ATTR_ACCESS:                    699  * @KFD_IOCTL_SVM_ATTR_ACCESS:
700  * @KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE:           700  * @KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE:
701  * @KFD_IOCTL_SVM_ATTR_NO_ACCESS: specify memo    701  * @KFD_IOCTL_SVM_ATTR_NO_ACCESS: specify memory access for the gpuid given
702  *                                by the attri    702  *                                by the attribute value
703  * @KFD_IOCTL_SVM_ATTR_SET_FLAGS: bitmask of f    703  * @KFD_IOCTL_SVM_ATTR_SET_FLAGS: bitmask of flags to set (see
704  *                                KFD_IOCTL_SV    704  *                                KFD_IOCTL_SVM_FLAG_...)
705  * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS: bitmask of f    705  * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS: bitmask of flags to clear
706  * @KFD_IOCTL_SVM_ATTR_GRANULARITY: migration     706  * @KFD_IOCTL_SVM_ATTR_GRANULARITY: migration granularity
707  *                                  (log2 num     707  *                                  (log2 num pages)
708  */                                               708  */
709 enum kfd_ioctl_svm_attr_type {                    709 enum kfd_ioctl_svm_attr_type {
710         KFD_IOCTL_SVM_ATTR_PREFERRED_LOC,         710         KFD_IOCTL_SVM_ATTR_PREFERRED_LOC,
711         KFD_IOCTL_SVM_ATTR_PREFETCH_LOC,          711         KFD_IOCTL_SVM_ATTR_PREFETCH_LOC,
712         KFD_IOCTL_SVM_ATTR_ACCESS,                712         KFD_IOCTL_SVM_ATTR_ACCESS,
713         KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE,       713         KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE,
714         KFD_IOCTL_SVM_ATTR_NO_ACCESS,             714         KFD_IOCTL_SVM_ATTR_NO_ACCESS,
715         KFD_IOCTL_SVM_ATTR_SET_FLAGS,             715         KFD_IOCTL_SVM_ATTR_SET_FLAGS,
716         KFD_IOCTL_SVM_ATTR_CLR_FLAGS,             716         KFD_IOCTL_SVM_ATTR_CLR_FLAGS,
717         KFD_IOCTL_SVM_ATTR_GRANULARITY            717         KFD_IOCTL_SVM_ATTR_GRANULARITY
718 };                                                718 };
719                                                   719 
720 /**                                               720 /**
721  * kfd_ioctl_svm_attribute - Attributes as pai    721  * kfd_ioctl_svm_attribute - Attributes as pairs of type and value
722  *                                                722  *
723  * The meaning of the @value depends on the at    723  * The meaning of the @value depends on the attribute type.
724  *                                                724  *
725  * @type: attribute type (see enum @kfd_ioctl_    725  * @type: attribute type (see enum @kfd_ioctl_svm_attr_type)
726  * @value: attribute value                        726  * @value: attribute value
727  */                                               727  */
728 struct kfd_ioctl_svm_attribute {                  728 struct kfd_ioctl_svm_attribute {
729         __u32 type;                               729         __u32 type;
730         __u32 value;                              730         __u32 value;
731 };                                                731 };
732                                                   732 
733 /**                                               733 /**
734  * kfd_ioctl_svm_args - Arguments for SVM ioct    734  * kfd_ioctl_svm_args - Arguments for SVM ioctl
735  *                                                735  *
736  * @op specifies the operation to perform (see    736  * @op specifies the operation to perform (see enum
737  * @kfd_ioctl_svm_op).  @start_addr and @size     737  * @kfd_ioctl_svm_op).  @start_addr and @size are common for all
738  * operations.                                    738  * operations.
739  *                                                739  *
740  * A variable number of attributes can be give    740  * A variable number of attributes can be given in @attrs.
741  * @nattr specifies the number of attributes.     741  * @nattr specifies the number of attributes. New attributes can be
742  * added in the future without breaking the AB    742  * added in the future without breaking the ABI. If unknown attributes
743  * are given, the function returns -EINVAL.       743  * are given, the function returns -EINVAL.
744  *                                                744  *
745  * @KFD_IOCTL_SVM_OP_SET_ATTR sets attributes     745  * @KFD_IOCTL_SVM_OP_SET_ATTR sets attributes for a virtual address
746  * range. It may overlap existing virtual addr    746  * range. It may overlap existing virtual address ranges. If it does,
747  * the existing ranges will be split such that    747  * the existing ranges will be split such that the attribute changes
748  * only apply to the specified address range.     748  * only apply to the specified address range.
749  *                                                749  *
750  * @KFD_IOCTL_SVM_OP_GET_ATTR returns the inte    750  * @KFD_IOCTL_SVM_OP_GET_ATTR returns the intersection of attributes
751  * over all memory in the given range and retu    751  * over all memory in the given range and returns the result as the
752  * attribute value. If different pages have di    752  * attribute value. If different pages have different preferred or
753  * prefetch locations, 0xffffffff will be retu    753  * prefetch locations, 0xffffffff will be returned for
754  * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC or           754  * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC or
755  * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC resepctive    755  * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC resepctively. For
756  * @KFD_IOCTL_SVM_ATTR_SET_FLAGS, flags of all    756  * @KFD_IOCTL_SVM_ATTR_SET_FLAGS, flags of all pages will be
757  * aggregated by bitwise AND. That means, a fl    757  * aggregated by bitwise AND. That means, a flag will be set in the
758  * output, if that flag is set for all pages i    758  * output, if that flag is set for all pages in the range. For
759  * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS, flags of all    759  * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS, flags of all pages will be
760  * aggregated by bitwise NOR. That means, a fl    760  * aggregated by bitwise NOR. That means, a flag will be set in the
761  * output, if that flag is clear for all pages    761  * output, if that flag is clear for all pages in the range.
762  * The minimum migration granularity throughou    762  * The minimum migration granularity throughout the range will be
763  * returned for @KFD_IOCTL_SVM_ATTR_GRANULARIT    763  * returned for @KFD_IOCTL_SVM_ATTR_GRANULARITY.
764  *                                                764  *
765  * Querying of accessibility attributes works     765  * Querying of accessibility attributes works by initializing the
766  * attribute type to @KFD_IOCTL_SVM_ATTR_ACCES    766  * attribute type to @KFD_IOCTL_SVM_ATTR_ACCESS and the value to the
767  * GPUID being queried. Multiple attributes ca    767  * GPUID being queried. Multiple attributes can be given to allow
768  * querying multiple GPUIDs. The ioctl functio    768  * querying multiple GPUIDs. The ioctl function overwrites the
769  * attribute type to indicate the access for t    769  * attribute type to indicate the access for the specified GPU.
770  */                                               770  */
771 struct kfd_ioctl_svm_args {                       771 struct kfd_ioctl_svm_args {
772         __u64 start_addr;                         772         __u64 start_addr;
773         __u64 size;                               773         __u64 size;
774         __u32 op;                                 774         __u32 op;
775         __u32 nattr;                              775         __u32 nattr;
776         /* Variable length array of attributes    776         /* Variable length array of attributes */
777         struct kfd_ioctl_svm_attribute attrs[]    777         struct kfd_ioctl_svm_attribute attrs[];
778 };                                                778 };
779                                                   779 
780 /**                                               780 /**
781  * kfd_ioctl_set_xnack_mode_args - Arguments f    781  * kfd_ioctl_set_xnack_mode_args - Arguments for set_xnack_mode
782  *                                                782  *
783  * @xnack_enabled:       [in/out] Whether to e    783  * @xnack_enabled:       [in/out] Whether to enable XNACK mode for this process
784  *                                                784  *
785  * @xnack_enabled indicates whether recoverabl    785  * @xnack_enabled indicates whether recoverable page faults should be
786  * enabled for the current process. 0 means di    786  * enabled for the current process. 0 means disabled, positive means
787  * enabled, negative means leave unchanged. If    787  * enabled, negative means leave unchanged. If enabled, virtual address
788  * translations on GFXv9 and later AMD GPUs ca    788  * translations on GFXv9 and later AMD GPUs can return XNACK and retry
789  * the access until a valid PTE is available.     789  * the access until a valid PTE is available. This is used to implement
790  * device page faults.                            790  * device page faults.
791  *                                                791  *
792  * On output, @xnack_enabled returns the (new)    792  * On output, @xnack_enabled returns the (new) current mode (0 or
793  * positive). Therefore, a negative input valu    793  * positive). Therefore, a negative input value can be used to query
794  * the current mode without changing it.          794  * the current mode without changing it.
795  *                                                795  *
796  * The XNACK mode fundamentally changes the wa    796  * The XNACK mode fundamentally changes the way SVM managed memory works
797  * in the driver, with subtle effects on appli    797  * in the driver, with subtle effects on application performance and
798  * functionality.                                 798  * functionality.
799  *                                                799  *
800  * Enabling XNACK mode requires shader program    800  * Enabling XNACK mode requires shader programs to be compiled
801  * differently. Furthermore, not all GPUs supp    801  * differently. Furthermore, not all GPUs support changing the mode
802  * per-process. Therefore changing the mode is    802  * per-process. Therefore changing the mode is only allowed while no
803  * user mode queues exist in the process. This    803  * user mode queues exist in the process. This ensure that no shader
804  * code is running that may be compiled for th    804  * code is running that may be compiled for the wrong mode. And GPUs
805  * that cannot change to the requested mode wi    805  * that cannot change to the requested mode will prevent the XNACK
806  * mode from occurring. All GPUs used by the p    806  * mode from occurring. All GPUs used by the process must be in the
807  * same XNACK mode.                               807  * same XNACK mode.
808  *                                                808  *
809  * GFXv8 or older GPUs do not support 48 bit v    809  * GFXv8 or older GPUs do not support 48 bit virtual addresses or SVM.
810  * Therefore those GPUs are not considered for    810  * Therefore those GPUs are not considered for the XNACK mode switch.
811  *                                                811  *
812  * Return: 0 on success, -errno on failure        812  * Return: 0 on success, -errno on failure
813  */                                               813  */
814 struct kfd_ioctl_set_xnack_mode_args {            814 struct kfd_ioctl_set_xnack_mode_args {
815         __s32 xnack_enabled;                      815         __s32 xnack_enabled;
816 };                                                816 };
817                                                   817 
818 /* Wave launch override modes */                  818 /* Wave launch override modes */
819 enum kfd_dbg_trap_override_mode {                 819 enum kfd_dbg_trap_override_mode {
820         KFD_DBG_TRAP_OVERRIDE_OR = 0,             820         KFD_DBG_TRAP_OVERRIDE_OR = 0,
821         KFD_DBG_TRAP_OVERRIDE_REPLACE = 1         821         KFD_DBG_TRAP_OVERRIDE_REPLACE = 1
822 };                                                822 };
823                                                   823 
824 /* Wave launch overrides */                       824 /* Wave launch overrides */
825 enum kfd_dbg_trap_mask {                          825 enum kfd_dbg_trap_mask {
826         KFD_DBG_TRAP_MASK_FP_INVALID = 1,         826         KFD_DBG_TRAP_MASK_FP_INVALID = 1,
827         KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL =     827         KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL = 2,
828         KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO =     828         KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO = 4,
829         KFD_DBG_TRAP_MASK_FP_OVERFLOW = 8,        829         KFD_DBG_TRAP_MASK_FP_OVERFLOW = 8,
830         KFD_DBG_TRAP_MASK_FP_UNDERFLOW = 16,      830         KFD_DBG_TRAP_MASK_FP_UNDERFLOW = 16,
831         KFD_DBG_TRAP_MASK_FP_INEXACT = 32,        831         KFD_DBG_TRAP_MASK_FP_INEXACT = 32,
832         KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO =    832         KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO = 64,
833         KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH =     833         KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH = 128,
834         KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION    834         KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION = 256,
835         KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START =    835         KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START = (1 << 30),
836         KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END = (    836         KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END = (1 << 31)
837 };                                                837 };
838                                                   838 
839 /* Wave launch modes */                           839 /* Wave launch modes */
840 enum kfd_dbg_trap_wave_launch_mode {              840 enum kfd_dbg_trap_wave_launch_mode {
841         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL =    841         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL = 0,
842         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT = 1    842         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT = 1,
843         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG =     843         KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG = 3
844 };                                                844 };
845                                                   845 
846 /* Address watch modes */                         846 /* Address watch modes */
847 enum kfd_dbg_trap_address_watch_mode {            847 enum kfd_dbg_trap_address_watch_mode {
848         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ =    848         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ = 0,
849         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREA    849         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREAD = 1,
850         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC    850         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC = 2,
851         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL =     851         KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL = 3
852 };                                                852 };
853                                                   853 
854 /* Additional wave settings */                    854 /* Additional wave settings */
855 enum kfd_dbg_trap_flags {                         855 enum kfd_dbg_trap_flags {
856         KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP = 1,      856         KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP = 1,
857         KFD_DBG_TRAP_FLAG_SINGLE_ALU_OP = 2,      857         KFD_DBG_TRAP_FLAG_SINGLE_ALU_OP = 2,
858 };                                                858 };
859                                                   859 
860 /* Trap exceptions */                             860 /* Trap exceptions */
861 enum kfd_dbg_trap_exception_code {                861 enum kfd_dbg_trap_exception_code {
862         EC_NONE = 0,                              862         EC_NONE = 0,
863         /* per queue */                           863         /* per queue */
864         EC_QUEUE_WAVE_ABORT = 1,                  864         EC_QUEUE_WAVE_ABORT = 1,
865         EC_QUEUE_WAVE_TRAP = 2,                   865         EC_QUEUE_WAVE_TRAP = 2,
866         EC_QUEUE_WAVE_MATH_ERROR = 3,             866         EC_QUEUE_WAVE_MATH_ERROR = 3,
867         EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION = 4,    867         EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION = 4,
868         EC_QUEUE_WAVE_MEMORY_VIOLATION = 5,       868         EC_QUEUE_WAVE_MEMORY_VIOLATION = 5,
869         EC_QUEUE_WAVE_APERTURE_VIOLATION = 6,     869         EC_QUEUE_WAVE_APERTURE_VIOLATION = 6,
870         EC_QUEUE_PACKET_DISPATCH_DIM_INVALID =    870         EC_QUEUE_PACKET_DISPATCH_DIM_INVALID = 16,
871         EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT    871         EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID = 17,
872         EC_QUEUE_PACKET_DISPATCH_CODE_INVALID     872         EC_QUEUE_PACKET_DISPATCH_CODE_INVALID = 18,
873         EC_QUEUE_PACKET_RESERVED = 19,            873         EC_QUEUE_PACKET_RESERVED = 19,
874         EC_QUEUE_PACKET_UNSUPPORTED = 20,         874         EC_QUEUE_PACKET_UNSUPPORTED = 20,
875         EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SI    875         EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID = 21,
876         EC_QUEUE_PACKET_DISPATCH_REGISTER_INVA    876         EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID = 22,
877         EC_QUEUE_PACKET_VENDOR_UNSUPPORTED = 2    877         EC_QUEUE_PACKET_VENDOR_UNSUPPORTED = 23,
878         EC_QUEUE_PREEMPTION_ERROR = 30,           878         EC_QUEUE_PREEMPTION_ERROR = 30,
879         EC_QUEUE_NEW = 31,                        879         EC_QUEUE_NEW = 31,
880         /* per device */                          880         /* per device */
881         EC_DEVICE_QUEUE_DELETE = 32,              881         EC_DEVICE_QUEUE_DELETE = 32,
882         EC_DEVICE_MEMORY_VIOLATION = 33,          882         EC_DEVICE_MEMORY_VIOLATION = 33,
883         EC_DEVICE_RAS_ERROR = 34,                 883         EC_DEVICE_RAS_ERROR = 34,
884         EC_DEVICE_FATAL_HALT = 35,                884         EC_DEVICE_FATAL_HALT = 35,
885         EC_DEVICE_NEW = 36,                       885         EC_DEVICE_NEW = 36,
886         /* per process */                         886         /* per process */
887         EC_PROCESS_RUNTIME = 48,                  887         EC_PROCESS_RUNTIME = 48,
888         EC_PROCESS_DEVICE_REMOVE = 49,            888         EC_PROCESS_DEVICE_REMOVE = 49,
889         EC_MAX                                    889         EC_MAX
890 };                                                890 };
891                                                   891 
892 /* Mask generated by ecode in kfd_dbg_trap_exc    892 /* Mask generated by ecode in kfd_dbg_trap_exception_code */
893 #define KFD_EC_MASK(ecode)      (1ULL << (ecod    893 #define KFD_EC_MASK(ecode)      (1ULL << (ecode - 1))
894                                                   894 
895 /* Masks for exception code type checks below     895 /* Masks for exception code type checks below */
896 #define KFD_EC_MASK_QUEUE       (KFD_EC_MASK(E    896 #define KFD_EC_MASK_QUEUE       (KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) |     \
897                                  KFD_EC_MASK(E    897                                  KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) |      \
898                                  KFD_EC_MASK(E    898                                  KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) |        \
899                                  KFD_EC_MASK(E    899                                  KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) |       \
900                                  KFD_EC_MASK(E    900                                  KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) |  \
901                                  KFD_EC_MASK(E    901                                  KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) |        \
902                                  KFD_EC_MASK(E    902                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) |    \
903                                  KFD_EC_MASK(E    903                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) |     \
904                                  KFD_EC_MASK(E    904                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) |   \
905                                  KFD_EC_MASK(E    905                                  KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) |        \
906                                  KFD_EC_MASK(E    906                                  KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) |     \
907                                  KFD_EC_MASK(E    907                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) |        \
908                                  KFD_EC_MASK(E    908                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) |       \
909                                  KFD_EC_MASK(E    909                                  KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED)        |       \
910                                  KFD_EC_MASK(E    910                                  KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR) |       \
911                                  KFD_EC_MASK(E    911                                  KFD_EC_MASK(EC_QUEUE_NEW))
912 #define KFD_EC_MASK_DEVICE      (KFD_EC_MASK(E    912 #define KFD_EC_MASK_DEVICE      (KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) |          \
913                                  KFD_EC_MASK(E    913                                  KFD_EC_MASK(EC_DEVICE_RAS_ERROR) |             \
914                                  KFD_EC_MASK(E    914                                  KFD_EC_MASK(EC_DEVICE_FATAL_HALT) |            \
915                                  KFD_EC_MASK(E    915                                  KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) |      \
916                                  KFD_EC_MASK(E    916                                  KFD_EC_MASK(EC_DEVICE_NEW))
917 #define KFD_EC_MASK_PROCESS     (KFD_EC_MASK(E    917 #define KFD_EC_MASK_PROCESS     (KFD_EC_MASK(EC_PROCESS_RUNTIME) |      \
918                                  KFD_EC_MASK(E    918                                  KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE))
919 #define KFD_EC_MASK_PACKET      (KFD_EC_MASK(E    919 #define KFD_EC_MASK_PACKET      (KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) |    \
920                                  KFD_EC_MASK(E    920                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) |     \
921                                  KFD_EC_MASK(E    921                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) |   \
922                                  KFD_EC_MASK(E    922                                  KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) |        \
923                                  KFD_EC_MASK(E    923                                  KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) |     \
924                                  KFD_EC_MASK(E    924                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) |        \
925                                  KFD_EC_MASK(E    925                                  KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) |       \
926                                  KFD_EC_MASK(E    926                                  KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED))
927                                                   927 
928 /* Checks for exception code types for KFD sea    928 /* Checks for exception code types for KFD search */
929 #define KFD_DBG_EC_IS_VALID(ecode) (ecode > EC    929 #define KFD_DBG_EC_IS_VALID(ecode) (ecode > EC_NONE && ecode < EC_MAX)
930 #define KFD_DBG_EC_TYPE_IS_QUEUE(ecode)           930 #define KFD_DBG_EC_TYPE_IS_QUEUE(ecode)                                 \
931                         (KFD_DBG_EC_IS_VALID(e    931                         (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
932 #define KFD_DBG_EC_TYPE_IS_DEVICE(ecode)          932 #define KFD_DBG_EC_TYPE_IS_DEVICE(ecode)                                \
933                         (KFD_DBG_EC_IS_VALID(e    933                         (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
934 #define KFD_DBG_EC_TYPE_IS_PROCESS(ecode)         934 #define KFD_DBG_EC_TYPE_IS_PROCESS(ecode)                               \
935                         (KFD_DBG_EC_IS_VALID(e    935                         (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
936 #define KFD_DBG_EC_TYPE_IS_PACKET(ecode)          936 #define KFD_DBG_EC_TYPE_IS_PACKET(ecode)                                \
937                         (KFD_DBG_EC_IS_VALID(e    937                         (KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PACKET))
938                                                   938 
939                                                   939 
940 /* Runtime enable states */                       940 /* Runtime enable states */
941 enum kfd_dbg_runtime_state {                      941 enum kfd_dbg_runtime_state {
942         DEBUG_RUNTIME_STATE_DISABLED = 0,         942         DEBUG_RUNTIME_STATE_DISABLED = 0,
943         DEBUG_RUNTIME_STATE_ENABLED = 1,          943         DEBUG_RUNTIME_STATE_ENABLED = 1,
944         DEBUG_RUNTIME_STATE_ENABLED_BUSY = 2,     944         DEBUG_RUNTIME_STATE_ENABLED_BUSY = 2,
945         DEBUG_RUNTIME_STATE_ENABLED_ERROR = 3     945         DEBUG_RUNTIME_STATE_ENABLED_ERROR = 3
946 };                                                946 };
947                                                   947 
948 /* Runtime enable status */                       948 /* Runtime enable status */
949 struct kfd_runtime_info {                         949 struct kfd_runtime_info {
950         __u64 r_debug;                            950         __u64 r_debug;
951         __u32 runtime_state;                      951         __u32 runtime_state;
952         __u32 ttmp_setup;                         952         __u32 ttmp_setup;
953 };                                                953 };
954                                                   954 
955 /* Enable modes for runtime enable */             955 /* Enable modes for runtime enable */
956 #define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK       956 #define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK     1
957 #define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK    957 #define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK  2
958                                                   958 
959 /**                                               959 /**
960  * kfd_ioctl_runtime_enable_args - Arguments f    960  * kfd_ioctl_runtime_enable_args - Arguments for runtime enable
961  *                                                961  *
962  * Coordinates debug exception signalling and     962  * Coordinates debug exception signalling and debug device enablement with runtime.
963  *                                                963  *
964  * @r_debug - pointer to user struct for shari    964  * @r_debug - pointer to user struct for sharing information between ROCr and the debuggger
965  * @mode_mask - mask to set mode                  965  * @mode_mask - mask to set mode
966  *      KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK -     966  *      KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK - enable runtime for debugging, otherwise disable
967  *      KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK    967  *      KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK - enable trap temporary setup (ignore on disable)
968  * @capabilities_mask - mask to notify runtime    968  * @capabilities_mask - mask to notify runtime on what KFD supports
969  *                                                969  *
970  * Return - 0 on SUCCESS.                         970  * Return - 0 on SUCCESS.
971  *        - EBUSY if runtime enable call alrea    971  *        - EBUSY if runtime enable call already pending.
972  *        - EEXIST if user queues already acti    972  *        - EEXIST if user queues already active prior to call.
973  *          If process is debug enabled, runti    973  *          If process is debug enabled, runtime enable will enable debug devices and
974  *          wait for debugger process to send     974  *          wait for debugger process to send runtime exception EC_PROCESS_RUNTIME
975  *          to unblock - see kfd_ioctl_dbg_tra    975  *          to unblock - see kfd_ioctl_dbg_trap_args.
976  *                                                976  *
977  */                                               977  */
978 struct kfd_ioctl_runtime_enable_args {            978 struct kfd_ioctl_runtime_enable_args {
979         __u64 r_debug;                            979         __u64 r_debug;
980         __u32 mode_mask;                          980         __u32 mode_mask;
981         __u32 capabilities_mask;                  981         __u32 capabilities_mask;
982 };                                                982 };
983                                                   983 
984 /* Queue information */                           984 /* Queue information */
985 struct kfd_queue_snapshot_entry {                 985 struct kfd_queue_snapshot_entry {
986         __u64 exception_status;                   986         __u64 exception_status;
987         __u64 ring_base_address;                  987         __u64 ring_base_address;
988         __u64 write_pointer_address;              988         __u64 write_pointer_address;
989         __u64 read_pointer_address;               989         __u64 read_pointer_address;
990         __u64 ctx_save_restore_address;           990         __u64 ctx_save_restore_address;
991         __u32 queue_id;                           991         __u32 queue_id;
992         __u32 gpu_id;                             992         __u32 gpu_id;
993         __u32 ring_size;                          993         __u32 ring_size;
994         __u32 queue_type;                         994         __u32 queue_type;
995         __u32 ctx_save_restore_area_size;         995         __u32 ctx_save_restore_area_size;
996         __u32 reserved;                           996         __u32 reserved;
997 };                                                997 };
998                                                   998 
999 /* Queue status return for suspend/resume */      999 /* Queue status return for suspend/resume */
1000 #define KFD_DBG_QUEUE_ERROR_BIT         30       1000 #define KFD_DBG_QUEUE_ERROR_BIT         30
1001 #define KFD_DBG_QUEUE_INVALID_BIT       31       1001 #define KFD_DBG_QUEUE_INVALID_BIT       31
1002 #define KFD_DBG_QUEUE_ERROR_MASK        (1 <<    1002 #define KFD_DBG_QUEUE_ERROR_MASK        (1 << KFD_DBG_QUEUE_ERROR_BIT)
1003 #define KFD_DBG_QUEUE_INVALID_MASK      (1 <<    1003 #define KFD_DBG_QUEUE_INVALID_MASK      (1 << KFD_DBG_QUEUE_INVALID_BIT)
1004                                                  1004 
1005 /* Context save area header information */       1005 /* Context save area header information */
1006 struct kfd_context_save_area_header {            1006 struct kfd_context_save_area_header {
1007         struct {                                 1007         struct {
1008                 __u32 control_stack_offset;      1008                 __u32 control_stack_offset;
1009                 __u32 control_stack_size;        1009                 __u32 control_stack_size;
1010                 __u32 wave_state_offset;         1010                 __u32 wave_state_offset;
1011                 __u32 wave_state_size;           1011                 __u32 wave_state_size;
1012         } wave_state;                            1012         } wave_state;
1013         __u32 debug_offset;                      1013         __u32 debug_offset;
1014         __u32 debug_size;                        1014         __u32 debug_size;
1015         __u64 err_payload_addr;                  1015         __u64 err_payload_addr;
1016         __u32 err_event_id;                      1016         __u32 err_event_id;
1017         __u32 reserved1;                         1017         __u32 reserved1;
1018 };                                               1018 };
1019                                                  1019 
1020 /*                                               1020 /*
1021  * Debug operations                              1021  * Debug operations
1022  *                                               1022  *
1023  * For specifics on usage and return values,     1023  * For specifics on usage and return values, see documentation per operation
1024  * below.  Otherwise, generic error returns a    1024  * below.  Otherwise, generic error returns apply:
1025  *      - ESRCH if the process to debug does     1025  *      - ESRCH if the process to debug does not exist.
1026  *                                               1026  *
1027  *      - EINVAL (with KFD_IOC_DBG_TRAP_ENABL    1027  *      - EINVAL (with KFD_IOC_DBG_TRAP_ENABLE exempt) if operation
1028  *               KFD_IOC_DBG_TRAP_ENABLE has     1028  *               KFD_IOC_DBG_TRAP_ENABLE has not succeeded prior.
1029  *               Also returns this error if G    1029  *               Also returns this error if GPU hardware scheduling is not supported.
1030  *                                               1030  *
1031  *      - EPERM (with KFD_IOC_DBG_TRAP_DISABL    1031  *      - EPERM (with KFD_IOC_DBG_TRAP_DISABLE exempt) if target process is not
1032  *               PTRACE_ATTACHED.  KFD_IOC_DB    1032  *               PTRACE_ATTACHED.  KFD_IOC_DBG_TRAP_DISABLE is exempt to allow
1033  *               clean up of debug mode as lo    1033  *               clean up of debug mode as long as process is debug enabled.
1034  *                                               1034  *
1035  *      - EACCES if any DBG_HW_OP (debug hard    1035  *      - EACCES if any DBG_HW_OP (debug hardware operation) is requested when
1036  *               AMDKFD_IOC_RUNTIME_ENABLE ha    1036  *               AMDKFD_IOC_RUNTIME_ENABLE has not succeeded prior.
1037  *                                               1037  *
1038  *      - ENODEV if any GPU does not support     1038  *      - ENODEV if any GPU does not support debugging on a DBG_HW_OP call.
1039  *                                               1039  *
1040  *      - Other errors may be returned when a    1040  *      - Other errors may be returned when a DBG_HW_OP occurs while the GPU
1041  *        is in a fatal state.                   1041  *        is in a fatal state.
1042  *                                               1042  *
1043  */                                              1043  */
1044 enum kfd_dbg_trap_operations {                   1044 enum kfd_dbg_trap_operations {
1045         KFD_IOC_DBG_TRAP_ENABLE = 0,             1045         KFD_IOC_DBG_TRAP_ENABLE = 0,
1046         KFD_IOC_DBG_TRAP_DISABLE = 1,            1046         KFD_IOC_DBG_TRAP_DISABLE = 1,
1047         KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT =    1047         KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT = 2,
1048         KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABL    1048         KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED = 3,
1049         KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVER    1049         KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE = 4,  /* DBG_HW_OP */
1050         KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE    1050         KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE = 5,      /* DBG_HW_OP */
1051         KFD_IOC_DBG_TRAP_SUSPEND_QUEUES = 6,     1051         KFD_IOC_DBG_TRAP_SUSPEND_QUEUES = 6,            /* DBG_HW_OP */
1052         KFD_IOC_DBG_TRAP_RESUME_QUEUES = 7,      1052         KFD_IOC_DBG_TRAP_RESUME_QUEUES = 7,             /* DBG_HW_OP */
1053         KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WAT    1053         KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH = 8,    /* DBG_HW_OP */
1054         KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_W    1054         KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH = 9,  /* DBG_HW_OP */
1055         KFD_IOC_DBG_TRAP_SET_FLAGS = 10,         1055         KFD_IOC_DBG_TRAP_SET_FLAGS = 10,
1056         KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT =     1056         KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT = 11,
1057         KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO    1057         KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO = 12,
1058         KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT =    1058         KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT = 13,
1059         KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT     1059         KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT = 14
1060 };                                               1060 };
1061                                                  1061 
1062 /**                                              1062 /**
1063  * kfd_ioctl_dbg_trap_enable_args                1063  * kfd_ioctl_dbg_trap_enable_args
1064  *                                               1064  *
1065  *     Arguments for KFD_IOC_DBG_TRAP_ENABLE.    1065  *     Arguments for KFD_IOC_DBG_TRAP_ENABLE.
1066  *                                               1066  *
1067  *     Enables debug session for target proce    1067  *     Enables debug session for target process. Call @op KFD_IOC_DBG_TRAP_DISABLE in
1068  *     kfd_ioctl_dbg_trap_args to disable deb    1068  *     kfd_ioctl_dbg_trap_args to disable debug session.
1069  *                                               1069  *
1070  *     @exception_mask (IN)     - exceptions     1070  *     @exception_mask (IN)     - exceptions to raise to the debugger
1071  *     @rinfo_ptr      (IN)     - pointer to     1071  *     @rinfo_ptr      (IN)     - pointer to runtime info buffer (see kfd_runtime_info)
1072  *     @rinfo_size     (IN/OUT) - size of run    1072  *     @rinfo_size     (IN/OUT) - size of runtime info buffer in bytes
1073  *     @dbg_fd         (IN)     - fd the KFD     1073  *     @dbg_fd         (IN)     - fd the KFD will nofify the debugger with of raised
1074  *                                exceptions     1074  *                                exceptions set in exception_mask.
1075  *                                               1075  *
1076  *     Generic errors apply (see kfd_dbg_trap    1076  *     Generic errors apply (see kfd_dbg_trap_operations).
1077  *     Return - 0 on SUCCESS.                    1077  *     Return - 0 on SUCCESS.
1078  *              Copies KFD saved kfd_runtime_    1078  *              Copies KFD saved kfd_runtime_info to @rinfo_ptr on enable.
1079  *              Size of kfd_runtime saved by     1079  *              Size of kfd_runtime saved by the KFD returned to @rinfo_size.
1080  *            - EBADF if KFD cannot get a ref    1080  *            - EBADF if KFD cannot get a reference to dbg_fd.
1081  *            - EFAULT if KFD cannot copy run    1081  *            - EFAULT if KFD cannot copy runtime info to rinfo_ptr.
1082  *            - EINVAL if target process is a    1082  *            - EINVAL if target process is already debug enabled.
1083  *                                               1083  *
1084  */                                              1084  */
1085 struct kfd_ioctl_dbg_trap_enable_args {          1085 struct kfd_ioctl_dbg_trap_enable_args {
1086         __u64 exception_mask;                    1086         __u64 exception_mask;
1087         __u64 rinfo_ptr;                         1087         __u64 rinfo_ptr;
1088         __u32 rinfo_size;                        1088         __u32 rinfo_size;
1089         __u32 dbg_fd;                            1089         __u32 dbg_fd;
1090 };                                               1090 };
1091                                                  1091 
1092 /**                                              1092 /**
1093  * kfd_ioctl_dbg_trap_send_runtime_event_args    1093  * kfd_ioctl_dbg_trap_send_runtime_event_args
1094  *                                               1094  *
1095  *                                               1095  *
1096  *     Arguments for KFD_IOC_DBG_TRAP_SEND_RU    1096  *     Arguments for KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT.
1097  *     Raises exceptions to runtime.             1097  *     Raises exceptions to runtime.
1098  *                                               1098  *
1099  *     @exception_mask (IN) - exceptions to r    1099  *     @exception_mask (IN) - exceptions to raise to runtime
1100  *     @gpu_id         (IN) - target device i    1100  *     @gpu_id         (IN) - target device id
1101  *     @queue_id       (IN) - target queue id    1101  *     @queue_id       (IN) - target queue id
1102  *                                               1102  *
1103  *     Generic errors apply (see kfd_dbg_trap    1103  *     Generic errors apply (see kfd_dbg_trap_operations).
1104  *     Return - 0 on SUCCESS.                    1104  *     Return - 0 on SUCCESS.
1105  *            - ENODEV if gpu_id not found.      1105  *            - ENODEV if gpu_id not found.
1106  *              If exception_mask contains EC    1106  *              If exception_mask contains EC_PROCESS_RUNTIME, unblocks pending
1107  *              AMDKFD_IOC_RUNTIME_ENABLE cal    1107  *              AMDKFD_IOC_RUNTIME_ENABLE call - see kfd_ioctl_runtime_enable_args.
1108  *              All other exceptions are rais    1108  *              All other exceptions are raised to runtime through err_payload_addr.
1109  *              See kfd_context_save_area_hea    1109  *              See kfd_context_save_area_header.
1110  */                                              1110  */
1111 struct kfd_ioctl_dbg_trap_send_runtime_event_    1111 struct kfd_ioctl_dbg_trap_send_runtime_event_args {
1112         __u64 exception_mask;                    1112         __u64 exception_mask;
1113         __u32 gpu_id;                            1113         __u32 gpu_id;
1114         __u32 queue_id;                          1114         __u32 queue_id;
1115 };                                               1115 };
1116                                                  1116 
1117 /**                                              1117 /**
1118  * kfd_ioctl_dbg_trap_set_exceptions_enabled_    1118  * kfd_ioctl_dbg_trap_set_exceptions_enabled_args
1119  *                                               1119  *
1120  *     Arguments for KFD_IOC_SET_EXCEPTIONS_E    1120  *     Arguments for KFD_IOC_SET_EXCEPTIONS_ENABLED
1121  *     Set new exceptions to be raised to the    1121  *     Set new exceptions to be raised to the debugger.
1122  *                                               1122  *
1123  *     @exception_mask (IN) - new exceptions     1123  *     @exception_mask (IN) - new exceptions to raise the debugger
1124  *                                               1124  *
1125  *     Generic errors apply (see kfd_dbg_trap    1125  *     Generic errors apply (see kfd_dbg_trap_operations).
1126  *     Return - 0 on SUCCESS.                    1126  *     Return - 0 on SUCCESS.
1127  */                                              1127  */
1128 struct kfd_ioctl_dbg_trap_set_exceptions_enab    1128 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args {
1129         __u64 exception_mask;                    1129         __u64 exception_mask;
1130 };                                               1130 };
1131                                                  1131 
1132 /**                                              1132 /**
1133  * kfd_ioctl_dbg_trap_set_wave_launch_overrid    1133  * kfd_ioctl_dbg_trap_set_wave_launch_override_args
1134  *                                               1134  *
1135  *     Arguments for KFD_IOC_DBG_TRAP_SET_WAV    1135  *     Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE
1136  *     Enable HW exceptions to raise trap.       1136  *     Enable HW exceptions to raise trap.
1137  *                                               1137  *
1138  *     @override_mode        (IN)     - see k    1138  *     @override_mode        (IN)     - see kfd_dbg_trap_override_mode
1139  *     @enable_mask          (IN/OUT) - refer    1139  *     @enable_mask          (IN/OUT) - reference kfd_dbg_trap_mask.
1140  *                                      IN is    1140  *                                      IN is the override modes requested to be enabled.
1141  *                                      OUT i    1141  *                                      OUT is referenced in Return below.
1142  *     @support_request_mask (IN/OUT) - refer    1142  *     @support_request_mask (IN/OUT) - reference kfd_dbg_trap_mask.
1143  *                                      IN is    1143  *                                      IN is the override modes requested for support check.
1144  *                                      OUT i    1144  *                                      OUT is referenced in Return below.
1145  *                                               1145  *
1146  *     Generic errors apply (see kfd_dbg_trap    1146  *     Generic errors apply (see kfd_dbg_trap_operations).
1147  *     Return - 0 on SUCCESS.                    1147  *     Return - 0 on SUCCESS.
1148  *              Previous enablement is return    1148  *              Previous enablement is returned in @enable_mask.
1149  *              Actual override support is re    1149  *              Actual override support is returned in @support_request_mask.
1150  *            - EINVAL if override mode is no    1150  *            - EINVAL if override mode is not supported.
1151  *            - EACCES if trap support reques    1151  *            - EACCES if trap support requested is not actually supported.
1152  *              i.e. enable_mask (IN) is not     1152  *              i.e. enable_mask (IN) is not a subset of support_request_mask (OUT).
1153  *              Otherwise it is considered a     1153  *              Otherwise it is considered a generic error (see kfd_dbg_trap_operations).
1154  */                                              1154  */
1155 struct kfd_ioctl_dbg_trap_set_wave_launch_ove    1155 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args {
1156         __u32 override_mode;                     1156         __u32 override_mode;
1157         __u32 enable_mask;                       1157         __u32 enable_mask;
1158         __u32 support_request_mask;              1158         __u32 support_request_mask;
1159         __u32 pad;                               1159         __u32 pad;
1160 };                                               1160 };
1161                                                  1161 
1162 /**                                              1162 /**
1163  * kfd_ioctl_dbg_trap_set_wave_launch_mode_ar    1163  * kfd_ioctl_dbg_trap_set_wave_launch_mode_args
1164  *                                               1164  *
1165  *     Arguments for KFD_IOC_DBG_TRAP_SET_WAV    1165  *     Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE
1166  *     Set wave launch mode.                     1166  *     Set wave launch mode.
1167  *                                               1167  *
1168  *     @mode (IN) - see kfd_dbg_trap_wave_lau    1168  *     @mode (IN) - see kfd_dbg_trap_wave_launch_mode
1169  *                                               1169  *
1170  *     Generic errors apply (see kfd_dbg_trap    1170  *     Generic errors apply (see kfd_dbg_trap_operations).
1171  *     Return - 0 on SUCCESS.                    1171  *     Return - 0 on SUCCESS.
1172  */                                              1172  */
1173 struct kfd_ioctl_dbg_trap_set_wave_launch_mod    1173 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args {
1174         __u32 launch_mode;                       1174         __u32 launch_mode;
1175         __u32 pad;                               1175         __u32 pad;
1176 };                                               1176 };
1177                                                  1177 
1178 /**                                              1178 /**
1179  * kfd_ioctl_dbg_trap_suspend_queues_ags         1179  * kfd_ioctl_dbg_trap_suspend_queues_ags
1180  *                                               1180  *
1181  *     Arguments for KFD_IOC_DBG_TRAP_SUSPEND    1181  *     Arguments for KFD_IOC_DBG_TRAP_SUSPEND_QUEUES
1182  *     Suspend queues.                           1182  *     Suspend queues.
1183  *                                               1183  *
1184  *     @exception_mask  (IN) - raised excepti    1184  *     @exception_mask  (IN) - raised exceptions to clear
1185  *     @queue_array_ptr (IN) - pointer to arr    1185  *     @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1186  *                             to suspend        1186  *                             to suspend
1187  *     @num_queues      (IN) - number of queu    1187  *     @num_queues      (IN) - number of queues to suspend in @queue_array_ptr
1188  *     @grace_period    (IN) - wave time allo    1188  *     @grace_period    (IN) - wave time allowance before preemption
1189  *                             per 1K GPU clo    1189  *                             per 1K GPU clock cycle unit
1190  *                                               1190  *
1191  *     Generic errors apply (see kfd_dbg_trap    1191  *     Generic errors apply (see kfd_dbg_trap_operations).
1192  *     Destruction of a suspended queue is bl    1192  *     Destruction of a suspended queue is blocked until the queue is
1193  *     resumed.  This allows the debugger to     1193  *     resumed.  This allows the debugger to access queue information and
1194  *     the its context save area without runn    1194  *     the its context save area without running into a race condition on
1195  *     queue destruction.                        1195  *     queue destruction.
1196  *     Automatically copies per queue context    1196  *     Automatically copies per queue context save area header information
1197  *     into the save area base                   1197  *     into the save area base
1198  *     (see kfd_queue_snapshot_entry and kfd_    1198  *     (see kfd_queue_snapshot_entry and kfd_context_save_area_header).
1199  *                                               1199  *
1200  *     Return - Number of queues suspended on    1200  *     Return - Number of queues suspended on SUCCESS.
1201  *      .       KFD_DBG_QUEUE_ERROR_MASK and     1201  *      .       KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK masked
1202  *              for each queue id in @queue_a    1202  *              for each queue id in @queue_array_ptr array reports unsuccessful
1203  *              suspend reason.                  1203  *              suspend reason.
1204  *              KFD_DBG_QUEUE_ERROR_MASK = HW    1204  *              KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1205  *              KFD_DBG_QUEUE_INVALID_MASK =     1205  *              KFD_DBG_QUEUE_INVALID_MASK = queue does not exist, is new or
1206  *              is being destroyed.              1206  *              is being destroyed.
1207  */                                              1207  */
1208 struct kfd_ioctl_dbg_trap_suspend_queues_args    1208 struct kfd_ioctl_dbg_trap_suspend_queues_args {
1209         __u64 exception_mask;                    1209         __u64 exception_mask;
1210         __u64 queue_array_ptr;                   1210         __u64 queue_array_ptr;
1211         __u32 num_queues;                        1211         __u32 num_queues;
1212         __u32 grace_period;                      1212         __u32 grace_period;
1213 };                                               1213 };
1214                                                  1214 
1215 /**                                              1215 /**
1216  * kfd_ioctl_dbg_trap_resume_queues_args         1216  * kfd_ioctl_dbg_trap_resume_queues_args
1217  *                                               1217  *
1218  *     Arguments for KFD_IOC_DBG_TRAP_RESUME_    1218  *     Arguments for KFD_IOC_DBG_TRAP_RESUME_QUEUES
1219  *     Resume queues.                            1219  *     Resume queues.
1220  *                                               1220  *
1221  *     @queue_array_ptr (IN) - pointer to arr    1221  *     @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1222  *                             to resume         1222  *                             to resume
1223  *     @num_queues      (IN) - number of queu    1223  *     @num_queues      (IN) - number of queues to resume in @queue_array_ptr
1224  *                                               1224  *
1225  *     Generic errors apply (see kfd_dbg_trap    1225  *     Generic errors apply (see kfd_dbg_trap_operations).
1226  *     Return - Number of queues resumed on S    1226  *     Return - Number of queues resumed on SUCCESS.
1227  *              KFD_DBG_QUEUE_ERROR_MASK and     1227  *              KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK mask
1228  *              for each queue id in @queue_a    1228  *              for each queue id in @queue_array_ptr array reports unsuccessful
1229  *              resume reason.                   1229  *              resume reason.
1230  *              KFD_DBG_QUEUE_ERROR_MASK = HW    1230  *              KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1231  *              KFD_DBG_QUEUE_INVALID_MASK =     1231  *              KFD_DBG_QUEUE_INVALID_MASK = queue does not exist.
1232  */                                              1232  */
1233 struct kfd_ioctl_dbg_trap_resume_queues_args     1233 struct kfd_ioctl_dbg_trap_resume_queues_args {
1234         __u64 queue_array_ptr;                   1234         __u64 queue_array_ptr;
1235         __u32 num_queues;                        1235         __u32 num_queues;
1236         __u32 pad;                               1236         __u32 pad;
1237 };                                               1237 };
1238                                                  1238 
1239 /**                                              1239 /**
1240  * kfd_ioctl_dbg_trap_set_node_address_watch_    1240  * kfd_ioctl_dbg_trap_set_node_address_watch_args
1241  *                                               1241  *
1242  *     Arguments for KFD_IOC_DBG_TRAP_SET_NOD    1242  *     Arguments for KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH
1243  *     Sets address watch for device.            1243  *     Sets address watch for device.
1244  *                                               1244  *
1245  *     @address (IN)  - watch address to set     1245  *     @address (IN)  - watch address to set
1246  *     @mode    (IN)  - see kfd_dbg_trap_addr    1246  *     @mode    (IN)  - see kfd_dbg_trap_address_watch_mode
1247  *     @mask    (IN)  - watch address mask       1247  *     @mask    (IN)  - watch address mask
1248  *     @gpu_id  (IN)  - target gpu to set wat    1248  *     @gpu_id  (IN)  - target gpu to set watch point
1249  *     @id      (OUT) - watch id allocated       1249  *     @id      (OUT) - watch id allocated
1250  *                                               1250  *
1251  *     Generic errors apply (see kfd_dbg_trap    1251  *     Generic errors apply (see kfd_dbg_trap_operations).
1252  *     Return - 0 on SUCCESS.                    1252  *     Return - 0 on SUCCESS.
1253  *              Allocated watch ID returned t    1253  *              Allocated watch ID returned to @id.
1254  *            - ENODEV if gpu_id not found.      1254  *            - ENODEV if gpu_id not found.
1255  *            - ENOMEM if watch IDs can be al    1255  *            - ENOMEM if watch IDs can be allocated
1256  */                                              1256  */
1257 struct kfd_ioctl_dbg_trap_set_node_address_wa    1257 struct kfd_ioctl_dbg_trap_set_node_address_watch_args {
1258         __u64 address;                           1258         __u64 address;
1259         __u32 mode;                              1259         __u32 mode;
1260         __u32 mask;                              1260         __u32 mask;
1261         __u32 gpu_id;                            1261         __u32 gpu_id;
1262         __u32 id;                                1262         __u32 id;
1263 };                                               1263 };
1264                                                  1264 
1265 /**                                              1265 /**
1266  * kfd_ioctl_dbg_trap_clear_node_address_watc    1266  * kfd_ioctl_dbg_trap_clear_node_address_watch_args
1267  *                                               1267  *
1268  *     Arguments for KFD_IOC_DBG_TRAP_CLEAR_N    1268  *     Arguments for KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH
1269  *     Clear address watch for device.           1269  *     Clear address watch for device.
1270  *                                               1270  *
1271  *     @gpu_id  (IN)  - target device to clea    1271  *     @gpu_id  (IN)  - target device to clear watch point
1272  *     @id      (IN) - allocated watch id to     1272  *     @id      (IN) - allocated watch id to clear
1273  *                                               1273  *
1274  *     Generic errors apply (see kfd_dbg_trap    1274  *     Generic errors apply (see kfd_dbg_trap_operations).
1275  *     Return - 0 on SUCCESS.                    1275  *     Return - 0 on SUCCESS.
1276  *            - ENODEV if gpu_id not found.      1276  *            - ENODEV if gpu_id not found.
1277  *            - EINVAL if watch ID has not be    1277  *            - EINVAL if watch ID has not been allocated.
1278  */                                              1278  */
1279 struct kfd_ioctl_dbg_trap_clear_node_address_    1279 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args {
1280         __u32 gpu_id;                            1280         __u32 gpu_id;
1281         __u32 id;                                1281         __u32 id;
1282 };                                               1282 };
1283                                                  1283 
1284 /**                                              1284 /**
1285  * kfd_ioctl_dbg_trap_set_flags_args             1285  * kfd_ioctl_dbg_trap_set_flags_args
1286  *                                               1286  *
1287  *     Arguments for KFD_IOC_DBG_TRAP_SET_FLA    1287  *     Arguments for KFD_IOC_DBG_TRAP_SET_FLAGS
1288  *     Sets flags for wave behaviour.            1288  *     Sets flags for wave behaviour.
1289  *                                               1289  *
1290  *     @flags (IN/OUT) - IN = flags to enable    1290  *     @flags (IN/OUT) - IN = flags to enable, OUT = flags previously enabled
1291  *                                               1291  *
1292  *     Generic errors apply (see kfd_dbg_trap    1292  *     Generic errors apply (see kfd_dbg_trap_operations).
1293  *     Return - 0 on SUCCESS.                    1293  *     Return - 0 on SUCCESS.
1294  *            - EACCESS if any debug device d    1294  *            - EACCESS if any debug device does not allow flag options.
1295  */                                              1295  */
1296 struct kfd_ioctl_dbg_trap_set_flags_args {       1296 struct kfd_ioctl_dbg_trap_set_flags_args {
1297         __u32 flags;                             1297         __u32 flags;
1298         __u32 pad;                               1298         __u32 pad;
1299 };                                               1299 };
1300                                                  1300 
1301 /**                                              1301 /**
1302  * kfd_ioctl_dbg_trap_query_debug_event_args     1302  * kfd_ioctl_dbg_trap_query_debug_event_args
1303  *                                               1303  *
1304  *     Arguments for KFD_IOC_DBG_TRAP_QUERY_D    1304  *     Arguments for KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT
1305  *                                               1305  *
1306  *     Find one or more raised exceptions. Th    1306  *     Find one or more raised exceptions. This function can return multiple
1307  *     exceptions from a single queue or a si    1307  *     exceptions from a single queue or a single device with one call. To find
1308  *     all raised exceptions, this function m    1308  *     all raised exceptions, this function must be called repeatedly until it
1309  *     returns -EAGAIN. Returned exceptions c    1309  *     returns -EAGAIN. Returned exceptions can optionally be cleared by
1310  *     setting the corresponding bit in the @    1310  *     setting the corresponding bit in the @exception_mask input parameter.
1311  *     However, clearing an exception prevent    1311  *     However, clearing an exception prevents retrieving further information
1312  *     about it with KFD_IOC_DBG_TRAP_QUERY_E    1312  *     about it with KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO.
1313  *                                               1313  *
1314  *     @exception_mask (IN/OUT) - exception t    1314  *     @exception_mask (IN/OUT) - exception to clear (IN) and raised (OUT)
1315  *     @gpu_id         (OUT)    - gpu id of e    1315  *     @gpu_id         (OUT)    - gpu id of exceptions raised
1316  *     @queue_id       (OUT)    - queue id of    1316  *     @queue_id       (OUT)    - queue id of exceptions raised
1317  *                                               1317  *
1318  *     Generic errors apply (see kfd_dbg_trap    1318  *     Generic errors apply (see kfd_dbg_trap_operations).
1319  *     Return - 0 on raised exception found      1319  *     Return - 0 on raised exception found
1320  *              Raised exceptions found are r    1320  *              Raised exceptions found are returned in @exception mask
1321  *              with reported source id retur    1321  *              with reported source id returned in @gpu_id or @queue_id.
1322  *            - EAGAIN if no raised exception    1322  *            - EAGAIN if no raised exception has been found
1323  */                                              1323  */
1324 struct kfd_ioctl_dbg_trap_query_debug_event_a    1324 struct kfd_ioctl_dbg_trap_query_debug_event_args {
1325         __u64 exception_mask;                    1325         __u64 exception_mask;
1326         __u32 gpu_id;                            1326         __u32 gpu_id;
1327         __u32 queue_id;                          1327         __u32 queue_id;
1328 };                                               1328 };
1329                                                  1329 
1330 /**                                              1330 /**
1331  * kfd_ioctl_dbg_trap_query_exception_info_ar    1331  * kfd_ioctl_dbg_trap_query_exception_info_args
1332  *                                               1332  *
1333  *     Arguments KFD_IOC_DBG_TRAP_QUERY_EXCEP    1333  *     Arguments KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO
1334  *     Get additional info on raised exceptio    1334  *     Get additional info on raised exception.
1335  *                                               1335  *
1336  *     @info_ptr        (IN)     - pointer to    1336  *     @info_ptr        (IN)     - pointer to exception info buffer to copy to
1337  *     @info_size       (IN/OUT) - exception     1337  *     @info_size       (IN/OUT) - exception info buffer size (bytes)
1338  *     @source_id       (IN)     - target gpu    1338  *     @source_id       (IN)     - target gpu or queue id
1339  *     @exception_code  (IN)     - target exc    1339  *     @exception_code  (IN)     - target exception
1340  *     @clear_exception (IN)     - clear rais    1340  *     @clear_exception (IN)     - clear raised @exception_code exception
1341  *                                 (0 = false    1341  *                                 (0 = false, 1 = true)
1342  *                                               1342  *
1343  *     Generic errors apply (see kfd_dbg_trap    1343  *     Generic errors apply (see kfd_dbg_trap_operations).
1344  *     Return - 0 on SUCCESS.                    1344  *     Return - 0 on SUCCESS.
1345  *              If @exception_code is EC_DEVI    1345  *              If @exception_code is EC_DEVICE_MEMORY_VIOLATION, copy @info_size(OUT)
1346  *              bytes of memory exception dat    1346  *              bytes of memory exception data to @info_ptr.
1347  *              If @exception_code is EC_PROC    1347  *              If @exception_code is EC_PROCESS_RUNTIME, copy saved
1348  *              kfd_runtime_info to @info_ptr    1348  *              kfd_runtime_info to @info_ptr.
1349  *              Actual required @info_ptr siz    1349  *              Actual required @info_ptr size (bytes) is returned in @info_size.
1350  */                                              1350  */
1351 struct kfd_ioctl_dbg_trap_query_exception_inf    1351 struct kfd_ioctl_dbg_trap_query_exception_info_args {
1352         __u64 info_ptr;                          1352         __u64 info_ptr;
1353         __u32 info_size;                         1353         __u32 info_size;
1354         __u32 source_id;                         1354         __u32 source_id;
1355         __u32 exception_code;                    1355         __u32 exception_code;
1356         __u32 clear_exception;                   1356         __u32 clear_exception;
1357 };                                               1357 };
1358                                                  1358 
1359 /**                                              1359 /**
1360  * kfd_ioctl_dbg_trap_get_queue_snapshot_args    1360  * kfd_ioctl_dbg_trap_get_queue_snapshot_args
1361  *                                               1361  *
1362  *     Arguments KFD_IOC_DBG_TRAP_GET_QUEUE_S    1362  *     Arguments KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT
1363  *     Get queue information.                    1363  *     Get queue information.
1364  *                                               1364  *
1365  *     @exception_mask   (IN)     - exception    1365  *     @exception_mask   (IN)     - exceptions raised to clear
1366  *     @snapshot_buf_ptr (IN)     - queue sna    1366  *     @snapshot_buf_ptr (IN)     - queue snapshot entry buffer (see kfd_queue_snapshot_entry)
1367  *     @num_queues       (IN/OUT) - number of    1367  *     @num_queues       (IN/OUT) - number of queue snapshot entries
1368  *         The debugger specifies the size of    1368  *         The debugger specifies the size of the array allocated in @num_queues.
1369  *         KFD returns the number of queues t    1369  *         KFD returns the number of queues that actually existed. If this is
1370  *         larger than the size specified by     1370  *         larger than the size specified by the debugger, KFD will not overflow
1371  *         the array allocated by the debugge    1371  *         the array allocated by the debugger.
1372  *                                               1372  *
1373  *     @entry_size       (IN/OUT) - size per     1373  *     @entry_size       (IN/OUT) - size per entry in bytes
1374  *         The debugger specifies sizeof(stru    1374  *         The debugger specifies sizeof(struct kfd_queue_snapshot_entry) in
1375  *         @entry_size. KFD returns the numbe    1375  *         @entry_size. KFD returns the number of bytes actually populated per
1376  *         entry. The debugger should use the    1376  *         entry. The debugger should use the KFD_IOCTL_MINOR_VERSION to determine,
1377  *         which fields in struct kfd_queue_s    1377  *         which fields in struct kfd_queue_snapshot_entry are valid. This allows
1378  *         growing the ABI in a backwards com    1378  *         growing the ABI in a backwards compatible manner.
1379  *         Note that entry_size(IN) should st    1379  *         Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1380  *         event that it's larger than actual    1380  *         event that it's larger than actual kfd_queue_snapshot_entry.
1381  *                                               1381  *
1382  *     Generic errors apply (see kfd_dbg_trap    1382  *     Generic errors apply (see kfd_dbg_trap_operations).
1383  *     Return - 0 on SUCCESS.                    1383  *     Return - 0 on SUCCESS.
1384  *              Copies @num_queues(IN) queue     1384  *              Copies @num_queues(IN) queue snapshot entries of size @entry_size(IN)
1385  *              into @snapshot_buf_ptr if @nu    1385  *              into @snapshot_buf_ptr if @num_queues(IN) > 0.
1386  *              Otherwise return @num_queues(    1386  *              Otherwise return @num_queues(OUT) queue snapshot entries that exist.
1387  */                                              1387  */
1388 struct kfd_ioctl_dbg_trap_queue_snapshot_args    1388 struct kfd_ioctl_dbg_trap_queue_snapshot_args {
1389         __u64 exception_mask;                    1389         __u64 exception_mask;
1390         __u64 snapshot_buf_ptr;                  1390         __u64 snapshot_buf_ptr;
1391         __u32 num_queues;                        1391         __u32 num_queues;
1392         __u32 entry_size;                        1392         __u32 entry_size;
1393 };                                               1393 };
1394                                                  1394 
1395 /**                                              1395 /**
1396  * kfd_ioctl_dbg_trap_get_device_snapshot_arg    1396  * kfd_ioctl_dbg_trap_get_device_snapshot_args
1397  *                                               1397  *
1398  *     Arguments for KFD_IOC_DBG_TRAP_GET_DEV    1398  *     Arguments for KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT
1399  *     Get device information.                   1399  *     Get device information.
1400  *                                               1400  *
1401  *     @exception_mask   (IN)     - exception    1401  *     @exception_mask   (IN)     - exceptions raised to clear
1402  *     @snapshot_buf_ptr (IN)     - pointer t    1402  *     @snapshot_buf_ptr (IN)     - pointer to snapshot buffer (see kfd_dbg_device_info_entry)
1403  *     @num_devices      (IN/OUT) - number of    1403  *     @num_devices      (IN/OUT) - number of debug devices to snapshot
1404  *         The debugger specifies the size of    1404  *         The debugger specifies the size of the array allocated in @num_devices.
1405  *         KFD returns the number of devices     1405  *         KFD returns the number of devices that actually existed. If this is
1406  *         larger than the size specified by     1406  *         larger than the size specified by the debugger, KFD will not overflow
1407  *         the array allocated by the debugge    1407  *         the array allocated by the debugger.
1408  *                                               1408  *
1409  *     @entry_size       (IN/OUT) - size per     1409  *     @entry_size       (IN/OUT) - size per entry in bytes
1410  *         The debugger specifies sizeof(stru    1410  *         The debugger specifies sizeof(struct kfd_dbg_device_info_entry) in
1411  *         @entry_size. KFD returns the numbe    1411  *         @entry_size. KFD returns the number of bytes actually populated. The
1412  *         debugger should use KFD_IOCTL_MINO    1412  *         debugger should use KFD_IOCTL_MINOR_VERSION to determine, which fields
1413  *         in struct kfd_dbg_device_info_entr    1413  *         in struct kfd_dbg_device_info_entry are valid. This allows growing the
1414  *         ABI in a backwards compatible mann    1414  *         ABI in a backwards compatible manner.
1415  *         Note that entry_size(IN) should st    1415  *         Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1416  *         event that it's larger than actual    1416  *         event that it's larger than actual kfd_dbg_device_info_entry.
1417  *                                               1417  *
1418  *     Generic errors apply (see kfd_dbg_trap    1418  *     Generic errors apply (see kfd_dbg_trap_operations).
1419  *     Return - 0 on SUCCESS.                    1419  *     Return - 0 on SUCCESS.
1420  *              Copies @num_devices(IN) devic    1420  *              Copies @num_devices(IN) device snapshot entries of size @entry_size(IN)
1421  *              into @snapshot_buf_ptr if @nu    1421  *              into @snapshot_buf_ptr if @num_devices(IN) > 0.
1422  *              Otherwise return @num_devices    1422  *              Otherwise return @num_devices(OUT) queue snapshot entries that exist.
1423  */                                              1423  */
1424 struct kfd_ioctl_dbg_trap_device_snapshot_arg    1424 struct kfd_ioctl_dbg_trap_device_snapshot_args {
1425         __u64 exception_mask;                    1425         __u64 exception_mask;
1426         __u64 snapshot_buf_ptr;                  1426         __u64 snapshot_buf_ptr;
1427         __u32 num_devices;                       1427         __u32 num_devices;
1428         __u32 entry_size;                        1428         __u32 entry_size;
1429 };                                               1429 };
1430                                                  1430 
1431 /**                                              1431 /**
1432  * kfd_ioctl_dbg_trap_args                       1432  * kfd_ioctl_dbg_trap_args
1433  *                                               1433  *
1434  * Arguments to debug target process.            1434  * Arguments to debug target process.
1435  *                                               1435  *
1436  *     @pid - target process to debug            1436  *     @pid - target process to debug
1437  *     @op  - debug operation (see kfd_dbg_tr    1437  *     @op  - debug operation (see kfd_dbg_trap_operations)
1438  *                                               1438  *
1439  *     @op determines which union struct args    1439  *     @op determines which union struct args to use.
1440  *     Refer to kern docs for each kfd_ioctl_    1440  *     Refer to kern docs for each kfd_ioctl_dbg_trap_*_args struct.
1441  */                                              1441  */
1442 struct kfd_ioctl_dbg_trap_args {                 1442 struct kfd_ioctl_dbg_trap_args {
1443         __u32 pid;                               1443         __u32 pid;
1444         __u32 op;                                1444         __u32 op;
1445                                                  1445 
1446         union {                                  1446         union {
1447                 struct kfd_ioctl_dbg_trap_ena    1447                 struct kfd_ioctl_dbg_trap_enable_args enable;
1448                 struct kfd_ioctl_dbg_trap_sen    1448                 struct kfd_ioctl_dbg_trap_send_runtime_event_args send_runtime_event;
1449                 struct kfd_ioctl_dbg_trap_set    1449                 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args set_exceptions_enabled;
1450                 struct kfd_ioctl_dbg_trap_set    1450                 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args launch_override;
1451                 struct kfd_ioctl_dbg_trap_set    1451                 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args launch_mode;
1452                 struct kfd_ioctl_dbg_trap_sus    1452                 struct kfd_ioctl_dbg_trap_suspend_queues_args suspend_queues;
1453                 struct kfd_ioctl_dbg_trap_res    1453                 struct kfd_ioctl_dbg_trap_resume_queues_args resume_queues;
1454                 struct kfd_ioctl_dbg_trap_set    1454                 struct kfd_ioctl_dbg_trap_set_node_address_watch_args set_node_address_watch;
1455                 struct kfd_ioctl_dbg_trap_cle    1455                 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args clear_node_address_watch;
1456                 struct kfd_ioctl_dbg_trap_set    1456                 struct kfd_ioctl_dbg_trap_set_flags_args set_flags;
1457                 struct kfd_ioctl_dbg_trap_que    1457                 struct kfd_ioctl_dbg_trap_query_debug_event_args query_debug_event;
1458                 struct kfd_ioctl_dbg_trap_que    1458                 struct kfd_ioctl_dbg_trap_query_exception_info_args query_exception_info;
1459                 struct kfd_ioctl_dbg_trap_que    1459                 struct kfd_ioctl_dbg_trap_queue_snapshot_args queue_snapshot;
1460                 struct kfd_ioctl_dbg_trap_dev    1460                 struct kfd_ioctl_dbg_trap_device_snapshot_args device_snapshot;
1461         };                                       1461         };
1462 };                                               1462 };
1463                                                  1463 
1464 #define AMDKFD_IOCTL_BASE 'K'                    1464 #define AMDKFD_IOCTL_BASE 'K'
1465 #define AMDKFD_IO(nr)                   _IO(A    1465 #define AMDKFD_IO(nr)                   _IO(AMDKFD_IOCTL_BASE, nr)
1466 #define AMDKFD_IOR(nr, type)            _IOR(    1466 #define AMDKFD_IOR(nr, type)            _IOR(AMDKFD_IOCTL_BASE, nr, type)
1467 #define AMDKFD_IOW(nr, type)            _IOW(    1467 #define AMDKFD_IOW(nr, type)            _IOW(AMDKFD_IOCTL_BASE, nr, type)
1468 #define AMDKFD_IOWR(nr, type)           _IOWR    1468 #define AMDKFD_IOWR(nr, type)           _IOWR(AMDKFD_IOCTL_BASE, nr, type)
1469                                                  1469 
1470 #define AMDKFD_IOC_GET_VERSION                   1470 #define AMDKFD_IOC_GET_VERSION                  \
1471                 AMDKFD_IOR(0x01, struct kfd_i    1471                 AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
1472                                                  1472 
1473 #define AMDKFD_IOC_CREATE_QUEUE                  1473 #define AMDKFD_IOC_CREATE_QUEUE                 \
1474                 AMDKFD_IOWR(0x02, struct kfd_    1474                 AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
1475                                                  1475 
1476 #define AMDKFD_IOC_DESTROY_QUEUE                 1476 #define AMDKFD_IOC_DESTROY_QUEUE                \
1477                 AMDKFD_IOWR(0x03, struct kfd_    1477                 AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
1478                                                  1478 
1479 #define AMDKFD_IOC_SET_MEMORY_POLICY             1479 #define AMDKFD_IOC_SET_MEMORY_POLICY            \
1480                 AMDKFD_IOW(0x04, struct kfd_i    1480                 AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
1481                                                  1481 
1482 #define AMDKFD_IOC_GET_CLOCK_COUNTERS            1482 #define AMDKFD_IOC_GET_CLOCK_COUNTERS           \
1483                 AMDKFD_IOWR(0x05, struct kfd_    1483                 AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
1484                                                  1484 
1485 #define AMDKFD_IOC_GET_PROCESS_APERTURES         1485 #define AMDKFD_IOC_GET_PROCESS_APERTURES        \
1486                 AMDKFD_IOR(0x06, struct kfd_i    1486                 AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
1487                                                  1487 
1488 #define AMDKFD_IOC_UPDATE_QUEUE                  1488 #define AMDKFD_IOC_UPDATE_QUEUE                 \
1489                 AMDKFD_IOW(0x07, struct kfd_i    1489                 AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
1490                                                  1490 
1491 #define AMDKFD_IOC_CREATE_EVENT                  1491 #define AMDKFD_IOC_CREATE_EVENT                 \
1492                 AMDKFD_IOWR(0x08, struct kfd_    1492                 AMDKFD_IOWR(0x08, struct kfd_ioctl_create_event_args)
1493                                                  1493 
1494 #define AMDKFD_IOC_DESTROY_EVENT                 1494 #define AMDKFD_IOC_DESTROY_EVENT                \
1495                 AMDKFD_IOW(0x09, struct kfd_i    1495                 AMDKFD_IOW(0x09, struct kfd_ioctl_destroy_event_args)
1496                                                  1496 
1497 #define AMDKFD_IOC_SET_EVENT                     1497 #define AMDKFD_IOC_SET_EVENT                    \
1498                 AMDKFD_IOW(0x0A, struct kfd_i    1498                 AMDKFD_IOW(0x0A, struct kfd_ioctl_set_event_args)
1499                                                  1499 
1500 #define AMDKFD_IOC_RESET_EVENT                   1500 #define AMDKFD_IOC_RESET_EVENT                  \
1501                 AMDKFD_IOW(0x0B, struct kfd_i    1501                 AMDKFD_IOW(0x0B, struct kfd_ioctl_reset_event_args)
1502                                                  1502 
1503 #define AMDKFD_IOC_WAIT_EVENTS                   1503 #define AMDKFD_IOC_WAIT_EVENTS                  \
1504                 AMDKFD_IOWR(0x0C, struct kfd_    1504                 AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
1505                                                  1505 
1506 #define AMDKFD_IOC_DBG_REGISTER_DEPRECATED       1506 #define AMDKFD_IOC_DBG_REGISTER_DEPRECATED      \
1507                 AMDKFD_IOW(0x0D, struct kfd_i    1507                 AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
1508                                                  1508 
1509 #define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED     1509 #define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED    \
1510                 AMDKFD_IOW(0x0E, struct kfd_i    1510                 AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
1511                                                  1511 
1512 #define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECAT    1512 #define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECATED \
1513                 AMDKFD_IOW(0x0F, struct kfd_i    1513                 AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
1514                                                  1514 
1515 #define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATE    1515 #define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATED  \
1516                 AMDKFD_IOW(0x10, struct kfd_i    1516                 AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
1517                                                  1517 
1518 #define AMDKFD_IOC_SET_SCRATCH_BACKING_VA        1518 #define AMDKFD_IOC_SET_SCRATCH_BACKING_VA       \
1519                 AMDKFD_IOWR(0x11, struct kfd_    1519                 AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
1520                                                  1520 
1521 #define AMDKFD_IOC_GET_TILE_CONFIG               1521 #define AMDKFD_IOC_GET_TILE_CONFIG                                      \
1522                 AMDKFD_IOWR(0x12, struct kfd_    1522                 AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
1523                                                  1523 
1524 #define AMDKFD_IOC_SET_TRAP_HANDLER              1524 #define AMDKFD_IOC_SET_TRAP_HANDLER             \
1525                 AMDKFD_IOW(0x13, struct kfd_i    1525                 AMDKFD_IOW(0x13, struct kfd_ioctl_set_trap_handler_args)
1526                                                  1526 
1527 #define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW     1527 #define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW    \
1528                 AMDKFD_IOWR(0x14,                1528                 AMDKFD_IOWR(0x14,               \
1529                         struct kfd_ioctl_get_    1529                         struct kfd_ioctl_get_process_apertures_new_args)
1530                                                  1530 
1531 #define AMDKFD_IOC_ACQUIRE_VM                    1531 #define AMDKFD_IOC_ACQUIRE_VM                   \
1532                 AMDKFD_IOW(0x15, struct kfd_i    1532                 AMDKFD_IOW(0x15, struct kfd_ioctl_acquire_vm_args)
1533                                                  1533 
1534 #define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU           1534 #define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU          \
1535                 AMDKFD_IOWR(0x16, struct kfd_    1535                 AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args)
1536                                                  1536 
1537 #define AMDKFD_IOC_FREE_MEMORY_OF_GPU            1537 #define AMDKFD_IOC_FREE_MEMORY_OF_GPU           \
1538                 AMDKFD_IOW(0x17, struct kfd_i    1538                 AMDKFD_IOW(0x17, struct kfd_ioctl_free_memory_of_gpu_args)
1539                                                  1539 
1540 #define AMDKFD_IOC_MAP_MEMORY_TO_GPU             1540 #define AMDKFD_IOC_MAP_MEMORY_TO_GPU            \
1541                 AMDKFD_IOWR(0x18, struct kfd_    1541                 AMDKFD_IOWR(0x18, struct kfd_ioctl_map_memory_to_gpu_args)
1542                                                  1542 
1543 #define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU         1543 #define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU        \
1544                 AMDKFD_IOWR(0x19, struct kfd_    1544                 AMDKFD_IOWR(0x19, struct kfd_ioctl_unmap_memory_from_gpu_args)
1545                                                  1545 
1546 #define AMDKFD_IOC_SET_CU_MASK          \        1546 #define AMDKFD_IOC_SET_CU_MASK          \
1547                 AMDKFD_IOW(0x1A, struct kfd_i    1547                 AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
1548                                                  1548 
1549 #define AMDKFD_IOC_GET_QUEUE_WAVE_STATE          1549 #define AMDKFD_IOC_GET_QUEUE_WAVE_STATE         \
1550                 AMDKFD_IOWR(0x1B, struct kfd_    1550                 AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args)
1551                                                  1551 
1552 #define AMDKFD_IOC_GET_DMABUF_INFO               1552 #define AMDKFD_IOC_GET_DMABUF_INFO              \
1553                 AMDKFD_IOWR(0x1C, struct kfd_    1553                 AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args)
1554                                                  1554 
1555 #define AMDKFD_IOC_IMPORT_DMABUF                 1555 #define AMDKFD_IOC_IMPORT_DMABUF                \
1556                 AMDKFD_IOWR(0x1D, struct kfd_    1556                 AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
1557                                                  1557 
1558 #define AMDKFD_IOC_ALLOC_QUEUE_GWS               1558 #define AMDKFD_IOC_ALLOC_QUEUE_GWS              \
1559                 AMDKFD_IOWR(0x1E, struct kfd_    1559                 AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
1560                                                  1560 
1561 #define AMDKFD_IOC_SMI_EVENTS                    1561 #define AMDKFD_IOC_SMI_EVENTS                   \
1562                 AMDKFD_IOWR(0x1F, struct kfd_    1562                 AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
1563                                                  1563 
1564 #define AMDKFD_IOC_SVM  AMDKFD_IOWR(0x20, str    1564 #define AMDKFD_IOC_SVM  AMDKFD_IOWR(0x20, struct kfd_ioctl_svm_args)
1565                                                  1565 
1566 #define AMDKFD_IOC_SET_XNACK_MODE                1566 #define AMDKFD_IOC_SET_XNACK_MODE               \
1567                 AMDKFD_IOWR(0x21, struct kfd_    1567                 AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)
1568                                                  1568 
1569 #define AMDKFD_IOC_CRIU_OP                       1569 #define AMDKFD_IOC_CRIU_OP                      \
1570                 AMDKFD_IOWR(0x22, struct kfd_    1570                 AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_args)
1571                                                  1571 
1572 #define AMDKFD_IOC_AVAILABLE_MEMORY              1572 #define AMDKFD_IOC_AVAILABLE_MEMORY             \
1573                 AMDKFD_IOWR(0x23, struct kfd_    1573                 AMDKFD_IOWR(0x23, struct kfd_ioctl_get_available_memory_args)
1574                                                  1574 
1575 #define AMDKFD_IOC_EXPORT_DMABUF                 1575 #define AMDKFD_IOC_EXPORT_DMABUF                \
1576                 AMDKFD_IOWR(0x24, struct kfd_    1576                 AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args)
1577                                                  1577 
1578 #define AMDKFD_IOC_RUNTIME_ENABLE                1578 #define AMDKFD_IOC_RUNTIME_ENABLE               \
1579                 AMDKFD_IOWR(0x25, struct kfd_    1579                 AMDKFD_IOWR(0x25, struct kfd_ioctl_runtime_enable_args)
1580                                                  1580 
1581 #define AMDKFD_IOC_DBG_TRAP                      1581 #define AMDKFD_IOC_DBG_TRAP                     \
1582                 AMDKFD_IOWR(0x26, struct kfd_    1582                 AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args)
1583                                                  1583 
1584 #define AMDKFD_COMMAND_START            0x01     1584 #define AMDKFD_COMMAND_START            0x01
1585 #define AMDKFD_COMMAND_END              0x27     1585 #define AMDKFD_COMMAND_END              0x27
1586                                                  1586 
1587 #endif                                           1587 #endif
1588                                                  1588 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php