return (event->attr.config >> I915_PMU_SAMPLE_BITS) & 0xff;
 }
 
-static bool is_engine_config(u64 config)
+static bool is_engine_config(const u64 config)
 {
        return config < __I915_PMU_OTHER(0);
 }
                return other_bit(config);
 }
 
-static u64 config_mask(u64 config)
+static u32 config_mask(const u64 config)
 {
-       return BIT_ULL(config_bit(config));
+       unsigned int bit = config_bit(config);
+
+       if (__builtin_constant_p(config))
+               BUILD_BUG_ON(bit >
+                            BITS_PER_TYPE(typeof_member(struct i915_pmu,
+                                                        enable)) - 1);
+       else
+               WARN_ON_ONCE(bit >
+                            BITS_PER_TYPE(typeof_member(struct i915_pmu,
+                                                        enable)) - 1);
+
+       return BIT(config_bit(config));
 }
 
 static bool is_engine_event(struct perf_event *event)
 {
        struct drm_i915_private *i915 =
                container_of(event->pmu, typeof(*i915), pmu.base);
+       const unsigned int bit = event_bit(event);
        struct i915_pmu *pmu = &i915->pmu;
        unsigned long flags;
-       unsigned int bit;
 
-       bit = event_bit(event);
        if (bit == -1)
                goto update;
 
        GEM_BUG_ON(bit >= ARRAY_SIZE(pmu->enable_count));
        GEM_BUG_ON(pmu->enable_count[bit] == ~0);
 
-       pmu->enable |= BIT_ULL(bit);
+       pmu->enable |= BIT(bit);
        pmu->enable_count[bit]++;
 
        /*
 {
        struct drm_i915_private *i915 =
                container_of(event->pmu, typeof(*i915), pmu.base);
-       unsigned int bit = event_bit(event);
+       const unsigned int bit = event_bit(event);
        struct i915_pmu *pmu = &i915->pmu;
        unsigned long flags;
 
         * bitmask when the last listener on an event goes away.
         */
        if (--pmu->enable_count[bit] == 0) {
-               pmu->enable &= ~BIT_ULL(bit);
+               pmu->enable &= ~BIT(bit);
                pmu->timer_enabled &= pmu_needs_timer(pmu, true);
        }