* [PATCH igt 1/2] lib/igt_aux: Add function to swap int64 in array
@ 2018-02-16 13:49 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:49 UTC (permalink / raw)
To: intel-gfx; +Cc: igt-dev
From: Antonio Argenziano <antonio.argenziano@intel.com>
v2: Use igt_swap()
Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
lib/igt_aux.c | 16 ++++++++++++++++
lib/igt_aux.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 8ca0b60d..a23375a4 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -577,6 +577,22 @@ void igt_exchange_int(void *array, unsigned i, unsigned j)
int_arr[j] = tmp;
}
+/**
+ * igt_exchange_int64:
+ * @array: pointer to the array of int64_t
+ * @i: first position
+ * @j: second position
+ *
+ * Exchanges the two values at array indices @i and @j. Useful as an exchange
+ * function for igt_permute_array().
+ */
+void igt_exchange_int64(void *array, unsigned i, unsigned j)
+{
+ int64_t *a = array;
+
+ igt_swap(a[i], a[j]);
+}
+
/**
* igt_permute_array:
* @array: pointer to array
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index f9c75992..43dd15fe 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -118,6 +118,7 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt);
for (struct timespec t__={}; igt_nsec_elapsed(&t__)>>20 < (t); )
void igt_exchange_int(void *array, unsigned i, unsigned j);
+void igt_exchange_int64(void *array, unsigned i, unsigned j);
void igt_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
unsigned i,
--
2.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [igt-dev] [PATCH igt 1/2] lib/igt_aux: Add function to swap int64 in array
@ 2018-02-16 13:49 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:49 UTC (permalink / raw)
To: intel-gfx; +Cc: igt-dev
From: Antonio Argenziano <antonio.argenziano@intel.com>
v2: Use igt_swap()
Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
lib/igt_aux.c | 16 ++++++++++++++++
lib/igt_aux.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 8ca0b60d..a23375a4 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -577,6 +577,22 @@ void igt_exchange_int(void *array, unsigned i, unsigned j)
int_arr[j] = tmp;
}
+/**
+ * igt_exchange_int64:
+ * @array: pointer to the array of int64_t
+ * @i: first position
+ * @j: second position
+ *
+ * Exchanges the two values at array indices @i and @j. Useful as an exchange
+ * function for igt_permute_array().
+ */
+void igt_exchange_int64(void *array, unsigned i, unsigned j)
+{
+ int64_t *a = array;
+
+ igt_swap(a[i], a[j]);
+}
+
/**
* igt_permute_array:
* @array: pointer to array
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index f9c75992..43dd15fe 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -118,6 +118,7 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt);
for (struct timespec t__={}; igt_nsec_elapsed(&t__)>>20 < (t); )
void igt_exchange_int(void *array, unsigned i, unsigned j);
+void igt_exchange_int64(void *array, unsigned i, unsigned j);
void igt_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
unsigned i,
--
2.16.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
@ 2018-02-16 13:49 ` Chris Wilson
-1 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:49 UTC (permalink / raw)
To: intel-gfx; +Cc: igt-dev
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/gem_ctx_param.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 136 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..c00488c7 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -25,9 +25,103 @@
*/
#include "igt.h"
+#include <limits.h>
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static void set_priority(int fd)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +232,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [igt-dev] [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param
@ 2018-02-16 13:49 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:49 UTC (permalink / raw)
To: intel-gfx; +Cc: Tvrtko Ursulin, Mika Kuoppala, igt-dev
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/gem_ctx_param.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 136 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..c00488c7 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -25,9 +25,103 @@
*/
#include "igt.h"
+#include <limits.h>
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static void set_priority(int fd)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +232,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
@ 2018-02-16 13:57 ` Chris Wilson
-1 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:57 UTC (permalink / raw)
To: intel-gfx; +Cc: igt-dev
Quoting Chris Wilson (2018-02-16 13:49:51)
> + for (unsigned i = 0; i < size; i++) {
> + int64_t prio = values[i];
> + int expected = 0;
> + int err;
> +
> + arg.value = prio;
> +
> + if (flags & USER &&
> + prio > I915_CONTEXT_DEFAULT_PRIORITY)
> + expected = -EPERM;
> +
> + if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
> + prio > I915_CONTEXT_MAX_USER_PRIORITY)
> + expected = -EINVAL;
> +
> + err =__gem_context_set_param(fd, &arg);
> + igt_assert_f(err == expected,
> + "Priority requested %" PRId64 ", expected result %d, returned %d\n",
> + prio, expected, err);
> +
> + gem_context_get_param(fd, &arg);
> + if (!err)
> + old_prio = prio;
> + igt_assert_eq(arg.value, old_prio);
Fwiw, I still believe that simply reimplementing^baking the kernel in
userspace does not make for a good test.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [igt-dev] [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param
@ 2018-02-16 13:57 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 13:57 UTC (permalink / raw)
To: intel-gfx; +Cc: Tvrtko Ursulin, Mika Kuoppala, igt-dev
Quoting Chris Wilson (2018-02-16 13:49:51)
> + for (unsigned i = 0; i < size; i++) {
> + int64_t prio = values[i];
> + int expected = 0;
> + int err;
> +
> + arg.value = prio;
> +
> + if (flags & USER &&
> + prio > I915_CONTEXT_DEFAULT_PRIORITY)
> + expected = -EPERM;
> +
> + if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
> + prio > I915_CONTEXT_MAX_USER_PRIORITY)
> + expected = -EINVAL;
> +
> + err =__gem_context_set_param(fd, &arg);
> + igt_assert_f(err == expected,
> + "Priority requested %" PRId64 ", expected result %d, returned %d\n",
> + prio, expected, err);
> +
> + gem_context_get_param(fd, &arg);
> + if (!err)
> + old_prio = prio;
> + igt_assert_eq(arg.value, old_prio);
Fwiw, I still believe that simply reimplementing^baking the kernel in
userspace does not make for a good test.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH igt] tests/gem_ctx_param: Update invalid param
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
(?)
(?)
@ 2018-02-16 18:37 ` Chris Wilson
-1 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 18:37 UTC (permalink / raw)
To: intel-gfx
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/gem_ctx_param.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 151 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..558470b3 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -24,10 +24,119 @@
* Daniel Vetter <daniel.vetter@ffwll.ch>
*/
+#include <fcntl.h>
+#include <limits.h>
+
#include "igt.h"
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static int reopen_driver(int fd)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+ fd = open(path, O_RDWR);
+ igt_assert_lte(0, fd);
+
+ return fd;
+}
+
+static void set_priority(int fd)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+ fd = reopen_driver(fd);
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +247,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib/igt_aux: Add function to swap int64 in array
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
(?)
(?)
@ 2018-02-16 14:09 ` Patchwork
-1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-02-16 14:09 UTC (permalink / raw)
To: Chris Wilson; +Cc: igt-dev
== Series Details ==
Series: series starting with [1/2] lib/igt_aux: Add function to swap int64 in array
URL : https://patchwork.freedesktop.org/series/38432/
State : success
== Summary ==
IGT patchset tested on top of latest successful build
2b64cac7d858d0c63b87e7a889a21a36bfcc4138 lib/i915_pciids.h: Add Cannonlake PCI IDs for another SKU.
with latest DRM-Tip kernel build CI_DRM_3783
8a1ed2480c14 drm-tip: 2018y-02m-16d-08h-56m-34s UTC integration manifest
Testlist changes:
+igt@gem_ctx_param@get-priority-new-ctx
+igt@gem_ctx_param@set-priority-invalid-size
+igt@gem_ctx_param@set-priority-not-supported
+igt@gem_ctx_param@set-priority-range
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:420s
fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:427s
fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:376s
fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:493s
fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:291s
fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:490s
fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:491s
fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:476s
fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:464s
fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:573s
fi-cnl-y3 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:579s
fi-elk-e7500 total:288 pass:229 dwarn:0 dfail:0 fail:0 skip:59 time:418s
fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:284s
fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:512s
fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:392s
fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:414s
fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:455s
fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:414s
fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:460s
fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:496s
fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:453s
fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:500s
fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:596s
fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:433s
fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:512s
fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:527s
fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:492s
fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:481s
fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:414s
fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:431s
fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:522s
fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:400s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_938/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 12+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] lib/igt_aux: Add function to swap int64 in array
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
` (2 preceding siblings ...)
(?)
@ 2018-02-16 16:14 ` Patchwork
-1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-02-16 16:14 UTC (permalink / raw)
To: Chris Wilson; +Cc: igt-dev
== Series Details ==
Series: series starting with [1/2] lib/igt_aux: Add function to swap int64 in array
URL : https://patchwork.freedesktop.org/series/38432/
State : success
== Summary ==
Test kms_flip:
Subgroup dpms-vs-vblank-race-interruptible:
fail -> PASS (shard-snb) fdo#103060 +1
Subgroup 2x-plain-flip-ts-check-interruptible:
fail -> PASS (shard-hsw) fdo#100368 +1
Test kms_frontbuffer_tracking:
Subgroup fbc-rgb565-draw-mmap-cpu:
fail -> PASS (shard-apl) fdo#101623
Subgroup fbc-1p-primscrn-cur-indfb-draw-mmap-cpu:
dmesg-warn -> PASS (shard-apl) fdo#105128
Subgroup fbc-rgb101010-draw-mmap-wc:
skip -> PASS (shard-snb) fdo#103167
Test kms_rotation_crc:
Subgroup sprite-rotation-180:
fail -> PASS (shard-snb) fdo#103925
Test perf:
Subgroup buffer-fill:
fail -> PASS (shard-apl) fdo#103755
Test kms_plane_multiple:
Subgroup legacy-pipe-a-tiling-none:
fail -> PASS (shard-apl) fdo#103166
Test gem_ctx_param:
Subgroup invalid-param-set:
fail -> PASS (shard-snb) fdo#103107 +5
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#103755 https://bugs.freedesktop.org/show_bug.cgi?id=103755
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103107 https://bugs.freedesktop.org/show_bug.cgi?id=103107
shard-apl total:3405 pass:1768 dwarn:1 dfail:0 fail:17 skip:1618 time:12594s
shard-hsw total:3431 pass:1761 dwarn:1 dfail:0 fail:9 skip:1659 time:11800s
shard-snb total:3431 pass:1351 dwarn:1 dfail:0 fail:9 skip:2070 time:6690s
Blacklisted hosts:
shard-kbl total:3431 pass:1909 dwarn:2 dfail:0 fail:18 skip:1502 time:9838s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_938/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 12+ messages in thread
* ✗ Fi.CI.BAT: failure for tests/gem_ctx_param: Update invalid param (rev3)
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
` (3 preceding siblings ...)
(?)
@ 2018-02-16 19:04 ` Patchwork
-1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-02-16 19:04 UTC (permalink / raw)
To: Antonio Argenziano; +Cc: intel-gfx
== Series Details ==
Series: tests/gem_ctx_param: Update invalid param (rev3)
URL : https://patchwork.freedesktop.org/series/35438/
State : failure
== Summary ==
IGT patchset build failed on latest successful build
1aec09098d3c3729ed152aee9ee4e6e656fa7a3f igt/kms_frontbuffer_tracking: Disable FBC testing for -ENODEV
CCLD core_auth
CCLD core_get_client_auth
CCLD core_getclient
CCLD core_getstats
CCLD core_getversion
CCLD core_prop_blob
CCLD core_setmaster_vs_auth
CCLD debugfs_test
CCLD drm_import_export
CCLD drm_mm
CCLD drm_read
CCLD drm_vma_limiter
CCLD drm_vma_limiter_cached
CCLD drm_vma_limiter_cpu
CCLD drm_vma_limiter_gtt
CCLD drv_getparams_basic
CCLD drv_hangman
CCLD drv_missed_irq
CCLD drv_module_reload
CCLD drv_selftest
CCLD drv_suspend
CCLD gem_bad_reloc
CCLD gem_basic
CCLD gem_busy
CCLD gem_caching
CCLD gem_close
CCLD gem_close_race
CCLD gem_concurrent_blit
CCLD gem_cpu_reloc
CCLD gem_create
CCLD gem_cs_prefetch
CCLD gem_cs_tlb
CCLD gem_ctx_bad_destroy
CCLD gem_ctx_bad_exec
CCLD gem_ctx_create
CCLD gem_ctx_exec
CC gem_ctx_param.o
gem_ctx_param.c: In function ‘set_priority’:
gem_ctx_param.c:84:34: error: ‘igt_exchange_int64’ undeclared (first use in this function)
igt_permute_array(values, size, igt_exchange_int64);
^~~~~~~~~~~~~~~~~~
gem_ctx_param.c:84:34: note: each undeclared identifier is reported only once for each function it appears in
Makefile:3903: recipe for target 'gem_ctx_param.o' failed
make[3]: *** [gem_ctx_param.o] Error 1
Makefile:4304: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
Makefile:532: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
Makefile:464: recipe for target 'all' failed
make: *** [all] Error 2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param
@ 2018-02-16 23:20 Chris Wilson
2018-02-17 9:11 ` [PATCH igt] " Chris Wilson
2018-02-17 9:49 ` Chris Wilson
0 siblings, 2 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-16 23:20 UTC (permalink / raw)
To: intel-gfx
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/gem_ctx_param.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 151 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..558470b3 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -24,10 +24,119 @@
* Daniel Vetter <daniel.vetter@ffwll.ch>
*/
+#include <fcntl.h>
+#include <limits.h>
+
#include "igt.h"
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static int reopen_driver(int fd)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+ fd = open(path, O_RDWR);
+ igt_assert_lte(0, fd);
+
+ return fd;
+}
+
+static void set_priority(int fd)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+ fd = reopen_driver(fd);
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +247,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH igt] tests/gem_ctx_param: Update invalid param
2018-02-16 23:20 [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param Chris Wilson
@ 2018-02-17 9:11 ` Chris Wilson
2018-02-17 9:49 ` Chris Wilson
1 sibling, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-17 9:11 UTC (permalink / raw)
To: intel-gfx
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/gem_ctx_param.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 151 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..6745b0f1 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -24,10 +24,119 @@
* Daniel Vetter <daniel.vetter@ffwll.ch>
*/
+#include <fcntl.h>
+#include <limits.h>
+
#include "igt.h"
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static int reopen_driver(int fd)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+ fd = open(path, O_RDWR);
+ igt_assert_lte(0, fd);
+
+ return fd;
+}
+
+static void set_priority(int i915)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ int fd = reopen_driver(i915);
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +247,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH igt] tests/gem_ctx_param: Update invalid param
2018-02-16 23:20 [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param Chris Wilson
2018-02-17 9:11 ` [PATCH igt] " Chris Wilson
@ 2018-02-17 9:49 ` Chris Wilson
1 sibling, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-02-17 9:49 UTC (permalink / raw)
To: intel-gfx; +Cc: igt-dev
From: Antonio Argenziano <antonio.argenziano@intel.com>
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)
v3:
- Parametrize tests. (Chris)
v4:
- Code-style refactoring. (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>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/gem_ctx_param.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 151 insertions(+), 1 deletion(-)
diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index db68f57b..6745b0f1 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -24,10 +24,119 @@
* Daniel Vetter <daniel.vetter@ffwll.ch>
*/
+#include <fcntl.h>
+#include <limits.h>
+
#include "igt.h"
IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
+#define BIT(x) (1ul << (x))
+
+#define NEW_CTX BIT(0)
+#define USER BIT(1)
+
+static int reopen_driver(int fd)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+ fd = open(path, O_RDWR);
+ igt_assert_lte(0, fd);
+
+ return fd;
+}
+
+static void set_priority(int i915)
+{
+ static const int64_t test_values[] = {
+ /* Test space too big, pick significant values */
+ INT_MIN,
+
+ I915_CONTEXT_MIN_USER_PRIORITY - 1,
+ I915_CONTEXT_MIN_USER_PRIORITY,
+ I915_CONTEXT_MIN_USER_PRIORITY + 1,
+
+ I915_CONTEXT_DEFAULT_PRIORITY - 1,
+ I915_CONTEXT_DEFAULT_PRIORITY,
+ I915_CONTEXT_DEFAULT_PRIORITY + 1,
+
+ I915_CONTEXT_MAX_USER_PRIORITY - 1,
+ I915_CONTEXT_MAX_USER_PRIORITY,
+ I915_CONTEXT_MAX_USER_PRIORITY + 1,
+
+ INT_MAX
+ };
+ unsigned int size;
+ int64_t *values;
+
+ igt_require(getuid() == 0);
+
+ size = ARRAY_SIZE(test_values);
+ values = malloc(sizeof(test_values) * 2);
+ igt_assert(values);
+
+ for (unsigned i = 0; i < size; i++) {
+ values[i] = test_values[i];
+ values[i + size] = test_values[i] | (uint64_t)rand() << 32;
+ }
+
+ igt_permute_array(values, size, igt_exchange_int64);
+
+ igt_fork(flags, NEW_CTX | USER) {
+ int fd = reopen_driver(i915);
+ struct drm_i915_gem_context_param arg = {
+ .param = I915_CONTEXT_PARAM_PRIORITY,
+ .ctx_id = flags & NEW_CTX ? gem_context_create(fd) : 0,
+ };
+ int64_t old_prio;
+
+
+ if (flags & USER) {
+ igt_debug("Dropping root privilege\n");
+ igt_drop_root();
+ }
+
+ gem_context_get_param(fd, &arg);
+ old_prio = arg.value;
+
+ for (unsigned i = 0; i < size; i++) {
+ int64_t prio = values[i];
+ int expected = 0;
+ int err;
+
+ arg.value = prio;
+
+ if (flags & USER &&
+ prio > I915_CONTEXT_DEFAULT_PRIORITY)
+ expected = -EPERM;
+
+ if (prio < I915_CONTEXT_MIN_USER_PRIORITY ||
+ prio > I915_CONTEXT_MAX_USER_PRIORITY)
+ expected = -EINVAL;
+
+ err =__gem_context_set_param(fd, &arg);
+ igt_assert_f(err == expected,
+ "Priority requested %" PRId64 ", expected result %d, returned %d\n",
+ prio, expected, err);
+
+ gem_context_get_param(fd, &arg);
+ if (!err)
+ old_prio = prio;
+ igt_assert_eq(arg.value, old_prio);
+ }
+
+ arg.value = 0;
+ gem_context_set_param(fd, &arg);
+
+ if (flags & NEW_CTX)
+ gem_context_destroy(fd, arg.ctx_id);
+ }
+
+ igt_waitchildren();
+ free(values);
+}
+
igt_main
{
struct drm_i915_gem_context_param arg;
@@ -138,11 +247,52 @@ igt_main
gem_context_set_param(fd, &arg);
}
+ arg.param = I915_CONTEXT_PARAM_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") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ uint32_t local_ctx = gem_context_create(fd);
+
+ local_arg.ctx_id = local_ctx;
+
+ gem_context_get_param(fd, &local_arg);
+ igt_assert_eq(local_arg.value, I915_CONTEXT_DEFAULT_PRIORITY);
+
+ gem_context_destroy(fd, local_ctx);
+ }
+
+ igt_subtest("set-priority-invalid-size") {
+ struct drm_i915_gem_context_param local_arg = arg;
+ local_arg.ctx_id = ctx;
+ local_arg.value = 0;
+ local_arg.size = ~0;
+
+ igt_assert_eq(__gem_context_set_param(fd, &local_arg), -EINVAL);
+ }
+
+ igt_subtest("set-priority-range")
+ set_priority(fd);
+ }
+
/* 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.16.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-02-17 9:49 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-16 13:49 [PATCH igt 1/2] lib/igt_aux: Add function to swap int64 in array Chris Wilson
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
2018-02-16 13:49 ` [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param Chris Wilson
2018-02-16 13:49 ` [igt-dev] " Chris Wilson
2018-02-16 13:57 ` Chris Wilson
2018-02-16 13:57 ` [igt-dev] " Chris Wilson
2018-02-16 18:37 ` [PATCH igt] " Chris Wilson
2018-02-16 14:09 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib/igt_aux: Add function to swap int64 in array Patchwork
2018-02-16 16:14 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-02-16 19:04 ` ✗ Fi.CI.BAT: failure for tests/gem_ctx_param: Update invalid param (rev3) Patchwork
2018-02-16 23:20 [PATCH igt 2/2] tests/gem_ctx_param: Update invalid param Chris Wilson
2018-02-17 9:11 ` [PATCH igt] " Chris Wilson
2018-02-17 9:49 ` Chris Wilson
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.