All of lore.kernel.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 33/37] drm/i915: Verify page layout for rotated VMA
Date: Thu, 12 Jan 2017 17:41:31 +0000	[thread overview]
Message-ID: <bbee9e16-f9ec-a080-7d9b-4857d92cb725@linux.intel.com> (raw)
In-Reply-To: <20170111210937.29252-34-chris@chris-wilson.co.uk>


On 11/01/2017 21:09, Chris Wilson wrote:
> Exercise creating rotated VMA and checking the page order within.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/selftests/i915_vma.c | 130 ++++++++++++++++++++++++++++++
>  1 file changed, 130 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c
> index d229adabc5f8..95c5db2b0881 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_vma.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
> @@ -287,11 +287,141 @@ static int igt_vma_pin1(void *arg)
>  	return err;
>  }
>
> +static unsigned long rotated_index(const struct intel_rotation_info *r,
> +				   unsigned int n,
> +				   unsigned int x,
> +				   unsigned int y)
> +{
> +	return r->plane[n].stride * (r->plane[n].height - y - 1) + x;
> +}
> +
> +static struct scatterlist *
> +assert_rotated(struct drm_i915_gem_object *obj,
> +	       const struct intel_rotation_info *r, unsigned int n,
> +	       struct scatterlist *sg)
> +{
> +	unsigned int x, y;
> +
> +	for (x = 0; x < r->plane[n].width; x++) {
> +		for (y = 0; y < r->plane[n].height; y++) {
> +			unsigned long src_idx;
> +			dma_addr_t src;
> +
> +			src_idx = rotated_index(r, n, x, y);
> +			src = i915_gem_object_get_dma_address(obj, src_idx);

Right, this is actually more like unrotate, from rotated coords to 
unrotated index. I'll assume the formula is correct if it passes. :)

> +
> +			if (sg_dma_len(sg) != PAGE_SIZE) {
> +				pr_err("Invalid sg.length, found %d, expected %lu for rotated page (%d, %d) [src index %lu]\n",
> +				       sg_dma_len(sg), PAGE_SIZE,
> +				       x, y, src_idx);
> +				return NULL;
> +			}
> +
> +			if (sg_dma_address(sg) != src) {
> +				pr_err("Invalid address for rotated page (%d, %d) [src index %lu]\n",
> +				       x, y, src_idx);
> +				return NULL;
> +			}
> +
> +			sg = ____sg_next(sg);
> +		}
> +	}
> +
> +	return sg;
> +}
> +
> +static int igt_vma_rotate(void *arg)
> +{
> +	struct drm_i915_private *i915 = arg;
> +	struct drm_i915_gem_object *obj;
> +	const unsigned int width = 6;
> +	const unsigned int height = 4;
> +	const unsigned int npages = 24;
> +	struct i915_vma *vma;
> +	struct i915_ggtt_view view;
> +	struct scatterlist *sg;
> +	unsigned int n;
> +	int err = -ENOMEM;
> +
> +	obj = i915_gem_object_create_internal(i915, npages*PAGE_SIZE);
> +	if (IS_ERR(obj))
> +		goto err;
> +
> +	view.type = I915_GGTT_VIEW_ROTATED;
> +	view.rotated.plane[0].offset = 0;
> +	view.rotated.plane[0].width = width;
> +	view.rotated.plane[0].height = height;
> +	view.rotated.plane[0].stride = width;
> +
> +	view.rotated.plane[1].offset = 0;
> +	view.rotated.plane[1].width = height;
> +	view.rotated.plane[1].height = width;
> +	view.rotated.plane[1].stride = height;

Ahem, why are the width & height assignments different between the 
planes and how can a single assert possibly work with this? Perhaps it 
all works totally differently after Ville's rewrite, I don't know any 
more obviously.

> +
> +	vma = i915_gem_obj_lookup_or_create_vma(obj, &i915->ggtt.base, &view);
> +	if (IS_ERR(vma)) {
> +		err = PTR_ERR(vma);
> +		goto err_object;
> +	}
> +
> +	if (!i915_vma_is_ggtt(vma)) {
> +		pr_err("VMA is not in the GGTT!\n");
> +		err = -EINVAL;
> +		goto err_object;
> +	}
> +
> +	err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL);
> +	if (err)
> +		goto err_object;

Log message would be good.

> +
> +	if (memcmp(&vma->ggtt_view, &view, sizeof(view))) {
> +		pr_err("VMA mismatch upon creation!\n");
> +		err = -EINVAL;
> +		goto err_object;
> +	}

i915_vma_compare to cover any future tweaking in that area?

> +
> +	if (vma->size != 2*npages*PAGE_SIZE) {
> +		pr_err("VMA is wrong size, expected %lu, found %llu\n",
> +		       2*npages*PAGE_SIZE, vma->size);
> +		err = -EINVAL;
> +		goto err_object;
> +	}

Wait a minute, how can rotated view be bigger than the object?!

[after some head scratching and bringing up the code]

Right, you are playing tricks with pretend two planes. It would be good 
to split the test into one plane only first, and then the two-plane 
configuration. Probably with a "real" backing store, I mean object with 
enough pages for both planes and a proper offset.

> +
> +	if (vma->node.size < vma->size) {
> +		pr_err("VMA binding too small, expected %llu, found %llu\n",
> +		       vma->size, vma->node.size);
> +		err = -EINVAL;
> +		goto err_object;
> +	}
> +
> +	if (vma->pages == obj->mm.pages) {
> +		pr_err("VMA using unrotated object pages!\n");
> +		err = -EINVAL;
> +		goto err_object;
> +	}
> +
> +	sg = vma->pages->sgl;
> +	for (n = 0; n < ARRAY_SIZE(view.rotated.plane); n++) {
> +		sg = assert_rotated(obj, &view.rotated, n, sg);
> +		if (!sg) {
> +			pr_err("Inconsistent VMA pages for plane %d\n", n);
> +			err = -EINVAL;
> +			goto err_object;
> +		}
> +	}
> +
> +err_object:
> +	i915_gem_object_put(obj);
> +err:
> +	return err;
> +}
> +
>  int i915_vma_mock_selftests(void)
>  {
>  	static const struct i915_subtest tests[] = {
>  		SUBTEST(igt_vma_create),
>  		SUBTEST(igt_vma_pin1),
> +		SUBTEST(igt_vma_rotate),
>  	};
>  	struct drm_i915_private *i915;
>  	int err;
>

Regards,

Tvrtko

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

  reply	other threads:[~2017-01-12 17:41 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 21:09 Selftests Chris Wilson
2017-01-11 21:09 ` [PATCH 01/37] drm: Provide a driver hook for drm_dev_release() Chris Wilson
2017-01-11 21:09 ` [PATCH 02/37] drm/i915: Provide a hook for selftests Chris Wilson
2017-01-12  7:29   ` Tvrtko Ursulin
2017-01-12  7:40     ` Chris Wilson
2017-01-13  8:31   ` Chris Wilson
2017-01-13 10:12     ` Tvrtko Ursulin
2017-01-13 10:22       ` Chris Wilson
2017-01-13 10:42         ` Tvrtko Ursulin
2017-01-11 21:09 ` [PATCH 03/37] drm/i915: Add some selftests for sg_table manipulation Chris Wilson
2017-01-12 10:56   ` Tvrtko Ursulin
2017-01-12 11:14     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 04/37] drm/i915: Add unit tests for the breadcrumb rbtree, insert/remove Chris Wilson
2017-01-11 21:09 ` [PATCH 05/37] drm/i915: Add unit tests for the breadcrumb rbtree, completion Chris Wilson
2017-01-11 21:09 ` [PATCH 06/37] drm/i915: Add unit tests for the breadcrumb rbtree, wakeups Chris Wilson
2017-01-12 11:11   ` Tvrtko Ursulin
2017-01-12 14:37     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 07/37] drm/i915: Mock the GEM device for self-testing Chris Wilson
2017-01-11 21:09 ` [PATCH 08/37] drm/i915: Mock a GGTT " Chris Wilson
2017-01-11 21:09 ` [PATCH 09/37] drm/i915: Mock infrastructure for request emission Chris Wilson
2017-01-12 13:11   ` Tvrtko Ursulin
2017-01-12 13:27     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 10/37] drm/i915: Create a fake object for testing huge allocations Chris Wilson
2017-01-12 10:56   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 11/37] drm/i915: Add selftests for i915_gem_request Chris Wilson
2017-01-12 11:20   ` Tvrtko Ursulin
2017-01-12 11:32     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 12/37] drm/i915: Add a simple request selftest for waiting Chris Wilson
2017-01-12 11:25   ` Tvrtko Ursulin
2017-01-11 21:09 ` [PATCH 13/37] drm/i915: Add a simple fence selftest to i915_gem_request Chris Wilson
2017-01-11 21:09 ` [PATCH 14/37] drm/i915: Simple selftest to exercise live requests Chris Wilson
2017-01-12 12:10   ` Tvrtko Ursulin
2017-01-12 12:20     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 15/37] drm/i915: Add selftests for object allocation, phys Chris Wilson
2017-01-11 21:09 ` [PATCH 16/37] drm/i915: Add a live seftest for GEM objects Chris Wilson
2017-01-12 11:17   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 17/37] drm/i915: Test partial mappings Chris Wilson
2017-01-16 22:05   ` Matthew Auld
2017-01-16 22:25     ` Chris Wilson
2017-01-17 12:12   ` Matthew Auld
2017-01-17 12:29     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 18/37] drm/i915: Test exhaustion of the mmap space Chris Wilson
2017-01-12 17:29   ` Matthew Auld
2017-01-11 21:09 ` [PATCH 19/37] drm/i915: Test coherency of and barriers between cache domains Chris Wilson
2017-01-13 11:44   ` Matthew Auld
2017-01-13 14:13     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 20/37] drm/i915: Move uncore selfchecks to live selftest infrastructure Chris Wilson
2017-01-11 21:09 ` [PATCH 21/37] drm/i915: Test all fw tables during mock selftests Chris Wilson
2017-01-11 21:09 ` [PATCH 22/37] drm/i915: Sanity check all registers for matching fw domains Chris Wilson
2017-01-11 21:09 ` [PATCH 23/37] drm/i915: Add some mock tests for dmabuf interop Chris Wilson
2017-01-11 21:09 ` [PATCH 24/37] drm/i915: Add initial selftests for i915_gem_gtt Chris Wilson
2017-01-11 21:09 ` [PATCH 25/37] drm/i915: Move i915_ppgtt_close() into i915_gem_gtt.c Chris Wilson
2017-01-12 12:43   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 26/37] drm/i915: Assert that we have allocated the drm_mm_node upon pinning Chris Wilson
2017-01-12 12:45   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 27/37] drm/i915: Exercising filling the top/bottom portions of the ppgtt Chris Wilson
2017-01-12 13:32   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 28/37] drm/i915: Exercising filling the top/bottom portions of the global GTT Chris Wilson
2017-01-12 14:05   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 29/37] drm/i915: Fill different pages of the GTT Chris Wilson
2017-01-13  7:47   ` Joonas Lahtinen
2017-01-13 20:45     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 30/37] drm/i915: Exercise filling and removing random ranges from the live GTT Chris Wilson
2017-01-13  8:59   ` Joonas Lahtinen
2017-01-13  9:08     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 31/37] drm/i915: Test creation of VMA Chris Wilson
2017-01-13 12:28   ` Joonas Lahtinen
2017-01-13 12:50     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 32/37] drm/i915: Exercise i915_vma_pin/i915_vma_insert Chris Wilson
2017-01-13 12:49   ` Joonas Lahtinen
2017-01-13 12:57     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 33/37] drm/i915: Verify page layout for rotated VMA Chris Wilson
2017-01-12 17:41   ` Tvrtko Ursulin [this message]
2017-01-11 21:09 ` [PATCH 34/37] drm/i915: Test creation of partial VMA Chris Wilson
2017-01-13 13:10   ` Joonas Lahtinen
2017-01-11 21:09 ` [PATCH 35/37] drm/i915: Live testing for context execution Chris Wilson
2017-01-13 14:28   ` Joonas Lahtinen
2017-01-13 18:35     ` Chris Wilson
2017-01-11 21:09 ` [PATCH 36/37] drm/i915: Initial selftests for exercising eviction Chris Wilson
2017-01-11 21:09 ` [PATCH 37/37] drm/i915: Add initial selftests for hang detection and resets Chris Wilson
2017-01-11 22:23 ` ✓ Fi.CI.BAT: success for series starting with [01/37] drm: Provide a driver hook for drm_dev_release() 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=bbee9e16-f9ec-a080-7d9b-4857d92cb725@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.