dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Oded Gabbay <oded.gabbay@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] drm/amdkfd: unbind only existing processes
Date: Thu, 26 May 2016 12:43:58 +0300	[thread overview]
Message-ID: <1464255839-5205-1-git-send-email-oded.gabbay@gmail.com> (raw)

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@gmail.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2016-05-26  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26  9:43 Oded Gabbay [this message]
2016-05-26  9:43 ` [PATCH 2/2] drm/amdkfd: destroy dbgmgr in notifier release Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464255839-5205-1-git-send-email-oded.gabbay@gmail.com \
    --to=oded.gabbay@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox