Re: [Intel-gfx] [PATCH i-g-t 2/3] tests/gem_reset_stats: test no progress detection

2016-12-01 Thread Chris Wilson
On Thu, Dec 01, 2016 at 03:31:44PM +0200, Mika Kuoppala wrote:
> If seqno is not incrementing but head is moving,
> we declare hang but much slower. Add test to check
> that this mechanism is working properly.
> 
> Signed-off-by: Mika Kuoppala 
> ---
>  tests/gem_reset_stats.c | 75 
> +
>  1 file changed, 75 insertions(+)
> 
> diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
> index 2718a33..669a30a 100644
> --- a/tests/gem_reset_stats.c
> +++ b/tests/gem_reset_stats.c
> @@ -711,6 +711,75 @@ static void defer_hangcheck(const struct 
> intel_execution_engine *engine)
>   close(fd);
>  }
>  
> +static void test_no_seqno_progress(const struct intel_execution_engine 
> *engine,
> +const bool use_ctx)
> +{
> + struct drm_i915_gem_relocation_entry reloc;
> + struct drm_i915_gem_execbuffer2 eb;
> + struct drm_i915_gem_exec_object2 exec;

I would advise using obj instead of exec

> + struct local_drm_i915_reset_stats before, after;
> + int len = 0, ctx, fd;
> + uint32_t batch[16*1024];

Not needed, see later.
#define BATCH_SIZE (16 << 10)

> + struct timespec ts_start;
> +
> + fd = drm_open_driver(DRIVER_INTEL);
> +
> + memset(, 0, sizeof(reloc));
> +memset(, 0, sizeof(exec));
> +memset(, 0, sizeof(eb));

> + memset(, 0, sizeof(batch));
> +
> + exec.handle = gem_create(fd, sizeof(batch));
> + exec.relocation_count = 1;
> +exec.relocs_ptr = (uintptr_t)
> +
> + igt_assert((int)exec.handle > 0);

Already asserted for you.

> +
> + if (use_ctx)
> + ctx = gem_context_create(fd);
> + else
> + ctx = 0;
> +
> + len = 2;
> + if (intel_gen(intel_get_drm_devid(fd)) >= 8)
> + len++;
> +
> + batch[sizeof(batch)/sizeof(uint32_t) - len] = MI_BATCH_BUFFER_START | 
> (len - 2);
> +gem_write(fd, exec.handle, 0, batch, sizeof(batch));

gem_write(fd, exec.handle, BATCH_SIZE - 16, , sizeof(cmd));

> +
> +reloc.offset = sizeof(batch) - ((len-1) * 4);

reloc.offset = BATCH_SIZE - 16 + sizeof(cmd);

> +reloc.delta = 0;
> +reloc.target_handle = exec.handle;
> +reloc.read_domains = I915_GEM_DOMAIN_COMMAND;

> + eb.buffers_ptr = (uintptr_t)
> + eb.buffer_count = 1;
> + eb.flags = engine->exec_id;
> +if (ctx)
> + i915_execbuffer2_set_context_id(eb, ctx);

eb.rsvd1 = ctx; It's perfectly fine to set it to zero.

> + igt_assert_eq(gem_reset_stats(fd, ctx, ), 0);
> +
> + clock_gettime(CLOCK_MONOTONIC, _start);

struct timespec ts = {};
igt_seconds_elapsed(_start)

> +
> + igt_assert_eq(0, __gem_execbuf(fd, ));

gem_execbuf();

> + igt_assert_lte(0, noop(fd, ctx, engine));

See earlier comments about noop.

> + gem_sync(fd, exec.handle);
> +
> + igt_assert_lte(0, noop(fd, ctx, engine));
> + igt_assert_eq(gem_reset_stats(fd, ctx, ), 0);
> +
> + sync_gpu();
> +
> + igt_assert(after.batch_active == before.batch_active + 1);

igt_assert_eq(after, before + 1);

> + gem_close(fd, exec.handle);
> + close(fd);
> +
> + igt_assert(igt_seconds_elapsed(_start) > 5);

You really want to demand a minimum time?

> + igt_assert(igt_seconds_elapsed(_start) < 15);

Play state thy sources. Upper bound should be closer to 120s.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t 2/3] tests/gem_reset_stats: test no progress detection

2016-12-01 Thread Mika Kuoppala
If seqno is not incrementing but head is moving,
we declare hang but much slower. Add test to check
that this mechanism is working properly.

Signed-off-by: Mika Kuoppala 
---
 tests/gem_reset_stats.c | 75 +
 1 file changed, 75 insertions(+)

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 2718a33..669a30a 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -711,6 +711,75 @@ static void defer_hangcheck(const struct 
intel_execution_engine *engine)
close(fd);
 }
 
+static void test_no_seqno_progress(const struct intel_execution_engine *engine,
+  const bool use_ctx)
+{
+   struct drm_i915_gem_relocation_entry reloc;
+   struct drm_i915_gem_execbuffer2 eb;
+   struct drm_i915_gem_exec_object2 exec;
+   struct local_drm_i915_reset_stats before, after;
+   int len = 0, ctx, fd;
+   uint32_t batch[16*1024];
+   struct timespec ts_start;
+
+   fd = drm_open_driver(DRIVER_INTEL);
+
+   memset(, 0, sizeof(reloc));
+memset(, 0, sizeof(exec));
+memset(, 0, sizeof(eb));
+   memset(, 0, sizeof(batch));
+
+   exec.handle = gem_create(fd, sizeof(batch));
+   exec.relocation_count = 1;
+exec.relocs_ptr = (uintptr_t)
+
+   igt_assert((int)exec.handle > 0);
+
+   if (use_ctx)
+   ctx = gem_context_create(fd);
+   else
+   ctx = 0;
+
+   len = 2;
+   if (intel_gen(intel_get_drm_devid(fd)) >= 8)
+   len++;
+
+   batch[sizeof(batch)/sizeof(uint32_t) - len] = MI_BATCH_BUFFER_START | 
(len - 2);
+gem_write(fd, exec.handle, 0, batch, sizeof(batch));
+
+reloc.offset = sizeof(batch) - ((len-1) * 4);
+reloc.delta = 0;
+reloc.target_handle = exec.handle;
+reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+
+   eb.buffers_ptr = (uintptr_t)
+   eb.buffer_count = 1;
+   eb.flags = engine->exec_id;
+if (ctx)
+   i915_execbuffer2_set_context_id(eb, ctx);
+
+   igt_assert_eq(gem_reset_stats(fd, ctx, ), 0);
+
+   clock_gettime(CLOCK_MONOTONIC, _start);
+
+   igt_assert_eq(0, __gem_execbuf(fd, ));
+   igt_assert_lte(0, noop(fd, ctx, engine));
+   gem_sync(fd, exec.handle);
+
+   igt_assert_lte(0, noop(fd, ctx, engine));
+   igt_assert_eq(gem_reset_stats(fd, ctx, ), 0);
+
+   sync_gpu();
+
+   igt_assert(after.batch_active == before.batch_active + 1);
+
+   gem_close(fd, exec.handle);
+   close(fd);
+
+   igt_assert(igt_seconds_elapsed(_start) > 5);
+   igt_assert(igt_seconds_elapsed(_start) < 15);
+}
+
 static bool gem_has_reset_stats(int fd)
 {
struct local_drm_i915_reset_stats rs;
@@ -798,5 +867,11 @@ igt_main
 
igt_subtest_f("defer-hangcheck-%s", e->name)
RUN_TEST(defer_hangcheck(e));
+
+   igt_subtest_f("no-progress-%s", e->name)
+   RUN_TEST(test_no_seqno_progress(e, false));
+
+   igt_subtest_f("no-progress-ctx-%s", e->name)
+   RUN_CTX_TEST(test_no_seqno_progress(e, true));
}
 }
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx