Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: [Intel-xe] [PATCH 2/2] drm/xe: Properly remove the vma from the vm::notifer::rebind_list when destroyed
Date: Wed, 10 May 2023 16:19:32 +0200	[thread overview]
Message-ID: <20230510141932.413348-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20230510141932.413348-1-thomas.hellstrom@linux.intel.com>

If a vma was destroyed with the bo evicted, it might happen that we forget
to remove it from the notifer::rebind_list. Fix to make sure that really
happens.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 5f93d78c2e58..f54b3b7566c9 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -978,6 +978,15 @@ static void xe_vma_destroy(struct xe_vma *vma, struct dma_fence *fence)
 	} else {
 		xe_bo_assert_held(vma->bo);
 		list_del(&vma->bo_link);
+		/*
+		 * TODO: We can do an advisory check for list link empty here,
+		 * if this lock becomes too costly. Nobody can re-add to the
+		 * bo to the vm::notifier::rebind_list at this point since we
+		 * have the bo lock.
+		 */
+		 spin_lock(&vm->notifier.list_lock);
+		 list_del(&vma->notifier.rebind_link);
+		 spin_unlock(&vm->notifier.list_lock);
 		if (!vma->bo->vm)
 			vm_remove_extobj(vma);
 	}
-- 
2.39.2


  parent reply	other threads:[~2023-05-10 14:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10 14:19 [Intel-xe] [PATCH 0/2] drm/xe: Fix unprotected rebind_list accesses Thomas Hellström
2023-05-10 14:19 ` [Intel-xe] [PATCH 1/2] drm/xe: Fix unlocked access of the vma::rebind_link Thomas Hellström
2023-05-11 14:57   ` Matthew Brost
2023-05-10 14:19 ` Thomas Hellström [this message]
2023-05-11 14:54   ` [Intel-xe] [PATCH 2/2] drm/xe: Properly remove the vma from the vm::notifer::rebind_list when destroyed Matthew Brost
2023-05-11 15:38     ` Thomas Hellström
2023-05-12  1:31       ` Matthew Brost
2023-05-10 14:22 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Fix unprotected rebind_list accesses Patchwork
2023-05-10 14:23 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-10 14:27 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-10 14:52 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-10 20:36 ` [Intel-xe] [PATCH 0/2] " Souza, Jose

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=20230510141932.413348-3-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@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