From: John Harrison <John.C.Harrison@xxxxxxxxx> The GPU scheduler has added an execution priority level to the context object. There is an IOCTL interface to allow user apps/libraries to set this priority. This patch updates the context paramter IOCTL test to include the new interface. For: VIZ-1587 Signed-off-by: John Harrison <John.C.Harrison@xxxxxxxxx> --- lib/ioctl_wrappers.h | 1 + tests/gem_ctx_param_basic.c | 108 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 8fe35b0..00cf324 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -109,6 +109,7 @@ struct local_i915_gem_context_param { #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1 #define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2 #define LOCAL_CONTEXT_PARAM_GTT_SIZE 0x3 +#define LOCAL_CONTEXT_PARAM_PRIORITY 0x4 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 b75800c..1a10c01 100644 --- a/tests/gem_ctx_param_basic.c +++ b/tests/gem_ctx_param_basic.c @@ -147,10 +147,116 @@ igt_main TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); } + ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY; + + igt_subtest("priority-root-set") { + ctx_param.context = ctx; + ctx_param.value = 2048; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL); + ctx_param.value = -2048; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL); + ctx_param.value = 512; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + ctx_param.value = -512; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + ctx_param.value = 0; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + } + + igt_subtest("priority-root-set-egl") { + drm_intel_context *context; + drm_intel_bufmgr *bufmgr; + int ret, priority; + + bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); + context = drm_intel_gem_context_create(bufmgr); + igt_require(context); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, -500); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, 0); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, 500); + + drm_intel_gem_context_destroy(context); + drm_intel_bufmgr_destroy(bufmgr); + } + + igt_subtest("priority-non-root-set") { + igt_fork(child, 1) { + igt_drop_root(); + + ctx_param.context = ctx; + ctx_param.value = 512; + TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM); + ctx_param.value = -512; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + ctx_param.value = 0; + TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM); + } + + igt_waitchildren(); + } + + igt_subtest("priority-non-root-set-egl") { + igt_fork(child, 1) { + igt_drop_root(); + + drm_intel_context *context; + drm_intel_bufmgr *bufmgr; + int ret, priority; + + bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); + context = drm_intel_gem_context_create(bufmgr); + igt_require(context); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, -500); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, 0); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW); + igt_assert_eq(ret, 0); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, -500); + + ret = drm_intel_gem_context_set_priority(context, DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH); + igt_assert_eq(ret, -EPERM); + ret = drm_intel_gem_context_get_priority(context, &priority); + igt_assert_eq(ret, 0); + igt_assert_eq(priority, -500); + + drm_intel_gem_context_destroy(context); + drm_intel_bufmgr_destroy(bufmgr); + } + + 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. */ - ctx_param.param = LOCAL_CONTEXT_PARAM_GTT_SIZE + 1; + ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY + 1; igt_subtest("invalid-param-get") { ctx_param.context = ctx; -- 1.9.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx