Re: [igt-dev] [PATCH i-g-t 14/24] i915/gem_ctx_create: Basic checks for constructor properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 22/03/2019 09:21, Chris Wilson wrote:
Check that the extended create interface accepts setparam.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
  tests/i915/gem_ctx_create.c | 57 +++++++++++++++++++++++++++++++++++++
  1 file changed, 57 insertions(+)

diff --git a/tests/i915/gem_ctx_create.c b/tests/i915/gem_ctx_create.c
index a664070db..e12f41691 100644
--- a/tests/i915/gem_ctx_create.c
+++ b/tests/i915/gem_ctx_create.c
@@ -308,6 +308,60 @@ static void maximum(int fd, int ncpus, unsigned mode)
  	free(contexts);
  }
+static int __create_ext(int i915, struct drm_i915_gem_context_create_ext *arg)
+{
+	int err;
+
+	err = 0;
+	if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, arg))
+		err = -errno;
+
+	errno = 0;
+	return err;
+}
+
+static void basic_ext_param(int i915)
+{
+	struct drm_i915_gem_context_create_ext_setparam ext = {
+		{ .name = I915_CONTEXT_CREATE_EXT_SETPARAM },
+	};
+	struct drm_i915_gem_context_create_ext create = {
+		.flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS
+	};
+	struct drm_i915_gem_context_param get;
+
+	igt_require(__create_ext(i915, &create) == 0);
+	gem_context_destroy(i915, create.ctx_id);
+
+	create.extensions = -1ull;
+	igt_assert_eq(__create_ext(i915, &create), -EFAULT);
+
+	create.extensions = to_user_pointer(&ext);
+	igt_assert_eq(__create_ext(i915, &create), -EINVAL);
+
+	ext.param.param = I915_CONTEXT_PARAM_PRIORITY;
+	if (__create_ext(i915, &create) != -ENODEV) {

Alternatively split into two subtests, one to test invalid and up to here, and second one to test the rest and use igt_require(... != ENODEV) so can skip where priority is not supported.

Actually could also use with some more basic param which has no ENODEV path.

+		gem_context_destroy(i915, create.ctx_id);
+
+		ext.base.next_extension = -1ull;
+		igt_assert_eq(__create_ext(i915, &create), -EFAULT);
+		ext.base.next_extension = to_user_pointer(&ext);
+		igt_assert_eq(__create_ext(i915, &create), -E2BIG);
+		ext.base.next_extension = 0;

These two can then also be coupled from CAP_SCHEDULER into the first subtest.

+
+		ext.param.value = 32;

Why 32? Add comment like /* random non-default priority level */

For complete future proofing should probably query it first to assert it is unused.

Although again if you used something like bannable it could run on all platforms AFAICS.

+		igt_assert_eq(__create_ext(i915, &create), 0);
+
+		memset(&get, 0, sizeof(get));
+		get.ctx_id = create.ctx_id;
+		get.param = I915_CONTEXT_PARAM_PRIORITY;
+		gem_context_get_param(i915, &get);
+		igt_assert_eq(get.value, ext.param.value);
+
+		gem_context_destroy(i915, create.ctx_id);
+	}
+}
+
  igt_main
  {
  	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
@@ -352,6 +406,9 @@ igt_main
  		igt_assert_eq(__gem_context_create_local(fd, &create), -EINVAL);
  	}
+ igt_subtest("ext-param")
+		basic_ext_param(fd);
+
  	igt_subtest("maximum-mem")
  		maximum(fd, ncpus, CHECK_RAM);
  	igt_subtest("maximum-swap")


Regards,

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




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux