[PATCH 2/3] drm/i915/gem: Lock the object as we unbind

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

 



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@xxxxxxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux