[Intel-gfx] [PATCH 14/22] drm/i915: Make i915_vma_pin() small and inline

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Thu Jul 28 11:06:26 UTC 2016


On ke, 2016-07-27 at 12:14 +0100, Chris Wilson wrote:
> +int __i915_vma_do_pin(struct i915_vma *vma,
> +		      u64 size, u64 alignment, u64 flags);
> +static inline int __must_check
> +i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
> +{
> +	BUILD_BUG_ON(PIN_MBZ != I915_VMA_PIN_OVERFLOW);
> +	BUILD_BUG_ON(PIN_GLOBAL != I915_VMA_GLOBAL_BIND);
> +	BUILD_BUG_ON(PIN_USER != I915_VMA_LOCAL_BIND);
> +
> +	/* Pin early to prevent the shrinker/eviction logic from destroying
> +	 * our vma as we insert and bind.
> +	 */
> +	if (likely(((++vma->flags ^ flags) & I915_VMA_BIND_MASK) == 0))
> +		return 0;

GCC can't optimize a separate increment and flags equality test? The
expression tries to be tad too smart (but nothing compared to the
semaphore funcs).

Apart from that, looks good,

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