summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-01-11 08:46:21 +0000
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-01-15 12:33:14 +0000
commite8fbd9b11da4e039299b3bfd5b4b7e55dac6cdc5 (patch)
treefb2dab27ada4f3d9d65acc344cf3051a1ce3ff2c
parentb64c093fe5a2b65201ebf8305491ea923151d6e7 (diff)
tests/perf_pmu: Verify busyness when PMU is enabled after engine got busy
Make sure busyness is correctly reported when PMU is enabled after the engine is already busy with a single long batch. v2: * Make the sleep unconditional and use scientific notiation for large constants. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/perf_pmu.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 45e2f614..e1653b03 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -157,6 +157,40 @@ single(int gem_fd, const struct intel_execution_engine2 *e, bool busy)
gem_quiescent_gpu(gem_fd);
}
+static void
+busy_start(int gem_fd, const struct intel_execution_engine2 *e)
+{
+ unsigned long slept;
+ igt_spin_t *spin;
+ uint64_t val;
+ int fd;
+
+ /*
+ * Defeat the busy stats delayed disable, we need to guarantee we are
+ * the first user.
+ */
+ sleep(2);
+
+ spin = __igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0);
+
+ /*
+ * Sleep for a bit after making the engine busy to make sure the PMU
+ * gets enabled when the batch is already running.
+ */
+ usleep(500e3);
+
+ fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance));
+
+ slept = measured_usleep(batch_duration_ns / 1000);
+ val = pmu_read_single(fd);
+
+ igt_spin_batch_free(gem_fd, spin);
+ close(fd);
+
+ assert_within_epsilon(val, slept, tolerance);
+ gem_quiescent_gpu(gem_fd);
+}
+
static void log_busy(int fd, unsigned int num_engines, uint64_t *val)
{
char buf[1024];
@@ -1164,6 +1198,13 @@ igt_main
*/
igt_subtest_f("multi-client-%s", e->name)
multi_client(fd, e);
+
+ /**
+ * Check that reported usage is correct when PMU is enabled
+ * after the batch is running.
+ */
+ igt_subtest_f("busy-start-%s", e->name)
+ busy_start(fd, e);
}
/**