Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/11] drm/i915: Split detaching and removing the vma
@ 2019-10-30 19:21 Chris Wilson
  2019-10-30 19:21 ` [Intel-gfx] " Chris Wilson
                   ` (13 more replies)
  0 siblings, 14 replies; 28+ messages in thread
From: Chris Wilson @ 2019-10-30 19:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: Matthew Auld

In order to keep the assert_bind_count() valid, we need to hold the vma
page reference until after we drop the bind count. However, we must also
keep the drm_mm_remove_node() as the last action of i915_vma_unbind() so
that it serialises with the unlocked check inside i915_vma_destroy(). So
we need to split up i915_vma_remove() so that we order the detach, drop
pages and remove as required during unbind.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=112067
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 37 +++++++++++++++------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index d733bcf262f0..e5512f26e20a 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -700,41 +700,35 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
 	GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
 	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, color));
 
-	list_add_tail(&vma->vm_link, &vma->vm->bound_list);
-
 	if (vma->obj) {
-		atomic_inc(&vma->obj->bind_count);
-		assert_bind_count(vma->obj);
+		struct drm_i915_gem_object *obj = vma->obj;
+
+		atomic_inc(&obj->bind_count);
+		assert_bind_count(obj);
 	}
+	list_add_tail(&vma->vm_link, &vma->vm->bound_list);
 
 	return 0;
 }
 
 static void
-i915_vma_remove(struct i915_vma *vma)
+i915_vma_detach(struct i915_vma *vma)
 {
 	GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
 	GEM_BUG_ON(i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND));
 
-	list_del(&vma->vm_link);
-
 	/*
-	 * Since the unbound list is global, only move to that list if
-	 * no more VMAs exist.
+	 * And finally now the object is completely decoupled from this
+	 * vma, we can drop its hold on the backing storage and allow
+	 * it to be reaped by the shrinker.
 	 */
+	list_del(&vma->vm_link);
 	if (vma->obj) {
 		struct drm_i915_gem_object *obj = vma->obj;
 
-		/*
-		 * And finally now the object is completely decoupled from this
-		 * vma, we can drop its hold on the backing storage and allow
-		 * it to be reaped by the shrinker.
-		 */
-		atomic_dec(&obj->bind_count);
 		assert_bind_count(obj);
+		atomic_dec(&obj->bind_count);
 	}
-
-	drm_mm_remove_node(&vma->node);
 }
 
 static bool try_qad_pin(struct i915_vma *vma, unsigned int flags)
@@ -929,8 +923,10 @@ int i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
 	GEM_BUG_ON(i915_vma_misplaced(vma, size, alignment, flags));
 
 err_remove:
-	if (!i915_vma_is_bound(vma, I915_VMA_BIND_MASK))
-		i915_vma_remove(vma);
+	if (!i915_vma_is_bound(vma, I915_VMA_BIND_MASK)) {
+		i915_vma_detach(vma);
+		drm_mm_remove_node(&vma->node);
+	}
 err_active:
 	i915_active_release(&vma->active);
 err_unlock:
@@ -1187,9 +1183,10 @@ int __i915_vma_unbind(struct i915_vma *vma)
 	}
 	atomic_and(~(I915_VMA_BIND_MASK | I915_VMA_ERROR), &vma->flags);
 
+	i915_vma_detach(vma);
 	vma_unbind_pages(vma);
-	i915_vma_remove(vma);
 
+	drm_mm_remove_node(&vma->node); /* pairs with i915_vma_destroy() */
 	return 0;
 }
 
-- 
2.24.0.rc1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2019-11-01  1:22 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-30 19:21 [PATCH 01/11] drm/i915: Split detaching and removing the vma Chris Wilson
2019-10-30 19:21 ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 02/11] drm/i915/gt: Call intel_gt_sanitize() directly Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 03/11] drm/i915/gem: Leave reloading kernel context on resume to GT Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 04/11] drm/i915/gt: Move user_forcewake application " Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 05/11] drm/i915: Defer rc6 shutdown to suspend_late Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 06/11] drm/i915: Drop GEM context as a direct link from i915_request Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 07/11] drm/i915: Push the use-semaphore marker onto the intel_context Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 08/11] drm/i915: Remove i915->kernel_context Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 09/11] drm/i915/gt: Defer engine registration until fully initialised Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 10/11] drm/i915/gt: Pull timeline initialise to intel_gt_init_early Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 19:21 ` [PATCH 11/11] drm/i915: Move i915_gem_init_contexts() earlier Chris Wilson
2019-10-30 19:21   ` [Intel-gfx] " Chris Wilson
2019-10-30 21:19 ` ✓ Fi.CI.BAT: success for series starting with [01/11] drm/i915: Split detaching and removing the vma Patchwork
2019-10-30 21:19   ` [Intel-gfx] " Patchwork
2019-10-31 13:49 ` [PATCH 01/11] " Matthew Auld
2019-10-31 13:49   ` [Intel-gfx] " Matthew Auld
2019-11-01  1:22 ` ✗ Fi.CI.IGT: failure for series starting with [01/11] " Patchwork
2019-11-01  1:22   ` [Intel-gfx] " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox