[Intel-gfx] [PATCH v4] drm/i915: Small compaction of the engine init code

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 23 14:03:18 UTC 2016


On Thu, Jun 23, 2016 at 02:52:41PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Effectively removes one layer of indirection between the mask of
> possible engines and the engine constructors. Instead of spelling
> out in code the mapping of HAS_<engine> to constructors, makes
> more use of the recently added data driven approach by putting
> engine constructor vfuncs into the table as well.
> 
> Effect is fewer lines of source and smaller binary.
> 
> At the same time simplify the error handling since engine
> destructors can run on unitialized engines anyway.
> 
> Similar approach could be done for legacy submission is wanted.
> 
> v2: Removed ugly BUILD_BUG_ONs in favour of newly introduced
>     ENGINE_MASK and HAS_ENGINE macros.
>     Also removed the forward declarations by shuffling functions
>     around.
> 
> v3: Warn when logical_rings table does not contain enough data
>     and disable the engines which could not be initialized.
>     (Chris Wilson)
> 
> v4: Chris Wilson suggested a nicer engine init loop.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

> +	WARN_ON(INTEL_INFO(dev_priv)->ring_mask &
> +		GENMASK(sizeof(mask) * BITS_PER_BYTE - 1, I915_NUM_ENGINES));

It's computed as a long, so BITS_PER_LONG would suffice

p/x GENMASK(sizeof(mask) * BITS_PER_BYTE - 1, I915_NUM_ENGINES))
    = ((~0UL) << I915_NUM_ENGINES)
    = 0xffffffc0

p/x -(1 << I915_NUM_ENGINES)
    = 0xffffffc0

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list