[PATCH i-g-t 1/2] tests/perf_pmu: Compare against requested freq in frequency subtest
Ashutosh Dixit
ashutosh.dixit at intel.com
Thu Mar 23 23:36:34 UTC 2023
After the i915 commit 95ccf312a1e4f ("drm/i915/guc/slpc: Allow SLPC to use
efficient frequency"), FW uses the requested freq as the efficient freq
which can exceed the max freq set. Therefore, in the "min freq" part of the
igt at perf_pmu@frequency subtest, compare the requested freq reported by PMU
not against the set freq but against the requested freq reported in sysfs.
v2: Remove previously added delays. GuC FW is now updated to set min/max
freq in top half so delays are not needed
v3: Increase tolerance between measured and requested freq to 10% to
account for sporadic failures due to dynamically changing efficient
freq. Also document the changes in code.
Bug: https://gitlab.freedesktop.org/drm/intel/-/issues/6806
Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
tests/i915/perf_pmu.c | 50 +++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
index 197e7cd2542..94f582b6f43 100644
--- a/tests/i915/perf_pmu.c
+++ b/tests/i915/perf_pmu.c
@@ -1636,19 +1636,18 @@ test_frequency(int gem_fd)
}
static void
-test_frequency_idle(int gem_fd)
+test_frequency_idle_busy(int gem_fd, bool busy)
{
- uint32_t min_freq;
+ uint32_t sys_min, sys_req, sys_act;
uint64_t val[2], start[2], slept;
- double idle[2];
+ double freq[2];
int fd[2], sysfs;
+ igt_spin_t *spin = NULL;
+ uint64_t ahnd = get_reloc_ahnd(gem_fd, 0);
sysfs = igt_sysfs_open(gem_fd);
igt_require(sysfs >= 0);
- min_freq = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
- close(sysfs);
-
/* While parked, our convention is to report the GPU at 0Hz */
fd[0] = open_group(gem_fd, I915_PMU_REQUESTED_FREQUENCY, -1);
@@ -1656,24 +1655,39 @@ test_frequency_idle(int gem_fd)
gem_quiescent_gpu(gem_fd); /* Be idle! */
measured_usleep(2000); /* Wait for timers to cease */
+ if (busy)
+ spin = spin_sync_flags(gem_fd, ahnd, 0, I915_EXEC_DEFAULT);
slept = pmu_read_multi(fd[0], 2, start);
measured_usleep(batch_duration_ns / 1000);
slept = pmu_read_multi(fd[0], 2, val) - slept;
+ freq[0] = 1e9*(val[0] - start[0]) / slept;
+ freq[1] = 1e9*(val[1] - start[1]) / slept;
+
+ sys_min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
+ sys_req = igt_sysfs_get_u32(sysfs, "gt_cur_freq_mhz");
+ sys_act = igt_sysfs_get_u32(sysfs, "gt_act_freq_mhz");
+
close(fd[0]);
close(fd[1]);
+ igt_spin_free(gem_fd, spin);
+ gem_quiescent_gpu(gem_fd);
+ put_ahnd(ahnd);
+ close(sysfs);
- idle[0] = 1e9*(val[0] - start[0]) / slept;
- idle[1] = 1e9*(val[1] - start[1]) / slept;
+ igt_info("PMU: requested %.1f, actual %.1f, sysfs: requested %u, actual %u; HW min %u\n",
+ freq[0], freq[1], sys_req, sys_act, sys_min);
- igt_info("Idle frequency: requested %.1f, actual %.1f; HW min %u\n",
- idle[0], idle[1], min_freq);
+ assert_within_epsilon(freq[0], sys_req, tolerance);
+ assert_within_epsilon(freq[1], sys_act, tolerance);
- igt_assert_f(idle[0] <= min_freq,
- "Request frequency should be 0 while parked!\n");
- igt_assert_f(idle[1] <= min_freq,
- "Actual frequency should be 0 while parked!\n");
+ if (!busy) {
+ igt_assert_f(freq[0] <= sys_min,
+ "Request frequency should be 0 while parked!\n");
+ igt_assert_f(freq[1] <= sys_min,
+ "Actual frequency should be 0 while parked!\n");
+ }
}
static bool wait_for_rc6(int fd, int timeout)
@@ -2378,10 +2392,14 @@ igt_main
/**
* Test GPU frequency.
*/
- igt_subtest("frequency")
+ igt_subtest("frequency") {
+ igt_require(!i915_is_slpc_enabled(fd));
test_frequency(fd);
+ }
igt_subtest("frequency-idle")
- test_frequency_idle(fd);
+ test_frequency_idle_busy(fd, false);
+ igt_subtest("frequency-busy")
+ test_frequency_idle_busy(fd, true);
/**
* Test interrupt count reporting.
--
2.38.0
More information about the Intel-gfx-trybot
mailing list