[i-g-t,6/6] i915/gem_softpin: Active rebinds
diff mbox series

Message ID 20200710093234.1438712-6-chris@chris-wilson.co.uk
State New
Headers show
Series
  • [i-g-t,1/6] lib/i915: Report unknown device as the future
Related show

Commit Message

Chris Wilson July 10, 2020, 9:32 a.m. UTC
Verify that we do not block userspace [controlling fence progress] if it
requires vma recycling.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_softpin.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Patch
diff mbox series

diff --git a/tests/i915/gem_softpin.c b/tests/i915/gem_softpin.c
index 202abdd88..55ceb1bf2 100644
--- a/tests/i915/gem_softpin.c
+++ b/tests/i915/gem_softpin.c
@@ -263,6 +263,33 @@  static void test_reverse(int i915)
 	gem_close(i915, handle);
 }
 
+static void test_active(int i915)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	struct drm_i915_gem_exec_object2 obj = {
+		.handle = gem_create(i915, 4096),
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&obj),
+		.buffer_count = 1,
+	};
+	igt_spin_t *spin;
+
+	gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe));
+
+	/* Make a busy spot */
+	spin = igt_spin_new(i915);
+
+	/* Reuse it for ourselves */
+	obj.offset = spin->obj[IGT_SPIN_BATCH].offset;
+	obj.flags = EXEC_OBJECT_PINNED;
+	gem_execbuf(i915, &execbuf);
+	igt_assert_eq_u64(obj.offset, spin->obj[IGT_SPIN_BATCH].offset);
+
+	gem_close(i915, obj.handle);
+	igt_spin_free(i915, spin);
+}
+
 static uint64_t busy_batch(int fd)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -565,6 +592,8 @@  igt_main
 		test_overlap(fd);
 	igt_subtest("reverse")
 		test_reverse(fd);
+	igt_subtest("active")
+		test_active(fd);
 
 	igt_subtest("noreloc")
 		test_noreloc(fd, NOSLEEP, 0);