Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org,
	Chris Wilson <ickle@braswell.alporthouse.com>
Subject: [igt-dev] [PATCH i-g-t] i915/gem_ctx_shared: Prebind both context images
Date: Sun,  1 Sep 2019 16:45:27 +0100	[thread overview]
Message-ID: <20190901154527.20817-1-chris@chris-wilson.co.uk> (raw)

If we are using an aliasing-ppgtt, the context images are in the same
virtual address space as our target objects. We have to be careful that
cloning and using a new context does not evict our unreferenced target
object. To avoid that, we first bind both context images while creating
the hole in the address space to ensure that the hole is still available
later on.

Signed-off-by: Chris Wilson <ickle@braswell.alporthouse.com>
---
 tests/i915/gem_ctx_shared.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index b073bdfc9..c9e7b8a1a 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -191,6 +191,7 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 		.buffer_count = 1,
 		.flags = ring,
 	};
+	uint32_t clone;
 	uint32_t scratch, *s;
 	uint32_t batch, cs[16];
 	uint64_t offset;
@@ -199,13 +200,18 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 	gem_require_ring(i915, ring);
 	igt_require(gem_can_store_dword(i915, ring));
 
+	clone = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0);
+
 	/* Find a hole big enough for both objects later */
-	scratch = gem_create(i915, 16384);
+	scratch = gem_create(i915, 64<<10);
 	gem_write(i915, scratch, 0, &bbe, sizeof(bbe));
 	obj.handle = scratch;
 	gem_execbuf(i915, &execbuf);
-	gem_close(i915, scratch);
 	obj.flags |= EXEC_OBJECT_PINNED; /* reuse this address */
+	execbuf.rsvd1 = clone; /* and bind the second context image */
+	gem_execbuf(i915, &execbuf);
+	execbuf.rsvd1 = 0;
+	gem_close(i915, scratch);
 
 	scratch = gem_create(i915, 4096);
 	s = gem_mmap__wc(i915, scratch, 0, 4096, PROT_WRITE);
@@ -241,7 +247,7 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 
 	obj.handle = batch;
 	obj.offset += 8192; /* make sure we don't cause an eviction! */
-	execbuf.rsvd1 = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0);
+	execbuf.rsvd1 = clone;
 	if (gen > 3 && gen < 6)
 		execbuf.flags |= I915_EXEC_SECURE;
 	gem_execbuf(i915, &execbuf);
@@ -253,7 +259,6 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 	execbuf.batch_start_offset = 64 * sizeof(s[0]);
 	gem_execbuf(i915, &execbuf);
 	igt_assert_eq_u64(obj.offset, offset);
-	gem_context_destroy(i915, execbuf.rsvd1);
 
 	gem_sync(i915, batch); /* write hazard lies */
 	gem_close(i915, batch);
@@ -268,6 +273,8 @@ static void exec_shared_gtt(int i915, unsigned int ring)
 
 	munmap(s, 4096);
 	gem_close(i915, scratch);
+
+	gem_context_destroy(i915, clone);
 }
 
 static int nop_sync(int i915, uint32_t ctx, unsigned int ring, int64_t timeout)
-- 
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-09-01 15:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-01 15:45 Chris Wilson [this message]
2019-09-01 16:31 ` [igt-dev] ✗ Fi.CI.BAT: failure for i915/gem_ctx_shared: Prebind both context images 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=20190901154527.20817-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=ickle@braswell.alporthouse.com \
    --cc=igt-dev@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox