diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2016-09-17 01:01:42 -0400 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2016-09-19 13:58:35 -0400 |
commit | ad16a469ffa1f1bbf8f31e110b4d68cee39757d2 (patch) | |
tree | 732da2669abb45f9a1051621ef78910168d0b9ce | |
parent | 78b13f7964d97be4329e6410423a66affd7a68ad (diff) |
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>
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_process.c | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 4f3849ac8c07..ef7c8de7060e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c | |||
@@ -404,58 +404,47 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid) | |||
404 | { | 404 | { |
405 | struct kfd_process *p; | 405 | struct kfd_process *p; |
406 | struct kfd_process_device *pdd; | 406 | struct kfd_process_device *pdd; |
407 | int idx, i; | ||
408 | 407 | ||
409 | BUG_ON(dev == NULL); | 408 | BUG_ON(dev == NULL); |
410 | 409 | ||
411 | idx = srcu_read_lock(&kfd_processes_srcu); | ||
412 | |||
413 | /* | 410 | /* |
414 | * Look for the process that matches the pasid. If there is no such | 411 | * Look for the process that matches the pasid. If there is no such |
415 | * process, we either released it in amdkfd's own notifier, or there | 412 | * process, we either released it in amdkfd's own notifier, or there |
416 | * is a bug. Unfortunately, there is no way to tell... | 413 | * is a bug. Unfortunately, there is no way to tell... |
417 | */ | 414 | */ |
418 | hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes) | 415 | p = kfd_lookup_process_by_pasid(pasid); |
419 | if (p->pasid == pasid) { | 416 | if (!p) |
420 | 417 | return; | |
421 | srcu_read_unlock(&kfd_processes_srcu, idx); | ||
422 | |||
423 | pr_debug("Unbinding process %d from IOMMU\n", pasid); | ||
424 | 418 | ||
425 | mutex_lock(&p->mutex); | 419 | pr_debug("Unbinding process %d from IOMMU\n", pasid); |
426 | |||
427 | if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid)) | ||
428 | kfd_dbgmgr_destroy(dev->dbgmgr); | ||
429 | |||
430 | pqm_uninit(&p->pqm); | ||
431 | 420 | ||
432 | pdd = kfd_get_process_device_data(dev, p); | 421 | if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid)) |
422 | kfd_dbgmgr_destroy(dev->dbgmgr); | ||
433 | 423 | ||
434 | if (!pdd) { | 424 | pqm_uninit(&p->pqm); |
435 | mutex_unlock(&p->mutex); | ||
436 | return; | ||
437 | } | ||
438 | 425 | ||
439 | if (pdd->reset_wavefronts) { | 426 | pdd = kfd_get_process_device_data(dev, p); |
440 | dbgdev_wave_reset_wavefronts(pdd->dev, p); | ||
441 | pdd->reset_wavefronts = false; | ||
442 | } | ||
443 | 427 | ||
444 | /* | 428 | if (!pdd) { |
445 | * Just mark pdd as unbound, because we still need it | 429 | mutex_unlock(&p->mutex); |
446 | * to call amd_iommu_unbind_pasid() in when the | 430 | return; |
447 | * process exits. | 431 | } |
448 | * We don't call amd_iommu_unbind_pasid() here | ||
449 | * because the IOMMU called us. | ||
450 | */ | ||
451 | pdd->bound = false; | ||
452 | 432 | ||
453 | mutex_unlock(&p->mutex); | 433 | if (pdd->reset_wavefronts) { |
434 | dbgdev_wave_reset_wavefronts(pdd->dev, p); | ||
435 | pdd->reset_wavefronts = false; | ||
436 | } | ||
454 | 437 | ||
455 | return; | 438 | /* |
456 | } | 439 | * Just mark pdd as unbound, because we still need it |
440 | * to call amd_iommu_unbind_pasid() in when the | ||
441 | * process exits. | ||
442 | * We don't call amd_iommu_unbind_pasid() here | ||
443 | * because the IOMMU called us. | ||
444 | */ | ||
445 | pdd->bound = false; | ||
457 | 446 | ||
458 | srcu_read_unlock(&kfd_processes_srcu, idx); | 447 | mutex_unlock(&p->mutex); |
459 | } | 448 | } |
460 | 449 | ||
461 | struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p) | 450 | struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p) |