All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface
@ 2023-06-25 12:29 priyanka.dandamudi
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

New lib function has been added to iterate over sysfs/engines.
Added 4 new tests to validate basic scheduler control interface and its defaults.

v2: Adjust space issues.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Priyanka Dandamudi (5):
  lib/igt_sysfs: Add support to iterate over engines
  xe/xe_sysfs_defaults: Verify .defaults in engines directory
  xe/xe_sysfs_preempt_timeout: Verify preempt_timeout
  xe/xe_sysfs_timeslice: Verify timeslice_duration
  xe/xe_sysfs_job_timeout: Verify job_timeout

 lib/igt_sysfs.c                     |  35 +++++++
 lib/igt_sysfs.h                     |   3 +
 tests/meson.build                   |   4 +
 tests/xe/xe_sysfs_defaults.c        | 105 +++++++++++++++++++++
 tests/xe/xe_sysfs_job_timeout.c     | 138 +++++++++++++++++++++++++++
 tests/xe/xe_sysfs_preempt_timeout.c | 139 ++++++++++++++++++++++++++++
 tests/xe/xe_sysfs_timeslice.c       | 138 +++++++++++++++++++++++++++
 7 files changed, 562 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_defaults.c
 create mode 100644 tests/xe/xe_sysfs_job_timeout.c
 create mode 100644 tests/xe/xe_sysfs_preempt_timeout.c
 create mode 100644 tests/xe/xe_sysfs_timeslice.c

-- 
2.25.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines
  2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
@ 2023-06-25 12:29 ` priyanka.dandamudi
  2023-06-27 16:16   ` Kamil Konieczny
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

It helps to test engines by iterating over sysfs/engines.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 lib/igt_sysfs.c | 35 +++++++++++++++++++++++++++++++++++
 lib/igt_sysfs.h |  3 +++
 2 files changed, 38 insertions(+)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 35a4faa9..1f32e659 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -856,3 +856,38 @@ void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw)
 	igt_assert_eq(get, prev);
 	igt_assert(!ret);
 }
+
+void igt_sysfs_engines(int xe, int engines, const char *file,
+					   void (*test)(int, int))
+{
+	struct dirent *de;
+	DIR *dir;
+
+	lseek(engines, 0, SEEK_SET);
+
+	dir = fdopendir(engines);
+	if (!dir)
+		close(engines);
+
+	while ((de = readdir(dir))) {
+		int engine;
+
+		if (*de->d_name == '.')
+			continue;
+
+		engine = openat(engines, de->d_name, O_RDONLY);
+		if (engine < 0)
+			continue;
+
+		igt_dynamic(de->d_name) {
+			if (file) {
+				struct stat st;
+
+				igt_require(fstatat(engine, file, &st, 0) == 0);
+			}
+			errno = 0;
+			test(xe, engine);
+		}
+		close(engine);
+	}
+}
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 978b6906..c89780ac 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -147,4 +147,7 @@ typedef struct igt_sysfs_rw_attr {
 
 void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw);
 
+void igt_sysfs_engines(int xe, int gt, const char *file,
+		       void (*test)(int, int));
+
 #endif /* __IGT_SYSFS_H__ */
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory
  2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
@ 2023-06-25 12:29 ` priyanka.dandamudi
  2023-06-27 10:37   ` Kumar, Janga Rahul
  2023-06-27 16:03   ` Kamil Konieczny
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout priyanka.dandamudi
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Add a new test which verifies .defaults are readonly and all
parameters are present.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 tests/meson.build            |   1 +
 tests/xe/xe_sysfs_defaults.c | 105 +++++++++++++++++++++++++++++++++++
 2 files changed, 106 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_defaults.c

diff --git a/tests/meson.build b/tests/meson.build
index 85ea7e74..b24bae5c 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -270,6 +270,7 @@ xe_progs = [
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
+	'xe_sysfs_defaults',
 ]
 
 msm_progs = [
diff --git a/tests/xe/xe_sysfs_defaults.c b/tests/xe/xe_sysfs_defaults.c
new file mode 100644
index 00000000..1733ade7
--- /dev/null
+++ b/tests/xe/xe_sysfs_defaults.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#include "xe_drm.h"
+#include "xe/xe_query.h"
+
+/**
+ * TEST: xe sysfs defaults
+ * Category: Infrastructure
+ * Functionality: driver handler
+ * Run type: FULL
+ * Sub-category: xe
+ * Test category: SysMan
+ * SUBTEST: defaults
+ */
+
+static void test_defaults(int xe, int engine)
+{
+	struct dirent *de;
+	int defaults;
+	DIR *dir;
+
+	defaults = openat(engine, ".defaults", O_DIRECTORY);
+	igt_require(defaults != -1);
+
+	dir = fdopendir(engine);
+	while ((de = readdir(dir))) {
+		if (*de->d_name == '.')
+			continue;
+
+		igt_debug("Checking attr '%s'\n", de->d_name);
+
+		igt_assert_f(igt_sysfs_get(defaults, de->d_name),
+					 "Default value %s is not present!\n",
+					 de->d_name);
+
+		igt_assert_f(!igt_sysfs_set(defaults, de->d_name, "garbage"),
+					 "write into default value of %s succeeded!\n",
+					 de->d_name);
+	}
+	closedir(dir);
+}
+
+igt_main
+{
+	int xe, sys;
+	int gt;
+
+	igt_fixture {
+		xe = drm_open_driver(DRIVER_XE);
+		xe_device_get(xe);
+
+		sys = igt_sysfs_open(xe);
+		igt_require(sys != -1);
+	}
+	igt_subtest_with_dynamic("defaults") {
+		xe_for_each_gt(xe, gt) {
+			int engines = -1;
+			char buf[100];
+
+			sprintf(buf, "device/gt%d/engines", gt);
+			engines = openat(sys, buf, O_RDONLY);
+			igt_require(engines != -1);
+
+			igt_sysfs_engines(xe, engines, NULL, test_defaults);
+
+			close(engines);
+		}
+	}
+
+	igt_fixture {
+		close(sys);
+		xe_device_put(xe);
+		close(xe);
+	}
+}
+
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout
  2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
@ 2023-06-25 12:29 ` priyanka.dandamudi
  2023-06-27 16:09   ` Kamil Konieczny
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration priyanka.dandamudi
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 5/5] xe/xe_sysfs_job_timeout: Verify job_timeout priyanka.dandamudi
  4 siblings, 1 reply; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Basic tests idempotent and invalid are added to verify
preempt_timeout for each engine.
It verifies whether parameter value within in the range.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 tests/meson.build                   |   1 +
 tests/xe/xe_sysfs_preempt_timeout.c | 139 ++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_preempt_timeout.c

diff --git a/tests/meson.build b/tests/meson.build
index b24bae5c..ea6c9239 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -271,6 +271,7 @@ xe_progs = [
 	'xe_waitfence',
 	'xe_spin_batch',
 	'xe_sysfs_defaults',
+	'xe_sysfs_preempt_timeout',
 ]
 
 msm_progs = [
diff --git a/tests/xe/xe_sysfs_preempt_timeout.c b/tests/xe/xe_sysfs_preempt_timeout.c
new file mode 100644
index 00000000..5a357128
--- /dev/null
+++ b/tests/xe/xe_sysfs_preempt_timeout.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Permission is hereby ggit ranted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#include "xe_drm.h"
+#include "xe/xe_query.h"
+
+/**
+ * TEST: xe sysfs preempt timeout
+ * Run type: FULL
+ *
+ * SUBTEST: idempotent
+ * Description: Test to check whether the preempt_timeout_us parameter reports the values set.
+ * Test category: SysMan
+ *
+ * SUBTEST: invalid
+ * Description: Test to check if preempt_timeout parameter rejects any unrepresentable intervals.
+ * Test category: SysMan
+ */
+
+#define ATTR "preempt_timeout_us"
+#define ATTR_MIN "preempt_timeout_min"
+#define ATTR_MAX "preempt_timeout_max"
+
+static void set_preempt_timeout(int engine, unsigned int value)
+{
+	unsigned int delay;
+
+	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
+	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
+	igt_assert_eq(delay, value);
+}
+
+static void test_idempotent(int xe, int engine)
+{
+	unsigned int delays[] = { 1, 1000, 1234, 54321 };
+	unsigned int saved;
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	for (int i = 0; i < ARRAY_SIZE(delays); i++)
+		set_preempt_timeout(engine, delays[i]);
+
+	set_preempt_timeout(engine, saved);
+}
+
+static void test_invalid(int xe, int engine)
+{
+	unsigned int saved, set;
+	unsigned int min, max;
+
+	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
+	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", max+1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", min-1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+}
+
+igt_main
+{
+	static const struct {
+		const char *name;
+		void (*fn)(int, int);
+	} tests[] = {
+		{ "idempotent", test_idempotent },
+		{ "invalid", test_invalid },
+		{ }
+	};
+	int xe = -1;
+	int sys;
+	int gt;
+
+	igt_fixture {
+		xe = drm_open_driver(DRIVER_XE);
+		xe_device_get(xe);
+
+		sys = igt_sysfs_open(xe);
+		igt_require(sys != -1);
+	}
+
+	for (typeof(*tests) *t = tests; t->name; t++)
+	    igt_subtest_with_dynamic(t->name) {
+		    xe_for_each_gt(xe, gt) {
+			    int engines = -1;
+			    char buf[100];
+
+			    sprintf(buf, "device/gt%d/engines", gt);
+			    engines = openat(sys, buf, O_RDONLY);
+			    igt_require(engines != -1);
+
+			    igt_sysfs_engines(xe, engines, ATTR, t->fn);
+
+			    close(engines);
+			}
+		}
+
+	igt_fixture {
+		close(sys);
+		xe_device_put(xe);
+		close(xe);
+	}
+}
+
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration
  2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
                   ` (2 preceding siblings ...)
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout priyanka.dandamudi
@ 2023-06-25 12:29 ` priyanka.dandamudi
  2023-06-27 11:38   ` Kumar, Janga Rahul
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 5/5] xe/xe_sysfs_job_timeout: Verify job_timeout priyanka.dandamudi
  4 siblings, 1 reply; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Basic tests idempotent and invalid are added to verify
timeslice_duration for each engine.
It verifies whether parameter value within in the range.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 tests/meson.build             |   1 +
 tests/xe/xe_sysfs_timeslice.c | 138 ++++++++++++++++++++++++++++++++++
 2 files changed, 139 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_timeslice.c

diff --git a/tests/meson.build b/tests/meson.build
index ea6c9239..1474a494 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -272,6 +272,7 @@ xe_progs = [
 	'xe_spin_batch',
 	'xe_sysfs_defaults',
 	'xe_sysfs_preempt_timeout',
+	'xe_sysfs_timeslice',
 ]
 
 msm_progs = [
diff --git a/tests/xe/xe_sysfs_timeslice.c b/tests/xe/xe_sysfs_timeslice.c
new file mode 100644
index 00000000..94bed383
--- /dev/null
+++ b/tests/xe/xe_sysfs_timeslice.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#include "xe_drm.h"
+#include "xe/xe_query.h"
+
+/**
+ * TEST: xe sysfs timeslice
+ * Run type: FULL
+ *
+ * SUBTEST: idempotent
+ * Description: Test to check whether the timelslice_duration_us parameter reports the values set.
+ * Test category: SysMan
+ *
+ * SUBTEST: invalid
+ * Description: Test to check if timeslice_duration parameter rejects any unrepresentable intervals.
+ * Test category: SysMan
+ */
+
+#define ATTR "timeslice_duration_us"
+#define ATTR_MIN "timeslice_duration_min"
+#define ATTR_MAX "timeslice_duration_max"
+
+static void set_timeslice_duration(int engine, unsigned int value)
+{
+	unsigned int delay;
+
+	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
+	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
+	igt_assert_eq(delay, value);
+}
+
+static void test_idempotent(int xe, int engine)
+{
+	unsigned int delays[] = { 1, 1000, 1234, 10000000 };
+	unsigned int saved;
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	for (int i = 0; i < ARRAY_SIZE(delays); i++)
+		set_timeslice_duration(engine, delays[i]);
+
+	set_timeslice_duration(engine, saved);
+}
+
+static void test_invalid(int xe, int engine)
+{
+	unsigned int saved, set;
+	unsigned int min, max;
+
+	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
+	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", max+1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", min-1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+}
+
+igt_main
+{
+	static const struct {
+		const char *name;
+		void (*fn)(int, int);
+	} tests[] = {
+		{ "idempotent", test_idempotent },
+		{ "invalid", test_invalid },
+		{ }
+	};
+	int xe = -1;
+	int sys;
+	int gt;
+
+	igt_fixture {
+		xe = drm_open_driver(DRIVER_XE);
+		xe_device_get(xe);
+
+		sys = igt_sysfs_open(xe);
+		igt_require(sys != -1);
+	}
+	for (typeof(*tests) *t = tests; t->name; t++)
+		igt_subtest_with_dynamic(t->name) {
+			xe_for_each_gt(xe, gt) {
+				int engines = -1;
+				char buf[100];
+
+				sprintf(buf, "device/gt%d/engines", gt);
+				engines = openat(sys, buf, O_RDONLY);
+				igt_require(engines != -1);
+
+				igt_sysfs_engines(xe, engines, ATTR, t->fn);
+
+				close(engines);
+			}
+		}
+
+	igt_fixture {
+		close(sys);
+		xe_device_put(xe);
+		close(xe);
+	}
+}
+
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 5/5] xe/xe_sysfs_job_timeout: Verify job_timeout
  2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
                   ` (3 preceding siblings ...)
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration priyanka.dandamudi
@ 2023-06-25 12:29 ` priyanka.dandamudi
  4 siblings, 0 replies; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 12:29 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Basic tests idempotent and invalid are added to verify
job_timeout for each engine.
It verifies whether parameter value within in the range.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 tests/meson.build               |   1 +
 tests/xe/xe_sysfs_job_timeout.c | 138 ++++++++++++++++++++++++++++++++
 2 files changed, 139 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_job_timeout.c

diff --git a/tests/meson.build b/tests/meson.build
index 1474a494..45e6975e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -273,6 +273,7 @@ xe_progs = [
 	'xe_sysfs_defaults',
 	'xe_sysfs_preempt_timeout',
 	'xe_sysfs_timeslice',
+	'xe_sysfs_job_timeout',
 ]
 
 msm_progs = [
diff --git a/tests/xe/xe_sysfs_job_timeout.c b/tests/xe/xe_sysfs_job_timeout.c
new file mode 100644
index 00000000..89ef33d2
--- /dev/null
+++ b/tests/xe/xe_sysfs_job_timeout.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#include "xe_drm.h"
+#include "xe/xe_query.h"
+
+/**
+ * TEST: xe sysfs job timeout
+ * Run type: FULL
+ *
+ * SUBTEST: idempotent
+ * Description: Test to check whether the job_timeout_ms parameter reports the values set.
+ * Test category: SysMan
+ *
+ * SUBTEST: invalid
+ * Description: Test to check if job_timeout parameter rejects any unrepresentable intervals.
+ * Test category: SysMan
+ */
+
+#define ATTR "job_timeout_ms"
+#define ATTR_MIN "job_timeout_min"
+#define ATTR_MAX "job_timeout_max"
+
+static void set_job_timeout(int engine, unsigned int value)
+{
+	unsigned int delay;
+
+	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
+	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
+	igt_assert_eq(delay, value);
+}
+
+static void test_idempotent(int xe, int engine)
+{
+	unsigned int delays[] = {1, 2000, 4500, 10000 };
+	unsigned int saved;
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	for (int i = 0; i < ARRAY_SIZE(delays); i++)
+		set_job_timeout(engine, delays[i]);
+
+	set_job_timeout(engine, saved);
+}
+
+static void test_invalid(int xe, int engine)
+{
+	unsigned int saved, set;
+	unsigned int min, max;
+
+	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
+	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
+
+	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
+	igt_debug("Initial %s:%u\n", ATTR, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", max+1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+
+	igt_sysfs_printf(engine, ATTR, "%d", min-1);
+	igt_sysfs_scanf(engine, ATTR, "%u", &set);
+	igt_assert_eq(set, saved);
+}
+
+igt_main
+{
+	static const struct {
+		const char *name;
+		void (*fn)(int, int);
+	} tests[] = {
+		{ "idempotent", test_idempotent },
+		{ "invalid", test_invalid },
+		{ }
+	};
+	int xe = -1;
+	int sys;
+	int gt;
+
+	igt_fixture {
+		xe = drm_open_driver(DRIVER_XE);
+		xe_device_get(xe);
+
+		sys = igt_sysfs_open(xe);
+		igt_require(sys != -1);
+	}
+	for (typeof(*tests) *t = tests; t->name; t++)
+		igt_subtest_with_dynamic(t->name) {
+			xe_for_each_gt(xe, gt) {
+				int engines = -1;
+				char buf[100];
+
+				sprintf(buf, "device/gt%d/engines", gt);
+				engines = openat(sys, buf, O_RDONLY);
+				igt_require(engines != -1);
+
+				igt_sysfs_engines(xe, engines, ATTR, t->fn);
+
+				close(engines);
+			}
+		}
+
+	igt_fixture {
+		close(sys);
+		xe_device_put(xe);
+		close(xe);
+	}
+}
+
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
@ 2023-06-27 10:37   ` Kumar, Janga Rahul
  2023-06-28  7:19     ` Dandamudi, Priyanka
  2023-06-27 16:03   ` Kamil Konieczny
  1 sibling, 1 reply; 15+ messages in thread
From: Kumar, Janga Rahul @ 2023-06-27 10:37 UTC (permalink / raw)
  To: Dandamudi, Priyanka, Upadhyay, Tejas, igt-dev



> -----Original Message-----
> From: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>
> Sent: 25 June 2023 18:00
> To: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>; Upadhyay, Tejas
> <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org; Dandamudi,
> Priyanka <priyanka.dandamudi@intel.com>
> Subject: [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines
> directory
> 
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> Add a new test which verifies .defaults are readonly and all parameters are
> present.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> ---
>  tests/meson.build            |   1 +
>  tests/xe/xe_sysfs_defaults.c | 105 +++++++++++++++++++++++++++++++++++
>  2 files changed, 106 insertions(+)
>  create mode 100644 tests/xe/xe_sysfs_defaults.c
> 
> diff --git a/tests/meson.build b/tests/meson.build index 85ea7e74..b24bae5c
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -270,6 +270,7 @@ xe_progs = [
>  	'xe_vm',
>  	'xe_waitfence',
>  	'xe_spin_batch',
> +	'xe_sysfs_defaults',
>  ]
> 
>  msm_progs = [
> diff --git a/tests/xe/xe_sysfs_defaults.c b/tests/xe/xe_sysfs_defaults.c new file
> mode 100644 index 00000000..1733ade7
> --- /dev/null
> +++ b/tests/xe/xe_sysfs_defaults.c
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright © 2023 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> +obtaining a
> + * copy of this software and associated documentation files (the
> +"Software"),
> + * to deal in the Software without restriction, including without
> +limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> +sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom
> +the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> +next
> + * paragraph) shall be included in all copies or substantial portions
> +of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> +EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> EVENT
> +SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> DAMAGES OR
> +OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> +ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER
> +DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include <dirent.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +#include "xe_drm.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * TEST: xe sysfs defaults
> + * Category: Infrastructure
> + * Functionality: driver handler
> + * Run type: FULL
> + * Sub-category: xe
> + * Test category: SysMan
> + * SUBTEST: defaults
> + */
> +
> +static void test_defaults(int xe, int engine) {
> +	struct dirent *de;
> +	int defaults;
> +	DIR *dir;
> +
> +	defaults = openat(engine, ".defaults", O_DIRECTORY);
Check even .defaults dir has readonly access or not
> +	igt_require(defaults != -1);
> +
> +	dir = fdopendir(engine);
> +	while ((de = readdir(dir))) {
> +		if (*de->d_name == '.')
> +			continue;
> +
> +		igt_debug("Checking attr '%s'\n", de->d_name);
> +
> +		igt_assert_f(igt_sysfs_get(defaults, de->d_name),
> +					 "Default value %s is not present!\n",
> +					 de->d_name);
> +
> +		igt_assert_f(!igt_sysfs_set(defaults, de->d_name, "garbage"),
> +					 "write into default value of %s
> succeeded!\n",
> +					 de->d_name);
> +	}
> +	closedir(dir);
> +}
> +
> +igt_main
> +{
> +	int xe, sys;
> +	int gt;
> +
> +	igt_fixture {
> +		xe = drm_open_driver(DRIVER_XE);
> +		xe_device_get(xe);
> +
> +		sys = igt_sysfs_open(xe);
> +		igt_require(sys != -1);
> +	}
> +	igt_subtest_with_dynamic("defaults") {
> +		xe_for_each_gt(xe, gt) {
> +			int engines = -1;
> +			char buf[100];
> +
> +			sprintf(buf, "device/gt%d/engines", gt);
Patch https://patchwork.freedesktop.org/series/118927/
is moving gt sysfs parent under tile folder.

With the above patch path for sysfs changes:
from: /sys/class/drm/cardX/device/gtN/ to :
/sys/class/drm/cardX/device/tileN/gtN

I would suggest to add some get_gt_sysfs_path() type of functions which can be used in all the tests and will be
easy to maintain if the path is change by kernel in future as well.

Thanks,
Rahul
> +			engines = openat(sys, buf, O_RDONLY);
> +			igt_require(engines != -1);
> +
> +			igt_sysfs_engines(xe, engines, NULL, test_defaults);
> +
> +			close(engines);
> +		}
> +	}
> +
> +	igt_fixture {
> +		close(sys);
> +		xe_device_put(xe);
> +		close(xe);
> +	}
> +}
> +
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration priyanka.dandamudi
@ 2023-06-27 11:38   ` Kumar, Janga Rahul
  2023-06-28  7:20     ` Dandamudi, Priyanka
  0 siblings, 1 reply; 15+ messages in thread
From: Kumar, Janga Rahul @ 2023-06-27 11:38 UTC (permalink / raw)
  To: Dandamudi, Priyanka, Upadhyay, Tejas, igt-dev



> -----Original Message-----
> From: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>
> Sent: 25 June 2023 18:00
> To: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>; Upadhyay, Tejas
> <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org; Dandamudi,
> Priyanka <priyanka.dandamudi@intel.com>
> Subject: [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration
> 
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> Basic tests idempotent and invalid are added to verify timeslice_duration for
> each engine.
> It verifies whether parameter value within in the range.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> ---
>  tests/meson.build             |   1 +
>  tests/xe/xe_sysfs_timeslice.c | 138 ++++++++++++++++++++++++++++++++++
>  2 files changed, 139 insertions(+)
>  create mode 100644 tests/xe/xe_sysfs_timeslice.c
> 
> diff --git a/tests/meson.build b/tests/meson.build index ea6c9239..1474a494
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -272,6 +272,7 @@ xe_progs = [
>  	'xe_spin_batch',
>  	'xe_sysfs_defaults',
>  	'xe_sysfs_preempt_timeout',
> +	'xe_sysfs_timeslice',
>  ]
> 
>  msm_progs = [
> diff --git a/tests/xe/xe_sysfs_timeslice.c b/tests/xe/xe_sysfs_timeslice.c new
> file mode 100644 index 00000000..94bed383
> --- /dev/null
> +++ b/tests/xe/xe_sysfs_timeslice.c
> @@ -0,0 +1,138 @@
> +/*
> + * Copyright © 2023 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> +obtaining a
> + * copy of this software and associated documentation files (the
> +"Software"),
> + * to deal in the Software without restriction, including without
> +limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> +sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom
> +the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> +next
> + * paragraph) shall be included in all copies or substantial portions
> +of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> +EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> EVENT
> +SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> DAMAGES OR
> +OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> +ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER
> +DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include <dirent.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +#include "xe_drm.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * TEST: xe sysfs timeslice
> + * Run type: FULL
> + *
> + * SUBTEST: idempotent
> + * Description: Test to check whether the timelslice_duration_us parameter
> reports the values set.
> + * Test category: SysMan
> + *
> + * SUBTEST: invalid
> + * Description: Test to check if timeslice_duration parameter rejects any
> unrepresentable intervals.
> + * Test category: SysMan
> + */
> +
> +#define ATTR "timeslice_duration_us"
> +#define ATTR_MIN "timeslice_duration_min"
> +#define ATTR_MAX "timeslice_duration_max"
> +
> +static void set_timeslice_duration(int engine, unsigned int value) {
> +	unsigned int delay;
> +
> +	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
> +	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
> +	igt_assert_eq(delay, value);
> +}
> +
> +static void test_idempotent(int xe, int engine) {
> +	unsigned int delays[] = { 1, 1000, 1234, 10000000 };
> +	unsigned int saved;
> +
> +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> +	igt_debug("Initial %s:%u\n", ATTR, saved);
> +
> +	for (int i = 0; i < ARRAY_SIZE(delays); i++)
> +		set_timeslice_duration(engine, delays[i]);
> +
> +	set_timeslice_duration(engine, saved); }
> +
> +static void test_invalid(int xe, int engine) {
Modify this to sysfs_range(min_max)_invalid(int xe, int engine_fd,  const char *attr, const char *attr_min, const char *attr_max)
and move this to lib and reuse it in other tests.

> +	unsigned int saved, set;
> +	unsigned int min, max;
> +
> +	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
> +	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
> +
> +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> +	igt_debug("Initial %s:%u\n", ATTR, saved);
> +
> +	igt_sysfs_printf(engine, ATTR, "%d", max+1);
> +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> +	igt_assert_eq(set, saved);
> +
> +	igt_sysfs_printf(engine, ATTR, "%d", min-1);
> +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> +	igt_assert_eq(set, saved);
> +}
> +
> +igt_main
> +{
> +	static const struct {
> +		const char *name;
> +		void (*fn)(int, int);
> +	} tests[] = {
> +		{ "idempotent", test_idempotent },
> +		{ "invalid", test_invalid },
> +		{ }
> +	};
> +	int xe = -1;
> +	int sys;
> +	int gt;
> +
> +	igt_fixture {
> +		xe = drm_open_driver(DRIVER_XE);
> +		xe_device_get(xe);
> +
> +		sys = igt_sysfs_open(xe);
> +		igt_require(sys != -1);
> +	}
> +	for (typeof(*tests) *t = tests; t->name; t++)
> +		igt_subtest_with_dynamic(t->name) {
> +			xe_for_each_gt(xe, gt) {
> +				int engines = -1;
> +				char buf[100];
> +
> +				sprintf(buf, "device/gt%d/engines", gt);
> +				engines = openat(sys, buf, O_RDONLY);
For variables being used for storing fd's, Pls append "_fd" to improve readability.

Thanks,
Rahul
> +				igt_require(engines != -1);
> +
> +				igt_sysfs_engines(xe, engines, ATTR, t->fn);
> +
> +				close(engines);
> +			}
> +		}
> +
> +	igt_fixture {
> +		close(sys);
> +		xe_device_put(xe);
> +		close(xe);
> +	}
> +}
> +
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
  2023-06-27 10:37   ` Kumar, Janga Rahul
@ 2023-06-27 16:03   ` Kamil Konieczny
  1 sibling, 0 replies; 15+ messages in thread
From: Kamil Konieczny @ 2023-06-27 16:03 UTC (permalink / raw)
  To: igt-dev; +Cc: tejas.upadhyay

Hi Priyanka,

On 2023-06-25 at 17:59:45 +0530, priyanka.dandamudi@intel.com wrote:
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> Add a new test which verifies .defaults are readonly and all
> parameters are present.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> ---
>  tests/meson.build            |   1 +
>  tests/xe/xe_sysfs_defaults.c | 105 +++++++++++++++++++++++++++++++++++
>  2 files changed, 106 insertions(+)
>  create mode 100644 tests/xe/xe_sysfs_defaults.c
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 85ea7e74..b24bae5c 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -270,6 +270,7 @@ xe_progs = [
>  	'xe_vm',
>  	'xe_waitfence',
>  	'xe_spin_batch',
> +	'xe_sysfs_defaults',
>  ]
>  
>  msm_progs = [
> diff --git a/tests/xe/xe_sysfs_defaults.c b/tests/xe/xe_sysfs_defaults.c
> new file mode 100644
> index 00000000..1733ade7
> --- /dev/null
> +++ b/tests/xe/xe_sysfs_defaults.c
> @@ -0,0 +1,105 @@

Please add SPDX licence here.

> +/*
> + * Copyright © 2023 Intel Corporation
> + *

Then delete following text "Permission...".

> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include <dirent.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +#include "xe_drm.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * TEST: xe sysfs defaults
> + * Category: Infrastructure
> + * Functionality: driver handler
> + * Run type: FULL
> + * Sub-category: xe
> + * Test category: SysMan
> + * SUBTEST: defaults
> + */
> +
> +static void test_defaults(int xe, int engine)
> +{
> +	struct dirent *de;
> +	int defaults;
> +	DIR *dir;
> +
> +	defaults = openat(engine, ".defaults", O_DIRECTORY);
> +	igt_require(defaults != -1);
> +
> +	dir = fdopendir(engine);
> +	while ((de = readdir(dir))) {
> +		if (*de->d_name == '.')
> +			continue;
> +
> +		igt_debug("Checking attr '%s'\n", de->d_name);
> +
> +		igt_assert_f(igt_sysfs_get(defaults, de->d_name),
> +					 "Default value %s is not present!\n",
> +					 de->d_name);
> +
> +		igt_assert_f(!igt_sysfs_set(defaults, de->d_name, "garbage"),
> +					 "write into default value of %s succeeded!\n",
> +					 de->d_name);
> +	}
> +	closedir(dir);
> +}
> +
> +igt_main
> +{
> +	int xe, sys;
> +	int gt;
> +
> +	igt_fixture {
> +		xe = drm_open_driver(DRIVER_XE);
> +		xe_device_get(xe);
> +
> +		sys = igt_sysfs_open(xe);
> +		igt_require(sys != -1);
> +	}

Add newline here.

> +	igt_subtest_with_dynamic("defaults") {
> +		xe_for_each_gt(xe, gt) {
> +			int engines = -1;
> +			char buf[100];
> +
> +			sprintf(buf, "device/gt%d/engines", gt);

These is for engines defaults ? Maybe name tests as such?

Regards,
Kamil

> +			engines = openat(sys, buf, O_RDONLY);
> +			igt_require(engines != -1);
> +
> +			igt_sysfs_engines(xe, engines, NULL, test_defaults);
> +
> +			close(engines);
> +		}
> +	}
> +
> +	igt_fixture {
> +		close(sys);
> +		xe_device_put(xe);
> +		close(xe);
> +	}
> +}
> +
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout priyanka.dandamudi
@ 2023-06-27 16:09   ` Kamil Konieczny
  0 siblings, 0 replies; 15+ messages in thread
From: Kamil Konieczny @ 2023-06-27 16:09 UTC (permalink / raw)
  To: igt-dev; +Cc: tejas.upadhyay

Hi Priyanka,

On 2023-06-25 at 17:59:46 +0530, priyanka.dandamudi@intel.com wrote:
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> Basic tests idempotent and invalid are added to verify
> preempt_timeout for each engine.
> It verifies whether parameter value within in the range.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> ---
>  tests/meson.build                   |   1 +
>  tests/xe/xe_sysfs_preempt_timeout.c | 139 ++++++++++++++++++++++++++++
>  2 files changed, 140 insertions(+)
>  create mode 100644 tests/xe/xe_sysfs_preempt_timeout.c
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index b24bae5c..ea6c9239 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -271,6 +271,7 @@ xe_progs = [
>  	'xe_waitfence',
>  	'xe_spin_batch',
>  	'xe_sysfs_defaults',
> +	'xe_sysfs_preempt_timeout',

Why not just one test xe_sysfs_scheduler and adding more subtests
into it? So we can limit number of files.

>  ]
>  
>  msm_progs = [
> diff --git a/tests/xe/xe_sysfs_preempt_timeout.c b/tests/xe/xe_sysfs_preempt_timeout.c
> new file mode 100644
> index 00000000..5a357128
> --- /dev/null
> +++ b/tests/xe/xe_sysfs_preempt_timeout.c
> @@ -0,0 +1,139 @@
> +/*
> + * Copyright © 2023 Intel Corporation
> + *
> + * Permission is hereby ggit ranted, free of charge, to any person obtaining a

Same here, use SPDX.

> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include <dirent.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +#include "xe_drm.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * TEST: xe sysfs preempt timeout
> + * Run type: FULL
> + *
> + * SUBTEST: idempotent
> + * Description: Test to check whether the preempt_timeout_us parameter reports the values set.
> + * Test category: SysMan
> + *
> + * SUBTEST: invalid
> + * Description: Test to check if preempt_timeout parameter rejects any unrepresentable intervals.
> + * Test category: SysMan
> + */
> +
> +#define ATTR "preempt_timeout_us"
> +#define ATTR_MIN "preempt_timeout_min"
> +#define ATTR_MAX "preempt_timeout_max"
> +
> +static void set_preempt_timeout(int engine, unsigned int value)
> +{
> +	unsigned int delay;
> +
> +	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
> +	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
> +	igt_assert_eq(delay, value);
> +}
> +
> +static void test_idempotent(int xe, int engine)
> +{
> +	unsigned int delays[] = { 1, 1000, 1234, 54321 };
> +	unsigned int saved;
> +
> +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> +	igt_debug("Initial %s:%u\n", ATTR, saved);
> +
> +	for (int i = 0; i < ARRAY_SIZE(delays); i++)
> +		set_preempt_timeout(engine, delays[i]);
> +
> +	set_preempt_timeout(engine, saved);
> +}
> +
> +static void test_invalid(int xe, int engine)
> +{
> +	unsigned int saved, set;
> +	unsigned int min, max;
> +
> +	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
> +	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
> +
> +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> +	igt_debug("Initial %s:%u\n", ATTR, saved);
> +
> +	igt_sysfs_printf(engine, ATTR, "%d", max+1);
> +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> +	igt_assert_eq(set, saved);
> +
> +	igt_sysfs_printf(engine, ATTR, "%d", min-1);
> +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> +	igt_assert_eq(set, saved);
> +}
> +
> +igt_main
> +{
> +	static const struct {
> +		const char *name;
> +		void (*fn)(int, int);
> +	} tests[] = {
> +		{ "idempotent", test_idempotent },
> +		{ "invalid", test_invalid },
> +		{ }
> +	};
> +	int xe = -1;
> +	int sys;
> +	int gt;
> +
> +	igt_fixture {
> +		xe = drm_open_driver(DRIVER_XE);
> +		xe_device_get(xe);
> +
> +		sys = igt_sysfs_open(xe);
> +		igt_require(sys != -1);
> +	}
> +
> +	for (typeof(*tests) *t = tests; t->name; t++)
> +	    igt_subtest_with_dynamic(t->name) {
> +		    xe_for_each_gt(xe, gt) {
> +			    int engines = -1;
> +			    char buf[100];
> +
> +			    sprintf(buf, "device/gt%d/engines", gt);
> +			    engines = openat(sys, buf, O_RDONLY);
> +			    igt_require(engines != -1);
> +
> +			    igt_sysfs_engines(xe, engines, ATTR, t->fn);
> +
> +			    close(engines);
> +			}
> +		}
> +
> +	igt_fixture {
> +		close(sys);
> +		xe_device_put(xe);
> +		close(xe);

May we wait a little here? There is patchset by Bhanuprakash
with drm_close_driver() which may help here and with open above.

Regards,
Kamil

> +	}
> +}
> +
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines
  2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
@ 2023-06-27 16:16   ` Kamil Konieczny
  0 siblings, 0 replies; 15+ messages in thread
From: Kamil Konieczny @ 2023-06-27 16:16 UTC (permalink / raw)
  To: igt-dev; +Cc: tejas.upadhyay

Hi Priyanka,

On 2023-06-25 at 17:59:44 +0530, priyanka.dandamudi@intel.com wrote:
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> It helps to test engines by iterating over sysfs/engines.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> ---
>  lib/igt_sysfs.c | 35 +++++++++++++++++++++++++++++++++++
>  lib/igt_sysfs.h |  3 +++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 35a4faa9..1f32e659 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -856,3 +856,38 @@ void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw)
>  	igt_assert_eq(get, prev);
>  	igt_assert(!ret);
>  }
> +

Please add description to each new public function.

Regards,
Kamil

> +void igt_sysfs_engines(int xe, int engines, const char *file,
> +					   void (*test)(int, int))
> +{
> +	struct dirent *de;
> +	DIR *dir;
> +
> +	lseek(engines, 0, SEEK_SET);
> +
> +	dir = fdopendir(engines);
> +	if (!dir)
> +		close(engines);
> +
> +	while ((de = readdir(dir))) {
> +		int engine;
> +
> +		if (*de->d_name == '.')
> +			continue;
> +
> +		engine = openat(engines, de->d_name, O_RDONLY);
> +		if (engine < 0)
> +			continue;
> +
> +		igt_dynamic(de->d_name) {
> +			if (file) {
> +				struct stat st;
> +
> +				igt_require(fstatat(engine, file, &st, 0) == 0);
> +			}
> +			errno = 0;
> +			test(xe, engine);
> +		}
> +		close(engine);
> +	}
> +}
> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
> index 978b6906..c89780ac 100644
> --- a/lib/igt_sysfs.h
> +++ b/lib/igt_sysfs.h
> @@ -147,4 +147,7 @@ typedef struct igt_sysfs_rw_attr {
>  
>  void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw);
>  
> +void igt_sysfs_engines(int xe, int gt, const char *file,
> +		       void (*test)(int, int));
> +
>  #endif /* __IGT_SYSFS_H__ */
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory
  2023-06-27 10:37   ` Kumar, Janga Rahul
@ 2023-06-28  7:19     ` Dandamudi, Priyanka
  0 siblings, 0 replies; 15+ messages in thread
From: Dandamudi, Priyanka @ 2023-06-28  7:19 UTC (permalink / raw)
  To: Kumar, Janga Rahul, Upadhyay, Tejas, igt-dev



> -----Original Message-----
> From: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>
> Sent: 27 June 2023 04:07 PM
> To: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>; Upadhyay,
> Tejas <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org
> Subject: RE: [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in
> engines directory
> 
> 
> 
> > -----Original Message-----
> > From: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>
> > Sent: 25 June 2023 18:00
> > To: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>; Upadhyay, Tejas
> > <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org; Dandamudi,
> > Priyanka <priyanka.dandamudi@intel.com>
> > Subject: [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in
> > engines directory
> >
> > From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> >
> > Add a new test which verifies .defaults are readonly and all
> > parameters are present.
> >
> > Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> > Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> > Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> > ---
> >  tests/meson.build            |   1 +
> >  tests/xe/xe_sysfs_defaults.c | 105
> > +++++++++++++++++++++++++++++++++++
> >  2 files changed, 106 insertions(+)
> >  create mode 100644 tests/xe/xe_sysfs_defaults.c
> >
> > diff --git a/tests/meson.build b/tests/meson.build index
> > 85ea7e74..b24bae5c
> > 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -270,6 +270,7 @@ xe_progs = [
> >  	'xe_vm',
> >  	'xe_waitfence',
> >  	'xe_spin_batch',
> > +	'xe_sysfs_defaults',
> >  ]
> >
> >  msm_progs = [
> > diff --git a/tests/xe/xe_sysfs_defaults.c
> > b/tests/xe/xe_sysfs_defaults.c new file mode 100644 index
> > 00000000..1733ade7
> > --- /dev/null
> > +++ b/tests/xe/xe_sysfs_defaults.c
> > @@ -0,0 +1,105 @@
> > +/*
> > + * Copyright © 2023 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> > +obtaining a
> > + * copy of this software and associated documentation files (the
> > +"Software"),
> > + * to deal in the Software without restriction, including without
> > +limitation
> > + * the rights to use, copy, modify, merge, publish, distribute,
> > +sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom
> > +the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including
> > +the next
> > + * paragraph) shall be included in all copies or substantial portions
> > +of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
> KIND,
> > +EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > +MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> > EVENT
> > +SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> > DAMAGES OR
> > +OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> OTHERWISE,
> > +ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
> OR
> > OTHER
> > +DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include <dirent.h>
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
> > +#include <unistd.h>
> > +
> > +#include "igt.h"
> > +#include "igt_sysfs.h"
> > +
> > +#include "xe_drm.h"
> > +#include "xe/xe_query.h"
> > +
> > +/**
> > + * TEST: xe sysfs defaults
> > + * Category: Infrastructure
> > + * Functionality: driver handler
> > + * Run type: FULL
> > + * Sub-category: xe
> > + * Test category: SysMan
> > + * SUBTEST: defaults
> > + */
> > +
> > +static void test_defaults(int xe, int engine) {
> > +	struct dirent *de;
> > +	int defaults;
> > +	DIR *dir;
> > +
> > +	defaults = openat(engine, ".defaults", O_DIRECTORY);
> Check even .defaults dir has readonly access or not
> > +	igt_require(defaults != -1);
> > +
> > +	dir = fdopendir(engine);
> > +	while ((de = readdir(dir))) {
> > +		if (*de->d_name == '.')
> > +			continue;
> > +
> > +		igt_debug("Checking attr '%s'\n", de->d_name);
> > +
> > +		igt_assert_f(igt_sysfs_get(defaults, de->d_name),
> > +					 "Default value %s is not present!\n",
> > +					 de->d_name);
> > +
> > +		igt_assert_f(!igt_sysfs_set(defaults, de->d_name, "garbage"),
> > +					 "write into default value of %s
> > succeeded!\n",
> > +					 de->d_name);
> > +	}
> > +	closedir(dir);
> > +}
> > +
> > +igt_main
> > +{
> > +	int xe, sys;
> > +	int gt;
> > +
> > +	igt_fixture {
> > +		xe = drm_open_driver(DRIVER_XE);
> > +		xe_device_get(xe);
> > +
> > +		sys = igt_sysfs_open(xe);
> > +		igt_require(sys != -1);
> > +	}
> > +	igt_subtest_with_dynamic("defaults") {
> > +		xe_for_each_gt(xe, gt) {
> > +			int engines = -1;
> > +			char buf[100];
> > +
> > +			sprintf(buf, "device/gt%d/engines", gt);
> Patch https://patchwork.freedesktop.org/series/118927/
> is moving gt sysfs parent under tile folder.
> 
> With the above patch path for sysfs changes:
> from: /sys/class/drm/cardX/device/gtN/ to :
> /sys/class/drm/cardX/device/tileN/gtN
> 
> I would suggest to add some get_gt_sysfs_path() type of functions which can
> be used in all the tests and will be easy to maintain if the path is change by
> kernel in future as well.
> 
> Thanks,
> Rahul

There is already a function similar to the one you mentioned but it doesn't work for xe.
For now, let this be and later we can improve lib which works for both xe and i915.
Thanks,
Priyanka
> > +			engines = openat(sys, buf, O_RDONLY);
> > +			igt_require(engines != -1);
> > +
> > +			igt_sysfs_engines(xe, engines, NULL, test_defaults);
> > +
> > +			close(engines);
> > +		}
> > +	}
> > +
> > +	igt_fixture {
> > +		close(sys);
> > +		xe_device_put(xe);
> > +		close(xe);
> > +	}
> > +}
> > +
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration
  2023-06-27 11:38   ` Kumar, Janga Rahul
@ 2023-06-28  7:20     ` Dandamudi, Priyanka
  0 siblings, 0 replies; 15+ messages in thread
From: Dandamudi, Priyanka @ 2023-06-28  7:20 UTC (permalink / raw)
  To: Kumar, Janga Rahul, Upadhyay, Tejas, igt-dev



> -----Original Message-----
> From: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>
> Sent: 27 June 2023 05:09 PM
> To: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>; Upadhyay, Tejas
> <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org
> Subject: RE: [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration
> 
> 
> 
> > -----Original Message-----
> > From: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>
> > Sent: 25 June 2023 18:00
> > To: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>; Upadhyay, Tejas
> > <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org; Dandamudi,
> > Priyanka <priyanka.dandamudi@intel.com>
> > Subject: [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify
> > timeslice_duration
> >
> > From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> >
> > Basic tests idempotent and invalid are added to verify
> > timeslice_duration for each engine.
> > It verifies whether parameter value within in the range.
> >
> > Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> > Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> > Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> > ---
> >  tests/meson.build             |   1 +
> >  tests/xe/xe_sysfs_timeslice.c | 138
> > ++++++++++++++++++++++++++++++++++
> >  2 files changed, 139 insertions(+)
> >  create mode 100644 tests/xe/xe_sysfs_timeslice.c
> >
> > diff --git a/tests/meson.build b/tests/meson.build index
> > ea6c9239..1474a494
> > 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -272,6 +272,7 @@ xe_progs = [
> >  	'xe_spin_batch',
> >  	'xe_sysfs_defaults',
> >  	'xe_sysfs_preempt_timeout',
> > +	'xe_sysfs_timeslice',
> >  ]
> >
> >  msm_progs = [
> > diff --git a/tests/xe/xe_sysfs_timeslice.c
> > b/tests/xe/xe_sysfs_timeslice.c new file mode 100644 index
> > 00000000..94bed383
> > --- /dev/null
> > +++ b/tests/xe/xe_sysfs_timeslice.c
> > @@ -0,0 +1,138 @@
> > +/*
> > + * Copyright © 2023 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> > +obtaining a
> > + * copy of this software and associated documentation files (the
> > +"Software"),
> > + * to deal in the Software without restriction, including without
> > +limitation
> > + * the rights to use, copy, modify, merge, publish, distribute,
> > +sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom
> > +the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including
> > +the next
> > + * paragraph) shall be included in all copies or substantial portions
> > +of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > +EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > +MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> > EVENT
> > +SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> > DAMAGES OR
> > +OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> > +ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> > OTHER
> > +DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include <dirent.h>
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
> > +#include <unistd.h>
> > +
> > +#include "igt.h"
> > +#include "igt_sysfs.h"
> > +
> > +#include "xe_drm.h"
> > +#include "xe/xe_query.h"
> > +
> > +/**
> > + * TEST: xe sysfs timeslice
> > + * Run type: FULL
> > + *
> > + * SUBTEST: idempotent
> > + * Description: Test to check whether the timelslice_duration_us
> > +parameter
> > reports the values set.
> > + * Test category: SysMan
> > + *
> > + * SUBTEST: invalid
> > + * Description: Test to check if timeslice_duration parameter rejects
> > + any
> > unrepresentable intervals.
> > + * Test category: SysMan
> > + */
> > +
> > +#define ATTR "timeslice_duration_us"
> > +#define ATTR_MIN "timeslice_duration_min"
> > +#define ATTR_MAX "timeslice_duration_max"
> > +
> > +static void set_timeslice_duration(int engine, unsigned int value) {
> > +	unsigned int delay;
> > +
> > +	igt_assert_lte(0, igt_sysfs_printf(engine, ATTR, "%u", value));
> > +	igt_sysfs_scanf(engine, ATTR, "%u", &delay);
> > +	igt_assert_eq(delay, value);
> > +}
> > +
> > +static void test_idempotent(int xe, int engine) {
> > +	unsigned int delays[] = { 1, 1000, 1234, 10000000 };
> > +	unsigned int saved;
> > +
> > +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> > +	igt_debug("Initial %s:%u\n", ATTR, saved);
> > +
> > +	for (int i = 0; i < ARRAY_SIZE(delays); i++)
> > +		set_timeslice_duration(engine, delays[i]);
> > +
> > +	set_timeslice_duration(engine, saved); }
> > +
> > +static void test_invalid(int xe, int engine) {
> Modify this to sysfs_range(min_max)_invalid(int xe, int engine_fd,  const char
> *attr, const char *attr_min, const char *attr_max) and move this to lib and reuse
> it in other tests.
I modified entire tests and will send the change in next patch series.
> 
> > +	unsigned int saved, set;
> > +	unsigned int min, max;
> > +
> > +	igt_sysfs_scanf(engine, ATTR_MAX, "%u", &max);
> > +	igt_sysfs_scanf(engine, ATTR_MIN, "%u", &min);
> > +
> > +	igt_assert(igt_sysfs_scanf(engine, ATTR, "%u", &saved) == 1);
> > +	igt_debug("Initial %s:%u\n", ATTR, saved);
> > +
> > +	igt_sysfs_printf(engine, ATTR, "%d", max+1);
> > +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> > +	igt_assert_eq(set, saved);
> > +
> > +	igt_sysfs_printf(engine, ATTR, "%d", min-1);
> > +	igt_sysfs_scanf(engine, ATTR, "%u", &set);
> > +	igt_assert_eq(set, saved);
> > +}
> > +
> > +igt_main
> > +{
> > +	static const struct {
> > +		const char *name;
> > +		void (*fn)(int, int);
> > +	} tests[] = {
> > +		{ "idempotent", test_idempotent },
> > +		{ "invalid", test_invalid },
> > +		{ }
> > +	};
> > +	int xe = -1;
> > +	int sys;
> > +	int gt;
> > +
> > +	igt_fixture {
> > +		xe = drm_open_driver(DRIVER_XE);
> > +		xe_device_get(xe);
> > +
> > +		sys = igt_sysfs_open(xe);
> > +		igt_require(sys != -1);
> > +	}
> > +	for (typeof(*tests) *t = tests; t->name; t++)
> > +		igt_subtest_with_dynamic(t->name) {
> > +			xe_for_each_gt(xe, gt) {
> > +				int engines = -1;
> > +				char buf[100];
> > +
> > +				sprintf(buf, "device/gt%d/engines", gt);
> > +				engines = openat(sys, buf, O_RDONLY);
> For variables being used for storing fd's, Pls append "_fd" to improve readability.
> 
> Thanks,
> Rahul
Will make that change.
Thanks,
Priyanka
> > +				igt_require(engines != -1);
> > +
> > +				igt_sysfs_engines(xe, engines, ATTR, t->fn);
> > +
> > +				close(engines);
> > +			}
> > +		}
> > +
> > +	igt_fixture {
> > +		close(sys);
> > +		xe_device_put(xe);
> > +		close(xe);
> > +	}
> > +}
> > +
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface
  2023-06-25 11:13 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
@ 2023-06-26 10:13 ` Upadhyay, Tejas
  0 siblings, 0 replies; 15+ messages in thread
From: Upadhyay, Tejas @ 2023-06-26 10:13 UTC (permalink / raw)
  To: Dandamudi, Priyanka, Kumar, Janga Rahul, igt-dev



> -----Original Message-----
> From: Dandamudi, Priyanka <priyanka.dandamudi@intel.com>
> Sent: Sunday, June 25, 2023 4:43 PM
> To: Kumar, Janga Rahul <janga.rahul.kumar@intel.com>; Upadhyay, Tejas
> <tejas.upadhyay@intel.com>; igt-dev@lists.freedesktop.org; Dandamudi,
> Priyanka <priyanka.dandamudi@intel.com>
> Subject: [PATCH i-g-t 0/5] Add tests for scheduler control interface
> 
> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> New lib function has been added to iterate over sysfs/engines.
> Added 4 new tests to validate basic scheduler control interface and its
> defaults.
> 
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
> 
> Priyanka Dandamudi (5):
>   lib/igt_sysfs: Add support to iterate over engines
>   xe/xe_sysfs_defaults: Verify .defaults in engines directory
>   xe/xe_sysfs_preempt_timeout: Verify preempt_timeout
>   xe/xe_sysfs_timeslice: Verify timeslice_duration
>   xe/xe_sysfs_job_timeout: Verify job_timeout

These basic tests are enough, though one basic test for min/max cap range would complete basic test requirement here.

Thanks,
Tejas
> 
>  lib/igt_sysfs.c                     |  35 +++++++
>  lib/igt_sysfs.h                     |   3 +
>  tests/meson.build                   |   4 +
>  tests/xe/xe_sysfs_defaults.c        | 105 +++++++++++++++++++++
>  tests/xe/xe_sysfs_job_timeout.c     | 138 +++++++++++++++++++++++++++
>  tests/xe/xe_sysfs_preempt_timeout.c | 139
> ++++++++++++++++++++++++++++
>  tests/xe/xe_sysfs_timeslice.c       | 138 +++++++++++++++++++++++++++
>  7 files changed, 562 insertions(+)
>  create mode 100644 tests/xe/xe_sysfs_defaults.c  create mode 100644
> tests/xe/xe_sysfs_job_timeout.c  create mode 100644
> tests/xe/xe_sysfs_preempt_timeout.c
>  create mode 100644 tests/xe/xe_sysfs_timeslice.c
> 
> --
> 2.25.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface
@ 2023-06-25 11:13 priyanka.dandamudi
  2023-06-26 10:13 ` Upadhyay, Tejas
  0 siblings, 1 reply; 15+ messages in thread
From: priyanka.dandamudi @ 2023-06-25 11:13 UTC (permalink / raw)
  To: janga.rahul.kumar, tejas.upadhyay, igt-dev, priyanka.dandamudi

From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

New lib function has been added to iterate over sysfs/engines.
Added 4 new tests to validate basic scheduler control interface and its defaults.

Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>

Priyanka Dandamudi (5):
  lib/igt_sysfs: Add support to iterate over engines
  xe/xe_sysfs_defaults: Verify .defaults in engines directory
  xe/xe_sysfs_preempt_timeout: Verify preempt_timeout
  xe/xe_sysfs_timeslice: Verify timeslice_duration
  xe/xe_sysfs_job_timeout: Verify job_timeout

 lib/igt_sysfs.c                     |  35 +++++++
 lib/igt_sysfs.h                     |   3 +
 tests/meson.build                   |   4 +
 tests/xe/xe_sysfs_defaults.c        | 105 +++++++++++++++++++++
 tests/xe/xe_sysfs_job_timeout.c     | 138 +++++++++++++++++++++++++++
 tests/xe/xe_sysfs_preempt_timeout.c | 139 ++++++++++++++++++++++++++++
 tests/xe/xe_sysfs_timeslice.c       | 138 +++++++++++++++++++++++++++
 7 files changed, 562 insertions(+)
 create mode 100644 tests/xe/xe_sysfs_defaults.c
 create mode 100644 tests/xe/xe_sysfs_job_timeout.c
 create mode 100644 tests/xe/xe_sysfs_preempt_timeout.c
 create mode 100644 tests/xe/xe_sysfs_timeslice.c

-- 
2.25.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-06-28  7:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-25 12:29 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_sysfs: Add support to iterate over engines priyanka.dandamudi
2023-06-27 16:16   ` Kamil Konieczny
2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 2/5] xe/xe_sysfs_defaults: Verify .defaults in engines directory priyanka.dandamudi
2023-06-27 10:37   ` Kumar, Janga Rahul
2023-06-28  7:19     ` Dandamudi, Priyanka
2023-06-27 16:03   ` Kamil Konieczny
2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 3/5] xe/xe_sysfs_preempt_timeout: Verify preempt_timeout priyanka.dandamudi
2023-06-27 16:09   ` Kamil Konieczny
2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 4/5] xe/xe_sysfs_timeslice: Verify timeslice_duration priyanka.dandamudi
2023-06-27 11:38   ` Kumar, Janga Rahul
2023-06-28  7:20     ` Dandamudi, Priyanka
2023-06-25 12:29 ` [igt-dev] [PATCH i-g-t 5/5] xe/xe_sysfs_job_timeout: Verify job_timeout priyanka.dandamudi
  -- strict thread matches above, loose matches on Subject: below --
2023-06-25 11:13 [igt-dev] [PATCH i-g-t 0/5] Add tests for scheduler control interface priyanka.dandamudi
2023-06-26 10:13 ` Upadhyay, Tejas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.