[Intel-gfx] [PATCH igt 4/5] igt/perf_pmu: Measure the reference batch for all-busy-check-all
Chris Wilson
chris at chris-wilson.co.uk
Fri Dec 22 11:03:22 UTC 2017
Don't rely on the timer being precise when we can sleep for a known
duration.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
tests/perf_pmu.c | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index b3b289656..d88287c17 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -288,36 +288,50 @@ all_busy_check_all(int gem_fd, const unsigned int num_engines)
const struct intel_execution_engine2 *e;
uint64_t val[num_engines];
int fd[num_engines];
- igt_spin_t *spin[num_engines];
+ unsigned long slept;
+ igt_spin_t *spin = NULL;
unsigned int i;
i = 0;
- fd[0] = -1;
for_each_engine_class_instance(fd, e) {
if (!gem_has_engine(gem_fd, e->class, e->instance))
continue;
- fd[i] = open_group(I915_PMU_ENGINE_BUSY(e->class, e->instance),
- fd[0]);
-
- spin[i] = igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0);
- igt_spin_batch_set_timeout(spin[i], batch_duration_ns);
+ if (spin) {
+ struct drm_i915_gem_exec_object2 obj = {
+ .handle = spin->handle
+ };
+ struct drm_i915_gem_execbuffer2 eb = {
+ .buffer_count = 1,
+ .buffers_ptr = to_user_pointer(&obj),
+ .flags = e2ring(gem_fd, e),
+ };
+ gem_execbuf(gem_fd, &eb);
+ } else {
+ spin = igt_spin_batch_new(gem_fd, 0,
+ e2ring(gem_fd, e), 0);
+ }
- i++;
+ val[i++] = I915_PMU_ENGINE_BUSY(e->class, e->instance);
}
+ igt_assert(i == num_engines);
+ fd[0] = -1;
for (i = 0; i < num_engines; i++)
- gem_sync(gem_fd, spin[i]->handle);
+ fd[i] = open_group(val[i], fd[0]);
+
+ slept = measured_usleep(batch_duration_ns / 1000);
+ igt_spin_batch_end(spin);
pmu_read_multi(fd[0], num_engines, val);
log_busy(fd[0], num_engines, val);
- for (i = 0; i < num_engines; i++)
- igt_spin_batch_free(gem_fd, spin[i]);
+ igt_spin_batch_free(gem_fd, spin);
close(fd[0]);
for (i = 0; i < num_engines; i++)
- assert_within_epsilon(val[i], batch_duration_ns, tolerance);
+ assert_within_epsilon(val[i], slept, tolerance);
+ gem_quiescent_gpu(gem_fd);
}
static void
--
2.15.1
More information about the Intel-gfx
mailing list