A client that submits 'bad' contexts will be banned eventually while
other clients are not affected. Add a test for this.

v2
        - Do not use a fixed number of contexts to ban client (Chris)

Signed-off-by: Antonio Argenziano <antonio.argenzi...@intel.com>

Cc: Michel Thierry <michel.thie...@intel.com>
Cc: Chris Wilson <ch...@chris-wilson.co.uk>
---
 tests/gem_reset_stats.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index edc40767..da309237 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -438,6 +438,61 @@ static void test_ban_ctx(const struct 
intel_execution_engine *e)
        close(fd);
 }
 
+static void test_client_ban(const struct intel_execution_engine *e)
+{
+       int fd_bad,fd_good;
+       struct local_drm_i915_reset_stats rs_bad, rs_good;
+       int ban, ctx_bans_retry = 10;
+       int client_ban, client_bans_retry = 10;
+       uint32_t ctx_bad;
+       uint32_t test_ctx;
+       int active_count = 0;
+
+       fd_bad = drm_open_driver(DRIVER_INTEL);
+       fd_good = drm_open_driver(DRIVER_INTEL);
+
+       assert_reset_status(fd_bad, fd_bad, 0, RS_NO_ERROR);
+       assert_reset_status(fd_good, fd_good, 0, RS_NO_ERROR);
+
+       while (client_bans_retry--) {
+               client_ban = __gem_context_create(fd_bad, &ctx_bad);
+               if (client_ban == -EIO)
+                       break;
+
+               noop(fd_bad, ctx_bad, e);
+               assert_reset_status(fd_bad, fd_bad, ctx_bad, RS_NO_ERROR);
+
+               ctx_bans_retry = 10;
+               active_count = 0;
+               while (ctx_bans_retry--) {
+                       inject_hang(fd_bad, ctx_bad, e, BAN);
+                       active_count++;
+
+                       ban = noop(fd_bad, ctx_bad, e);
+                       if (ban == -EIO)
+                               break;
+               }
+
+               igt_assert_eq(ban, -EIO);
+
+               assert_reset_status(fd_bad, fd_bad, ctx_bad, RS_BATCH_ACTIVE);
+               igt_assert_eq(gem_reset_stats(fd_bad, ctx_bad, &rs_bad), 0);
+               igt_assert_eq(rs_bad.batch_active, active_count);
+
+               igt_debug("retrying for client ban (%d)\n", client_bans_retry);
+       }
+
+       igt_assert_eq(__gem_context_create(fd_bad, &test_ctx), -EIO);
+
+       igt_assert_lt(0, noop(fd_good, 0, e));
+       assert_reset_status(fd_good, fd_good, 0, RS_NO_ERROR);
+       igt_assert_eq(gem_reset_stats(fd_good, 0, &rs_good), 0);
+       igt_assert_eq(rs_good.batch_active, 0);
+
+       close(fd_bad);
+       close(fd_good);
+}
+
 static void test_unrelated_ctx(const struct intel_execution_engine *e)
 {
        int fd1,fd2;
@@ -817,6 +872,9 @@ igt_main
                igt_subtest_f("ban-ctx-%s", e->name)
                        RUN_CTX_TEST(test_ban_ctx(e));
 
+               igt_subtest_f("ban-client-%s", e->name)
+                       RUN_CTX_TEST(test_client_ban(e));
+
                igt_subtest_f("reset-count-%s", e->name)
                        RUN_TEST(test_reset_count(e, false));
 
-- 
2.14.1

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

Reply via email to