All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Argenziano <antonio.argenziano@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t v2] tests/gem_ctx_param: Update invalid param
Date: Tue, 19 Dec 2017 13:16:40 -0800	[thread overview]
Message-ID: <20171219211640.21730-1-antonio.argenziano@intel.com> (raw)

Since commit: drm/i915/scheduler: Support user-defined priorities, the
driver support an extra context param to set context's priority. Add
tests for that interface and update invalid tests.

v2:
	- Add arg size validation test. (Chris)
	- Add arg value overflow test. (Chris)
	- Add test for unsupported platforms. (Chris)
	- Feed interface with all priority values and in random order. (Chris)

Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>
---
 tests/gem_ctx_param.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 142 insertions(+), 1 deletion(-)

diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index c20ae1ee..96eb2c3a 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -25,6 +25,7 @@
  */
 
 #include "igt.h"
+#include <limits.h>
 
 IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
 
@@ -136,11 +137,151 @@ igt_main
 		gem_context_set_param(fd, &arg);
 	}
 
+	arg.param = I915_CONTEXT_PARAM_PRIORITY;
+
+#define MAX_USER_SET_PRIO I915_CONTEXT_DEFAULT_PRIORITY /* Current max prio for non-root users */
+#define PRIO_RANGE (I915_CONTEXT_MAX_USER_PRIORITY - I915_CONTEXT_MIN_USER_PRIORITY)
+#define USER_PRIO_RANGE (MAX_USER_SET_PRIO - I915_CONTEXT_MIN_USER_PRIORITY)
+
+	igt_subtest("set-priority-not-supported") {
+			igt_require(!gem_scheduler_has_ctx_priority(fd));
+
+			arg.ctx_id = ctx;
+			arg.size = 0;
+
+			igt_assert_eq(__gem_context_set_param(fd, &arg), -ENODEV);
+	}
+
+	igt_subtest_group {
+		igt_fixture {
+			igt_require(gem_scheduler_has_ctx_priority(fd));
+		}
+
+		igt_subtest("get-priority-new-ctx") {
+			arg.ctx_id = gem_context_create(fd);
+
+			gem_context_get_param(fd, &arg);
+			igt_assert_eq(arg.value, 0);
+		}
+
+		igt_subtest("set-priority-invalid-size") {
+			arg.ctx_id = ctx;
+			arg.value = 0;
+			arg.size = ~0;
+
+			igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
+		}
+
+		igt_subtest("root-set-priority") {
+			int prio_values[PRIO_RANGE + 1];
+			for (int i = 0; i < PRIO_RANGE + 1; i++)
+				prio_values[i] = i + I915_CONTEXT_MIN_USER_PRIORITY;
+			igt_permute_array(prio_values, ARRAY_SIZE(prio_values), igt_exchange_int);
+
+			arg.ctx_id = ctx;
+			arg.size = 0;
+
+			for (int i = 0; i < PRIO_RANGE + 1; i++) {
+				arg.value = prio_values[i];
+				gem_context_set_param(fd, &arg);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert_eq(arg.value, prio_values[i]); /* Verify prio was set */
+			}
+		}
+
+		igt_subtest("root-set-priority-invalid-value") {
+			int prio_levels[]
+				= {INT_MIN,
+					I915_CONTEXT_MIN_USER_PRIORITY - 1,
+					I915_CONTEXT_MAX_USER_PRIORITY + 1,
+					INT_MAX}; /* Test space too big pick significant values */
+			int old_value;
+			arg.ctx_id = ctx;
+
+			gem_context_get_param(fd, &arg);
+			old_value = arg.value;
+
+			for (int i = 0; i < ARRAY_SIZE(prio_levels); i++) {
+				arg.value = prio_levels[i];
+				igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert_eq(arg.value, old_value); /* Verify prio was not set */
+			}
+		}
+
+		igt_subtest("root-set-priority-overflow-value") {
+			uint64_t prio_values[PRIO_RANGE + 1];
+			for (int i = 0; i < PRIO_RANGE + 1; i++)
+				prio_values[i] = (0x1 << 32) + (i + I915_CONTEXT_MIN_USER_PRIORITY);
+			igt_permute_array(prio_values, ARRAY_SIZE(prio_values), igt_exchange_int);
+
+			arg.ctx_id = gem_context_create(fd);
+			arg.size = 0;
+
+			for (int i = 0; i < PRIO_RANGE + 1; i++) {
+				arg.value = prio_values[i];
+				igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert_eq(arg.value, I915_CONTEXT_DEFAULT_PRIORITY); /* Verify prio was set */
+			}
+		}
+
+		igt_subtest("user-set-priority") {
+			int prio_values[USER_PRIO_RANGE + 1];
+			for (int i = 0; i < USER_PRIO_RANGE + 1; i++)
+				prio_values[i] = i + I915_CONTEXT_MIN_USER_PRIORITY;
+			igt_permute_array(prio_values, ARRAY_SIZE(prio_values), igt_exchange_int);
+
+			igt_fork(child, 1) {
+				igt_drop_root();
+				for (int i = 0; i < USER_PRIO_RANGE; i++) {
+					arg.size = 0;
+					arg.value = prio_values[i];
+
+					igt_debug("Setting prio: %d\n", prio_values[i]);
+					gem_context_set_param(fd, &arg);
+
+					gem_context_get_param(fd, &arg);
+					igt_assert_eq(arg.value, prio_values[i]); /* Verify prio was set */
+				}
+			}
+
+			igt_waitchildren();
+		}
+
+		igt_subtest("user-set-priority-invalid-value") {
+			int prio_values[PRIO_RANGE - USER_PRIO_RANGE];
+			for (int i = 0; i < (PRIO_RANGE - USER_PRIO_RANGE); i++)
+				prio_values[i] = i + (MAX_USER_SET_PRIO + 1);
+			igt_permute_array(prio_values, ARRAY_SIZE(prio_values), igt_exchange_int);
+
+			arg.ctx_id = gem_context_create(fd);
+			arg.size = 0;
+
+			igt_fork(child, 1) {
+				igt_drop_root();
+
+				for (int i = 0; i < ARRAY_SIZE(prio_values); i++) {
+					arg.value = prio_values[i];
+					igt_assert_eq(__gem_context_set_param(fd, &arg), -EPERM);
+
+					gem_context_get_param(fd, &arg);
+					igt_assert_eq(arg.value, I915_CONTEXT_DEFAULT_PRIORITY); /* Verify prio was not set */
+				}
+			}
+
+			igt_waitchildren();
+		}
+	}
+
 	/* NOTE: This testcase intentionally tests for the next free parameter
 	 * to catch ABI extensions. Don't "fix" this testcase without adding all
 	 * the tests for the new param first.
 	 */
-	arg.param = I915_CONTEXT_PARAM_BANNABLE + 1;
+	arg.param = I915_CONTEXT_PARAM_PRIORITY + 1;
 
 	igt_subtest("invalid-param-get") {
 		arg.ctx_id = ctx;
-- 
2.14.2

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

             reply	other threads:[~2017-12-19 21:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 21:16 Antonio Argenziano [this message]
2017-12-19 21:27 ` [PATCH i-g-t v2] tests/gem_ctx_param: Update invalid param Chris Wilson
2017-12-19 21:45 ` ✓ Fi.CI.BAT: success for tests/gem_ctx_param: Update invalid param (rev2) Patchwork
2017-12-19 23:24 ` ✓ 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=20171219211640.21730-1-antonio.argenziano@intel.com \
    --to=antonio.argenziano@intel.com \
    --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.