[PATCH 8/8] drm/i915: remove gen field in favor of gen_mask
Lucas De Marchi
lucas.demarchi at intel.com
Tue Nov 6 03:57:09 UTC 2018
Instead of storing the gen in 2 fields use only the mask
so when checking by several gens on ``if`` statements can
be optimized by the compiler.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
drivers/gpu/drm/i915/i915_drv.c | 4 ++--
drivers/gpu/drm/i915/i915_drv.h | 8 +++++++-
drivers/gpu/drm/i915/i915_pci.c | 4 +++-
drivers/gpu/drm/i915/intel_device_info.c | 2 +-
drivers/gpu/drm/i915/intel_device_info.h | 1 -
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 226030c0787f..7f7e79f727e3 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1652,7 +1652,6 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
BUILD_BUG_ON(INTEL_MAX_PLATFORMS >
BITS_PER_TYPE(device_info->platform_mask));
- BUG_ON(device_info->gen > BITS_PER_TYPE(device_info->gen_mask));
return i915;
}
@@ -1691,7 +1690,8 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
return PTR_ERR(dev_priv);
/* Disable nuclear pageflip by default on pre-ILK */
- if (!i915_modparams.nuclear_pageflip && match_info->gen < 5)
+ if (!i915_modparams.nuclear_pageflip &&
+ __GT_GEN_RANGE(match_info->gen_mask, 0, 5))
dev_priv->drm.driver_features &= ~DRIVER_ATOMIC;
ret = pci_enable_device(pdev);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 3cfefebe742a..e7c15551a8a4 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2371,13 +2371,19 @@ intel_info(const struct drm_i915_private *dev_priv)
(s) != GEN_FOREVER ? (s) - 1 : 0) \
)
+/*
+ * Like GT_GEN_RANGE(), but operates on the mask directly rather than
+ * on the private struct.
+ */
+#define __GT_GEN_RANGE(mask, s, e) (!!((mask) & INTEL_GEN_MASK((s), (e))))
+
/*
* Returns true if Gen is in inclusive range [Start, End].
*
* Use GEN_FOREVER for unbound start and or end.
*/
#define GT_GEN_RANGE(dev_priv, s, e) \
- (!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e))))
+ __GT_GEN_RANGE((dev_priv)->info.gen_mask, (s), (e))
#define GT_GEN(dev_priv, n) \
BUILD_BUG_ON_ZERO(!__builtin_constant_p(n)) + \
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 4ccab8372dd4..6e11cc88cc41 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -30,7 +30,9 @@
#include "i915_selftest.h"
#define PLATFORM(x) .platform = (x), .platform_mask = BIT(x)
-#define GEN(x) .gen = (x), .gen_mask = BIT((x) - 1)
+#define GEN(x) .gen_mask = \
+ BUILD_BUG_ON_ZERO(!__builtin_constant_p(x)) + \
+ BIT((x) - 1)
#define GEN_DEFAULT_PIPEOFFSETS \
.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index 1761529f3e69..d6da9a8ba094 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -119,7 +119,7 @@ void intel_device_info_dump(const struct intel_device_info *info,
INTEL_DEVID(dev_priv),
INTEL_REVID(dev_priv),
intel_platform_name(info->platform),
- info->gen);
+ INTEL_GEN(dev_priv));
intel_device_info_dump_flags(info, p);
}
diff --git a/drivers/gpu/drm/i915/intel_device_info.h b/drivers/gpu/drm/i915/intel_device_info.h
index 86ce1db1b33a..964414d97415 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -152,7 +152,6 @@ struct intel_device_info {
u16 device_id;
u16 gen_mask;
- u8 gen;
u8 gt; /* GT number, 0 if undefined */
u8 num_rings;
intel_ring_mask_t ring_mask; /* Rings supported by the HW */
--
2.19.1.1.g56c4683e68
More information about the Intel-gfx-trybot
mailing list