From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B95DE77175 for ; Wed, 4 Dec 2024 22:23:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10CA110ED69; Wed, 4 Dec 2024 22:23:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Wg/VqFVy"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC25710E5B4 for ; Wed, 4 Dec 2024 22:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733351029; x=1764887029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DnuhJVLGmho4UuAfvkaZXoG4/6+X8ftlaRfUnppo1EI=; b=Wg/VqFVy2UqZ+K/zQJs+NnSqMadtjvqfPXUic87AQFGMrqb0LFN83bPH 0zooBwC0wgXtg18SQ0/WZzSLaypkl9FE2OJGq0jsXDIGisADK1EMiKP// r5eztr8k74DAh+V+oqo6A6xYTvrP6eb9aSGUzLkLzxKcDpUfG4GJQ5Nd+ GKG7idN6x5bkyHP46xpEjkZo4MSOop4syebjAafvTAdrfpBJATEJ0FBtN ERwqgjjw7fbtnRrsfxc7YqJpoOxBwNHSvBFetYgctBM1x6ZWULTxRts63 2rsFfGzLXzn+BqYzG1RgNx+UCTOhQVvyMTLoUG2ejEHmIMkUAMNoIQAqY A==; X-CSE-ConnectionGUID: ccktxel6RSSCVbFNYqVtCw== X-CSE-MsgGUID: 9/Hl9jFUSpKN7STaDBpANg== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="37415826" X-IronPort-AV: E=Sophos;i="6.12,208,1728975600"; d="scan'208";a="37415826" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 14:23:49 -0800 X-CSE-ConnectionGUID: HQpuPkVsRs64PKFqb4kHRA== X-CSE-MsgGUID: siZV4LpSSmW1B++Z9J721g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,208,1728975600"; d="scan'208";a="94084698" Received: from dut4066lnl.fm.intel.com ([10.105.8.83]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 14:23:48 -0800 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: jonathan.cavitt@intel.com, saurabhg.gupta@intel.com, alex.zuo@intel.com, kamil.konieczny@linux.intel.com, vinay.belgaumkar@intel.com, tejas.upadhyay@intel.com Subject: [PATCH v10 4/4] tests/intel/xe_sysfs_scheduler: Assert sysfs params are restored Date: Wed, 4 Dec 2024 22:23:47 +0000 Message-ID: <20241204222347.108788-5-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204222347.108788-1-jonathan.cavitt@intel.com> References: <20241204222347.108788-1-jonathan.cavitt@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" The xe_sysfs_scheduler tests modify various sysfs parameters. At the end of the test, the sysfs parameters are restored, but we do not currently assert that the restoration process completes successfully. Assert the restoration is successful. Additionally, when the tests fail, it is possible that the various modified sysfs parameters may be left in modified states, which can cause future tests to behave unpredictably. At the end of the test, attempt to restore all modified sysfs parameters to their original values, aborting all tests if this is unsuccessful. v2: - Store engine lists (Kamil) Signed-off-by: Jonathan Cavitt Reviewed-by: Kamil Konieczny --- tests/intel/xe_sysfs_scheduler.c | 89 ++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/tests/intel/xe_sysfs_scheduler.c b/tests/intel/xe_sysfs_scheduler.c index 947dbdbc9b..89c87c2eed 100644 --- a/tests/intel/xe_sysfs_scheduler.c +++ b/tests/intel/xe_sysfs_scheduler.c @@ -107,10 +107,19 @@ static void test_min_max(int xe, int engine, const char **property, /* Reset property, max, min to original values */ igt_sysfs_printf(engine, property[0], "%d", store); + igt_sysfs_scanf(engine, property[0], "%u", &set); + igt_assert_eq(set, store); + igt_sysfs_printf(engine, property[1], "%d", default_min); + igt_sysfs_scanf(engine, property[1], "%u", &set); + igt_assert_eq(set, default_min); + igt_sysfs_printf(engine, property[2], "%d", default_max); + igt_sysfs_scanf(engine, property[2], "%u", &set); + igt_assert_eq(set, default_max); } +#define MAX_GTS 8 igt_main { static const struct { @@ -126,10 +135,15 @@ igt_main {"timeslice_duration_us", "timeslice_duration_min", "timeslice_duration_max"}, {"job_timeout_ms", "job_timeout_min", "job_timeout_max"}, }; + + unsigned int store[MAX_GTS][3][3]; int count = sizeof(property) / sizeof(property[0]); + int gt_count = 0; int xe = -1; int sys_fd; int gt; + int engines_fd[MAX_GTS], gt_fd[MAX_GTS]; + int *engine_list[MAX_GTS]; igt_fixture { xe = drm_open_driver(DRIVER_XE); @@ -138,28 +152,83 @@ igt_main sys_fd = igt_sysfs_open(xe); igt_require(sys_fd != -1); close(sys_fd); + + xe_for_each_gt(xe, gt) { + int *list, i = 0; + + igt_require(gt_count < MAX_GTS); + + gt_fd[gt_count] = xe_sysfs_gt_open(xe, gt); + igt_require(gt_fd[gt_count] != -1); + engines_fd[gt_count] = openat(gt_fd[gt_count], "engines", O_RDONLY); + igt_require(engines_fd[gt_count] != -1); + + list = igt_sysfs_get_engine_list(engines_fd[gt_count]); + + while (list[i] != -1) { + for (int j = 0; j < count; j++) { + const char **pl = property[j]; + + for (int k = 0; k < 3; k++) { + unsigned int *loc = &store[i][j][k]; + + igt_require(igt_sysfs_scanf(list[i], pl[k], + "%u", loc) == 1); + } + } + i++; + } + + igt_require(i > 0); + engine_list[gt_count] = list; + gt_count++; + } } for (int i = 0; i < count; i++) { for (typeof(*tests) *t = tests; t->name; t++) { igt_subtest_with_dynamic_f("%s-%s", property[i][0], t->name) { + int j = 0; xe_for_each_gt(xe, gt) { - int engines_fd = -1; - int gt_fd = -1; - - gt_fd = xe_sysfs_gt_open(xe, gt); - igt_require(gt_fd != -1); - engines_fd = openat(gt_fd, "engines", O_RDONLY); - igt_require(engines_fd != -1); + int e = engines_fd[j]; - igt_sysfs_engines(xe, engines_fd, 0, 0, property[i], t->fn); - close(engines_fd); - close(gt_fd); + igt_sysfs_engines(xe, e, 0, 0, property[i], t->fn); + j++; } } } } + igt_fixture { + for (int gtn = gt_count - 1; gtn >= 0; gtn--) { + int *list, i = 0; + + list = engine_list[gtn]; + + while (list[i] != -1) { + int e = list[i]; + + for (int j = count - 1; j >= 0; j--) { + const char **pl = property[j]; + + for (int k = 2; k >= 0; k--) { + unsigned int read = UINT_MAX; + unsigned int val = store[i][j][k]; + + igt_sysfs_printf(e, pl[k], "%u", val); + igt_sysfs_scanf(e, pl[k], "%u", &read); + igt_abort_on_f(read != val, + "%s not restored!\n", pl[k]); + } + } + i++; + } + + igt_sysfs_free_engine_list(list); + close(engines_fd[gtn]); + close(gt_fd[gtn]); + } + xe_device_put(xe); close(xe); } -- 2.43.0