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: [PATCH 29/37] drm/i915: Fill different pages of the GTT
Date: Wed, 11 Jan 2017 21:09:29 +0000	[thread overview]
Message-ID: <20170111210937.29252-30-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20170111210937.29252-1-chris@chris-wilson.co.uk>

Exercise filling different pages of the GTT

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

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 8ed88f438eef..68f7bfb7502e 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -231,6 +231,65 @@ static int fill_hole(struct drm_i915_private *i915,
 	return err;
 }
 
+static int walk_hole(struct drm_i915_private *i915,
+		     struct i915_address_space *vm,
+		     u64 hole_start, u64 hole_end)
+{
+	I915_SELFTEST_TIMEOUT(end_time);
+	struct drm_i915_gem_object *obj;
+	struct i915_vma *vma;
+	u64 addr;
+	int err;
+
+	obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
+	if (IS_ERR(obj))
+		return PTR_ERR(obj);
+
+	vma = vma_lookup(obj, vm);
+	if (IS_ERR(vma)) {
+		err = PTR_ERR(vma);
+		goto err;
+	}
+
+	for (addr = hole_start; addr < hole_end; addr += PAGE_SIZE) {
+		cond_resched();
+
+		err = i915_vma_pin(vma, 0, 0,
+				   addr | PIN_OFFSET_FIXED | PIN_USER);
+		if (err) {
+			pr_err("Walk bind failed at %llx with err=%d\n",
+			       addr, err);
+			break;
+		}
+		i915_vma_unpin(vma);
+
+		if (!drm_mm_node_allocated(&vma->node) ||
+		    i915_vma_misplaced(vma, 0, 0, addr | PIN_OFFSET_FIXED)) {
+			pr_err("Walk incorrect at %llx\n", addr);
+			err = -EINVAL;
+			break;
+		}
+
+		err = i915_vma_unbind(vma);
+		if (err) {
+			pr_err("Walk unbind failed at %llx with err=%d\n",
+			       addr, err);
+			break;
+		}
+
+		if (time_after(jiffies, end_time)) {
+			pr_warn("Walk timed out at %llx\n", addr);
+			break;
+		}
+	}
+
+	if (!i915_vma_is_ggtt(vma))
+		i915_vma_close(vma);
+err:
+	i915_gem_object_put(obj);
+	return err;
+}
+
 static int igt_ppgtt_fill(void *arg)
 {
 	struct drm_i915_private *dev_priv = arg;
@@ -264,6 +323,39 @@ static int igt_ppgtt_fill(void *arg)
 	return err;
 }
 
+static int igt_ppgtt_walk(void *arg)
+{
+	struct drm_i915_private *dev_priv = arg;
+	struct drm_file *file;
+	struct i915_hw_ppgtt *ppgtt;
+	int err;
+
+	if (!USES_FULL_PPGTT(dev_priv))
+		return 0;
+
+	file = fake_file(dev_priv);
+	if (IS_ERR(file))
+		return PTR_ERR(file);
+
+	mutex_lock(&dev_priv->drm.struct_mutex);
+	ppgtt = i915_ppgtt_create(dev_priv, file->driver_priv, "mock");
+	if (IS_ERR(ppgtt)) {
+		err = PTR_ERR(ppgtt);
+		goto err_unlock;
+	}
+	GEM_BUG_ON(ppgtt->base.total & ~PAGE_MASK);
+
+	err = walk_hole(dev_priv, &ppgtt->base, 0, ppgtt->base.total);
+
+	i915_ppgtt_close(&ppgtt->base);
+	i915_ppgtt_put(ppgtt);
+err_unlock:
+	mutex_unlock(&dev_priv->drm.struct_mutex);
+
+	fake_file_free(dev_priv, file);
+	return err;
+}
+
 static int igt_ggtt_fill(void *arg)
 {
 	struct drm_i915_private *i915 = arg;
@@ -300,11 +392,49 @@ static int igt_ggtt_fill(void *arg)
 	return err;
 }
 
+static int igt_ggtt_walk(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	struct i915_ggtt *ggtt = &i915->ggtt;
+	u64 hole_start = U64_MAX, hole_end = 0, hole_size = 0;
+	u64 this_start, this_end;
+	struct drm_mm_node *node;
+	int err;
+
+	GEM_BUG_ON(ggtt->base.total & ~PAGE_MASK);
+
+	mutex_lock(&i915->drm.struct_mutex);
+	drm_mm_for_each_hole(node, &ggtt->base.mm, this_start, this_end) {
+		u64 this_size;
+
+		if (ggtt->base.mm.color_adjust)
+			ggtt->base. mm.color_adjust(node, 0,
+						    &this_start, &this_end);
+
+		this_size = this_end - this_start;
+		if (this_size > hole_size) {
+			hole_size = this_size;
+			hole_start = this_start;
+			hole_end = this_end;
+		}
+	}
+	pr_info("Found GGTT hole [%llx, %llx], size %llx\n",
+		hole_start, hole_end, hole_size);
+	GEM_BUG_ON(hole_start >= hole_end);
+
+	err = walk_hole(i915, &ggtt->base, hole_start, hole_end);
+	mutex_unlock(&i915->drm.struct_mutex);
+
+	return err;
+}
+
 int i915_gem_gtt_live_selftests(struct drm_i915_private *i915)
 {
 	static const struct i915_subtest tests[] = {
 		SUBTEST(igt_ppgtt_alloc),
+		SUBTEST(igt_ppgtt_walk),
 		SUBTEST(igt_ppgtt_fill),
+		SUBTEST(igt_ggtt_walk),
 		SUBTEST(igt_ggtt_fill),
 	};
 
-- 
2.11.0

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

  parent reply	other threads:[~2017-01-11 21:10 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 21:09 Selftests Chris Wilson
2017-01-11 21:09 ` [PATCH 01/37] drm: Provide a driver hook for drm_dev_release() Chris Wilson
2017-01-11 21:09 ` [PATCH 02/37] drm/i915: Provide a hook for selftests Chris Wilson
2017-01-12  7:29   ` Tvrtko Ursulin
2017-01-12  7:40     ` Chris Wilson
2017-01-13  8:31   ` Chris Wilson
2017-01-13 10:12     ` Tvrtko Ursulin
2017-01-13 10:22       ` Chris Wilson
2017-01-13 10:42         ` Tvrtko Ursulin
2017-01-11 21:09 ` [PATCH 03/37] drm/i915: Add some selftests for sg_table manipulation Chris Wilson
2017-01-12 10:56   ` Tvrtko Ursulin
2017-01-12 11:14     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 04/37] drm/i915: Add unit tests for the breadcrumb rbtree, insert/remove Chris Wilson
2017-01-11 21:09 ` [PATCH 05/37] drm/i915: Add unit tests for the breadcrumb rbtree, completion Chris Wilson
2017-01-11 21:09 ` [PATCH 06/37] drm/i915: Add unit tests for the breadcrumb rbtree, wakeups Chris Wilson
2017-01-12 11:11   ` Tvrtko Ursulin
2017-01-12 14:37     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 07/37] drm/i915: Mock the GEM device for self-testing Chris Wilson
2017-01-11 21:09 ` [PATCH 08/37] drm/i915: Mock a GGTT " Chris Wilson
2017-01-11 21:09 ` [PATCH 09/37] drm/i915: Mock infrastructure for request emission Chris Wilson
2017-01-12 13:11   ` Tvrtko Ursulin
2017-01-12 13:27     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 10/37] drm/i915: Create a fake object for testing huge allocations Chris Wilson
2017-01-12 10:56   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 11/37] drm/i915: Add selftests for i915_gem_request Chris Wilson
2017-01-12 11:20   ` Tvrtko Ursulin
2017-01-12 11:32     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 12/37] drm/i915: Add a simple request selftest for waiting Chris Wilson
2017-01-12 11:25   ` Tvrtko Ursulin
2017-01-11 21:09 ` [PATCH 13/37] drm/i915: Add a simple fence selftest to i915_gem_request Chris Wilson
2017-01-11 21:09 ` [PATCH 14/37] drm/i915: Simple selftest to exercise live requests Chris Wilson
2017-01-12 12:10   ` Tvrtko Ursulin
2017-01-12 12:20     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 15/37] drm/i915: Add selftests for object allocation, phys Chris Wilson
2017-01-11 21:09 ` [PATCH 16/37] drm/i915: Add a live seftest for GEM objects Chris Wilson
2017-01-12 11:17   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 17/37] drm/i915: Test partial mappings Chris Wilson
2017-01-16 22:05   ` Matthew Auld
2017-01-16 22:25     ` Chris Wilson
2017-01-17 12:12   ` Matthew Auld
2017-01-17 12:29     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 18/37] drm/i915: Test exhaustion of the mmap space Chris Wilson
2017-01-12 17:29   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 19/37] drm/i915: Test coherency of and barriers between cache domains Chris Wilson
2017-01-13 11:44   ` Matthew Auld
2017-01-13 14:13     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 20/37] drm/i915: Move uncore selfchecks to live selftest infrastructure Chris Wilson
2017-01-11 21:09 ` [PATCH 21/37] drm/i915: Test all fw tables during mock selftests Chris Wilson
2017-01-11 21:09 ` [PATCH 22/37] drm/i915: Sanity check all registers for matching fw domains Chris Wilson
2017-01-11 21:09 ` [PATCH 23/37] drm/i915: Add some mock tests for dmabuf interop Chris Wilson
2017-01-11 21:09 ` [PATCH 24/37] drm/i915: Add initial selftests for i915_gem_gtt Chris Wilson
2017-01-11 21:09 ` [PATCH 25/37] drm/i915: Move i915_ppgtt_close() into i915_gem_gtt.c Chris Wilson
2017-01-12 12:43   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 26/37] drm/i915: Assert that we have allocated the drm_mm_node upon pinning Chris Wilson
2017-01-12 12:45   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 27/37] drm/i915: Exercising filling the top/bottom portions of the ppgtt Chris Wilson
2017-01-12 13:32   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 28/37] drm/i915: Exercising filling the top/bottom portions of the global GTT Chris Wilson
2017-01-12 14:05   ` Joonas Lahtinen
2017-01-11 21:09 ` Chris Wilson [this message]
2017-01-13  7:47   ` [PATCH 29/37] drm/i915: Fill different pages of the GTT Joonas Lahtinen
2017-01-13 20:45     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 30/37] drm/i915: Exercise filling and removing random ranges from the live GTT Chris Wilson
2017-01-13  8:59   ` Joonas Lahtinen
2017-01-13  9:08     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 31/37] drm/i915: Test creation of VMA Chris Wilson
2017-01-13 12:28   ` Joonas Lahtinen
2017-01-13 12:50     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 32/37] drm/i915: Exercise i915_vma_pin/i915_vma_insert Chris Wilson
2017-01-13 12:49   ` Joonas Lahtinen
2017-01-13 12:57     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 33/37] drm/i915: Verify page layout for rotated VMA Chris Wilson
2017-01-12 17:41   ` Tvrtko Ursulin
2017-01-11 21:09 ` [PATCH 34/37] drm/i915: Test creation of partial VMA Chris Wilson
2017-01-13 13:10   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 35/37] drm/i915: Live testing for context execution Chris Wilson
2017-01-13 14:28   ` Joonas Lahtinen
2017-01-13 18:35     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 36/37] drm/i915: Initial selftests for exercising eviction Chris Wilson
2017-01-11 21:09 ` [PATCH 37/37] drm/i915: Add initial selftests for hang detection and resets Chris Wilson
2017-01-11 22:23 ` ✓ Fi.CI.BAT: success for series starting with [01/37] drm: Provide a driver hook for drm_dev_release() 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=20170111210937.29252-30-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.