All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 8/9] drm: kselftest for drm_mm and top-down alignment
Date: Fri, 09 Dec 2016 17:41:43 +0200	[thread overview]
Message-ID: <1481298103.3210.15.camel@linux.intel.com> (raw)
In-Reply-To: <20161209130825.6854-8-chris@chris-wilson.co.uk>

On pe, 2016-12-09 at 13:08 +0000, Chris Wilson wrote:
> Check that if we request top-down allocation with a particular alignment
> from drm_mm_insert_node() that the start of the node matches our
> request.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

<SNIP>

> @@ -1038,6 +1038,98 @@ static int igt_topdown(void *ignored)
>  	return ret;
>  }
>  
> +static int igt_topdown_align(void *ignored)
> +{
> +	struct drm_mm mm;
> +	struct drm_mm_node tmp, resv;
> +	int ret = -EINVAL;
> +	int n, m, err;
> +
> +	drm_mm_init(&mm, 0, ~0ull);

U64_MAX

> +	memset(&tmp, 0, sizeof(tmp));
> +	memset(&resv, 0, sizeof(resv));
> +
> +	for (m = 0; m < 32; m++) {
> +		u64 end = ~0ull;
> +
> +		if (m) {
> +			resv.size = BIT_ULL(m);
> +			end -= resv.size;
> +			resv.start = end;
> +
> +			err = drm_mm_reserve_node(&mm, &resv);
> +			if (err) {
> +				pr_err("reservation of sentinel node failed\n");
> +				ret = err;
> +				goto out;
> +			}
> +		}
> +
> +		for (n = 0; n < 63 - m; n++) {
> +			u64 align = BIT_ULL(n);
> +
> +			err = drm_mm_insert_node_generic(&mm, &tmp, 1, align, 0,
> +							 DRM_MM_SEARCH_BELOW,
> +							 DRM_MM_CREATE_TOP);
> +			drm_mm_remove_node(&tmp);
> +			if (err) {
> +				pr_err("insert failed, ret=%d\n", err);
> +				ret = err;
> +				goto out;
> +			}

Just drm_mm_remove_node(&tmp) here to avoid an unnecessary extra splat.
I think the tests should be valid code.

> +
> +			if (tmp.start & (align - 1)) {
> +				pr_err("insert alignment failed, aligment=%llx, start=%llx\n",
> +				       align, tmp.start);
> +				goto out;
> +			}
> +
> +			if (tmp.start < end - align) {
> +				pr_err("topdown insert failed, start=%llx, align=%llx, end=%llx\n",
> +				       tmp.start, align, end);
> +				goto out;
> +			}
> +		}
> +
> +		for_each_prime(n, min(8192ull, end - 1)) {
> +			u64 rem;
> +
> +			err = drm_mm_insert_node_generic(&mm, &tmp, n, 0, 0,
> +							 DRM_MM_SEARCH_BELOW,
> +							 DRM_MM_CREATE_TOP);
> +			drm_mm_remove_node(&tmp);
> +			if (err) {
> +				pr_err("insert failed, ret=%d\n", err);
> +				ret = err;
> +				goto out;
> +			}

Ditto.

In addition to those, I would use more meaningful variable names than m
& n.

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-12-09 15:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09 13:08 [PATCH 1/9] drm: kselftest for drm_mm_init() Chris Wilson
2016-12-09 13:08 ` [PATCH 2/9] drm: kselftest for drm_mm_reserve_node() Chris Wilson
2016-12-09 14:31   ` Joonas Lahtinen
2016-12-09 14:43     ` Chris Wilson
2016-12-09 13:08 ` [PATCH 3/9] drm: kselftest for drm_mm_insert_node() Chris Wilson
2016-12-09 13:08 ` [PATCH 4/9] drm: kselftest for drm_mm_insert_node_in_range() Chris Wilson
2016-12-09 13:08 ` [PATCH 5/9] drm: kselftest for drm_mm and alignment Chris Wilson
2016-12-09 16:14   ` Joonas Lahtinen
2016-12-09 13:08 ` [PATCH 6/9] drm: kselftest for drm_mm and eviction Chris Wilson
2016-12-09 13:08 ` [PATCH 7/9] drm: kselftest for drm_mm and top-down allocation Chris Wilson
2016-12-09 13:08 ` [PATCH 8/9] drm: kselftest for drm_mm and top-down alignment Chris Wilson
2016-12-09 15:41   ` Joonas Lahtinen [this message]
2016-12-09 13:08 ` [PATCH 9/9] drm: kselftest for drm_mm and color adjustment Chris Wilson
2016-12-09 13:46 ` [PATCH 1/9] drm: kselftest for drm_mm_init() Joonas Lahtinen

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=1481298103.3210.15.camel@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --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.