From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Andi Shyti <andi.shyti@intel.com>,
IGT dev <igt-dev@lists.freedesktop.org>
Cc: Andi Shyti <andi@etezian.org>, Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [igt-dev] [RFC v2 3/3] tests: gem_gem_query_engines_demo: create test
Date: Thu, 22 Nov 2018 12:25:16 +0000 [thread overview]
Message-ID: <551db064-b7bd-22cb-f360-764dfeac623f@linux.intel.com> (raw)
In-Reply-To: <20181121161023.1603-4-andi.shyti@intel.com>
On 21/11/2018 16:10, Andi Shyti wrote:
> The "gem_query_engines_demo" is a demo test used to show how to
> use the new API in commit 65d2f30d ("lib: implement new engine
> discovery interface").
>
> The new API has uses two new ioctls to interrogate the driver
> about the engines.
>
> The test simply gets the engines and executes a buffer.
>
> Signed-off-by: Andi Shyti <andi.shyti@intel.com>
> ---
> tests/Makefile.sources | 3 ++
> tests/i915/gem_query_engines_demo.c | 56 +++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 3 files changed, 60 insertions(+)
> create mode 100644 tests/i915/gem_query_engines_demo.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 5620c1d6..e91d15f2 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -494,6 +494,9 @@ i915_selftest_SOURCES = i915/selftest.c
> TESTS_progs += i915_suspend
> i915_suspend_SOURCES = i915/suspend.c
>
> +TESTS_progs += gem_query_engines_demo
> +discover_engines_SOURCES = i915/gem_query_engines_demo.c
> +
> TESTS_progs_X = gem_concurrent_all
> gem_concurrent_all_SOURCES = i915/gem_concurrent_all.c
>
> diff --git a/tests/i915/gem_query_engines_demo.c b/tests/i915/gem_query_engines_demo.c
> new file mode 100644
> index 00000000..dc6b031e
> --- /dev/null
> +++ b/tests/i915/gem_query_engines_demo.c
> @@ -0,0 +1,56 @@
> +#include "igt.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <inttypes.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include <sys/time.h>
> +#include <time.h>
> +#include "drm.h"
Feels like to many includes, evidence of copy & paste? :) And license
header needs to be added.
> +
> +static void execbuf_in_ctx(int fd, uint32_t engine, uint32_t ctx, uint32_t handle)
I think plain unsigned int for engine.
> +{
> + 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,
> + };
Maybe add igt_assert(!(engine & I915_EXEC_RING_MASK)).
> +
> + gem_execbuf(fd, &execbuf);
> +}
> +
> +igt_main
> +{
> + int fd;
> + uint32_t ctx_id, e;
> + uint32_t handle;
> + uint32_t bbend = MI_BATCH_BUFFER_END;
> +
> + igt_fixture {
> + fd = drm_open_driver(DRIVER_INTEL);
> + ctx_id = gem_context_create(fd);
> +
> + handle = gem_create(fd, 4096);
> + gem_write(fd, handle, 0, &bbend, sizeof(bbend));
> + }
> +
> + igt_subtest("basic") {
> + for_each_engine_ctx(fd, ctx_id, e)
> + execbuf_in_ctx(fd, e, ctx_id, handle);
> + }
> +
> + igt_fixture {
> + gem_close(fd, handle);
> + gem_context_destroy(fd, ctx_id);
> + close(fd);
> + }
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 52f91a22..0c091cf3 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -217,6 +217,7 @@ gem_progs = [
> 'gem_wait',
> 'gem_workarounds',
> 'gem_write_read_ring_switch',
> + 'gem_query_engines_demo',
> ]
>
> gen3_progs = [
>
I'd be tempted to move this whole new test into gem_exec_basic. Either
to replace the current loop or add new noop based subtests. I suspect
Chris will have a stronger opinion on which option of the two.
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-11-22 12:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 16:10 [igt-dev] [RFC v2 0/3] new engine discovery interface Andi Shyti
2018-11-21 16:10 ` [igt-dev] [RFC v2 1/3] include/drm-uapi: import i915_drm.h header file Andi Shyti
2018-11-21 16:10 ` [igt-dev] [RFC v2 2/3] lib: implement new engine discovery interface Andi Shyti
2018-11-22 12:14 ` Tvrtko Ursulin
2018-11-22 13:28 ` Andi Shyti
2018-11-26 9:07 ` Andi Shyti
2018-11-26 9:27 ` Tvrtko Ursulin
2018-11-21 16:10 ` [igt-dev] [RFC v2 3/3] tests: gem_gem_query_engines_demo: create test Andi Shyti
2018-11-22 12:25 ` Tvrtko Ursulin [this message]
2018-11-21 16:51 ` [igt-dev] ✓ Fi.CI.BAT: success for new engine discovery interface (rev2) Patchwork
2018-11-22 2:45 ` [igt-dev] ✓ Fi.CI.IGT: " 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=551db064-b7bd-22cb-f360-764dfeac623f@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=andi.shyti@intel.com \
--cc=andi@etezian.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=tvrtko.ursulin@intel.com \
/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