public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] i915/gem_ctx_shared: Prebind both context images
@ 2019-09-01 15:45 Chris Wilson
  2019-09-01 16:31 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2019-09-01 15:45 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Chris Wilson

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

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

end of thread, other threads:[~2019-09-01 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-01 15:45 [igt-dev] [PATCH i-g-t] i915/gem_ctx_shared: Prebind both context images Chris Wilson
2019-09-01 16:31 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork

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