mirror of
https://github.com/torvalds/linux.git
synced 2026-05-13 00:28:54 +02:00
amdkfd: Introduce kfd_create_process_sysfs as a separate function
KFD creates sysfs entries for a kfd_process in function kfd_create_process when creating it. This commit extracts the code creating sysfs entries to a separate function because it would be invoked in other code path like creating secondary kfd contexts (kfd_process). Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f433db9c4b
commit
4cd255b969
|
|
@ -1053,6 +1053,7 @@ int kfd_process_create_wq(void);
|
|||
void kfd_process_destroy_wq(void);
|
||||
void kfd_cleanup_processes(void);
|
||||
struct kfd_process *kfd_create_process(struct task_struct *thread);
|
||||
int kfd_create_process_sysfs(struct kfd_process *process);
|
||||
struct kfd_process *kfd_get_process(const struct task_struct *task);
|
||||
struct kfd_process *kfd_lookup_process_by_pasid(u32 pasid,
|
||||
struct kfd_process_device **pdd);
|
||||
|
|
|
|||
|
|
@ -825,6 +825,44 @@ static void kfd_process_device_destroy_ib_mem(struct kfd_process_device *pdd)
|
|||
kfd_process_free_gpuvm(qpd->ib_mem, pdd, &qpd->ib_kaddr);
|
||||
}
|
||||
|
||||
int kfd_create_process_sysfs(struct kfd_process *process)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (process->kobj) {
|
||||
pr_warn("kobject already exsists for the kfd_process\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
process->kobj = kfd_alloc_struct(process->kobj);
|
||||
if (!process->kobj) {
|
||||
pr_warn("Creating procfs kobject failed");
|
||||
return -ENOMEM;
|
||||
}
|
||||
ret = kobject_init_and_add(process->kobj, &procfs_type,
|
||||
procfs.kobj, "%d",
|
||||
(int)process->lead_thread->pid);
|
||||
if (ret) {
|
||||
pr_warn("Creating procfs pid directory failed");
|
||||
kobject_put(process->kobj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
kfd_sysfs_create_file(process->kobj, &process->attr_pasid,
|
||||
"pasid");
|
||||
|
||||
process->kobj_queues = kobject_create_and_add("queues",
|
||||
process->kobj);
|
||||
if (!process->kobj_queues)
|
||||
pr_warn("Creating KFD proc/queues folder failed");
|
||||
|
||||
kfd_procfs_add_sysfs_stats(process);
|
||||
kfd_procfs_add_sysfs_files(process);
|
||||
kfd_procfs_add_sysfs_counters(process);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct kfd_process *kfd_create_process(struct task_struct *thread)
|
||||
{
|
||||
struct kfd_process *process;
|
||||
|
|
@ -874,31 +912,9 @@ struct kfd_process *kfd_create_process(struct task_struct *thread)
|
|||
if (!procfs.kobj)
|
||||
goto out;
|
||||
|
||||
process->kobj = kfd_alloc_struct(process->kobj);
|
||||
if (!process->kobj) {
|
||||
pr_warn("Creating procfs kobject failed");
|
||||
goto out;
|
||||
}
|
||||
ret = kobject_init_and_add(process->kobj, &procfs_type,
|
||||
procfs.kobj, "%d",
|
||||
(int)process->lead_thread->pid);
|
||||
if (ret) {
|
||||
pr_warn("Creating procfs pid directory failed");
|
||||
kobject_put(process->kobj);
|
||||
goto out;
|
||||
}
|
||||
|
||||
kfd_sysfs_create_file(process->kobj, &process->attr_pasid,
|
||||
"pasid");
|
||||
|
||||
process->kobj_queues = kobject_create_and_add("queues",
|
||||
process->kobj);
|
||||
if (!process->kobj_queues)
|
||||
pr_warn("Creating KFD proc/queues folder failed");
|
||||
|
||||
kfd_procfs_add_sysfs_stats(process);
|
||||
kfd_procfs_add_sysfs_files(process);
|
||||
kfd_procfs_add_sysfs_counters(process);
|
||||
ret = kfd_create_process_sysfs(process);
|
||||
if (ret)
|
||||
pr_warn("Failed to create sysfs entry for the kfd_process");
|
||||
|
||||
kfd_debugfs_add_process(process);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user