summaryrefslogtreecommitdiff
path: root/tests/perf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/perf.c')
-rw-r--r--tests/perf.c141
1 files changed, 9 insertions, 132 deletions
diff --git a/tests/perf.c b/tests/perf.c
index f7ecf38b..2304e6c0 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -293,12 +293,9 @@ static int card = -1;
static int n_eus;
static uint64_t test_metric_set_id = UINT64_MAX;
-static uint64_t gt_min_freq_mhz_saved = 0;
-static uint64_t gt_max_freq_mhz_saved = 0;
-static uint64_t gt_min_freq_mhz = 0;
-static uint64_t gt_max_freq_mhz = 0;
static uint64_t timestamp_frequency = 12500000;
+static uint64_t gt_max_freq_mhz = 0;
static enum drm_i915_oa_format test_oa_format;
static bool *undefined_a_counters;
static uint64_t oa_exp_1_millisec;
@@ -402,16 +399,6 @@ sysfs_read(const char *file)
return read_u64_file(buf);
}
-static void
-sysfs_write(const char *file, uint64_t val)
-{
- char buf[512];
-
- snprintf(buf, sizeof(buf), "/sys/class/drm/card%d/%s", card, file);
-
- write_u64_file(buf, val);
-}
-
static char *
read_debugfs_record(int device, const char *file, const char *key)
{
@@ -1008,54 +995,6 @@ init_sys_info(void)
return try_read_u64_file(buf, &test_metric_set_id);
}
-static void
-gt_frequency_range_save(void)
-{
- gt_min_freq_mhz_saved = sysfs_read("gt_min_freq_mhz");
- gt_max_freq_mhz_saved = sysfs_read("gt_max_freq_mhz");
-
- gt_min_freq_mhz = gt_min_freq_mhz_saved;
- gt_max_freq_mhz = gt_max_freq_mhz_saved;
-}
-
-static void
-gt_frequency_pin(int gt_freq_mhz)
-{
- igt_debug("requesting pinned GT freq = %dmhz\n", gt_freq_mhz);
-
- if (gt_freq_mhz > gt_max_freq_mhz) {
- sysfs_write("gt_max_freq_mhz", gt_freq_mhz);
- sysfs_write("gt_min_freq_mhz", gt_freq_mhz);
- } else {
- sysfs_write("gt_min_freq_mhz", gt_freq_mhz);
- sysfs_write("gt_max_freq_mhz", gt_freq_mhz);
- }
- gt_min_freq_mhz = gt_freq_mhz;
- gt_max_freq_mhz = gt_freq_mhz;
-}
-
-static void
-gt_frequency_range_restore(void)
-{
- igt_debug("restoring GT frequency range: min = %dmhz, max =%dmhz, current: min=%dmhz, max=%dmhz\n",
- (int)gt_min_freq_mhz_saved,
- (int)gt_max_freq_mhz_saved,
- (int)gt_min_freq_mhz,
- (int)gt_max_freq_mhz);
-
- /* Assume current min/max are the same */
- if (gt_min_freq_mhz_saved > gt_max_freq_mhz) {
- sysfs_write("gt_max_freq_mhz", gt_max_freq_mhz_saved);
- sysfs_write("gt_min_freq_mhz", gt_min_freq_mhz_saved);
- } else {
- sysfs_write("gt_min_freq_mhz", gt_min_freq_mhz_saved);
- sysfs_write("gt_max_freq_mhz", gt_max_freq_mhz_saved);
- }
-
- gt_min_freq_mhz = gt_min_freq_mhz_saved;
- gt_max_freq_mhz = gt_max_freq_mhz_saved;
-}
-
static int
i915_read_reports_until_timestamp(enum drm_i915_oa_format oa_format,
uint8_t *buf,
@@ -1632,33 +1571,9 @@ test_oa_formats(void)
}
static void
-test_oa_exponents(int gt_freq_mhz)
+test_oa_exponents(void)
{
- uint32_t freq_margin;
-
- /* This test tries to use the sysfs interface for pinning the GT
- * frequency so we have another point of reference for comparing with
- * the clock frequency as derived from OA reports.
- *
- * This test has been finicky to stabilise while the
- * gt_min/max_freq_mhz files in sysfs don't seem to be a reliable
- * mechanism for fixing the gpu frequency.
- *
- * Since these unit tests are focused on the OA unit not the ability to
- * pin the frequency via sysfs we make the test account for pinning not
- * being reliable and read back the current frequency for each
- * iteration of this test to take this into account.
- */
- gt_frequency_pin(gt_freq_mhz);
-
- igt_debug("Testing OA timer exponents with requested GT frequency = %dmhz\n",
- gt_freq_mhz);
-
- /* allow a +- 10% error margin when checking that the frequency
- * calculated from the OA reports matches the frequency according to
- * sysfs.
- */
- freq_margin = gt_freq_mhz * 0.1;
+ igt_debug("Testing OA timer exponents\n");
/* It's asking a lot to sample with a 160 nanosecond period and the
* test can fail due to buffer overflows if it wasn't possible to
@@ -1673,7 +1588,6 @@ test_oa_exponents(int gt_freq_mhz)
uint32_t clock_delta;
uint32_t freq;
int n_tested = 0;
- int n_freq_matches = 0;
/* The exponent is effectively selecting a bit in the timestamp
* to trigger reports on and so in practice we expect the raw
@@ -1683,15 +1597,10 @@ test_oa_exponents(int gt_freq_mhz)
expected_timestamp_delta = 2 << i;
for (int j = 0; n_tested < 10 && j < 100; j++) {
- int gt_freq_mhz_0, gt_freq_mhz_1;
uint32_t ticks0, ticks1;
- gt_freq_mhz_0 = sysfs_read("gt_act_freq_mhz");
-
- igt_debug("ITER %d: testing OA exponent %d (period = %"PRIu64"ns) with sysfs GT freq = %dmhz +- %u\n",
- j, i,
- oa_exponent_to_ns(i),
- gt_freq_mhz_0, freq_margin);
+ igt_debug("ITER %d: testing OA exponent %d (period = %"PRIu64"ns)\n",
+ j, i, oa_exponent_to_ns(i));
open_and_read_2_oa_reports(test_oa_format,
i, /* exponent */
@@ -1700,16 +1609,6 @@ test_oa_exponents(int gt_freq_mhz)
true); /* timer triggered
reports only */
- gt_freq_mhz_1 = sysfs_read("gt_act_freq_mhz");
-
- /* If it looks like the frequency has changed according
- * to sysfs then skip looking at this pair of reports
- */
- if (gt_freq_mhz_0 != gt_freq_mhz_1) {
- igt_debug("skipping OA reports pair due to GT frequency change according to sysfs\n");
- continue;
- }
-
timestamp_delta = oa_report1[1] - oa_report0[1];
igt_assert_neq(timestamp_delta, 0);
@@ -1732,31 +1631,13 @@ test_oa_exponents(int gt_freq_mhz)
igt_debug("ITER %d: time delta = %"PRIu32"(ns) clock delta = %"PRIu32" freq = %"PRIu32"(mhz)\n",
j, time_delta, clock_delta, freq);
- if (freq < (gt_freq_mhz_1 + freq_margin) &&
- freq > (gt_freq_mhz_1 - freq_margin))
- n_freq_matches++;
-
n_tested++;
}
if (n_tested < 10)
igt_debug("sysfs frequency pinning too unstable for cross-referencing with OA derived frequency");
igt_assert_eq(n_tested, 10);
-
- igt_debug("number of iterations with expected clock frequency = %d\n",
- n_freq_matches);
-
- /* Don't assert the calculated frequency for extremely short
- * durations.
- *
- * Allow some mismatches since can't be can't be sure about
- * frequency changes between sysfs reads.
- */
- if (i > 3)
- igt_assert(n_freq_matches >= 7);
}
-
- gt_frequency_range_restore();
}
/* The OA exponent selects a timestamp counter bit to trigger reports on.
@@ -3978,11 +3859,11 @@ igt_main
igt_require(init_sys_info());
- gt_frequency_range_save();
-
write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1);
write_u64_file("/proc/sys/dev/i915/oa_max_sample_rate", 100000);
+ gt_max_freq_mhz = sysfs_read("gt_boost_freq_mhz");
+
render_copy = igt_get_render_copyfunc(devid);
igt_require_f(render_copy, "no render-copy function\n");
}
@@ -4009,10 +3890,8 @@ igt_main
test_invalid_oa_exponent();
igt_subtest("low-oa-exponent-permissions")
test_low_oa_exponent_permissions();
- igt_subtest("oa-exponents") {
- test_oa_exponents(450);
- test_oa_exponents(550);
- }
+ igt_subtest("oa-exponents")
+ test_oa_exponents();
igt_subtest("per-context-mode-unprivileged") {
igt_require(IS_HASWELL(devid));
@@ -4078,8 +3957,6 @@ igt_main
write_u64_file("/proc/sys/dev/i915/oa_max_sample_rate", 100000);
write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1);
- gt_frequency_range_restore();
-
close(drm_fd);
}
}