All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/vma: Move the bind_count vs pin_count assertion to a helper
@ 2018-06-05  9:34 Chris Wilson
  2018-06-05  9:38 ` Mika Kuoppala
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Chris Wilson @ 2018-06-05  9:34 UTC (permalink / raw)
  To: intel-gfx

To spare ourselves a long line later, refactor the repeated check of
bind_count vs pin_count to a helper.

Suggested-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 9324d476e0a7..0b3de2f19e1c 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -459,6 +459,17 @@ bool i915_gem_valid_gtt_space(struct i915_vma *vma, unsigned long cache_level)
 	return true;
 }
 
+static void assert_bind_count(struct drm_i915_gem_object *obj)
+{
+	/*
+	 * Combine the assertion that the object is bound and that we have
+	 * pinned its pages. But we should never have pinned the pages
+	 * more than we have bound the object. (This, of course, assumes that
+	 * no one else decides to pin the pages!)
+	 */
+	GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
+}
+
 /**
  * i915_vma_insert - finds a slot for the vma in its address space
  * @vma: the vma
@@ -595,7 +606,7 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
 	obj->bind_count++;
 	spin_unlock(&dev_priv->mm.obj_lock);
 
-	GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
+	assert_bind_count(obj);
 
 	return 0;
 
@@ -633,7 +644,7 @@ i915_vma_remove(struct i915_vma *vma)
 	 * reaped by the shrinker.
 	 */
 	i915_gem_object_unpin_pages(obj);
-	GEM_BUG_ON(atomic_read(&obj->mm.pages_pin_count) < obj->bind_count);
+	assert_bind_count(obj);
 }
 
 int __i915_vma_do_pin(struct i915_vma *vma,
-- 
2.17.1

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

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

end of thread, other threads:[~2018-06-05 12:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05  9:34 [PATCH] drm/i915/vma: Move the bind_count vs pin_count assertion to a helper Chris Wilson
2018-06-05  9:38 ` Mika Kuoppala
2018-06-05  9:40 ` Chris Wilson
2018-06-05  9:41 ` [PATCH v2] " Chris Wilson
2018-06-05 10:22   ` Mika Kuoppala
2018-06-05 11:37 ` ✓ Fi.CI.BAT: success for drm/i915/vma: Move the bind_count vs pin_count assertion to a helper (rev2) Patchwork
2018-06-05 12:26 ` ✗ Fi.CI.IGT: failure " Patchwork

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.