[Intel-gfx] [PATCH v2 12/40] drm: kselftest for drm_mm_insert_node()

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Fri Dec 16 14:02:12 UTC 2016


On pe, 2016-12-16 at 07:46 +0000, Chris Wilson wrote:
> Exercise drm_mm_insert_node(), check that we can't overfill a range and
> that the lists are correct after reserving/removing.
> 
> v2: Extract helpers for the repeated tests
> v3: Iterate over all allocation flags
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

<SNIP>
 
> +static u64 misaligned(struct drm_mm_node *node, u64 alignment)

I'm not sure if 'misalignment' would be better name or not. This makes
me think of bool returning one.

> +static bool expect_insert_fail(struct drm_mm *mm, u64 size)
> +{
> +	struct drm_mm_node tmp = {};
> +	int err;
> +
> +	err = drm_mm_insert_node(mm, &tmp, size, 0, DRM_MM_SEARCH_DEFAULT);
> +	if (err != -ENOSPC)  {

For speed (this function gets called a lot);

if (likely(err == -ENOSPC))
	return true;

> +static int __igt_insert(unsigned int count, u64 size)
> +{

<SNIP>

> 
> +	for (mode = insert_modes; mode->name; mode++) {
> +		for (n = 0; n < count; n++) {
> +			node = &nodes[n];
> +			err = drm_mm_insert_node_generic(&mm, node, size, 0, n,
> +							 mode->search_flags,
> +							 mode->create_flags);
> +			if (err || !assert_node(node, &mm, size, 0, n)) {
> +				pr_err("%s insert failed, size %llu step %d\n",
> +				       mode->name, size, n);
> +				ret = err ?: -EINVAL;
> +				goto out;
> +			}

This construct is three times in this patch; Could be
expect_insert_generic?

Apart from nitpicks, no complaints; was much easier to review now!

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

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


More information about the Intel-gfx mailing list