From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Helper to spin till a specified timeout
Date: Wed, 29 May 2019 23:12:00 -0700 [thread overview]
Message-ID: <c9ddc57da367de874ba0d46ebc459674debf708e.1559195231.git.ashutosh.dixit@intel.com> (raw)
In-Reply-To: <c483bec64077c4b32991d6fbfa534c29f726f722.1559193413.git.ashutosh.dixit@intel.com>
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.
v2: Use the new engine API
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..732139a1 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)
+{
+ const struct intel_execution_engine2 *e;
+
+ __for_each_physical_engine(fd, e) {
+ struct igt_spin_factory opts = { .engine = e->flags };
+
+ 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
next prev parent reply other threads:[~2019-05-30 6:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Ashutosh Dixit [this message]
2019-05-30 6:56 ` [igt-dev] [PATCH i-g-t] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9ddc57da367de874ba0d46ebc459674debf708e.1559195231.git.ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox