-
static u64 get_rc6(struct intel_gt *gt)
{
struct drm_i915_private *i915 = gt->i915;
@@ -240,7 +213,7 @@ static u64 get_rc6(struct intel_gt *gt)
spin_lock_irqsave(&pmu->lock, flags);
if (awake) {
- store_sample(pmu, gt_id, __I915_SAMPLE_RC6, val);
+ pmu->sample[gt_id][__I915_SAMPLE_RC6].cur = val;
} else {
/*
* We think we are runtime suspended.
@@ -250,13 +223,13 @@ static u64 get_rc6(struct intel_gt *gt)
* counter value.
*/
val = ktime_since_raw(pmu->sleep_last[gt_id]);
- val += read_sample(pmu, gt_id, __I915_SAMPLE_RC6);
+ val += pmu->sample[gt_id][__I915_SAMPLE_RC6].cur;
}
- if (val < read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED))
- val = read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED);
+ if (val < pmu->sample[gt_id][__I915_SAMPLE_RC6_LAST_REPORTED].cur)
+ val = pmu->sample[gt_id][__I915_SAMPLE_RC6_LAST_REPORTED].cur;
else
- store_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED, val);
+ pmu->sample[gt_id][__I915_SAMPLE_RC6_LAST_REPORTED].cur = val;
spin_unlock_irqrestore(&pmu->lock, flags);
@@ -275,9 +248,8 @@ static void init_rc6(struct i915_pmu *pmu)
with_intel_runtime_pm(gt->uncore->rpm, wakeref) {
u64 val = __get_rc6(gt);
- store_sample(pmu, i, __I915_SAMPLE_RC6, val);
- store_sample(pmu, i, __I915_SAMPLE_RC6_LAST_REPORTED,
- val);
+ pmu->sample[i][__I915_SAMPLE_RC6].cur = val;
+ pmu->sample[i][__I915_SAMPLE_RC6_LAST_REPORTED].cur = val;
pmu->sleep_last[i] = ktime_get_raw();
}
}
@@ -287,7 +259,7 @@ static void park_rc6(struct intel_gt *gt)
{
struct i915_pmu *pmu = >->i915->pmu;
- store_sample(pmu, gt->info.id, __I915_SAMPLE_RC6, __get_rc6(gt));
+ pmu->sample[gt->info.id][__I915_SAMPLE_RC6].cur = __get_rc6(gt);
pmu->sleep_last[gt->info.id] = ktime_get_raw();
}
@@ -428,6 +400,12 @@ engines_sample(struct intel_gt *gt, unsigned int
period_ns)
}
}
+static void
+add_sample_mult(struct i915_pmu_sample *sample, u32 val, u32 mul)
+{
+ sample->cur += mul_u32_u32(val, mul);
+}
+
static bool
frequency_sampling_enabled(struct i915_pmu *pmu, unsigned int gt)
{
@@ -467,12 +445,12 @@ frequency_sample(struct intel_gt *gt, unsigned int period_ns)
if (!val)
val = intel_gpu_freq(rps, rps->cur_freq);
- add_sample_mult(pmu, gt_id, __I915_SAMPLE_FREQ_ACT,
+ add_sample_mult(&pmu->sample[gt_id][__I915_SAMPLE_FREQ_ACT],
val, period_ns / 1000);
}
if (pmu->enable &
config_mask(__I915_PMU_REQUESTED_FREQUENCY(gt_id))) {
- add_sample_mult(pmu, gt_id, __I915_SAMPLE_FREQ_REQ,
+ add_sample_mult(&pmu->sample[gt_id][__I915_SAMPLE_FREQ_REQ],
intel_rps_get_requested_frequency(rps),
period_ns / 1000);
}
@@ -673,14 +651,12 @@ static u64 __i915_pmu_event_read(struct perf_event *event)
switch (config) {
case I915_PMU_ACTUAL_FREQUENCY:
val =
- div_u64(read_sample(pmu, gt_id,
- __I915_SAMPLE_FREQ_ACT),
+ div_u64(pmu->sample[gt_id][__I915_SAMPLE_FREQ_ACT].cur,
USEC_PER_SEC /* to MHz */);
break;
case I915_PMU_REQUESTED_FREQUENCY:
val =
- div_u64(read_sample(pmu, gt_id,
- __I915_SAMPLE_FREQ_REQ),
+ div_u64(pmu->sample[gt_id][__I915_SAMPLE_FREQ_REQ].cur,
USEC_PER_SEC /* to MHz */);
break;
case I915_PMU_INTERRUPTS:
diff --git a/drivers/gpu/drm/i915/i915_pmu.h b/drivers/gpu/drm/i915/i915_pmu.h
index 33d80fbaab8bc..d20592e7db999 100644
--- a/drivers/gpu/drm/i915/i915_pmu.h
+++ b/drivers/gpu/drm/i915/i915_pmu.h
@@ -127,7 +127,7 @@ struct i915_pmu {
* Only global counters are held here, while the per-engine ones are in
* struct intel_engine_cs.
*/
- struct i915_pmu_sample sample[I915_PMU_MAX_GTS * __I915_NUM_PMU_SAMPLERS];
+ struct i915_pmu_sample sample[I915_PMU_MAX_GTS][__I915_NUM_PMU_SAMPLERS];
/**
* @sleep_last: Last time GT parked for RC6 estimation.
*/