[Intel-gfx] [PATCH] drm/i915: extract fence stealing code

Chris Wilson chris at chris-wilson.co.uk
Fri Jan 15 22:48:30 CET 2010


On Fri, 15 Jan 2010 22:36:37 +0100, Daniel Vetter <daniel.vetter at ffwll.ch> wrote:
> The spaghetti logic in there tripped up my brain's code parser for a
> few secs. Prevent this from happening again by extracting the fence
> stealing code into a seperate functions. IMHO this slightly clears up
> the code flow.
> 
> v2: Beautified according to ickle's comments.
> 
> v3: ickle forgot to flush his comment queue ... ;) Now there's also a
> we-are-paranoid BUG_ON in there.

[snip]

> +
> +	/* None available, try to steal one or wait for a user to finish */
> +	obj = NULL;
> +	list_for_each_entry(obj_priv, &dev_priv->mm.fence_list,
> +			    fence_list) {
> +		obj = obj_priv->obj;
                ^^^^^^^^^^^^^^^^^^^
The test is even more paranoid than I am, as obj will be set if we iterate the list.

> +		if (obj_priv->pin_count)
> +			continue;
> +
> +		/* found one! */
> +		i = obj_priv->fence_reg;
> +		break;
> +	}
> +
> +	BUG_ON(!obj);

Hence the fiddle with using obj_priv->obj->pin_count.
-ickle

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list