[PATCH 10/34] drm: kselftest for drm_mm_replace_node()

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Wed Dec 14 12:01:36 UTC 2016


On ma, 2016-12-12 at 11:53 +0000, Chris Wilson wrote:
> Reuse drm_mm_insert_node() with a temporary node to exercise
> drm_mm_replace_node(). We use the previous test in order to exercise the
> various lists following replacement.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

<SNIP>

> +static int __igt_insert(int count, u64 size, bool replace)
>  {
>  	u32 lcg_state = random_seed;
>  	struct drm_mm mm;@@ -264,9 +264,10 @@ static int __igt_insert(int count, u64 size)
>  	}
>  
>  	for (n = 0; n < count; n++) {
> +		struct drm_mm_node tmp, *node;
>  		int err;
>  
> -		node = &nodes[n];
> +		node = memset(replace ? &tmp : &nodes[n], 0, sizeof(*node));

Just memset in a separate line for readability.

> @@ -281,6 +282,20 @@ static int __igt_insert(int count, u64 size)
>                                n, node->start);
>                         goto out;
>                 }
> +
> +               if (replace) {
> +                       drm_mm_replace_node(&tmp, &nodes[n]);
> +                       if (!drm_mm_node_allocated(&nodes[n])) {
> +                               pr_err("replaced new-node not allocated! step %d\n",
> +                                      n);
> +                               goto out;
> +                       }

Maybe go the extra mile and make sure the start and size still match
after replacement.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation


More information about the dri-devel mailing list