From patchwork Tue Dec 19 21:16:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 10124405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEBF26019C for ; Tue, 19 Dec 2017 21:16:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B8D294FB for ; Tue, 19 Dec 2017 21:16:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93FF129570; Tue, 19 Dec 2017 21:16:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10136294FB for ; Tue, 19 Dec 2017 21:16:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B94466E279; Tue, 19 Dec 2017 21:16:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id D60436E279 for ; Tue, 19 Dec 2017 21:16:46 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 13:16:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="13166981" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by FMSMGA003.fm.intel.com with ESMTP; 19 Dec 2017 13:16:46 -0800 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Tue, 19 Dec 2017 13:16:40 -0800 Message-Id: <20171219211640.21730-1-antonio.argenziano@intel.com> X-Mailer: git-send-email 2.14.2 Subject: [Intel-gfx] [PATCH i-g-t v2] tests/gem_ctx_param: Update invalid param X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Chris Wilson Cc: Michal Winiarski --- 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 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;