diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpu/drm/i915/i915_pmu.c | 22 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/i915_pmu.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.h | 9 |
3 files changed, 22 insertions, 11 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 |
diff --git a/drivers/gpu/drm/i915/i915_pmu.h b/drivers/gpu/drm/i915/i915_pmu.h index 7f164ca3db12..b3728c5f13e7 100644 --- a/drivers/gpu/drm/i915/i915_pmu.h +++ b/drivers/gpu/drm/i915/i915_pmu.h | |||
| @@ -31,6 +31,8 @@ enum { | |||
| 31 | ((1 << I915_PMU_SAMPLE_BITS) + \ | 31 | ((1 << I915_PMU_SAMPLE_BITS) + \ |
| 32 | (I915_PMU_LAST + 1 - __I915_PMU_OTHER(0))) | 32 | (I915_PMU_LAST + 1 - __I915_PMU_OTHER(0))) |
| 33 | 33 | ||
| 34 | #define I915_ENGINE_SAMPLE_COUNT (I915_SAMPLE_SEMA + 1) | ||
| 35 | |||
| 34 | struct i915_pmu_sample { | 36 | struct i915_pmu_sample { |
| 35 | u64 cur; | 37 | u64 cur; |
| 36 | }; | 38 | }; |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 72edaa7ff411..a1a7cc29fdd1 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
| @@ -415,16 +415,17 @@ struct intel_engine_cs { | |||
| 415 | /** | 415 | /** |
| 416 | * @enable_count: Reference count for the enabled samplers. | 416 | * @enable_count: Reference count for the enabled samplers. |
| 417 | * | 417 | * |
| 418 | * Index number corresponds to the bit number from @enable. | 418 | * Index number corresponds to @enum drm_i915_pmu_engine_sample. |
| 419 | */ | 419 | */ |
| 420 | unsigned int enable_count[I915_PMU_SAMPLE_BITS]; | 420 | unsigned int enable_count[I915_ENGINE_SAMPLE_COUNT]; |
| 421 | /** | 421 | /** |
| 422 | * @sample: Counter values for sampling events. | 422 | * @sample: Counter values for sampling events. |
| 423 | * | 423 | * |
| 424 | * Our internal timer stores the current counters in this field. | 424 | * Our internal timer stores the current counters in this field. |
| 425 | * | ||
| 426 | * Index number corresponds to @enum drm_i915_pmu_engine_sample. | ||
| 425 | */ | 427 | */ |
| 426 | #define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_SEMA + 1) | 428 | struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_COUNT]; |
| 427 | struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX]; | ||
| 428 | } pmu; | 429 | } pmu; |
| 429 | 430 | ||
| 430 | /* | 431 | /* |
