Lines Matching full:args

177 	struct kfd_ioctl_get_version_args *args = data;  in kfd_ioctl_get_version()  local
179 args->major_version = KFD_IOCTL_MAJOR_VERSION; in kfd_ioctl_get_version()
180 args->minor_version = KFD_IOCTL_MINOR_VERSION; in kfd_ioctl_get_version()
186 struct kfd_ioctl_create_queue_args *args) in set_queue_properties_from_user() argument
193 if ((args->queue_percentage & 0xFF) > KFD_MAX_QUEUE_PERCENTAGE) { in set_queue_properties_from_user()
198 if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) { in set_queue_properties_from_user()
203 if ((args->ring_base_address) && in set_queue_properties_from_user()
204 (!access_ok((const void __user *) args->ring_base_address, in set_queue_properties_from_user()
210 if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) { in set_queue_properties_from_user()
215 if (!access_ok((const void __user *) args->read_pointer_address, in set_queue_properties_from_user()
221 if (!access_ok((const void __user *) args->write_pointer_address, in set_queue_properties_from_user()
227 if (args->eop_buffer_address && in set_queue_properties_from_user()
228 !access_ok((const void __user *) args->eop_buffer_address, in set_queue_properties_from_user()
234 if (args->ctx_save_restore_address && in set_queue_properties_from_user()
235 !access_ok((const void __user *) args->ctx_save_restore_address, in set_queue_properties_from_user()
243 q_properties->queue_percent = args->queue_percentage & 0xFF; in set_queue_properties_from_user()
245 q_properties->pm4_target_xcc = (args->queue_percentage >> 8) & 0xFF; in set_queue_properties_from_user()
246 q_properties->priority = args->queue_priority; in set_queue_properties_from_user()
247 q_properties->queue_address = args->ring_base_address; in set_queue_properties_from_user()
248 q_properties->queue_size = args->ring_size; in set_queue_properties_from_user()
249 q_properties->read_ptr = (void __user *)args->read_pointer_address; in set_queue_properties_from_user()
250 q_properties->write_ptr = (void __user *)args->write_pointer_address; in set_queue_properties_from_user()
251 q_properties->eop_ring_buffer_address = args->eop_buffer_address; in set_queue_properties_from_user()
252 q_properties->eop_ring_buffer_size = args->eop_buffer_size; in set_queue_properties_from_user()
254 args->ctx_save_restore_address; in set_queue_properties_from_user()
255 q_properties->ctx_save_restore_area_size = args->ctx_save_restore_size; in set_queue_properties_from_user()
256 q_properties->ctl_stack_size = args->ctl_stack_size; in set_queue_properties_from_user()
257 q_properties->sdma_engine_id = args->sdma_engine_id; in set_queue_properties_from_user()
258 if (args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE || in set_queue_properties_from_user()
259 args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE_AQL) in set_queue_properties_from_user()
261 else if (args->queue_type == KFD_IOC_QUEUE_TYPE_SDMA) in set_queue_properties_from_user()
263 else if (args->queue_type == KFD_IOC_QUEUE_TYPE_SDMA_XGMI) in set_queue_properties_from_user()
265 else if (args->queue_type == KFD_IOC_QUEUE_TYPE_SDMA_BY_ENG_ID) in set_queue_properties_from_user()
270 if (args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE_AQL) in set_queue_properties_from_user()
276 q_properties->queue_percent, args->queue_percentage); in set_queue_properties_from_user()
279 q_properties->priority, args->queue_priority); in set_queue_properties_from_user()
282 q_properties->queue_address, args->ring_base_address); in set_queue_properties_from_user()
285 q_properties->queue_size, args->ring_size); in set_queue_properties_from_user()
304 struct kfd_ioctl_create_queue_args *args = data; in kfd_ioctl_create_queue() local
316 err = set_queue_properties_from_user(&q_properties, args); in kfd_ioctl_create_queue()
320 pr_debug("Looking for gpu id 0x%x\n", args->gpu_id); in kfd_ioctl_create_queue()
324 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_create_queue()
326 pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); in kfd_ioctl_create_queue()
373 args->queue_id = queue_id; in kfd_ioctl_create_queue()
377 args->doorbell_offset = KFD_MMAP_TYPE_DOORBELL; in kfd_ioctl_create_queue()
378 args->doorbell_offset |= KFD_MMAP_GPU_ID(args->gpu_id); in kfd_ioctl_create_queue()
383 args->doorbell_offset |= doorbell_offset_in_process; in kfd_ioctl_create_queue()
387 pr_debug("Queue id %d was created successfully\n", args->queue_id); in kfd_ioctl_create_queue()
390 args->ring_base_address); in kfd_ioctl_create_queue()
393 args->read_pointer_address); in kfd_ioctl_create_queue()
396 args->write_pointer_address); in kfd_ioctl_create_queue()
416 struct kfd_ioctl_destroy_queue_args *args = data; in kfd_ioctl_destroy_queue() local
419 args->queue_id, in kfd_ioctl_destroy_queue()
424 retval = pqm_destroy_queue(&p->pqm, args->queue_id); in kfd_ioctl_destroy_queue()
434 struct kfd_ioctl_update_queue_args *args = data; in kfd_ioctl_update_queue() local
442 if ((args->queue_percentage & 0xFF) > KFD_MAX_QUEUE_PERCENTAGE) { in kfd_ioctl_update_queue()
447 if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) { in kfd_ioctl_update_queue()
452 if ((args->ring_base_address) && in kfd_ioctl_update_queue()
453 (!access_ok((const void __user *) args->ring_base_address, in kfd_ioctl_update_queue()
459 if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) { in kfd_ioctl_update_queue()
464 properties.queue_address = args->ring_base_address; in kfd_ioctl_update_queue()
465 properties.queue_size = args->ring_size; in kfd_ioctl_update_queue()
466 properties.queue_percent = args->queue_percentage & 0xFF; in kfd_ioctl_update_queue()
468 properties.pm4_target_xcc = (args->queue_percentage >> 8) & 0xFF; in kfd_ioctl_update_queue()
469 properties.priority = args->queue_priority; in kfd_ioctl_update_queue()
472 args->queue_id, p->pasid); in kfd_ioctl_update_queue()
476 retval = pqm_update_queue_properties(&p->pqm, args->queue_id, &properties); in kfd_ioctl_update_queue()
488 struct kfd_ioctl_set_cu_mask_args *args = data; in kfd_ioctl_set_cu_mask() local
490 uint32_t __user *cu_mask_ptr = (uint32_t __user *)args->cu_mask_ptr; in kfd_ioctl_set_cu_mask()
491 size_t cu_mask_size = sizeof(uint32_t) * (args->num_cu_mask / 32); in kfd_ioctl_set_cu_mask()
493 if ((args->num_cu_mask % 32) != 0) { in kfd_ioctl_set_cu_mask()
495 args->num_cu_mask); in kfd_ioctl_set_cu_mask()
499 minfo.cu_mask.count = args->num_cu_mask; in kfd_ioctl_set_cu_mask()
528 retval = pqm_update_mqd(&p->pqm, args->queue_id, &minfo); in kfd_ioctl_set_cu_mask()
540 struct kfd_ioctl_get_queue_wave_state_args *args = data; in kfd_ioctl_get_queue_wave_state() local
545 r = pqm_get_wave_state(&p->pqm, args->queue_id, in kfd_ioctl_get_queue_wave_state()
546 (void __user *)args->ctl_stack_address, in kfd_ioctl_get_queue_wave_state()
547 &args->ctl_stack_used_size, in kfd_ioctl_get_queue_wave_state()
548 &args->save_area_used_size); in kfd_ioctl_get_queue_wave_state()
558 struct kfd_ioctl_set_memory_policy_args *args = data; in kfd_ioctl_set_memory_policy() local
563 if (args->default_policy != KFD_IOC_CACHE_POLICY_COHERENT in kfd_ioctl_set_memory_policy()
564 && args->default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { in kfd_ioctl_set_memory_policy()
568 if (args->alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT in kfd_ioctl_set_memory_policy()
569 && args->alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { in kfd_ioctl_set_memory_policy()
574 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_set_memory_policy()
576 pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); in kfd_ioctl_set_memory_policy()
587 default_policy = (args->default_policy == KFD_IOC_CACHE_POLICY_COHERENT) in kfd_ioctl_set_memory_policy()
591 (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) in kfd_ioctl_set_memory_policy()
598 (void __user *)args->alternate_aperture_base, in kfd_ioctl_set_memory_policy()
599 args->alternate_aperture_size)) in kfd_ioctl_set_memory_policy()
612 struct kfd_ioctl_set_trap_handler_args *args = data; in kfd_ioctl_set_trap_handler() local
618 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_set_trap_handler()
630 kfd_process_set_trap_handler(&pdd->qpd, args->tba_addr, args->tma_addr); in kfd_ioctl_set_trap_handler()
667 struct kfd_ioctl_get_clock_counters_args *args = data; in kfd_ioctl_get_clock_counters() local
671 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_get_clock_counters()
675 args->gpu_clock_counter = amdgpu_amdkfd_get_gpu_clock_counter(pdd->dev->adev); in kfd_ioctl_get_clock_counters()
678 args->gpu_clock_counter = 0; in kfd_ioctl_get_clock_counters()
681 args->cpu_clock_counter = ktime_get_raw_ns(); in kfd_ioctl_get_clock_counters()
682 args->system_clock_counter = ktime_get_boottime_ns(); in kfd_ioctl_get_clock_counters()
685 args->system_clock_freq = 1000000000; in kfd_ioctl_get_clock_counters()
694 struct kfd_ioctl_get_process_apertures_args *args = data; in kfd_ioctl_get_process_apertures() local
700 args->num_of_nodes = 0; in kfd_ioctl_get_process_apertures()
708 &args->process_apertures[args->num_of_nodes]; in kfd_ioctl_get_process_apertures()
718 "node id %u\n", args->num_of_nodes); in kfd_ioctl_get_process_apertures()
734 if (++args->num_of_nodes >= NUM_OF_SUPPORTED_GPUS) in kfd_ioctl_get_process_apertures()
745 struct kfd_ioctl_get_process_apertures_new_args *args = data; in kfd_ioctl_get_process_apertures_new() local
752 if (args->num_of_nodes == 0) { in kfd_ioctl_get_process_apertures_new()
757 args->num_of_nodes = p->n_pdds; in kfd_ioctl_get_process_apertures_new()
762 * nodes, but not more than args->num_of_nodes as that is in kfd_ioctl_get_process_apertures_new()
765 pa = kcalloc(args->num_of_nodes, sizeof(struct kfd_process_device_apertures), in kfd_ioctl_get_process_apertures_new()
773 args->num_of_nodes = 0; in kfd_ioctl_get_process_apertures_new()
779 for (i = 0; i < min(p->n_pdds, args->num_of_nodes); i++) { in kfd_ioctl_get_process_apertures_new()
807 args->num_of_nodes = i; in kfd_ioctl_get_process_apertures_new()
809 (void __user *)args->kfd_process_device_apertures_ptr, in kfd_ioctl_get_process_apertures_new()
823 struct kfd_ioctl_create_event_args *args = data; in kfd_ioctl_create_event() local
830 if (args->event_page_offset) { in kfd_ioctl_create_event()
832 err = kfd_kmap_event_page(p, args->event_page_offset); in kfd_ioctl_create_event()
838 err = kfd_event_create(filp, p, args->event_type, in kfd_ioctl_create_event()
839 args->auto_reset != 0, args->node_id, in kfd_ioctl_create_event()
840 &args->event_id, &args->event_trigger_data, in kfd_ioctl_create_event()
841 &args->event_page_offset, in kfd_ioctl_create_event()
842 &args->event_slot_index); in kfd_ioctl_create_event()
844 pr_debug("Created event (id:0x%08x) (%s)\n", args->event_id, __func__); in kfd_ioctl_create_event()
851 struct kfd_ioctl_destroy_event_args *args = data; in kfd_ioctl_destroy_event() local
853 return kfd_event_destroy(p, args->event_id); in kfd_ioctl_destroy_event()
859 struct kfd_ioctl_set_event_args *args = data; in kfd_ioctl_set_event() local
861 return kfd_set_event(p, args->event_id); in kfd_ioctl_set_event()
867 struct kfd_ioctl_reset_event_args *args = data; in kfd_ioctl_reset_event() local
869 return kfd_reset_event(p, args->event_id); in kfd_ioctl_reset_event()
875 struct kfd_ioctl_wait_events_args *args = data; in kfd_ioctl_wait_events() local
877 return kfd_wait_on_events(p, args->num_events, in kfd_ioctl_wait_events()
878 (void __user *)args->events_ptr, in kfd_ioctl_wait_events()
879 (args->wait_for_all != 0), in kfd_ioctl_wait_events()
880 &args->timeout, &args->wait_result); in kfd_ioctl_wait_events()
885 struct kfd_ioctl_set_scratch_backing_va_args *args = data; in kfd_ioctl_set_scratch_backing_va() local
891 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_set_scratch_backing_va()
904 pdd->qpd.sh_hidden_private_base = args->va_addr; in kfd_ioctl_set_scratch_backing_va()
911 dev->adev, args->va_addr, pdd->qpd.vmid); in kfd_ioctl_set_scratch_backing_va()
924 struct kfd_ioctl_get_tile_config_args *args = data; in kfd_ioctl_get_tile_config() local
930 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_get_tile_config()
937 args->gb_addr_config = config.gb_addr_config; in kfd_ioctl_get_tile_config()
938 args->num_banks = config.num_banks; in kfd_ioctl_get_tile_config()
939 args->num_ranks = config.num_ranks; in kfd_ioctl_get_tile_config()
941 if (args->num_tile_configs > config.num_tile_configs) in kfd_ioctl_get_tile_config()
942 args->num_tile_configs = config.num_tile_configs; in kfd_ioctl_get_tile_config()
943 err = copy_to_user((void __user *)args->tile_config_ptr, in kfd_ioctl_get_tile_config()
945 args->num_tile_configs * sizeof(uint32_t)); in kfd_ioctl_get_tile_config()
947 args->num_tile_configs = 0; in kfd_ioctl_get_tile_config()
951 if (args->num_macro_tile_configs > config.num_macro_tile_configs) in kfd_ioctl_get_tile_config()
952 args->num_macro_tile_configs = in kfd_ioctl_get_tile_config()
954 err = copy_to_user((void __user *)args->macro_tile_config_ptr, in kfd_ioctl_get_tile_config()
956 args->num_macro_tile_configs * sizeof(uint32_t)); in kfd_ioctl_get_tile_config()
958 args->num_macro_tile_configs = 0; in kfd_ioctl_get_tile_config()
968 struct kfd_ioctl_acquire_vm_args *args = data; in kfd_ioctl_acquire_vm() local
973 drm_file = fget(args->drm_fd); in kfd_ioctl_acquire_vm()
978 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_acquire_vm()
1029 struct kfd_ioctl_get_available_memory_args *args = data; in kfd_ioctl_get_available_memory() local
1030 struct kfd_process_device *pdd = kfd_lock_pdd_by_id(p, args->gpu_id); in kfd_ioctl_get_available_memory()
1034 args->available = amdgpu_amdkfd_get_available_memory(pdd->dev->adev, in kfd_ioctl_get_available_memory()
1043 struct kfd_ioctl_alloc_memory_of_gpu_args *args = data; in kfd_ioctl_alloc_memory_of_gpu() local
1049 uint64_t offset = args->mmap_offset; in kfd_ioctl_alloc_memory_of_gpu()
1050 uint32_t flags = args->flags; in kfd_ioctl_alloc_memory_of_gpu()
1052 if (args->size == 0) in kfd_ioctl_alloc_memory_of_gpu()
1063 args->va_addr >> PAGE_SHIFT, in kfd_ioctl_alloc_memory_of_gpu()
1064 (args->va_addr + args->size - 1) >> PAGE_SHIFT)) { in kfd_ioctl_alloc_memory_of_gpu()
1066 args->va_addr); in kfd_ioctl_alloc_memory_of_gpu()
1076 args->mmap_offset >> PAGE_SHIFT, in kfd_ioctl_alloc_memory_of_gpu()
1077 (args->mmap_offset + args->size - 1) >> PAGE_SHIFT)) { in kfd_ioctl_alloc_memory_of_gpu()
1079 args->mmap_offset); in kfd_ioctl_alloc_memory_of_gpu()
1087 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_alloc_memory_of_gpu()
1110 if (args->size != kfd_doorbell_process_slice(dev->kfd)) { in kfd_ioctl_alloc_memory_of_gpu()
1120 if (args->size != PAGE_SIZE) { in kfd_ioctl_alloc_memory_of_gpu()
1132 dev->adev, args->va_addr, args->size, in kfd_ioctl_alloc_memory_of_gpu()
1147 uint64_t size = args->size; in kfd_ioctl_alloc_memory_of_gpu()
1156 args->handle = MAKE_HANDLE(args->gpu_id, idr_handle); in kfd_ioctl_alloc_memory_of_gpu()
1157 args->mmap_offset = offset; in kfd_ioctl_alloc_memory_of_gpu()
1163 args->mmap_offset = KFD_MMAP_TYPE_MMIO in kfd_ioctl_alloc_memory_of_gpu()
1164 | KFD_MMAP_GPU_ID(args->gpu_id); in kfd_ioctl_alloc_memory_of_gpu()
1181 struct kfd_ioctl_free_memory_of_gpu_args *args = data; in kfd_ioctl_free_memory_of_gpu() local
1192 if (p->signal_handle && (p->signal_handle == args->handle)) { in kfd_ioctl_free_memory_of_gpu()
1198 pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); in kfd_ioctl_free_memory_of_gpu()
1206 pdd, GET_IDR_HANDLE(args->handle)); in kfd_ioctl_free_memory_of_gpu()
1220 pdd, GET_IDR_HANDLE(args->handle)); in kfd_ioctl_free_memory_of_gpu()
1233 struct kfd_ioctl_map_memory_to_gpu_args *args = data; in kfd_ioctl_map_memory_to_gpu() local
1241 if (!args->n_devices) { in kfd_ioctl_map_memory_to_gpu()
1245 if (args->n_success > args->n_devices) { in kfd_ioctl_map_memory_to_gpu()
1250 devices_arr = kmalloc_array(args->n_devices, sizeof(*devices_arr), in kfd_ioctl_map_memory_to_gpu()
1256 (void __user *)args->device_ids_array_ptr, in kfd_ioctl_map_memory_to_gpu()
1257 args->n_devices * sizeof(*devices_arr)); in kfd_ioctl_map_memory_to_gpu()
1264 pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); in kfd_ioctl_map_memory_to_gpu()
1278 GET_IDR_HANDLE(args->handle)); in kfd_ioctl_map_memory_to_gpu()
1284 for (i = args->n_success; i < args->n_devices; i++) { in kfd_ioctl_map_memory_to_gpu()
1314 args->n_success = i+1; in kfd_ioctl_map_memory_to_gpu()
1326 for (i = 0; i < args->n_devices; i++) { in kfd_ioctl_map_memory_to_gpu()
1351 struct kfd_ioctl_unmap_memory_from_gpu_args *args = data; in kfd_ioctl_unmap_memory_from_gpu() local
1358 if (!args->n_devices) { in kfd_ioctl_unmap_memory_from_gpu()
1362 if (args->n_success > args->n_devices) { in kfd_ioctl_unmap_memory_from_gpu()
1367 devices_arr = kmalloc_array(args->n_devices, sizeof(*devices_arr), in kfd_ioctl_unmap_memory_from_gpu()
1373 (void __user *)args->device_ids_array_ptr, in kfd_ioctl_unmap_memory_from_gpu()
1374 args->n_devices * sizeof(*devices_arr)); in kfd_ioctl_unmap_memory_from_gpu()
1381 pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); in kfd_ioctl_unmap_memory_from_gpu()
1388 GET_IDR_HANDLE(args->handle)); in kfd_ioctl_unmap_memory_from_gpu()
1394 for (i = args->n_success; i < args->n_devices; i++) { in kfd_ioctl_unmap_memory_from_gpu()
1403 pr_debug("Failed to unmap from gpu %d/%d\n", i, args->n_devices); in kfd_ioctl_unmap_memory_from_gpu()
1406 args->n_success = i+1; in kfd_ioctl_unmap_memory_from_gpu()
1420 for (i = 0; i < args->n_devices; i++) { in kfd_ioctl_unmap_memory_from_gpu()
1453 struct kfd_ioctl_alloc_queue_gws_args *args = data; in kfd_ioctl_alloc_queue_gws() local
1458 q = pqm_get_user_queue(&p->pqm, args->queue_id); in kfd_ioctl_alloc_queue_gws()
1483 retval = pqm_set_gws(&p->pqm, args->queue_id, args->num_gws ? dev->gws : NULL); in kfd_ioctl_alloc_queue_gws()
1486 args->first_gws = 0; in kfd_ioctl_alloc_queue_gws()
1497 struct kfd_ioctl_get_dmabuf_info_args *args = data; in kfd_ioctl_get_dmabuf_info() local
1513 if (args->metadata_ptr) { in kfd_ioctl_get_dmabuf_info()
1514 metadata_buffer = kzalloc(args->metadata_size, GFP_KERNEL); in kfd_ioctl_get_dmabuf_info()
1520 r = amdgpu_amdkfd_get_dmabuf_info(dev->adev, args->dmabuf_fd, in kfd_ioctl_get_dmabuf_info()
1521 &dmabuf_adev, &args->size, in kfd_ioctl_get_dmabuf_info()
1522 metadata_buffer, args->metadata_size, in kfd_ioctl_get_dmabuf_info()
1523 &args->metadata_size, &flags, &xcp_id); in kfd_ioctl_get_dmabuf_info()
1528 args->gpu_id = dmabuf_adev->kfd.dev->nodes[xcp_id]->id; in kfd_ioctl_get_dmabuf_info()
1530 args->gpu_id = dev->id; in kfd_ioctl_get_dmabuf_info()
1531 args->flags = flags; in kfd_ioctl_get_dmabuf_info()
1535 r = copy_to_user((void __user *)args->metadata_ptr, in kfd_ioctl_get_dmabuf_info()
1536 metadata_buffer, args->metadata_size); in kfd_ioctl_get_dmabuf_info()
1550 struct kfd_ioctl_import_dmabuf_args *args = data; in kfd_ioctl_import_dmabuf() local
1558 pdd = kfd_process_device_data_by_id(p, args->gpu_id); in kfd_ioctl_import_dmabuf()
1570 r = amdgpu_amdkfd_gpuvm_import_dmabuf_fd(pdd->dev->adev, args->dmabuf_fd, in kfd_ioctl_import_dmabuf()
1571 args->va_addr, pdd->drm_priv, in kfd_ioctl_import_dmabuf()
1585 args->handle = MAKE_HANDLE(args->gpu_id, idr_handle); in kfd_ioctl_import_dmabuf()
1600 struct kfd_ioctl_export_dmabuf_args *args = data; in kfd_ioctl_export_dmabuf() local
1607 dev = kfd_device_by_id(GET_GPU_ID(args->handle)); in kfd_ioctl_export_dmabuf()
1620 GET_IDR_HANDLE(args->handle)); in kfd_ioctl_export_dmabuf()
1631 ret = dma_buf_fd(dmabuf, args->flags); in kfd_ioctl_export_dmabuf()
1639 args->dmabuf_fd = ret; in kfd_ioctl_export_dmabuf()
1653 struct kfd_ioctl_smi_events_args *args = data; in kfd_ioctl_smi_events() local
1658 pdd = kfd_process_device_data_by_id(p, args->gpuid); in kfd_ioctl_smi_events()
1663 return kfd_smi_event_open(pdd->dev, &args->anon_fd); in kfd_ioctl_smi_events()
1671 struct kfd_ioctl_set_xnack_mode_args *args = data; in kfd_ioctl_set_xnack_mode() local
1675 if (args->xnack_enabled >= 0) { in kfd_ioctl_set_xnack_mode()
1682 if (p->xnack_enabled == args->xnack_enabled) in kfd_ioctl_set_xnack_mode()
1685 if (args->xnack_enabled && !kfd_process_xnack_mode(p, true)) { in kfd_ioctl_set_xnack_mode()
1690 r = svm_range_switch_xnack_reserve_mem(p, args->xnack_enabled); in kfd_ioctl_set_xnack_mode()
1692 args->xnack_enabled = p->xnack_enabled; in kfd_ioctl_set_xnack_mode()
1703 struct kfd_ioctl_svm_args *args = data; in kfd_ioctl_svm() local
1707 args->start_addr, args->size, args->op, args->nattr); in kfd_ioctl_svm()
1709 if ((args->start_addr & ~PAGE_MASK) || (args->size & ~PAGE_MASK)) in kfd_ioctl_svm()
1711 if (!args->start_addr || !args->size) in kfd_ioctl_svm()
1714 r = svm_ioctl(p, args->op, args->start_addr, args->size, args->nattr, in kfd_ioctl_svm()
1715 args->attrs); in kfd_ioctl_svm()
2050 struct kfd_ioctl_criu_args *args) in criu_checkpoint() argument
2056 if (!args->devices || !args->bos || !args->priv_data) in criu_checkpoint()
2079 if (num_devices != args->num_devices || in criu_checkpoint()
2080 num_bos != args->num_bos || in criu_checkpoint()
2081 num_objects != args->num_objects || in criu_checkpoint()
2082 priv_size != args->priv_data_size) { in criu_checkpoint()
2089 ret = criu_checkpoint_process(p, (uint8_t __user *)args->priv_data, &priv_offset); in criu_checkpoint()
2093 ret = criu_checkpoint_devices(p, num_devices, (uint8_t __user *)args->devices, in criu_checkpoint()
2094 (uint8_t __user *)args->priv_data, &priv_offset); in criu_checkpoint()
2106 ret = kfd_criu_checkpoint_queues(p, (uint8_t __user *)args->priv_data, in criu_checkpoint()
2111 ret = kfd_criu_checkpoint_events(p, (uint8_t __user *)args->priv_data, in criu_checkpoint()
2116 ret = kfd_criu_checkpoint_svm(p, (uint8_t __user *)args->priv_data, &priv_offset); in criu_checkpoint()
2124 ret = criu_checkpoint_bos(p, num_bos, (uint8_t __user *)args->bos, in criu_checkpoint()
2125 (uint8_t __user *)args->priv_data, &bo_priv_offset); in criu_checkpoint()
2138 struct kfd_ioctl_criu_args *args, in criu_restore_process() argument
2149 (void __user *)(args->priv_data + *priv_offset), in criu_restore_process()
2179 struct kfd_ioctl_criu_args *args, in criu_restore_devices() argument
2188 if (args->num_devices != p->n_pdds) in criu_restore_devices()
2191 if (*priv_offset + (args->num_devices * sizeof(*device_privs)) > max_priv_data_size) in criu_restore_devices()
2194 device_buckets = kmalloc_array(args->num_devices, sizeof(*device_buckets), GFP_KERNEL); in criu_restore_devices()
2198 ret = copy_from_user(device_buckets, (void __user *)args->devices, in criu_restore_devices()
2199 args->num_devices * sizeof(*device_buckets)); in criu_restore_devices()
2206 for (i = 0; i < args->num_devices; i++) { in criu_restore_devices()
2279 *priv_offset += args->num_devices * sizeof(*device_privs); in criu_restore_devices()
2421 struct kfd_ioctl_criu_args *args, in criu_restore_bos() argument
2431 if (*priv_offset + (args->num_bos * sizeof(*bo_privs)) > max_priv_data_size) in criu_restore_bos()
2437 bo_buckets = kvmalloc_array(args->num_bos, sizeof(*bo_buckets), GFP_KERNEL); in criu_restore_bos()
2441 files = kvzalloc(args->num_bos * sizeof(struct file *), GFP_KERNEL); in criu_restore_bos()
2447 ret = copy_from_user(bo_buckets, (void __user *)args->bos, in criu_restore_bos()
2448 args->num_bos * sizeof(*bo_buckets)); in criu_restore_bos()
2455 bo_privs = kvmalloc_array(args->num_bos, sizeof(*bo_privs), GFP_KERNEL); in criu_restore_bos()
2461 ret = copy_from_user(bo_privs, (void __user *)args->priv_data + *priv_offset, in criu_restore_bos()
2462 args->num_bos * sizeof(*bo_privs)); in criu_restore_bos()
2468 *priv_offset += args->num_bos * sizeof(*bo_privs); in criu_restore_bos()
2471 for (; i < args->num_bos; i++) { in criu_restore_bos()
2480 ret = copy_to_user((void __user *)args->bos, in criu_restore_bos()
2482 (args->num_bos * sizeof(*bo_buckets))); in criu_restore_bos()
2496 struct kfd_ioctl_criu_args *args, in criu_restore_objects() argument
2507 for (i = 0; i < args->num_objects; i++) { in criu_restore_objects()
2515 ret = get_user(object_type, (uint32_t __user *)(args->priv_data + *priv_offset)); in criu_restore_objects()
2523 ret = kfd_criu_restore_queue(p, (uint8_t __user *)args->priv_data, in criu_restore_objects()
2529 ret = kfd_criu_restore_event(filep, p, (uint8_t __user *)args->priv_data, in criu_restore_objects()
2535 ret = kfd_criu_restore_svm(p, (uint8_t __user *)args->priv_data, in criu_restore_objects()
2552 struct kfd_ioctl_criu_args *args) in criu_restore() argument
2558 args->num_devices, args->num_bos, args->num_objects, args->priv_data_size); in criu_restore()
2560 if (!args->bos || !args->devices || !args->priv_data || !args->priv_data_size || in criu_restore()
2561 !args->num_devices || !args->num_bos) in criu_restore()
2575 ret = criu_restore_process(p, args, &priv_offset, args->priv_data_size); in criu_restore()
2579 ret = criu_restore_devices(p, args, &priv_offset, args->priv_data_size); in criu_restore()
2583 ret = criu_restore_bos(p, args, &priv_offset, args->priv_data_size); in criu_restore()
2587 ret = criu_restore_objects(filep, p, args, &priv_offset, args->priv_data_size); in criu_restore()
2591 if (priv_offset != args->priv_data_size) { in criu_restore()
2608 struct kfd_ioctl_criu_args *args) in criu_unpause() argument
2632 struct kfd_ioctl_criu_args *args) in criu_resume() argument
2639 args->pid); in criu_resume()
2641 pid = find_get_pid(args->pid); in criu_resume()
2643 pr_err("Cannot find pid info for %i\n", args->pid); in criu_resume()
2653 pr_debug("Cannot find process info for %i\n", args->pid); in criu_resume()
2660 pr_err("kfd_criu_resume_svm failed for %i\n", args->pid); in criu_resume()
2666 pr_err("amdgpu_amdkfd_criu_resume failed for %i\n", args->pid); in criu_resume()
2677 struct kfd_ioctl_criu_args *args) in criu_process_info() argument
2695 args->pid = task_pid_nr_ns(p->lead_thread, in criu_process_info()
2698 ret = criu_get_process_object_info(p, &args->num_devices, &args->num_bos, in criu_process_info()
2699 &args->num_objects, &args->priv_data_size); in criu_process_info()
2704 args->num_devices, args->num_bos, args->num_objects, in criu_process_info()
2705 args->priv_data_size); in criu_process_info()
2718 struct kfd_ioctl_criu_args *args = data; in kfd_ioctl_criu() local
2721 dev_dbg(kfd_device, "CRIU operation: %d\n", args->op); in kfd_ioctl_criu()
2722 switch (args->op) { in kfd_ioctl_criu()
2724 ret = criu_process_info(filep, p, args); in kfd_ioctl_criu()
2727 ret = criu_checkpoint(filep, p, args); in kfd_ioctl_criu()
2730 ret = criu_unpause(filep, p, args); in kfd_ioctl_criu()
2733 ret = criu_restore(filep, p, args); in kfd_ioctl_criu()
2736 ret = criu_resume(filep, p, args); in kfd_ioctl_criu()
2739 dev_dbg(kfd_device, "Unsupported CRIU operation:%d\n", args->op); in kfd_ioctl_criu()
2745 dev_dbg(kfd_device, "CRIU operation:%d err:%d\n", args->op, ret); in kfd_ioctl_criu()
2879 struct kfd_ioctl_runtime_enable_args *args = data; in kfd_ioctl_runtime_enable() local
2884 if (args->mode_mask & KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK) in kfd_ioctl_runtime_enable()
2885 r = runtime_enable(p, args->r_debug, in kfd_ioctl_runtime_enable()
2886 !!(args->mode_mask & KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK)); in kfd_ioctl_runtime_enable()
2897 struct kfd_ioctl_dbg_trap_args *args = data; in kfd_ioctl_set_debug_trap() local
2910 pid = find_get_pid(args->pid); in kfd_ioctl_set_debug_trap()
2912 pr_debug("Cannot find pid info for %i\n", args->pid); in kfd_ioctl_set_debug_trap()
2929 if (args->op == KFD_IOC_DBG_TRAP_ENABLE) { in kfd_ioctl_set_debug_trap()
2943 pr_debug("Cannot find process PID %i to debug\n", args->pid); in kfd_ioctl_set_debug_trap()
2951 if (target != p && args->op != KFD_IOC_DBG_TRAP_DISABLE in kfd_ioctl_set_debug_trap()
2953 pr_err("PID %i is not PTRACED and cannot be debugged\n", args->pid); in kfd_ioctl_set_debug_trap()
2963 if (args->op != KFD_IOC_DBG_TRAP_ENABLE && !target->debug_trap_enabled) { in kfd_ioctl_set_debug_trap()
2964 pr_err("PID %i not debug enabled for op %i\n", args->pid, args->op); in kfd_ioctl_set_debug_trap()
2970 (args->op == KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE || in kfd_ioctl_set_debug_trap()
2971 args->op == KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE || in kfd_ioctl_set_debug_trap()
2972 args->op == KFD_IOC_DBG_TRAP_SUSPEND_QUEUES || in kfd_ioctl_set_debug_trap()
2973 args->op == KFD_IOC_DBG_TRAP_RESUME_QUEUES || in kfd_ioctl_set_debug_trap()
2974 args->op == KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH || in kfd_ioctl_set_debug_trap()
2975 args->op == KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH || in kfd_ioctl_set_debug_trap()
2976 args->op == KFD_IOC_DBG_TRAP_SET_FLAGS)) { in kfd_ioctl_set_debug_trap()
2981 if (args->op == KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH || in kfd_ioctl_set_debug_trap()
2982 args->op == KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH) { in kfd_ioctl_set_debug_trap()
2984 args->op == KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH ? in kfd_ioctl_set_debug_trap()
2985 args->set_node_address_watch.gpu_id : in kfd_ioctl_set_debug_trap()
2986 args->clear_node_address_watch.gpu_id); in kfd_ioctl_set_debug_trap()
2995 switch (args->op) { in kfd_ioctl_set_debug_trap()
3001 args->enable.dbg_fd, in kfd_ioctl_set_debug_trap()
3002 (void __user *)args->enable.rinfo_ptr, in kfd_ioctl_set_debug_trap()
3003 &args->enable.rinfo_size); in kfd_ioctl_set_debug_trap()
3005 target->exception_enable_mask = args->enable.exception_mask; in kfd_ioctl_set_debug_trap()
3013 args->send_runtime_event.gpu_id, in kfd_ioctl_set_debug_trap()
3014 args->send_runtime_event.queue_id, in kfd_ioctl_set_debug_trap()
3015 args->send_runtime_event.exception_mask); in kfd_ioctl_set_debug_trap()
3019 args->set_exceptions_enabled.exception_mask); in kfd_ioctl_set_debug_trap()
3023 args->launch_override.override_mode, in kfd_ioctl_set_debug_trap()
3024 args->launch_override.enable_mask, in kfd_ioctl_set_debug_trap()
3025 args->launch_override.support_request_mask, in kfd_ioctl_set_debug_trap()
3026 &args->launch_override.enable_mask, in kfd_ioctl_set_debug_trap()
3027 &args->launch_override.support_request_mask); in kfd_ioctl_set_debug_trap()
3031 args->launch_mode.launch_mode); in kfd_ioctl_set_debug_trap()
3035 args->suspend_queues.num_queues, in kfd_ioctl_set_debug_trap()
3036 args->suspend_queues.grace_period, in kfd_ioctl_set_debug_trap()
3037 args->suspend_queues.exception_mask, in kfd_ioctl_set_debug_trap()
3038 (uint32_t *)args->suspend_queues.queue_array_ptr); in kfd_ioctl_set_debug_trap()
3042 r = resume_queues(target, args->resume_queues.num_queues, in kfd_ioctl_set_debug_trap()
3043 (uint32_t *)args->resume_queues.queue_array_ptr); in kfd_ioctl_set_debug_trap()
3047 args->set_node_address_watch.address, in kfd_ioctl_set_debug_trap()
3048 args->set_node_address_watch.mask, in kfd_ioctl_set_debug_trap()
3049 &args->set_node_address_watch.id, in kfd_ioctl_set_debug_trap()
3050 args->set_node_address_watch.mode); in kfd_ioctl_set_debug_trap()
3054 args->clear_node_address_watch.id); in kfd_ioctl_set_debug_trap()
3057 r = kfd_dbg_trap_set_flags(target, &args->set_flags.flags); in kfd_ioctl_set_debug_trap()
3061 &args->query_debug_event.queue_id, in kfd_ioctl_set_debug_trap()
3062 &args->query_debug_event.gpu_id, in kfd_ioctl_set_debug_trap()
3063 args->query_debug_event.exception_mask, in kfd_ioctl_set_debug_trap()
3064 &args->query_debug_event.exception_mask); in kfd_ioctl_set_debug_trap()
3068 args->query_exception_info.source_id, in kfd_ioctl_set_debug_trap()
3069 args->query_exception_info.exception_code, in kfd_ioctl_set_debug_trap()
3070 args->query_exception_info.clear_exception, in kfd_ioctl_set_debug_trap()
3071 (void __user *)args->query_exception_info.info_ptr, in kfd_ioctl_set_debug_trap()
3072 &args->query_exception_info.info_size); in kfd_ioctl_set_debug_trap()
3076 args->queue_snapshot.exception_mask, in kfd_ioctl_set_debug_trap()
3077 (void __user *)args->queue_snapshot.snapshot_buf_ptr, in kfd_ioctl_set_debug_trap()
3078 &args->queue_snapshot.num_queues, in kfd_ioctl_set_debug_trap()
3079 &args->queue_snapshot.entry_size); in kfd_ioctl_set_debug_trap()
3083 args->device_snapshot.exception_mask, in kfd_ioctl_set_debug_trap()
3084 (void __user *)args->device_snapshot.snapshot_buf_ptr, in kfd_ioctl_set_debug_trap()
3085 &args->device_snapshot.num_devices, in kfd_ioctl_set_debug_trap()
3086 &args->device_snapshot.entry_size); in kfd_ioctl_set_debug_trap()
3089 pr_err("Invalid option: %i\n", args->op); in kfd_ioctl_set_debug_trap()