[PATCH 1/2] drm/amdkfd: unbind only existing processes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When unbinding a process from a device (initiated by amd_iommu_v2), the
driver needs to make sure that process still exists in the process table.
There is a possibility that amdkfd's own notifier handler -
kfd_process_notifier_release() - was called before the unbind function
and it already removed the process from the process table.

Signed-off-by: Oded Gabbay <oded.gabbay@xxxxxxxxx>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index ac00579..248deb7 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -405,11 +405,17 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
 	idx = srcu_read_lock(&kfd_processes_srcu);
 
 	hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes)
-		if (p->pasid == pasid)
+		if ((!p) || (p->pasid == pasid))
 			break;
 
 	srcu_read_unlock(&kfd_processes_srcu, idx);
 
+	/* check if have a process in the hash. Maybe the relevant process was
+	 * already erased in kfd_process_notifier_release()
+	 */
+	if (!p)
+		return;
+
 	BUG_ON(p->pasid != pasid);
 
 	mutex_lock(&p->mutex);
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux