public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Helper to spin till a specified timeout
@ 2019-05-30  5:26 Ashutosh Dixit
  2019-05-30  6:10 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2019-05-30  5:26 UTC (permalink / raw)
  To: igt-dev

From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>

Even though similar functionality exists in other tests, perhaps there
is value in having a helper function which generates an artificial
load on an engine by spinning on it for a specified time.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 lib/igt_dummyload.c         | 23 +++++++++++++++++++++++
 lib/igt_dummyload.h         |  1 +
 tests/i915/gem_spin_batch.c | 17 +++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 0e06276a..7a2e5f4d 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -473,6 +473,29 @@ void igt_unshare_spins(void)
 	igt_list_init(&spin_list);
 }
 
+/**
+ * igt_spin_timeout:
+ * @fd: open i915 drm file descriptor
+ * @opts: controlling options such as context, engine, dependencies etc
+ * @ns: timeout in nano seconds
+ *
+ * Generate an artificial load on an engine by spinning for a specified
+ * timeout.
+ */
+int igt_spin_timeout(int fd, const struct igt_spin_factory *opts, int64_t ns)
+{
+       igt_spin_t *spin;
+
+       spin = igt_spin_factory(fd, opts);
+       if (!spin)
+	       return -EINVAL;
+
+       igt_spin_set_timeout(spin, ns);
+       gem_sync(fd, spin->handle);
+       igt_spin_free(fd, spin);
+       return 0;
+}
+
 static uint32_t plug_vgem_handle(struct igt_cork *cork, int fd)
 {
 	struct vgem_bo bo;
diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
index bb25751a..b3cf2124 100644
--- a/lib/igt_dummyload.h
+++ b/lib/igt_dummyload.h
@@ -94,6 +94,7 @@ static inline void igt_spin_busywait_until_started(igt_spin_t *spin)
 
 void igt_terminate_spins(void);
 void igt_unshare_spins(void);
+int igt_spin_timeout(int fd, const struct igt_spin_factory *opts, int64_t nsec);
 
 enum igt_cork_type {
 	CORK_SYNC_FD = 1,
diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index 3b4f9073..3b050ad0 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -32,6 +32,20 @@
 		     "'%s' != '%s' (%lld not within %d%% tolerance of %lld)\n",\
 		     #x, #ref, (long long)x, tolerance, (long long)ref)
 
+static void spin_timeout_all_engines(int fd, unsigned int sec)
+{
+	unsigned engine;
+
+	for_each_physical_engine(fd, engine) {
+		struct igt_spin_factory opts = { .engine = engine };
+
+		igt_fork(child, 1)
+			igt_spin_timeout(fd, &opts, sec * NSEC_PER_SEC);
+	}
+
+	igt_waitchildren();
+}
+
 static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
 {
 	const uint64_t timeout_100ms = 100000000LL;
@@ -162,6 +176,9 @@ igt_main
 	igt_subtest("spin-each")
 		spin_on_all_engines(fd, 3);
 
+	igt_subtest("spin-timeout")
+		spin_timeout_all_engines(fd, 1);
+
 	igt_fixture {
 		igt_stop_hang_detector();
 		close(fd);
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-05-31 14:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30  5:26 [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Helper to spin till a specified timeout Ashutosh Dixit
2019-05-30  6:10 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-05-30  6:12 ` [igt-dev] [PATCH i-g-t] " Ashutosh Dixit
2019-05-30  6:56 ` Chris Wilson
2019-05-31  2:54   ` Ashutosh Dixit
2019-05-31  6:26     ` Chris Wilson
2019-05-30  7:10 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_dummyload: Helper to spin till a specified timeout (rev2) Patchwork
2019-05-30 10:00 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/igt_dummyload: Helper to spin till a specified timeout Patchwork
2019-05-31  7:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_dummyload: Helper to spin till a specified timeout (rev2) Patchwork
2019-05-31  7:29 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_dummyload: Helper to spin till a specified timeout Patchwork
2019-05-31 14:33 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox