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] drm/i915/selftests: Extend partial vma coverage to check parallel creation
Date: Tue, 16 Jan 2018 10:11:43 +0000	[thread overview]
Message-ID: <20180116101143.18481-1-chris@chris-wilson.co.uk> (raw)

One important use of partial vma is to provide mappable access to the
object while it is being used elsewhere (pinned entirely into the
unmappable portion of the Global GTT, i.e. for use as a display scanout).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_vma.c | 59 +++++++++++++++++++++++++++----
 1 file changed, 52 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c
index eb89e301b602..ea48bac16927 100644
--- a/drivers/gpu/drm/i915/selftests/i915_vma.c
+++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
@@ -606,11 +606,17 @@ static int igt_vma_partial(void *arg)
 	struct drm_i915_private *i915 = arg;
 	struct i915_address_space *vm = &i915->ggtt.base;
 	const unsigned int npages = 1021; /* prime! */
-	struct drm_i915_gem_object *obj;
+	struct drm_i915_gem_object *obj = NULL;
 	const struct phase {
 		const char *name;
+		unsigned int flags;
+#define CREATE		BIT(0)
+#define WHOLE		BIT(1)
 	} phases[] = {
-		{ "create" },
+		{ "create", CREATE },
+		{ "lookup" },
+		{ "whole", WHOLE },
+		{ "recreate", CREATE | WHOLE },
 		{ "lookup" },
 		{ },
 	}, *p;
@@ -618,17 +624,44 @@ static int igt_vma_partial(void *arg)
 	struct i915_vma *vma;
 	int err = -ENOMEM;
 
-	/* Create lots of different VMA for the object and check that
+	/*
+	 * Create lots of different VMA for the object and check that
 	 * we are returned the same VMA when we later request the same range.
 	 */
 
-	obj = i915_gem_object_create_internal(i915, npages*PAGE_SIZE);
-	if (IS_ERR(obj))
-		goto out;
-
 	for (p = phases; p->name; p++) { /* exercise both create/lookup */
 		unsigned int count, nvma;
 
+		if (p->flags & CREATE) {
+			if (obj)
+				i915_gem_object_put(obj);
+
+			obj = i915_gem_object_create_internal(i915,
+							      npages*PAGE_SIZE);
+			if (IS_ERR(obj))
+				goto out;
+		}
+
+		if (p->flags & WHOLE) {
+			/*
+			 * Make sure we can create mappable partial vma
+			 * while the whole object is in use elsewhere.
+			 */
+			vma = i915_vma_instance(obj, vm, NULL);
+			if (IS_ERR(vma)) {
+				err = PTR_ERR(vma);
+				goto out_object;
+			}
+
+			err = i915_vma_unbind(vma);
+			if (err)
+				goto out_object;
+
+			err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
+			if (err)
+				goto out_object;
+		}
+
 		nvma = 0;
 		for_each_prime_number_from(sz, 1, npages) {
 			for_each_prime_number_from(offset, 0, npages - sz) {
@@ -707,12 +740,24 @@ static int igt_vma_partial(void *arg)
 			err = -EINVAL;
 			goto out_object;
 		}
+
+		if (p->flags & WHOLE) {
+			vma = i915_vma_instance(obj, vm, NULL);
+			if (IS_ERR(vma)) {
+				err = PTR_ERR(vma);
+				goto out_object;
+			}
+
+			i915_vma_unpin(vma);
+		}
 	}
 
 out_object:
 	i915_gem_object_put(obj);
 out:
 	return err;
+#undef CREATE
+#undef WHOLE
 }
 
 int i915_vma_mock_selftests(void)
-- 
2.15.1

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

             reply	other threads:[~2018-01-16 10:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 10:11 Chris Wilson [this message]
2018-01-16 10:44 ` ✓ Fi.CI.BAT: success for drm/i915/selftests: Extend partial vma coverage to check parallel creation Patchwork
2018-01-16 11:56 ` ✓ Fi.CI.IGT: " Patchwork
2018-02-22  9:48 ` [PATCH] " Chris Wilson
2018-03-05 14:28   ` Joonas Lahtinen

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=20180116101143.18481-1-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.