Lines Matching full:process

57 /* For process termination handling */
185 mm = get_task_mm(pdd->process->lead_thread); in kfd_sdma_activity_worker()
256 * by current process. Translates acquired wave count into number of compute units
284 proc = pdd->process; in kfd_get_cu_occupancy()
286 pr_debug("Gpu-Id: %d has no active queues for process %d\n", in kfd_get_cu_occupancy()
529 if (!q || !q->process) in kfd_procfs_add_queue()
531 proc = q->process; in kfd_procfs_add_queue()
736 /* kfd_process_alloc_gpuvm - Allocate GPU VM for the KFD process
737 * This function should be only called right after the process
790 * process for IB usage The memory reserved is for KFD to submit
833 struct kfd_process *process; in kfd_create_process() local
846 * take kfd processes mutex before starting of process creation in kfd_create_process()
847 * so there won't be a case where two threads of the same process in kfd_create_process()
853 pr_debug("KFD is locked! Cannot create process"); in kfd_create_process()
854 process = ERR_PTR(-EINVAL); in kfd_create_process()
858 /* A prior open of /dev/kfd could have already created the process. in kfd_create_process()
859 * find_process will increase process kref in this case in kfd_create_process()
861 process = find_process(thread, true); in kfd_create_process()
862 if (process) { in kfd_create_process()
863 pr_debug("Process already found\n"); in kfd_create_process()
865 /* If the process just called exec(3), it is possible that the in kfd_create_process()
867 * of the old process image) is still in the cleanup work queue. in kfd_create_process()
869 * resource for this process. in kfd_create_process()
873 process = create_process(thread); in kfd_create_process()
874 if (IS_ERR(process)) in kfd_create_process()
880 process->kobj = kfd_alloc_struct(process->kobj); in kfd_create_process()
881 if (!process->kobj) { in kfd_create_process()
885 ret = kobject_init_and_add(process->kobj, &procfs_type, in kfd_create_process()
887 (int)process->lead_thread->pid); in kfd_create_process()
890 kobject_put(process->kobj); in kfd_create_process()
894 kfd_sysfs_create_file(process->kobj, &process->attr_pasid, in kfd_create_process()
897 process->kobj_queues = kobject_create_and_add("queues", in kfd_create_process()
898 process->kobj); in kfd_create_process()
899 if (!process->kobj_queues) in kfd_create_process()
902 kfd_procfs_add_sysfs_stats(process); in kfd_create_process()
903 kfd_procfs_add_sysfs_files(process); in kfd_create_process()
904 kfd_procfs_add_sysfs_counters(process); in kfd_create_process()
906 init_waitqueue_head(&process->wait_irq_drain); in kfd_create_process()
912 return process; in kfd_create_process()
917 struct kfd_process *process; in kfd_get_process() local
926 process = find_process(thread, false); in kfd_get_process()
927 if (!process) in kfd_get_process()
930 return process; in kfd_get_process()
935 struct kfd_process *process; in find_process_by_mm() local
937 hash_for_each_possible_rcu(kfd_processes_table, process, in find_process_by_mm()
939 if (process->mm == mm) in find_process_by_mm()
940 return process; in find_process_by_mm()
965 /* This increments the process->ref counter. */
988 struct kfd_process *p = pdd->process; in kfd_process_device_free_bos()
1060 pr_debug("Releasing pdd (topology id %d) for process (pasid 0x%x)\n", in kfd_process_destroy_pdds()
1155 /* No process locking is needed in this function, because the process
1157 * using it any more, otherwise we couldn't safely free the process
1212 /* This increments p->ref counter if kfd process p exists */ in kfd_process_alloc_notifier()
1315 * Move all remaining kfd_process from the process table to a in kfd_cleanup_processes()
1409 pdd->process->debug_trap_enabled); in kfd_process_device_init_cwsr_dgpu()
1458 * XNACK mode for this process that's compatible with all GPUs. in kfd_process_xnack_mode()
1476 * per-process XNACK mode selection. But let the dev->noretry in kfd_process_xnack_mode()
1518 struct kfd_process *process; in create_process() local
1522 process = kzalloc(sizeof(*process), GFP_KERNEL); in create_process()
1523 if (!process) in create_process()
1526 kref_init(&process->ref); in create_process()
1527 mutex_init(&process->mutex); in create_process()
1528 process->mm = thread->mm; in create_process()
1529 process->lead_thread = thread->group_leader; in create_process()
1530 process->n_pdds = 0; in create_process()
1531 process->queues_paused = false; in create_process()
1532 INIT_DELAYED_WORK(&process->eviction_work, evict_process_worker); in create_process()
1533 INIT_DELAYED_WORK(&process->restore_work, restore_process_worker); in create_process()
1534 process->last_restore_timestamp = get_jiffies_64(); in create_process()
1535 err = kfd_event_init_process(process); in create_process()
1538 process->is_32bit_user_mode = in_compat_syscall(); in create_process()
1539 process->debug_trap_enabled = false; in create_process()
1540 process->debugger_process = NULL; in create_process()
1541 process->exception_enable_mask = 0; in create_process()
1542 atomic_set(&process->debugged_process_count, 0); in create_process()
1543 sema_init(&process->runtime_enable_sema, 0); in create_process()
1545 process->pasid = kfd_pasid_alloc(); in create_process()
1546 if (process->pasid == 0) { in create_process()
1551 err = pqm_init(&process->pqm, process); in create_process()
1555 /* init process apertures*/ in create_process()
1556 err = kfd_init_apertures(process); in create_process()
1561 process->xnack_enabled = kfd_process_xnack_mode(process, false); in create_process()
1563 err = svm_range_list_init(process); in create_process()
1567 /* alloc_notifier needs to find the process in the hash table */ in create_process()
1568 hash_add_rcu(kfd_processes_table, &process->kfd_processes, in create_process()
1569 (uintptr_t)process->mm); in create_process()
1574 kref_get(&process->ref); in create_process()
1577 * because after this point we cannot unwind the process creation. in create_process()
1579 * dropping the last process reference in the free_notifier. in create_process()
1581 mn = mmu_notifier_get(&kfd_process_mmu_notifier_ops, process->mm); in create_process()
1586 BUG_ON(mn != &process->mmu_notifier); in create_process()
1588 kfd_unref_process(process); in create_process()
1589 get_task_struct(process->lead_thread); in create_process()
1591 INIT_WORK(&process->debug_event_workarea, debug_event_write_work_handler); in create_process()
1593 return process; in create_process()
1596 hash_del_rcu(&process->kfd_processes); in create_process()
1597 svm_range_list_fini(process); in create_process()
1599 kfd_process_free_outstanding_kfd_bos(process); in create_process()
1600 kfd_process_destroy_pdds(process); in create_process()
1602 pqm_uninit(&process->pqm); in create_process()
1604 kfd_pasid_free(process->pasid); in create_process()
1606 kfd_event_free_process(process); in create_process()
1608 mutex_destroy(&process->mutex); in create_process()
1609 kfree(process); in create_process()
1644 pdd->process = p; in kfd_create_process_device_data()
1667 * kfd_process_device_init_vm - Initialize a VM for a process-device
1669 * @pdd: The process-device
1701 p = pdd->process; in kfd_process_device_init_vm()
1708 dev_err(dev->adev->dev, "Failed to create process VM object\n"); in kfd_process_device_init_vm()
1744 * Direct the IOMMU to bind the process (specifically the pasid->mm)
1746 * Unbinding occurs when the process dies or the device is removed.
1748 * Assumes that the process lock is held.
1758 dev_err(dev->adev->dev, "Process device data doesn't exist\n"); in kfd_bind_process_to_device()
1787 /* Create specific handle mapped to mem from process local memory idr
1788 * Assumes that the process lock is held.
1796 /* Translate specific handle from process local memory idr
1797 * Assumes that the process lock is held.
1808 /* Remove specific handle from process local memory idr
1809 * Assumes that the process lock is held.
1818 /* This increments the process->ref counter. */
1839 /* This increments the process->ref counter. */
1855 /* kfd_process_evict_queues - Evict all user queues of a process
1857 * Eviction is reference-counted per process-device. This means multiple
1880 dev_err(dev, "Failed to evict process queues\n"); in kfd_process_evict_queues()
1913 /* kfd_process_restore_queues - Restore all user queues of a process */
1928 dev_err(dev, "Failed to restore process queues\n"); in kfd_process_restore_queues()
1987 /* Process termination destroys this worker thread. So during the in evict_process_worker()
2038 /* Process termination destroys this worker thread. So during the in restore_process_worker()
2046 * before KFD BOs are unreserved. If not, the process can be evicted in restore_process_worker()
2075 pr_err("Failed to suspend process 0x%x\n", p->pasid); in kfd_suspend_all_processes()
2089 pr_err("Restore process %d failed during resume\n", in kfd_resume_all_processes()
2098 int kfd_reserved_mem_mmap(struct kfd_node *dev, struct kfd_process *process, in kfd_reserved_mem_mmap() argument
2109 pdd = kfd_get_process_device_data(dev, process); in kfd_reserved_mem_mmap()
2118 "Error allocating per process CWSR buffer.\n"); in kfd_reserved_mem_mmap()
2124 /* Mapping pages to user process */ in kfd_reserved_mem_mmap()
2130 /* assumes caller holds process lock. */
2140 pdd->process->irq_drain_is_open = true; in kfd_process_drain_interrupts()
2145 irq_drain_fence[3] = pdd->process->pasid; in kfd_process_drain_interrupts()
2160 pdd->process->irq_drain_is_open = false; in kfd_process_drain_interrupts()
2164 r = wait_event_interruptible(pdd->process->wait_irq_drain, in kfd_process_drain_interrupts()
2165 !READ_ONCE(pdd->process->irq_drain_is_open)); in kfd_process_drain_interrupts()
2167 pdd->process->irq_drain_is_open = false; in kfd_process_drain_interrupts()
2297 seq_printf(m, "Process %d PASID 0x%x:\n", in kfd_debugfs_mqds_by_process()