Re: [igt-dev] [RFC v2 06/43] test/prime_vgem: use the gem_engine_topology library

Chris Wilson
2019-06-21T10:08:34Z

Quoting Ramalingam C (2019-06-21 11:03:08)
> Replace the legacy for_each_engine* defines with the ones
> implemented in the gem_engine_topology library.
>
> v2:
> helper for getting the execbuf_flag from class is used.
>
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> ---
> tests/prime_vgem.c | 72 ++++++++++++++++++++++------------------------
> 1 file changed, 34 insertions(+), 38 deletions(-)
>
> diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
> index 69ae8c9b0710..030ca39de08c 100644
> --- a/tests/prime_vgem.c
> +++ b/tests/prime_vgem.c
> @@ -325,7 +325,7 @@ static bool prime_busy(int fd, bool excl)
> return poll(&pfd, 1, 0) == 0;
> }
>
> -static void work(int i915, int dmabuf, unsigned ring, uint32_t flags)
> +static void work(int i915, int dmabuf, const struct intel_execution_engine2 *e)
> {
> const int SCRATCH = 0;
> const int BATCH = 1;
> @@ -341,7 +341,9 @@ static void work(int i915, int dmabuf, unsigned ring, uint32_t flags)
> memset(&execbuf, 0, sizeof(execbuf));
> execbuf.buffers_ptr = (uintptr_t)obj;
> execbuf.buffer_count = 2;
> - execbuf.flags = ring | flags;
> + execbuf.flags = e ? e->flags :
> + gem_engine_class_to_execbuf_flags(i915, 0,
> + I915_ENGINE_CLASS_RENDER);
> if (gen < 6)
> execbuf.flags |= I915_EXEC_SECURE;
>
> @@ -420,7 +422,7 @@ static void work(int i915, int dmabuf, unsigned ring, uint32_t flags)
> igt_assert(read_busy && write_busy);
> }
>
> -static void test_busy(int i915, int vgem, unsigned ring, uint32_t flags)
> +static void test_busy(int i915, int vgem, const struct intel_execution_engine2 *e)
> {
> struct vgem_bo scratch;
> struct timespec tv;
> @@ -434,7 +436,7 @@ static void test_busy(int i915, int vgem, unsigned ring, uint32_t flags)
> vgem_create(vgem, &scratch);
> dmabuf = prime_handle_to_fd(vgem, scratch.handle);
>
> - work(i915, dmabuf, ring, flags);
> + work(i915, dmabuf, e);
>
> /* Calling busy in a loop should be enough to flush the rendering */
> memset(&tv, 0, sizeof(tv));
> @@ -450,7 +452,8 @@ static void test_busy(int i915, int vgem, unsigned ring, uint32_t flags)
> close(dmabuf);
> }
>
> -static void test_wait(int i915, int vgem, unsigned ring, uint32_t flags)
> +static void test_wait(int i915, int vgem,
> + const struct intel_execution_engine2 *e)
> {
> struct vgem_bo scratch;
> struct pollfd pfd;
> @@ -463,7 +466,7 @@ static void test_wait(int i915, int vgem, unsigned ring, uint32_t flags)
> vgem_create(vgem, &scratch);
> pfd.fd = prime_handle_to_fd(vgem, scratch.handle);
>
> - work(i915, pfd.fd, ring, flags);
> + work(i915, pfd.fd, e);
>
> pfd.events = POLLIN;
> igt_assert_eq(poll(&pfd, 1, 10000), 1);
> @@ -477,7 +480,7 @@ static void test_wait(int i915, int vgem, unsigned ring, uint32_t flags)
> close(pfd.fd);
> }
>
> -static void test_sync(int i915, int vgem, unsigned ring, uint32_t flags)
> +static void test_sync(int i915, int vgem, const struct intel_execution_engine2 *e)
> {
> struct vgem_bo scratch;
> uint32_t *ptr;
> @@ -494,7 +497,7 @@ static void test_sync(int i915, int vgem, unsigned ring, uint32_t flags)
> igt_assert(ptr != MAP_FAILED);
> gem_close(vgem, scratch.handle);
>
> - work(i915, dmabuf, ring, flags);
> + work(i915, dmabuf, e);
>
> prime_sync_start(dmabuf, false);
> for (i = 0; i < 1024; i++)
> @@ -506,7 +509,8 @@ static void test_sync(int i915, int vgem, unsigned ring, uint32_t flags)
> munmap(ptr, scratch.size);
> }
>
> -static void test_fence_wait(int i915, int vgem, unsigned ring, unsigned flags)
> +static void test_fence_wait(int i915, int vgem,
> + const struct intel_execution_engine2 *e)
> {
> struct vgem_bo scratch;
> uint32_t fence;
> @@ -527,7 +531,7 @@ static void test_fence_wait(int i915, int vgem, unsigned ring, unsigned flags)
> igt_assert(ptr != MAP_FAILED);
>
> igt_fork(child, 1)
> - work(i915, dmabuf, ring, flags);
> + work(i915, dmabuf, e);
>
> sleep(1);
>
> @@ -568,7 +572,7 @@ static void test_fence_hang(int i915, int vgem, unsigned flags)
> igt_assert(ptr != MAP_FAILED);
> gem_close(vgem, scratch.handle);
>
> - work(i915, dmabuf, I915_EXEC_DEFAULT, 0);
> + work(i915, dmabuf, NULL);
>
> /* The work should have been cancelled */
>
> @@ -811,7 +815,7 @@ static void test_flip(int i915, int vgem, unsigned hang)
>
> igt_main
> {
> - const struct intel_execution_engine *e;
> + const struct intel_execution_engine2 *e;
> int i915 = -1;
> int vgem = -1;
>
> @@ -840,39 +844,32 @@ igt_main
> igt_subtest("coherency-gtt")
> test_gtt_interleaved(vgem, i915);
>
> - for (e = intel_execution_engines; e->name; e++) {
> + __for_each_physical_engine(i915, e) {
> igt_subtest_f("%ssync-%s",
> - e->exec_id == 0 ? "basic-" : "",
> - e->name) {
> - gem_require_ring(i915, e->exec_id | e->flags);
> - igt_require(gem_can_store_dword(i915, e->exec_id | e->flags));
> + e->class == I915_ENGINE_CLASS_RENDER ?
> + "basic-" : "", e->name) {

Nak. Please restore this to using EXEC_DEFAULT explicitly.
-Chris