intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>, Intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915: Allow optimized platform checks
Date: Thu, 28 Sep 2017 10:34:58 +0300	[thread overview]
Message-ID: <87poab6ztp.fsf@intel.com> (raw)
In-Reply-To: <20170927164138.15474-1-tvrtko.ursulin@linux.intel.com>

On Wed, 27 Sep 2017, Tvrtko Ursulin <tursulin@ursulin.net> wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>

Acked-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 4 ++++
>  drivers/gpu/drm/i915/i915_drv.h | 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 03bbe23e4df8..187c0fad1b79 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -870,6 +870,10 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
>  	memcpy(device_info, match_info, sizeof(*device_info));
>  	device_info->device_id = dev_priv->drm.pdev->device;
>  
> +	BUILD_BUG_ON(INTEL_MAX_PLATFORMS >
> +		     sizeof(device_info->platform_mask) * BITS_PER_BYTE);
> +	device_info->platform_mask = BIT(device_info->platform);
> +
>  	BUG_ON(device_info->gen > sizeof(device_info->gen_mask) * BITS_PER_BYTE);
>  	device_info->gen_mask = BIT(device_info->gen - 1);
>  
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index bda91db3fc46..3a6a34882427 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -861,6 +861,7 @@ struct intel_device_info {
>  	u8 ring_mask; /* Rings supported by the HW */
>  
>  	enum intel_platform platform;
> +	u32 platform_mask;
>  
>  	u32 display_mmio_offset;
>  
> @@ -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))
>  
>  #define IS_I830(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I830)
>  #define IS_I845G(dev_priv)	IS_PLATFORM(dev_priv, INTEL_I845G)

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-09-28  7:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 16:41 [PATCH v2] drm/i915: Allow optimized platform checks Tvrtko Ursulin
2017-09-27 17:03 ` Chris Wilson
2017-09-27 17:07 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-09-28 11:49   ` Tvrtko Ursulin
2017-09-27 21:25 ` ✓ Fi.CI.IGT: " Patchwork
2017-09-28  7:34 ` Jani Nikula [this message]
2017-09-29  8:59 ` [PATCH v2] " Joonas Lahtinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87poab6ztp.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).