[Intel-gfx] [PATCH v2] drm/i915: Allow optimized platform checks

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Fri Sep 29 08:59:53 UTC 2017


On Wed, 2017-09-27 at 17:41 +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> If we store the platform as a bitmask, and convert the
> IS_PLATFORM macro to use it, we allow the compiler to
> merge the IS_PLATFORM(a) || IS_PLATFORM(b) || ... checks
> into a single conditional.
> 
> As a secondary benefit this saves almost 1k of text:
> 
>     text           data     bss     dec     hex filename
> -1460254          60014    3656 1523924  1740d4 drivers/gpu/drm/i915/i915.ko
> +1459260          60026    3656 1522942  173cfe drivers/gpu/drm/i915/i915.ko
> 
> v2: Removed the infamous -1.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Jani Nikula <jani.nikula at intel.com>

<SNIP>

> @@ -2986,7 +2987,7 @@ intel_info(const struct drm_i915_private *dev_priv)
>  #define IS_REVID(p, since, until) \
>  	(INTEL_REVID(p) >= (since) && INTEL_REVID(p) <= (until))
>  
> -#define IS_PLATFORM(dev_priv, p) ((dev_priv)->info.platform == (p))
> +#define IS_PLATFORM(dev_priv, p) ((dev_priv)->info.platform_mask & BIT(p))

|| BUILD_BUG_ON_ZERO(__builtin_constant_p(p))

To enforce it?

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation


More information about the Intel-gfx mailing list