amdkfd: destroy kfd secondary contexts through fd close

Life cycle of a KFD secondary context(kfd_process) is tied
to the opened file. Therefore this commit destroy a kfd
secondary context when close the fd it belonging to.

This commit extracts the code removing the kfd_process
from the kfd_process_table to a separate function and
call it in kfd_process_notifier_release_internal unconditionally.

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:
Zhu Lingshan
2024-10-28 15:55:01 +08:00
committed by Alex Deucher
parent 4cd255b969
commit 65cce2a172
3 changed files with 31 additions and 20 deletions

View File

@@ -164,8 +164,13 @@ static int kfd_release(struct inode *inode, struct file *filep)
{
struct kfd_process *process = filep->private_data;
if (process)
kfd_unref_process(process);
if (!process)
return 0;
if (process->context_id != KFD_CONTEXT_ID_PRIMARY)
kfd_process_notifier_release_internal(process);
kfd_unref_process(process);
return 0;
}