public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 04/16] drm/i915: Add unit tests for the breadcrumb rbtree, completion
Date: Thu, 8 Dec 2016 11:47:45 +0000	[thread overview]
Message-ID: <ef36e4bd-e1cd-1188-922e-b617d35fcd96@linux.intel.com> (raw)
In-Reply-To: <20161207135833.32740-5-chris@chris-wilson.co.uk>


On 07/12/2016 13:58, Chris Wilson wrote:
> Second retroactive test, make sure that the waiters are removed from the
> global wait-tree when their seqno completes.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_breadcrumbs.c | 110 +++++++++++++++++++++++++++++++
>  1 file changed, 110 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c
> index c768608974e1..fc950f7ff322 100644
> --- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
> +++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
> @@ -705,6 +705,12 @@ static struct intel_engine_cs *mock_engine(const char *name)
>  	return engine;
>  }
>
> +static void mock_seqno_advance(struct intel_engine_cs *engine, u32 seqno)
> +{
> +	intel_write_status_page(engine, I915_GEM_HWS_INDEX, seqno);
> +	intel_engine_wakeup(engine);
> +}
> +
>  static int *get_random_order(int count)
>  {
>  	int *order;
> @@ -766,6 +772,27 @@ static int check_rbtree(struct intel_engine_cs *engine,
>  	return 0;
>  }
>
> +static int check_completion(struct intel_engine_cs *engine,
> +			    const unsigned long *bitmap,
> +			    const struct intel_wait *waiters,
> +			    const int count)
> +{
> +	int n;
> +
> +	for (n = 0; n < count; n++) {
> +		if (intel_wait_complete(&waiters[n]) != !!test_bit(n, bitmap))
> +			continue;
> +
> +		pr_err("waiter[%d, seqno=%d] is %s, but expected %s\n",
> +		       n, waiters[n].seqno,
> +		       intel_wait_complete(&waiters[n]) ? "complete" : "active",
> +		       test_bit(n, bitmap) ? "active" : "complete");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  static int check_rbtree_empty(struct intel_engine_cs *engine)
>  {
>  	struct intel_breadcrumbs *b = &engine->breadcrumbs;
> @@ -857,10 +884,93 @@ static int igt_random_insert_remove(void *ignore)
>  	return err;
>  }
>
> +static int igt_insert_complete(void *ignore)
> +{
> +	struct intel_engine_cs *engine;
> +	struct intel_wait *waiters;
> +	const int count = 4096;
> +	unsigned long *bitmap;
> +	int err = -ENOMEM;
> +	int n, m;
> +
> +	engine = mock_engine("mock");
> +	if (!engine)
> +		goto out;
> +
> +	waiters = drm_malloc_gfp(count, sizeof(*waiters), GFP_TEMPORARY);
> +	if (!waiters)
> +		goto out_engines;
> +
> +	bitmap = kcalloc(DIV_ROUND_UP(count, BITS_PER_LONG), sizeof(*bitmap),
> +			 GFP_TEMPORARY);
> +	if (!bitmap)
> +		goto out_waiters;
> +
> +	for (n = 0; n < count; n++) {
> +		intel_wait_init(&waiters[n], n + 0x1000);

Maybe const int seqno_start = 0x1000 since there are multiple users.

> +		intel_engine_add_wait(engine, &waiters[n]);
> +		__set_bit(n, bitmap);
> +	}
> +	err = check_rbtree(engine, bitmap, waiters, count);
> +	if (err)
> +		goto err;
> +
> +	for (n = 0; n < count; n = m) {
> +		int seqno = 2 * n;
> +
> +		GEM_BUG_ON(find_first_bit(bitmap, count) != n);
> +
> +		if (intel_wait_complete(&waiters[n])) {
> +			pr_err("waiter[%d, seqno=%d] completed too early\n",
> +			       n, waiters[n].seqno);
> +			err = -EINVAL;
> +			goto err;
> +		}
> +
> +		/* complete the following waiters */
> +		mock_seqno_advance(engine, seqno + 0x1000);
> +		for (m = n; m <= seqno; m++) {
> +			if (m == count)
> +				break;
> +
> +			GEM_BUG_ON(!test_bit(m, bitmap));
> +			__clear_bit(m, bitmap);
> +		}
> +
> +		intel_engine_remove_wait(engine, &waiters[n]);
> +		RB_CLEAR_NODE(&waiters[n].node);
> +
> +		err = check_rbtree(engine, bitmap, waiters, count);
> +		if (err) {
> +			pr_err("rbtree corrupt after seqno advance to %d\n",
> +			       seqno + 0x1000);
> +			goto err;
> +		}
> +
> +		err = check_completion(engine, bitmap, waiters, count);
> +		if (err) {
> +			pr_err("completions after seqno advance to %d failed\n",
> +			       seqno + 0x1000);
> +			goto err;
> +		}
> +	}
> +
> +	err = check_rbtree_empty(engine);
> +err:
> +	kfree(bitmap);
> +out_waiters:
> +	drm_free_large(waiters);
> +out_engines:
> +	kfree(engine);
> +out:
> +	return err;
> +}
> +
>  int intel_breadcrumbs_selftest(void)
>  {
>  	static const struct i915_subtest tests[] = {
>  		SUBTEST(igt_random_insert_remove),
> +		SUBTEST(igt_insert_complete),
>  	};
>
>  	return i915_subtests(tests, NULL);
>

Looks OK.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

  reply	other threads:[~2016-12-08 11:47 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 13:58 [RFC] Smattering of selftests Chris Wilson
2016-12-07 13:58 ` [PATCH 01/16] drm/i915: Provide a hook for selftests Chris Wilson
2016-12-08 10:47   ` Tvrtko Ursulin
2016-12-08 11:15     ` Chris Wilson
2016-12-08 12:30       ` Tvrtko Ursulin
2016-12-08 12:40         ` Chris Wilson
2016-12-07 13:58 ` [PATCH 02/16] kselftests: Exercise hw-independent mock tests for i915.ko Chris Wilson
2016-12-07 14:09   ` Chris Wilson
2016-12-08 15:50     ` Shuah Khan
2016-12-08 16:01       ` Chris Wilson
2016-12-08 16:44         ` Shuah Khan
2016-12-07 13:58 ` [PATCH 03/16] drm/i915: Add unit tests for the breadcrumb rbtree, insert/remove Chris Wilson
2016-12-08 11:00   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 04/16] drm/i915: Add unit tests for the breadcrumb rbtree, completion Chris Wilson
2016-12-08 11:47   ` Tvrtko Ursulin [this message]
2016-12-07 13:58 ` [PATCH 05/16] drm/i915: Add unit tests for the breadcrumb rbtree, wakeups Chris Wilson
2016-12-08 17:38   ` Tvrtko Ursulin
2016-12-08 21:04     ` Chris Wilson
2016-12-09  9:33       ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 06/16] drm/i915: Add a reminder that i915_vma_move_to_active() requires struct_mutex Chris Wilson
2016-12-08 17:40   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 07/16] drm/i915: Move intel_lrc_context_pin() to avoid the forward declaration Chris Wilson
2016-12-08 17:45   ` Tvrtko Ursulin
2016-12-08 20:55     ` Chris Wilson
2016-12-07 13:58 ` [PATCH 08/16] drm/i915: Unify active context tracking between legacy/execlists/guc Chris Wilson
2016-12-09 11:48   ` Tvrtko Ursulin
2016-12-09 12:17     ` Chris Wilson
2016-12-07 13:58 ` [PATCH 09/16] drm/i915: Simplify releasing context reference Chris Wilson
2016-12-09 15:03   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 10/16] drm/i915: Mark the shadow gvt context as closed Chris Wilson
2016-12-09 15:07   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 11/16] drm/i915/execlists: Request the kernel context be pinned high Chris Wilson
2016-12-09 15:08   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 12/16] drm/i915: Swap if(enable_execlists) in i915_gem_request_alloc for a vfunc Chris Wilson
2016-12-09 15:16   ` Tvrtko Ursulin
2016-12-09 15:25     ` Chris Wilson
2016-12-09 15:53       ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 13/16] drm/i915: Add selftests for i915_gem_request Chris Wilson
2016-12-09 15:51   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 14/16] drm/i915: Add a simple request selftest for waiting Chris Wilson
2016-12-09 15:59   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 15/16] drm/i915: Add a simple fence selftest to i915_gem_request Chris Wilson
2016-12-09 16:02   ` Tvrtko Ursulin
2016-12-07 13:58 ` [PATCH 16/16] drm/i915: Add selftests for object allocation, phys Chris Wilson
2016-12-13 17:10   ` Tvrtko Ursulin
2016-12-17 13:55     ` Chris Wilson
2016-12-07 14:04 ` [RFC] Smattering of selftests Chris Wilson
2016-12-07 15:45 ` ✓ Fi.CI.BAT: success for series starting with [01/16] drm/i915: Provide a hook for selftests Patchwork
2016-12-07 18:52 ` [PATCH 1/2] drm/i915: Move uncore selfchecks to late selftest infrastructure Chris Wilson
2016-12-07 18:52   ` [PATCH 2/2] drm/i915: Test all fw tables during mock selftests Chris Wilson
2016-12-08 12:14     ` Tvrtko Ursulin
2016-12-08 12:28       ` Chris Wilson
2016-12-08 13:11     ` Joonas Lahtinen
2016-12-08 16:52     ` Tvrtko Ursulin
2016-12-08 22:29       ` Chris Wilson
2016-12-09  9:41         ` Tvrtko Ursulin
2016-12-09 10:18           ` Chris Wilson
2016-12-09 10:35             ` Tvrtko Ursulin
2016-12-09 10:51               ` Chris Wilson
2016-12-08 11:58   ` [PATCH 1/2] drm/i915: Move uncore selfchecks to late selftest infrastructure Tvrtko Ursulin
2016-12-07 19:56 ` [RFC] Smattering of selftests Paulo Zanoni
2016-12-07 20:52 ` ✓ Fi.CI.BAT: success for series starting with [01/16] drm/i915: Provide a hook for selftests (rev2) 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=ef36e4bd-e1cd-1188-922e-b617d35fcd96@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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