All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 2/3] drm/i915/gem: Lock the object as we unbind
Date: Mon, 16 Dec 2019 10:39:00 +0000	[thread overview]
Message-ID: <20191216103901.2518461-2-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20191216103901.2518461-1-chris@chris-wilson.co.uk>

If the object is closed while we wait, that may move the vma we are
waiting on to the parked list allowing it to be destroyed underneath the
waiter. (i915_vma.kref! When do we want it? Yesterday!)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 5eeef1ef7448..0f9e1411a031 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -139,6 +139,7 @@ int i915_gem_object_unbind(struct drm_i915_gem_object *obj,
 
 try_again:
 	ret = 0;
+	i915_gem_object_lock(obj); /* prevent i915_gem_close_object() */
 	spin_lock(&obj->vma.lock);
 	while (!ret && (vma = list_first_entry_or_null(&obj->vma.list,
 						       struct i915_vma,
@@ -177,6 +178,7 @@ int i915_gem_object_unbind(struct drm_i915_gem_object *obj,
 	}
 	list_splice_init(&still_in_list, &obj->vma.list);
 	spin_unlock(&obj->vma.lock);
+	i915_gem_object_unlock(obj);
 
 	if (ret == -EAGAIN && flags & I915_GEM_OBJECT_UNBIND_BARRIER) {
 		rcu_barrier(); /* flush the i915_vm_release() */
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-12-16 10:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 10:38 [Intel-gfx] [PATCH 1/3] drm/i915: Unpin vma->obj on early error Chris Wilson
2019-12-16 10:39 ` Chris Wilson [this message]
2019-12-16 10:39 ` [PATCH 3/3] drm/i915: Hold reference to intel_frontbuffer as we track activity Chris Wilson
2019-12-16 10:39   ` [Intel-gfx] " Chris Wilson
2019-12-16 16:15 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/3] drm/i915: Unpin vma->obj on early error Patchwork

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=20191216103901.2518461-2-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.