Commit 8ed0753b authored by Ashutosh Dixit's avatar Ashutosh Dixit
Browse files

drm/i915/pmu: Make PMU sample array two-dimensional



No functional changes but we can remove some unsightly index computation
and read/write functions if we convert the PMU sample array from a
one-dimensional to a two-dimensional array.

v2: Retain read/store helpers (Tvrtko)

Suggested-by: default avatarTvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230524215629.97920-3-ashutosh.dixit@intel.com
parent ab129025
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -191,31 +191,21 @@ static inline s64 ktime_since_raw(const ktime_t kt)
	return ktime_to_ns(ktime_sub(ktime_get_raw(), kt));
}

static unsigned int
__sample_idx(struct i915_pmu *pmu, unsigned int gt_id, int sample)
{
	unsigned int idx = gt_id * __I915_NUM_PMU_SAMPLERS + sample;

	GEM_BUG_ON(idx >= ARRAY_SIZE(pmu->sample));

	return idx;
}

static u64 read_sample(struct i915_pmu *pmu, unsigned int gt_id, int sample)
{
	return pmu->sample[__sample_idx(pmu, gt_id, sample)].cur;
	return pmu->sample[gt_id][sample].cur;
}

static void
store_sample(struct i915_pmu *pmu, unsigned int gt_id, int sample, u64 val)
{
	pmu->sample[__sample_idx(pmu, gt_id, sample)].cur = val;
	pmu->sample[gt_id][sample].cur = val;
}

static void
add_sample_mult(struct i915_pmu *pmu, unsigned int gt_id, int sample, u32 val, u32 mul)
{
	pmu->sample[__sample_idx(pmu, gt_id, sample)].cur += mul_u32_u32(val, mul);
	pmu->sample[gt_id][sample].cur += mul_u32_u32(val, mul);
}

static u64 get_rc6(struct intel_gt *gt)
+1 −1
Original line number Diff line number Diff line
@@ -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.
	 */