drm/amdkfd: Reuse function to find a process through pasid
The kfd_lookup_process_by_pasid() is just for that purpose, so use it instead of repeating the code. v2: return on the condition (p == NULL) instead of BUG_ON(!p). Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
This commit is contained in:
parent
78b13f7964
commit
ad16a469ff
@ -404,26 +404,20 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
|
||||
{
|
||||
struct kfd_process *p;
|
||||
struct kfd_process_device *pdd;
|
||||
int idx, i;
|
||||
|
||||
BUG_ON(dev == NULL);
|
||||
|
||||
idx = srcu_read_lock(&kfd_processes_srcu);
|
||||
|
||||
/*
|
||||
* Look for the process that matches the pasid. If there is no such
|
||||
* process, we either released it in amdkfd's own notifier, or there
|
||||
* is a bug. Unfortunately, there is no way to tell...
|
||||
*/
|
||||
hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes)
|
||||
if (p->pasid == pasid) {
|
||||
|
||||
srcu_read_unlock(&kfd_processes_srcu, idx);
|
||||
p = kfd_lookup_process_by_pasid(pasid);
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
pr_debug("Unbinding process %d from IOMMU\n", pasid);
|
||||
|
||||
mutex_lock(&p->mutex);
|
||||
|
||||
if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid))
|
||||
kfd_dbgmgr_destroy(dev->dbgmgr);
|
||||
|
||||
@ -451,11 +445,6 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
|
||||
pdd->bound = false;
|
||||
|
||||
mutex_unlock(&p->mutex);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
srcu_read_unlock(&kfd_processes_srcu, idx);
|
||||
}
|
||||
|
||||
struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p)
|
||||
|
Loading…
Reference in New Issue
Block a user