Skip to content

Commit b319cc5

Browse files
tursulinunerlige
authored andcommitted
drm/i915/pmu: Add reference counting to the sampling timer
We do not want to have timers per tile and waste CPU cycles and energy via multiple wake-up sources, for a relatively un-important task of PMU sampling, so keeping a single timer works well. But we also do not want the first GT which goes idle to turn off the timer. Add some reference counting, via a mask of unparked GTs, to solve this. v2: Drop the check for unparked in i915_sample (Ashutosh) v3: Revert v2 (Tvrtko) Signed-off-by: Tvrtko Ursulin <[email protected]> Reviewed-by: Umesh Nerlige Ramappa <[email protected]> Signed-off-by: Umesh Nerlige Ramappa <[email protected]> Reviewed-by: Ashutosh Dixit <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent da5d516 commit b319cc5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
262262
* Signal sampling timer to stop if only engine events are enabled and
263263
* GPU went idle.
264264
*/
265-
pmu->timer_enabled = pmu_needs_timer(pmu, false);
265+
pmu->unparked &= ~BIT(gt->info.id);
266+
if (pmu->unparked == 0)
267+
pmu->timer_enabled = pmu_needs_timer(pmu, false);
266268

267269
spin_unlock_irq(&pmu->lock);
268270
}
@@ -279,7 +281,10 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
279281
/*
280282
* Re-enable sampling timer when GPU goes active.
281283
*/
282-
__i915_pmu_maybe_start_timer(pmu);
284+
if (pmu->unparked == 0)
285+
__i915_pmu_maybe_start_timer(pmu);
286+
287+
pmu->unparked |= BIT(gt->info.id);
283288

284289
spin_unlock_irq(&pmu->lock);
285290
}
@@ -449,6 +454,9 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer)
449454
*/
450455

451456
for_each_gt(gt, i915, i) {
457+
if (!(pmu->unparked & BIT(i)))
458+
continue;
459+
452460
engines_sample(gt, period_ns);
453461

454462
if (i == 0) /* FIXME */

drivers/gpu/drm/i915/i915_pmu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ struct i915_pmu {
7676
* @lock: Lock protecting enable mask and ref count handling.
7777
*/
7878
spinlock_t lock;
79+
/**
80+
* @unparked: GT unparked mask.
81+
*/
82+
unsigned int unparked;
7983
/**
8084
* @timer: Timer for internal i915 PMU sampling.
8185
*/

0 commit comments

Comments
 (0)