[Intel-gfx] [PATCH 09/34] drm: kselftest for drm_mm_insert_node()

Chris Wilson chris at chris-wilson.co.uk
Wed Dec 14 12:51:26 UTC 2016


On Wed, Dec 14, 2016 at 02:26:36PM +0200, Joonas Lahtinen wrote:
> On ma, 2016-12-12 at 11:53 +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.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> 
> <SNIP>
> 
> > +static int __igt_insert(int count, u64 size)
> > +{
> 
> <SNIP>
> 
> > +	for (n = 0; n < count; n++) {
> > +		int err;
> > +
> > +		node = &nodes[n];
> > +		err = drm_mm_insert_node(&mm, node, size, 0,
> > +					 DRM_MM_SEARCH_DEFAULT);
> > +		if (err) {
> > +			pr_err("insert failed, step %d, start %llu\n",
> > +			       n, nodes[n].start);
> > +			ret = err;
> > +			goto out;
> > +		}
> > +
> > +		if (!drm_mm_node_allocated(node)) {
> > +			pr_err("inserted node not allocated! step %d, start %llu\n",
> > +			       n, node->start);
> > +			goto out;
> > +		}
> > +	}
> > +
> > +	/* Repeated use should then fail */
> > +	if (1) {
> 
> Why if (1)? What are you not telling me.

That I was too lazy to write a function and dislike bare '{' just to
instantiate a new local so use if(1) as an excuse to start a new block.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list