[Intel-gfx] [PATCH v6] drm/i915: Tidy workaround batch buffer emission

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 17 08:16:09 UTC 2017


On Fri, Feb 17, 2017 at 07:58:59AM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Use the "*batch++ = " style as in the ring emission for better
> readability and also simplify the logic a bit by consolidating
> the offset and size calculations and overflow checking. The
> latter is a programming error so it is not required to check
> for it after each write to the object, but rather do it once the
> whole state has been written and fail the driver if something
> went wrong.
> 
> v2: Rebase.
> 
> v3: Keep track of offsets and sizes in bytes for simplicity
>     and rename function pointer variable to _fn suffix.
>     (Chris Wilson)
> 
> v4: Fix size calc broken in v3 and add alignment warning. (Chris Wilson)
> 
> v5: Fix return code.
> 
> v6: I added an exit from loop in v5 but forgot to put back
>     the object teardown.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk> (v5)
> Cc: Chris Wilson <chris at chris-wilson.co.uk>

> +	/*
> +	 * Emit the two workaround batch buffers, recording the offset from the
> +	 * start of the workaround batch buffer object for each and their
> +	 * respective sizes.
> +	 */
> +	for (i = 0; i < ARRAY_SIZE(wa_bb_fn); i++) {
> +		wa_bb[i]->offset = batch_ptr - batch;
> +		if (WARN_ON(!IS_ALIGNED(wa_bb[i]->offset, CACHELINE_BYTES))) {
> +			ret = -EINVAL;
> +			break;
> +		}
> +		batch_ptr = wa_bb_fn[i](engine, batch_ptr);
> +		wa_bb[i]->size = batch_ptr - (batch + wa_bb[i]->offset);
>  	}
>  
> -out:
> +	BUG_ON(batch_ptr - batch > CTX_WA_BB_OBJ_SIZE);

Ok, I didn't spot it last time, so hopefully not missing anything this
time!
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list