Lines Matching defs:process
58 /* For process termination handling */
200 mm = get_task_mm(pdd->process->lead_thread);
271 * by current process. Translates acquired wave count into number of compute units
299 proc = pdd->process;
301 pr_debug("Gpu-Id: %d has no active queues for process pid %d\n",
543 if (!q || !q->process)
545 proc = q->process;
700 if (!q || !q->process->kobj)
767 /* kfd_process_alloc_gpuvm - Allocate GPU VM for the KFD process
768 * This function should be only called right after the process
827 * process for IB usage The memory reserved is for KFD to submit
868 int kfd_create_process_sysfs(struct kfd_process *process)
873 if (process->kobj) {
878 process->kobj = kfd_alloc_struct(process->kobj);
879 if (!process->kobj) {
884 if (process->context_id == KFD_CONTEXT_ID_PRIMARY)
885 ret = kobject_init_and_add(process->kobj, &procfs_type,
887 (int)process->lead_thread->pid);
889 primary_process = kfd_lookup_process_by_mm(process->lead_thread->mm);
893 ret = kobject_init_and_add(process->kobj, &procfs_type,
895 process->context_id);
901 kobject_put(process->kobj);
902 process->kobj = NULL;
906 kfd_sysfs_create_file(process->kobj, &process->attr_pasid,
909 process->kobj_queues = kobject_create_and_add("queues",
910 process->kobj);
911 if (!process->kobj_queues)
914 kfd_procfs_add_sysfs_stats(process);
915 kfd_procfs_add_sysfs_files(process);
916 kfd_procfs_add_sysfs_counters(process);
921 static int kfd_process_alloc_id(struct kfd_process *process)
927 if (process->context_id == KFD_CONTEXT_ID_PRIMARY)
930 primary_process = kfd_lookup_process_by_mm(process->lead_thread->mm);
940 process->context_id = ret;
949 static void kfd_process_free_id(struct kfd_process *process)
953 if (process->context_id == KFD_CONTEXT_ID_PRIMARY ||
954 process->context_id < KFD_CONTEXT_ID_MIN)
957 primary_process = kfd_lookup_process_by_mm(process->lead_thread->mm);
961 ida_free(&primary_process->id_table, process->context_id);
968 struct kfd_process *process;
974 /* If the process just called exec(3), it is possible that the
976 * of the old process image) is still in the cleanup work queue.
978 * resource for this process.
983 * take kfd processes mutex before starting of process creation
984 * so there won't be a case where two threads of the same process
990 pr_warn("no gpu node! Cannot create KFD process");
991 process = ERR_PTR(-EINVAL);
996 pr_debug("KFD is locked! Cannot create process");
997 process = ERR_PTR(-EINVAL);
1001 /* A prior open of /dev/kfd could have already created the process.
1002 * find_process will increase process kref in this case
1004 process = find_process(thread, true);
1005 if (process) {
1008 process = create_process(thread, true);
1009 if (IS_ERR(process))
1015 ret = kfd_create_process_sysfs(process);
1019 ret = kfd_debugfs_add_process(process);
1024 init_waitqueue_head(&process->wait_irq_drain);
1030 return process;
1034 * amdgpu_amdkfd_set_sigbus_delay - Set per-process KFD SIGBUS delay
1035 * @task: task in the target process
1040 * @task. If the calling process has not opened /dev/kfd yet (no
1062 struct kfd_process *process;
1064 hash_for_each_possible_rcu(kfd_processes_table, process,
1066 if (process->mm == mm && process->context_id == KFD_CONTEXT_ID_PRIMARY)
1067 return process;
1092 /* This increments the process->ref counter. */
1115 struct kfd_process *p = pdd->process;
1307 /* No process locking is needed in this function, because the process
1309 * using it any more, otherwise we couldn't safely free the process
1372 /* This increments p->ref counter if kfd process p exists */
1416 * Disable debug BEFORE dequeuing/flushing the MES process context.
1420 * process to the MES scheduler list. kfd_process_dequeue_from_all_devices()
1422 * teardown ran after the dequeue, those packets would put the process
1424 * on the freed process context. Retiring the context last avoids this.
1449 * exit_mmap free process memory afterwards.
1505 * Move all remaining kfd_process from the process table to a
1572 pdd->process->debug_trap_enabled);
1624 * XNACK mode for this process that's compatible with all GPUs.
1642 * per-process XNACK mode selection. But let the dev->noretry
1685 struct kfd_process *process;
1689 process = kzalloc_obj(*process);
1690 if (!process)
1693 kref_init(&process->ref);
1694 mutex_init(&process->mutex);
1695 process->mm = thread->mm;
1696 process->lead_thread = thread->group_leader;
1698 * Take the reference on the lead thread before the process can be
1701 get_task_struct(process->lead_thread);
1702 process->n_pdds = 0;
1703 process->queues_paused = false;
1705 INIT_DELAYED_WORK(&process->eviction_work, evict_process_worker);
1706 INIT_DELAYED_WORK(&process->restore_work, restore_process_worker);
1707 INIT_DELAYED_WORK(&process->signal_work, kfd_signal_sigbus_delayed_fn);
1708 process->last_restore_timestamp = get_jiffies_64();
1709 err = kfd_event_init_process(process);
1712 process->is_32bit_user_mode = in_compat_syscall();
1713 process->debug_trap_enabled = false;
1714 process->debugger_process = NULL;
1715 process->exception_enable_mask = 0;
1716 atomic_set(&process->debugged_process_count, 0);
1717 sema_init(&process->runtime_enable_sema, 0);
1719 err = pqm_init(&process->pqm, process);
1723 /* init process apertures*/
1724 err = kfd_init_apertures(process);
1729 process->xnack_enabled = kfd_process_xnack_mode(process, false);
1731 err = svm_range_list_init(process);
1735 /* alloc_notifier needs to find the process in the hash table */
1736 hash_add_rcu(kfd_processes_table, &process->kfd_processes,
1737 (uintptr_t)process->mm);
1742 kref_get(&process->ref);
1745 * because after this point we cannot unwind the process creation.
1747 * dropping the last process reference in the free_notifier.
1750 process->context_id = KFD_CONTEXT_ID_PRIMARY;
1752 * Must be initialized before the process can be given to
1755 ida_init(&process->id_table);
1756 mn = mmu_notifier_get(&kfd_process_mmu_notifier_ops, process->mm);
1761 BUG_ON(mn != &process->mmu_notifier);
1764 err = kfd_process_alloc_id(process);
1766 pr_err("Creating kfd process: failed to alloc an id\n");
1770 kfd_unref_process(process);
1772 INIT_WORK(&process->debug_event_workarea, debug_event_write_work_handler);
1774 return process;
1779 * The process is already in kfd_processes_table, so find_process()
1783 * can be taken and the ones already taken keep the process alive.
1787 hash_del_rcu(&process->kfd_processes);
1795 * registered for the process. The process is unlinked and no
1799 pqm_uninit(&process->pqm);
1806 kfd_unref_process(process);
1807 kfd_unref_process(process);
1812 kfd_process_free_outstanding_kfd_bos(process);
1813 kfd_process_destroy_pdds(process);
1815 pqm_uninit(&process->pqm);
1817 kfd_event_free_process(process);
1819 mutex_destroy(&process->mutex);
1820 put_task_struct(process->lead_thread);
1821 kfree(process);
1857 pdd->process = p;
1882 * kfd_process_device_init_vm - Initialize a VM for a process-device
1884 * @pdd: The process-device
1913 p = pdd->process;
1920 dev_err(dev->adev->dev, "Failed to create process VM object\n");
1962 * Direct the IOMMU to bind the process (specifically the pasid->mm)
1964 * Unbinding occurs when the process dies or the device is removed.
1966 * Assumes that the process lock is held.
2005 /* Create specific handle mapped to mem from process local memory idr
2006 * Assumes that the process lock is held.
2014 /* Translate specific handle from process local memory idr
2015 * Assumes that the process lock is held.
2026 /* Remove specific handle from process local memory idr
2027 * Assumes that the process lock is held.
2056 /* This increments the process->ref counter. */
2068 kref_get(&ret_p->process->ref);
2071 return ret_p->process;
2082 /* This increments the process->ref counter. */
2098 /* This increments the process->ref counter. */
2119 /* kfd_process_evict_queues - Evict all user queues of a process
2121 * Eviction is reference-counted per process-device. This means multiple
2144 dev_err(dev, "Failed to evict process queues\n");
2177 /* kfd_process_restore_queues - Restore all user queues of a process */
2192 dev_err(dev, "Failed to restore process queues\n");
2256 pr_debug("Started evicting process pid %d\n", p->lead_thread->pid);
2268 pr_debug("Finished evicting process pid %d\n", p->lead_thread->pid);
2270 pr_err("Failed to evict queues of process pid %d\n", p->lead_thread->pid);
2287 pr_debug("Finished restoring process pid %d\n",
2290 pr_err("Failed to restore queues of process pid %d\n",
2308 pr_debug("Started restoring process pasid %d\n", (int)p->lead_thread->pid);
2312 * before KFD BOs are unreserved. If not, the process can be evicted
2324 pr_debug("Failed to restore BOs of process pid %d, retry after %d ms\n",
2341 pr_err("Failed to suspend process pid %d\n", p->lead_thread->pid);
2355 pr_err("Restore process pid %d failed during resume\n",
2364 /* assumes caller holds process lock. */
2374 pdd->process->irq_drain_is_open = true;
2395 pdd->process->irq_drain_is_open = false;
2399 r = wait_event_interruptible(pdd->process->wait_irq_drain,
2400 !READ_ONCE(pdd->process->irq_drain_is_open));
2402 pdd->process->irq_drain_is_open = false;