All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_persistence: Check that we cannot hide hangs on old engines
Date: Wed,  5 Feb 2020 13:48:56 +0000	[thread overview]
Message-ID: <20200205134856.1886849-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20200205133154.1886680-1-chris@chris-wilson.co.uk>

As the kernel loses track of the context's old engines, if we request
that the context is non-persistent then any request on the untracked
engines must be cancelled.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/i915/gem_ctx_persistence.c | 60 +++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index c54797e9b..04a6c179e 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -761,6 +761,49 @@ static void smoketest(int i915)
 	gem_quiescent_gpu(i915);
 }
 
+static void replace_engines_hostile(int i915,
+				    const struct intel_execution_engine2 *e)
+{
+	I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = {
+		.engines = {{ e->class, e->instance }}
+	};
+	struct drm_i915_gem_context_param param = {
+		.ctx_id = gem_context_create(i915),
+		.param = I915_CONTEXT_PARAM_ENGINES,
+		.value = to_user_pointer(&engines),
+		.size = sizeof(engines),
+	};
+	igt_spin_t *spin[2];
+	int64_t timeout;
+
+	/*
+	 * Suppose the user tries to hide a hanging batch by replacing
+	 * the set of engines on the context so that it's not visible
+	 * at the time of closure? Then we must act when they replace
+	 * the engines!
+	 */
+
+	gem_context_set_persistence(i915, param.ctx_id, false);
+
+	gem_context_set_param(i915, &param);
+	spin[0] = igt_spin_new(i915, param.ctx_id);
+
+	gem_context_set_param(i915, &param);
+	spin[1] = igt_spin_new(i915, param.ctx_id);
+
+	gem_context_destroy(i915, param.ctx_id);
+
+	timeout = reset_timeout_ms * NSEC_PER_MSEC;
+	igt_assert_eq(gem_wait(i915, spin[1]->handle, &timeout), 0);
+
+	timeout = reset_timeout_ms * NSEC_PER_MSEC;
+	igt_assert_eq(gem_wait(i915, spin[0]->handle, &timeout), 0);
+
+	igt_spin_free(i915, spin[1]);
+	igt_spin_free(i915, spin[0]);
+	gem_quiescent_gpu(i915);
+}
+
 int i915;
 
 static void exit_handler(int sig)
@@ -793,10 +836,10 @@ igt_main
 		igt_assert(igt_sysfs_set_parameter
 			   (i915, "reset", "%d", -1 /* any [default] reset */));
 
-		igt_require(has_persistence(i915));
 		enable_hangcheck(i915);
 		igt_install_exit_handler(exit_handler);
 
+		igt_require(has_persistence(i915));
 		igt_allow_hang(i915, 0, 0);
 	}
 
@@ -861,6 +904,21 @@ igt_main
 			smoketest(i915);
 	}
 
+	/* Check interactions with set-engines */
+	igt_subtest_group {
+		const struct intel_execution_engine2 *e;
+
+		igt_fixture
+			gem_require_contexts(i915);
+
+		igt_subtest_with_dynamic("replace-hostile") {
+			__for_each_physical_engine(i915, e) {
+				igt_dynamic_f("%s", e->name)
+					replace_engines_hostile(i915, e);
+			}
+		}
+	}
+
 	igt_fixture {
 		close(i915);
 	}
-- 
2.25.0

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

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org, Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH i-g-t] i915/gem_ctx_persistence: Check that we cannot hide hangs on old engines
Date: Wed,  5 Feb 2020 13:48:56 +0000	[thread overview]
Message-ID: <20200205134856.1886849-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20200205133154.1886680-1-chris@chris-wilson.co.uk>

As the kernel loses track of the context's old engines, if we request
that the context is non-persistent then any request on the untracked
engines must be cancelled.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/i915/gem_ctx_persistence.c | 60 +++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index c54797e9b..04a6c179e 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -761,6 +761,49 @@ static void smoketest(int i915)
 	gem_quiescent_gpu(i915);
 }
 
+static void replace_engines_hostile(int i915,
+				    const struct intel_execution_engine2 *e)
+{
+	I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = {
+		.engines = {{ e->class, e->instance }}
+	};
+	struct drm_i915_gem_context_param param = {
+		.ctx_id = gem_context_create(i915),
+		.param = I915_CONTEXT_PARAM_ENGINES,
+		.value = to_user_pointer(&engines),
+		.size = sizeof(engines),
+	};
+	igt_spin_t *spin[2];
+	int64_t timeout;
+
+	/*
+	 * Suppose the user tries to hide a hanging batch by replacing
+	 * the set of engines on the context so that it's not visible
+	 * at the time of closure? Then we must act when they replace
+	 * the engines!
+	 */
+
+	gem_context_set_persistence(i915, param.ctx_id, false);
+
+	gem_context_set_param(i915, &param);
+	spin[0] = igt_spin_new(i915, param.ctx_id);
+
+	gem_context_set_param(i915, &param);
+	spin[1] = igt_spin_new(i915, param.ctx_id);
+
+	gem_context_destroy(i915, param.ctx_id);
+
+	timeout = reset_timeout_ms * NSEC_PER_MSEC;
+	igt_assert_eq(gem_wait(i915, spin[1]->handle, &timeout), 0);
+
+	timeout = reset_timeout_ms * NSEC_PER_MSEC;
+	igt_assert_eq(gem_wait(i915, spin[0]->handle, &timeout), 0);
+
+	igt_spin_free(i915, spin[1]);
+	igt_spin_free(i915, spin[0]);
+	gem_quiescent_gpu(i915);
+}
+
 int i915;
 
 static void exit_handler(int sig)
@@ -793,10 +836,10 @@ igt_main
 		igt_assert(igt_sysfs_set_parameter
 			   (i915, "reset", "%d", -1 /* any [default] reset */));
 
-		igt_require(has_persistence(i915));
 		enable_hangcheck(i915);
 		igt_install_exit_handler(exit_handler);
 
+		igt_require(has_persistence(i915));
 		igt_allow_hang(i915, 0, 0);
 	}
 
@@ -861,6 +904,21 @@ igt_main
 			smoketest(i915);
 	}
 
+	/* Check interactions with set-engines */
+	igt_subtest_group {
+		const struct intel_execution_engine2 *e;
+
+		igt_fixture
+			gem_require_contexts(i915);
+
+		igt_subtest_with_dynamic("replace-hostile") {
+			__for_each_physical_engine(i915, e) {
+				igt_dynamic_f("%s", e->name)
+					replace_engines_hostile(i915, e);
+			}
+		}
+	}
+
 	igt_fixture {
 		close(i915);
 	}
-- 
2.25.0

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

  reply	other threads:[~2020-02-05 13:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 13:31 [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_persistence: Check that we cannot hide hangs on old engines Chris Wilson
2020-02-05 13:31 ` [igt-dev] " Chris Wilson
2020-02-05 13:48 ` Chris Wilson [this message]
2020-02-05 13:48   ` Chris Wilson
2020-02-05 15:50   ` [Intel-gfx] " Tvrtko Ursulin
2020-02-05 15:50     ` [igt-dev] " Tvrtko Ursulin
2020-02-05 14:17 ` [igt-dev] ✗ GitLab.Pipeline: failure for i915/gem_ctx_persistence: Check that we cannot hide hangs on old engines (rev2) Patchwork
2020-02-05 14:33 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-02-08  0:26 ` [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=20200205134856.1886849-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.