diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index bc5d4bd827cf..f4deca6bd79e 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -102,6 +102,7 @@ struct local_i915_gem_context_param { uint32_t size; uint64_t param; #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1 +#define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2 uint64_t value; }; void gem_context_require_ban_period(int fd); diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c index b44b37cf0538..1e7e8ff40703 100644 --- a/tests/gem_ctx_param_basic.c +++ b/tests/gem_ctx_param_basic.c @@ -57,7 +57,7 @@ igt_main ctx = gem_context_create(fd); } - ctx_param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + ctx_param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; igt_subtest("basic") { ctx_param.context = ctx; @@ -98,21 +98,31 @@ igt_main ctx_param.size = 0; } - ctx_param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD + 1; + ctx_param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; - igt_subtest("invalid-param-get") { - ctx_param.context = ctx; - TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, EINVAL); + igt_subtest("non-root-set") { + igt_fork(child, 1) { + igt_drop_root(); + + ctx_param.context = ctx; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM); + ctx_param.value--; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM); + } + + igt_waitchildren(); } - igt_subtest("invalid-param-set") { + igt_subtest("root-set") { ctx_param.context = ctx; - TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL); + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM); + ctx_param.value--; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); } - ctx_param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD; + ctx_param.param = LOCAL_CONTEXT_PARAM_NO_ZEROMAP; - igt_subtest("non-root-set") { + igt_subtest("non-root-set-no-zeromap") { igt_fork(child, 1) { igt_drop_root(); @@ -125,13 +135,32 @@ igt_main igt_waitchildren(); } - igt_subtest("root-set") { + igt_subtest("root-set-no-zeromap-enabled") { ctx_param.context = ctx; TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM); - ctx_param.value--; + ctx_param.value = 1; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + } + + igt_subtest("root-set-no-zeromap-disabled") { + ctx_param.context = ctx; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM); + ctx_param.value = 0; TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); } + ctx_param.param = LOCAL_CONTEXT_PARAM_NO_ZEROMAP + 1; + + igt_subtest("invalid-param-get") { + ctx_param.context = ctx; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, EINVAL); + } + + igt_subtest("invalid-param-set") { + ctx_param.context = ctx; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL); + } + igt_fixture close(fd); }