Message ID | 20250113095912.356147-3-sk.anirban@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/i915/selftests: Correct frequency handling in RPS power measurement | expand |
On 13-01-2025 15:29, Sk Anirban wrote: > Previously, the RPS function was being used, which utilizes > raw frequency to calculate measured power. This commit introduces > a dedicated function specifically for measuring power in SLPC, > ensuring more accurate and reliable power measurements. > > Signed-off-by: Sk Anirban <sk.anirban@intel.com> > --- > drivers/gpu/drm/i915/gt/selftest_slpc.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/gt/selftest_slpc.c b/drivers/gpu/drm/i915/gt/selftest_slpc.c > index 4ecc4ae74a54..cb5d5e2c5dbe 100644 > --- a/drivers/gpu/drm/i915/gt/selftest_slpc.c > +++ b/drivers/gpu/drm/i915/gt/selftest_slpc.c > @@ -95,6 +95,21 @@ static int slpc_restore_freq(struct intel_guc_slpc *slpc, u32 min, u32 max) > return 0; > } > > +static u64 slpc_measure_power(struct intel_rps *rps, int *freq) > +{ > + u64 x[5]; > + int i; > + > + for (i = 0; i < 5; i++) > + x[i] = __measure_power(5); > + > + *freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2; > + > + /* A simple triangle filter for better result stability */ > + sort(x, 5, sizeof(*x), cmp_u64, NULL); > + return div_u64(x[1] + 2 * x[2] + x[3], 4); > +} > + > static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) > { > int err = 0; > @@ -103,7 +118,7 @@ static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) > if (err) > return err; > *freq = intel_rps_read_actual_frequency(>->rps); > - *power = measure_power(>->rps, freq); > + *power = slpc_measure_power(>->rps, freq); Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Regards, Badal > > return err; > }
diff --git a/drivers/gpu/drm/i915/gt/selftest_slpc.c b/drivers/gpu/drm/i915/gt/selftest_slpc.c index 4ecc4ae74a54..cb5d5e2c5dbe 100644 --- a/drivers/gpu/drm/i915/gt/selftest_slpc.c +++ b/drivers/gpu/drm/i915/gt/selftest_slpc.c @@ -95,6 +95,21 @@ static int slpc_restore_freq(struct intel_guc_slpc *slpc, u32 min, u32 max) return 0; } +static u64 slpc_measure_power(struct intel_rps *rps, int *freq) +{ + u64 x[5]; + int i; + + for (i = 0; i < 5; i++) + x[i] = __measure_power(5); + + *freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2; + + /* A simple triangle filter for better result stability */ + sort(x, 5, sizeof(*x), cmp_u64, NULL); + return div_u64(x[1] + 2 * x[2] + x[3], 4); +} + static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) { int err = 0; @@ -103,7 +118,7 @@ static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) if (err) return err; *freq = intel_rps_read_actual_frequency(>->rps); - *power = measure_power(>->rps, freq); + *power = slpc_measure_power(>->rps, freq); return err; }
Previously, the RPS function was being used, which utilizes raw frequency to calculate measured power. This commit introduces a dedicated function specifically for measuring power in SLPC, ensuring more accurate and reliable power measurements. Signed-off-by: Sk Anirban <sk.anirban@intel.com> --- drivers/gpu/drm/i915/gt/selftest_slpc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)