aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/i915_pmu.c')
-rw-r--r--drivers/gpu/drm/i915/i915_pmu.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index d6c8f8fdfda5..017fc602a10e 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -594,7 +594,8 @@ static void i915_pmu_enable(struct perf_event *event)
594 * Update the bitmask of enabled events and increment 594 * Update the bitmask of enabled events and increment
595 * the event reference counter. 595 * the event reference counter.
596 */ 596 */
597 GEM_BUG_ON(bit >= I915_PMU_MASK_BITS); 597 BUILD_BUG_ON(ARRAY_SIZE(i915->pmu.enable_count) != I915_PMU_MASK_BITS);
598 GEM_BUG_ON(bit >= ARRAY_SIZE(i915->pmu.enable_count));
598 GEM_BUG_ON(i915->pmu.enable_count[bit] == ~0); 599 GEM_BUG_ON(i915->pmu.enable_count[bit] == ~0);
599 i915->pmu.enable |= BIT_ULL(bit); 600 i915->pmu.enable |= BIT_ULL(bit);
600 i915->pmu.enable_count[bit]++; 601 i915->pmu.enable_count[bit]++;
@@ -615,11 +616,16 @@ static void i915_pmu_enable(struct perf_event *event)
615 engine = intel_engine_lookup_user(i915, 616 engine = intel_engine_lookup_user(i915,
616 engine_event_class(event), 617 engine_event_class(event),
617 engine_event_instance(event)); 618 engine_event_instance(event));
618 GEM_BUG_ON(!engine);
619 engine->pmu.enable |= BIT(sample);
620 619
621 GEM_BUG_ON(sample >= I915_PMU_SAMPLE_BITS); 620 BUILD_BUG_ON(ARRAY_SIZE(engine->pmu.enable_count) !=
621 I915_ENGINE_SAMPLE_COUNT);
622 BUILD_BUG_ON(ARRAY_SIZE(engine->pmu.sample) !=
623 I915_ENGINE_SAMPLE_COUNT);
624 GEM_BUG_ON(sample >= ARRAY_SIZE(engine->pmu.enable_count));
625 GEM_BUG_ON(sample >= ARRAY_SIZE(engine->pmu.sample));
622 GEM_BUG_ON(engine->pmu.enable_count[sample] == ~0); 626 GEM_BUG_ON(engine->pmu.enable_count[sample] == ~0);
627
628 engine->pmu.enable |= BIT(sample);
623 engine->pmu.enable_count[sample]++; 629 engine->pmu.enable_count[sample]++;
624 } 630 }
625 631
@@ -649,9 +655,11 @@ static void i915_pmu_disable(struct perf_event *event)
649 engine = intel_engine_lookup_user(i915, 655 engine = intel_engine_lookup_user(i915,
650 engine_event_class(event), 656 engine_event_class(event),
651 engine_event_instance(event)); 657 engine_event_instance(event));
652 GEM_BUG_ON(!engine); 658
653 GEM_BUG_ON(sample >= I915_PMU_SAMPLE_BITS); 659 GEM_BUG_ON(sample >= ARRAY_SIZE(engine->pmu.enable_count));
660 GEM_BUG_ON(sample >= ARRAY_SIZE(engine->pmu.sample));
654 GEM_BUG_ON(engine->pmu.enable_count[sample] == 0); 661 GEM_BUG_ON(engine->pmu.enable_count[sample] == 0);
662
655 /* 663 /*
656 * Decrement the reference count and clear the enabled 664 * Decrement the reference count and clear the enabled
657 * bitmask when the last listener on an event goes away. 665 * bitmask when the last listener on an event goes away.
@@ -660,7 +668,7 @@ static void i915_pmu_disable(struct perf_event *event)
660 engine->pmu.enable &= ~BIT(sample); 668 engine->pmu.enable &= ~BIT(sample);
661 } 669 }
662 670
663 GEM_BUG_ON(bit >= I915_PMU_MASK_BITS); 671 GEM_BUG_ON(bit >= ARRAY_SIZE(i915->pmu.enable_count));
664 GEM_BUG_ON(i915->pmu.enable_count[bit] == 0); 672 GEM_BUG_ON(i915->pmu.enable_count[bit] == 0);
665 /* 673 /*
666 * Decrement the reference count and clear the enabled 674 * Decrement the reference count and clear the enabled