Quoting Jani Nikula (2018-02-12 09:58:20) > On Fri, 09 Feb 2018, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote: > > Rather than deriving the gen_mask from the static intel_device_info->gen > > at runtime, prefill it in the static data. > > > > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > > --- > > drivers/gpu/drm/i915/i915_drv.c | 2 -- > > drivers/gpu/drm/i915/i915_pci.c | 39 ++++++++++++++++++++++++--------------- > > 2 files changed, 24 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > > index daa9060bdfcb..90f4adbbff28 100644 > > --- a/drivers/gpu/drm/i915/i915_drv.c > > +++ b/drivers/gpu/drm/i915/i915_drv.c > > @@ -902,8 +902,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv, > > 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); > > - > > spin_lock_init(&dev_priv->irq_lock); > > spin_lock_init(&dev_priv->gpu_error.lock); > > mutex_init(&dev_priv->backlight_lock); > > diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c > > index 4e7a10c89782..3b4516d7f9a4 100644 > > --- a/drivers/gpu/drm/i915/i915_pci.c > > +++ b/drivers/gpu/drm/i915/i915_pci.c > > @@ -29,6 +29,8 @@ > > #include "i915_drv.h" > > #include "i915_selftest.h" > > > > +#define GEN(x) .gen = (x), .gen_mask = BIT((x) - 1) > > Please #undef GEN afterwards, ditto for the other macros in the other > patches. I was working on this being local to the file, but sure :) > Does the compiler warn if you overflow .gen_mask? Can we drop the > runtime overflow check now? Or better be safe than sorry with the > BUG_ON? I know clang emits a warn, and I've vague memories about gcc warning for large constants. What I did contemplate is that given the macro, we could use BUILD_BUG_ON_OR_ZERO() and incorporate the overflow checks into the macro. -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx