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

Chris Wilson chris at chris-wilson.co.uk
Thu Dec 1 14:04:03 UTC 2016


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 <mika.kuoppala at intel.com>
> ---
>  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(&reloc, 0, sizeof(reloc));
> +        memset(&exec, 0, sizeof(exec));
> +        memset(&eb, 0, sizeof(eb));

> +	memset(&batch, 0, sizeof(batch));
> +
> +	exec.handle = gem_create(fd, sizeof(batch));
> +	exec.relocation_count = 1;
> +        exec.relocs_ptr = (uintptr_t)&reloc;
> +
> +	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, &cmd, 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)&exec;
> +	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, &before), 0);
> +
> +	clock_gettime(CLOCK_MONOTONIC, &ts_start);

struct timespec ts = {};
igt_seconds_elapsed(&ts_start)

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

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, &after), 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(&ts_start) > 5);

You really want to demand a minimum time?

> +	igt_assert(igt_seconds_elapsed(&ts_start) < 15);

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

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list