[PATCH i-g-t 1/2] tests/perf_pmu: Verify busyness when PMU is enabled after engine got busy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

Make sure busyness is correctly reported when PMU is enabled after the
engine is already busy with a single long batch.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
---
 tests/perf_pmu.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 45e2f6148453..e1f449d48808 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -157,6 +157,41 @@ 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.
+	 */
+	if (gem_has_execlists(gem_fd))
+		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(500000);
+
+	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 +1199,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);
 	}
 
 	/**
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux