[v3,3/3] tests: gem_exec_basic: add "exec-ctx" buffer execution demo test

Submitted by Andi Shyti on Nov. 26, 2018, 8:43 p.m.

Details

Message ID 20181126204349.6739-4-andi.shyti@intel.com
State New
Series "new engine discovery interface"
Headers show

Commit Message

Andi Shyti Nov. 26, 2018, 8:43 p.m.
The "exec-ctx" is a demo subtest inserted in the gem_exec_basic
test. The main scope is to demonstrate an alternative way for
querying engines as implemented in the new API in commit 87079e04
("lib: implement new engine discovery interface").

The "exec-ctx" subtest simply gets the list of engines, binds
them to a context and executes a buffer. This is done through a
new "for_each_engine_ctx" loop which iterates through the
engines.

Signed-off-by: Andi Shyti <andi.shyti@intel.com>
---
 tests/i915/gem_exec_basic.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/i915/gem_exec_basic.c b/tests/i915/gem_exec_basic.c
index dcb83864..70128547 100644
--- a/tests/i915/gem_exec_basic.c
+++ b/tests/i915/gem_exec_basic.c
@@ -114,6 +114,22 @@  static void gtt(int fd, unsigned ring)
 	munmap(execbuf, 4096);
 }
 
+static void execbuf_in_ctx(int fd, uint32_t engine, uint32_t ctx, uint32_t handle)
+{
+	struct drm_i915_gem_exec_object2 exec = {
+		.handle = handle,
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&exec),
+		.buffer_count = 1,
+		.flags = engine,
+		.rsvd1 = ctx & I915_EXEC_CONTEXT_ID_MASK,
+	};
+
+	igt_assert(execbuf.rsvd1);
+	gem_execbuf(fd, &execbuf);
+}
+
 igt_main
 {
 	const struct intel_execution_engine *e;
@@ -135,6 +151,22 @@  igt_main
 			gtt(fd, e->exec_id | e->flags);
 	}
 
+	igt_subtest("exec-ctx") {
+		uint32_t ctx_id, r;
+		uint32_t handle;
+		uint32_t bbend = MI_BATCH_BUFFER_END;
+
+		ctx_id = gem_context_create(fd);
+		handle = gem_create(fd, 4096);
+		gem_write(fd, handle, 0, &bbend, sizeof(bbend));
+
+		for_each_engine_ctx(fd, ctx_id, r)
+			execbuf_in_ctx(fd, r, ctx_id, handle);
+
+		gem_close(fd, handle);
+		gem_context_destroy(fd, ctx_id);
+	}
+
 	igt_fixture {
 		igt_stop_hang_detector();
 		close(fd);

Comments

Chris Wilson Nov. 26, 2018, 9:10 p.m.
Quoting Andi Shyti (2018-11-26 20:43:49)
> The "exec-ctx" is a demo subtest inserted in the gem_exec_basic
> test. The main scope is to demonstrate an alternative way for
> querying engines as implemented in the new API in commit 87079e04
> ("lib: implement new engine discovery interface").
> 
> The "exec-ctx" subtest simply gets the list of engines, binds
> them to a context and executes a buffer. This is done through a
> new "for_each_engine_ctx" loop which iterates through the
> engines.

See gem_ctx_engines for the intent of validating the ctx->engines[] api.
-Chris
Tvrtko Ursulin Nov. 27, 2018, 11:40 a.m.
On 26/11/2018 21:10, Chris Wilson wrote:
> Quoting Andi Shyti (2018-11-26 20:43:49)
>> The "exec-ctx" is a demo subtest inserted in the gem_exec_basic
>> test. The main scope is to demonstrate an alternative way for
>> querying engines as implemented in the new API in commit 87079e04
>> ("lib: implement new engine discovery interface").
>>
>> The "exec-ctx" subtest simply gets the list of engines, binds
>> them to a context and executes a buffer. This is done through a
>> new "for_each_engine_ctx" loop which iterates through the
>> engines.
> 
> See gem_ctx_engines for the intent of validating the ctx->engines[] api.

My bad, I wanted to suggest a simplest possible test which currently 
uses for_each_physical_engine, but gem_exec_basic is obviously not it.

Maybe gem_exec_nop?

Regards,

Tvrtko