Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs
@ 2025-06-15 17:14 Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

This series:
 - moves shared function to lib/igt_dir
 - creates gpu agnostic tests
   - core_debugfs
   - core_debugfs_display_on_off
   - core_sysfs
 - creates the xe-specific test
   - xe_debugfs (complementary to core_debugfs*)
 - Updates testlists and scripts
 - deletes tests/intel_sysfs_debugfs

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com

Peter Senna Tschudin (6):
  lib/igt_dir: Directory processing and flexible file handling
  tests: Add core_debugfs
  tests: Add core_debugfs_heads_power
  tests: Add core_sysfs
  tests: Add xe_debugfs
  tests/intel: Remove intel_sysfs_debugfs

 docs/code_coverage.md                    |  18 +-
 lib/igt_dir.c                            | 260 ++++++++++++++
 lib/igt_dir.h                            |  61 ++++
 lib/meson.build                          |   1 +
 scripts/code_cov_selftest.sh             |   2 +-
 tests/core_debugfs.c                     |  54 +++
 tests/core_debugfs_heads_power.c         | 156 ++++++++
 tests/core_sysfs.c                       |  58 +++
 tests/intel-ci/fast-feedback.testlist    |   4 +-
 tests/intel-ci/xe-fast-feedback.testlist |   8 +-
 tests/intel/intel_sysfs_debugfs.c        | 430 -----------------------
 tests/intel/xe_debugfs.c                 | 208 +++++++++++
 tests/intel/xe_test_config.json          |   2 +-
 tests/meson.build                        |   5 +-
 14 files changed, 819 insertions(+), 448 deletions(-)
 create mode 100644 lib/igt_dir.c
 create mode 100644 lib/igt_dir.h
 create mode 100644 tests/core_debugfs.c
 create mode 100644 tests/core_debugfs_heads_power.c
 create mode 100644 tests/core_sysfs.c
 delete mode 100644 tests/intel/intel_sysfs_debugfs.c
 create mode 100644 tests/intel/xe_debugfs.c

-- 
2.43.0


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

* [PATCH v3 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 2/6] tests: Add core_debugfs Peter Senna Tschudin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

This update introduces new utilities to facilitate reading and
processing files within a directory, giving test writers greater control
over file selection and processing.

For example, to read and discard all files from debugfs:

  fd = drm_open_driver_master(DRIVER_ANY);
  debugfs = igt_debugfs_dir(fd);

  igt_dir = igt_dir_create(debugfs);
  igt_dir_scan_dirfd(igt_dir, -1); // -1 means unlimited scan depth
  igt_dir_process_files(igt_dir, NULL, NULL);

The igt_dir_scan_dirfd() function builds a linked list of files (using
igt_list), making it easy to add or remove specific files before
processing. If you only want to process a predetermined set of files,
you can skip the scan step and add the files directly to the list.

The last two parameters of igt_dir_process_files() specify a callback
function and user data. If the callback is NULL, a default “read and
discard” function is used.

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - unchanged from v2
v2:
 - changed style of comparison to NULL

 lib/igt_dir.c   | 260 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_dir.h   |  61 ++++++++++++
 lib/meson.build |   1 +
 3 files changed, 322 insertions(+)
 create mode 100644 lib/igt_dir.c
 create mode 100644 lib/igt_dir.h

diff --git a/lib/igt_dir.c b/lib/igt_dir.c
new file mode 100644
index 000000000..8f5a25e35
--- /dev/null
+++ b/lib/igt_dir.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include <dirent.h>
+#include <fcntl.h>
+
+#include "igt.h"
+#include "lib/igt_dir.h"
+
+/**
+ * igt_dir_get_fd_path: Get the path of a file descriptor
+ * @fd: file descriptor to get the path for
+ * @path: buffer to store the path
+ * @path_len: length of the buffer
+ *
+ * Returns: 0 on success, a negative error code on failure
+ */
+int igt_dir_get_fd_path(int fd, char *path, size_t path_len)
+{
+	ssize_t len;
+	char proc_path[64];
+
+	snprintf(proc_path, sizeof(proc_path), "/proc/self/fd/%d", fd);
+	len = readlink(proc_path, path, path_len - 1);
+	if (len == -1)
+		return -1;
+
+	path[path_len] = '\0';
+	return 0;
+}
+
+/**
+ * igt_dir_callback_read_discard: Default callback function for reading and
+ *				  discarding file contents
+ * @filename: Path to the file
+ * @callback_data: Optional pointer to user-defined data passed to the callback
+ *
+ * Returns: 0 on success, a negative error code on failure
+ */
+int igt_dir_callback_read_discard(const char *filename,
+				  void *callback_data)
+{
+	int fd;
+	char buf[4096];
+	ssize_t bytes_read;
+
+	fd = open(filename, O_RDONLY);
+	if (fd < 0) {
+		igt_debug("Failed to open file %s\n", filename);
+		return -1;
+	}
+	bytes_read = read(fd, buf, sizeof(buf) - 1);
+	if (bytes_read < 0) {
+		igt_debug("Failed to read file %s\n", filename);
+		close(fd);
+		return -1;
+	}
+	buf[bytes_read] = '\0';
+	igt_debug("Read %zd bytes from file %s: %s\n", bytes_read,
+		  filename, buf);
+	close(fd);
+	return 0;
+}
+
+/**
+ * igt_dir_create: Create a new igt_dir_t struct
+ * @dirfd: file descriptor of the root directory
+ *
+ * Returns: Pointer to the new igt_dir_t struct, or NULL on failure
+ */
+igt_dir_t *igt_dir_create(int dirfd)
+{
+	igt_dir_t *config;
+	size_t path_len = 512;
+	char path[path_len];
+
+	config = malloc(sizeof(igt_dir_t));
+	if (!config)
+		return NULL;
+
+	config->dirfd = dirfd;
+
+	igt_dir_get_fd_path(dirfd, path, path_len);
+	igt_require(path[0] != '\0');
+
+	config->root_path = malloc(path_len);
+	if (!config->root_path) {
+		free(config);
+		return NULL;
+	}
+
+	strncpy(config->root_path, path, path_len);
+
+	IGT_INIT_LIST_HEAD(&config->file_list_head);
+
+	config->callback = NULL;
+
+	return config;
+}
+
+static int _igt_dir_scan_dirfd(igt_dir_t *config, int scan_maxdepth,
+			       int depth, const char *current_path)
+{
+	struct dirent *entry;
+	igt_dir_file_list_t *file_list_entry;
+	DIR *dirp;
+	int dirfd;
+	int ret = 0;
+
+	if (depth > scan_maxdepth && scan_maxdepth != -1)
+		return 0;
+
+	if (!current_path) {
+		igt_debug("Invalid current path\n");
+		return -1;
+	}
+
+	dirfd = open(current_path, O_RDONLY | O_DIRECTORY);
+	if (dirfd < 0) {
+		igt_debug("Failed to open directory %s\n", current_path);
+		return -1;
+	}
+
+	dirp = fdopendir(dirfd);
+	if (!dirp) {
+		igt_debug("Failed to fdopendir %s\n", current_path);
+		close(dirfd);
+		return -1;
+	}
+
+	while ((entry = readdir(dirp))) {
+		char entry_path[PATH_MAX];
+
+		if (strcmp(entry->d_name, ".") == 0 ||
+		    strcmp(entry->d_name, "..") == 0)
+			continue;
+
+		snprintf(entry_path, sizeof(entry_path),
+			 "%s/%s", current_path, entry->d_name);
+
+		if (entry->d_type == DT_DIR) {
+			ret = _igt_dir_scan_dirfd(config, scan_maxdepth,
+						  depth + 1, entry_path);
+			if (ret)
+				break;
+		} else {
+			/* Compute path relative to the scan root */
+			const char *relative_path = entry_path +
+						    strlen(config->root_path);
+			if (*relative_path == '/')
+				relative_path++; /* skip leading slash */
+
+			file_list_entry = malloc(sizeof(igt_dir_file_list_t));
+			if (!file_list_entry) {
+				igt_debug("Failed to allocate memory for file list entry\n");
+				continue;
+			}
+			file_list_entry->relative_path = strdup(relative_path);
+			file_list_entry->match = true;
+			igt_list_add(&file_list_entry->link,
+				     &config->file_list_head);
+		}
+	}
+
+	closedir(dirp);
+	close(dirfd);
+	return ret;
+}
+
+/**
+ * igt_dir_scan_dirfd: Perform a directory scan based on config.
+ * @config: Pointer to the igt_dir struct
+ * @scan_maxdepth: Maximum depth to scan the directory. -1 means no limit
+ *
+ * Returns: 0 on success, a negative error code on failure
+ */
+int igt_dir_scan_dirfd(igt_dir_t *config, int scan_maxdepth)
+{
+	igt_require(config);
+	igt_require(config->root_path);
+	igt_require(config->dirfd >= 0);
+	igt_require(scan_maxdepth >= -1);
+	igt_require(scan_maxdepth != 0);
+
+	/* If the linked list is not empty, clean it first */
+	if (!igt_list_empty(&config->file_list_head)) {
+		igt_dir_file_list_t *file_list_entry, *tmp;
+
+		igt_list_for_each_entry_safe(file_list_entry, tmp,
+					     &config->file_list_head, link) {
+			free(file_list_entry->relative_path);
+			free(file_list_entry);
+		}
+	}
+
+	return _igt_dir_scan_dirfd(config, scan_maxdepth, 0, config->root_path);
+}
+
+/**
+ * igt_dir_process_files: Process files in the directory
+ * @config: Pointer to the igt_dir struct
+ * @callback: Callback function to process each file
+ * @callback_data: Optional pointer to user-defined data passed to the callback
+ *
+ * Returns: 0 on success, a negative error code on failure
+ */
+int igt_dir_process_files(igt_dir_t *config,
+			 igt_dir_file_callback callback,
+			 void *callback_data)
+{
+	igt_dir_file_list_t *file_list_entry;
+	int ret = 0;
+
+	igt_require(config);
+	igt_require(config->root_path);
+	igt_require(config->dirfd >= 0);
+
+	if (!callback)
+		callback = igt_dir_callback_read_discard;
+
+	igt_list_for_each_entry(file_list_entry, &config->file_list_head, link) {
+		/* Only if match is true */
+		if (file_list_entry->match) {
+			char full_path[PATH_MAX];
+
+			snprintf(full_path, sizeof(full_path),
+				 "%s/%s", config->root_path,
+				 file_list_entry->relative_path);
+			ret = callback(full_path, callback_data);
+			if (ret)
+				break;
+		}
+	}
+
+	return ret;
+}
+
+/**
+ * igt_dir_destroy: Destroy the igt_dir struct
+ * @config: Pointer to the igt_dir struct
+ *
+ * Returns: 0 on success, a negative error code on failure
+ */
+void igt_dir_destroy(igt_dir_t *config)
+{
+	igt_dir_file_list_t *file_list_entry, *tmp;
+
+	igt_require(config);
+
+	igt_list_for_each_entry_safe(file_list_entry, tmp,
+				 &config->file_list_head, link) {
+		free(file_list_entry->relative_path);
+		free(file_list_entry);
+	}
+
+	free(config->root_path);
+	free(config);
+}
diff --git a/lib/igt_dir.h b/lib/igt_dir.h
new file mode 100644
index 000000000..fb9230862
--- /dev/null
+++ b/lib/igt_dir.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: MIT
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef IGT_DIR_H
+#define IGT_DIR_H
+
+#include "igt_list.h"
+
+/**
+ * Callback function type for processing files
+ * The callback is blocking, meaning traversal waits for it to return
+ * before proceeding to the next file
+ * @filename: Path to the file
+ * @callback_data: Optional pointer to user-defined data passed to the callback
+ *
+ * Returns:
+ * 0 on success, a negative error code on failure.
+ */
+typedef int (*igt_dir_file_callback)(const char *filename,
+				     void *callback_data);
+
+/**
+ * igt_dir_file_list_t: List of files with a relative path
+ * @relative_path: path to a file, relative to the root directory
+ * @match: a boolean used to filter the list of files. When match=true the
+ *	   file is processed, otherwise it is skipped
+ * @link: list head for linking files in the list
+ */
+typedef struct {
+	char *relative_path;
+	bool match;
+	struct igt_list_head link;
+} igt_dir_file_list_t;
+
+/**
+ * igt_dir_t: Main struct for igt_dir
+ * @dirfd: file descriptor of the root directory
+ * @root_path: string of the root path, for example:
+ *	       /sys/kernel/debug/dri/0000:00:02.0/
+ * @file_list_head: head of the list of files
+ * @callback: Callback function for file operations. If NULL, defaults
+ *	      to reading and discarding file contents
+ */
+typedef struct {
+	int dirfd;
+	char *root_path;
+	struct igt_list_head file_list_head;
+	igt_dir_file_callback callback;
+} igt_dir_t;
+
+int igt_dir_get_fd_path(int fd, char *path, size_t path_len);
+int igt_dir_callback_read_discard(const char *filename,
+				  void *callback_data);
+igt_dir_t *igt_dir_create(int dirfd);
+int igt_dir_scan_dirfd(igt_dir_t *config, int scan_maxdepth);
+int igt_dir_process_files(igt_dir_t *config,
+			  igt_dir_file_callback callback,
+			  void *callback_data);
+void igt_dir_destroy(igt_dir_t *config);
+#endif /* IGT_DIR_H */
diff --git a/lib/meson.build b/lib/meson.build
index ff81baae1..ec4a71bd7 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -91,6 +91,7 @@ lib_sources = [
 	'igt_kms.c',
 	'igt_fb.c',
 	'igt_core.c',
+	'igt_dir.c',
 	'igt_draw.c',
 	'igt_list.c',
 	'igt_map.c',
-- 
2.43.0


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

* [PATCH v3 i-g-t 2/6] tests: Add core_debugfs
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 3/6] tests: Add core_debugfs_heads_power Peter Senna Tschudin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

Introduce core_debugfs that is expected to work with any GPU, not
limited to i915 and Xe. The test attempts to open every file in debugfs
associated with the GPU.

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - removed "debugfs" from subtest name (Thanks Michal Wajdeczko)
v2:
 - changed style of comparison to NULL

 docs/code_coverage.md                    | 18 ++++----
 scripts/code_cov_selftest.sh             |  2 +-
 tests/core_debugfs.c                     | 54 ++++++++++++++++++++++++
 tests/intel-ci/fast-feedback.testlist    |  1 +
 tests/intel-ci/xe-fast-feedback.testlist |  1 +
 tests/meson.build                        |  1 +
 6 files changed, 67 insertions(+), 10 deletions(-)
 create mode 100644 tests/core_debugfs.c

diff --git a/docs/code_coverage.md b/docs/code_coverage.md
index 031611e69..8c4857412 100644
--- a/docs/code_coverage.md
+++ b/docs/code_coverage.md
@@ -162,23 +162,23 @@ For each script, the igt_runner passes just one parameter: the results
 directory + the test name.
 
 For instance, if it is needed to run a test called
-`intel_sysfs_debugfs (i915-debugfs-read-all-entries)` using `code_cov_capture`
+`core_debugfs (read-all-entries)` using `code_cov_capture`
 parameter, e. g.:
 
 ```
-$ echo "igt@intel_sysfs_debugfs@i915-debugfs-read-all-entries" > my.testlist
+$ echo "igt@core_debugfs@read-all-entries" > my.testlist
 $ ./scripts/run-tests.sh -T my.testlist -k ~/linux -c code_cov_capture -P
 Found test list: "/basedir/igt/build/tests/test-list.txt"
-[31410.499969] [1/1] intel_sysfs_debugfs (i915-debugfs-read-all-entries)
+[31410.499969] [1/1] core_debugfs (read-all-entries)
 [31411.060446] Storing code coverage results...
-[31418.01]     Code coverage wrote to /basedir/igt/results/code_cov/intel_sysfs_debugfs_i915_debugfs_read_all_entries.info
+[31418.01]     Code coverage wrote to /basedir/igt/results/code_cov/core_debugfs_debugfs_read_all_entries.info
 Done.
 ```
 
 The script will be called as:
 
 ```
-code_cov_capture results/code_cov/intel_sysfs_debugfs_i915_debugfs_read_all_entries
+code_cov_capture results/code_cov/core_debugfs_debugfs_read_all_entries
 ```
 
 Please notice that any character that it is not a number nor a letter at the
@@ -376,7 +376,7 @@ OUT_DIR="${HOME}/results"
 
 mkdir -p $OUT_DIR/html
 
-echo "igt@intel_sysfs_debugfs@i915-debugfs-read-all-entries" > $TESTLIST
+echo "igt@core_debugfs@read-all-entries" > $TESTLIST
 echo "igt@core_auth@basic-auth" >> $TESTLIST
 echo "igt@gem_exec_basic@basic" >> $TESTLIST
 
@@ -401,8 +401,8 @@ genhtml -q -s --legend --branch-coverage $OUT_DIR/results.info
 Running such script produces the following output:
 
 ```
-[3622.993304] [1/3] intel_sysfs_debugfs (i915-debugfs-read-all-entries)
-[3631.95]     Code coverage wrote to results/code_cov/intel_sysfs_debugfs_i915_debugfs_read_all_entries.info
+[3622.993304] [1/3] core_debugfs (read-all-entries)
+[3631.95]     Code coverage wrote to results/code_cov/core_debugfs_debugfs_read_all_entries.info
 [3626.217016] Storing code coverage results...
 [3631.957998] [2/3] core_auth (basic-auth)
 [3638.03]     Code coverage wrote to results/code_cov/core_auth_basic_auth.info
@@ -419,7 +419,7 @@ core_auth_basic_auth.info:
 Ignored......: non-drm headers and source files where none of its code ran.
 Source files.: 23.27% (165 of 709 total), 29.57% (165 of 558 filtered)
 
-intel_sysfs_debugfs_i915_debugfs_read_all_entries.info:
+core_debugfs_debugfs_read_all_entries.info:
   lines......: 19.3% (20266 of 104802 lines)
   functions..: 17.5% (1922 of 10971 functions)
   branches...: 12.7% (9462 of 74555 branches)
diff --git a/scripts/code_cov_selftest.sh b/scripts/code_cov_selftest.sh
index bc5ef7458..6f3a6db55 100755
--- a/scripts/code_cov_selftest.sh
+++ b/scripts/code_cov_selftest.sh
@@ -13,7 +13,7 @@ if [ -z "$IGT_KERNEL_TREE" ] ; then
         exit 1
 fi
 
-TEST="igt@intel_sysfs_debugfs@i915-debugfs-read-all-entries"
+TEST="igt@core_debugfs@read-all-entries"
 
 TESTLIST="my_tests.testlist"
 GATHER="scripts/code_cov_gather_on_test.py"
diff --git a/tests/core_debugfs.c b/tests/core_debugfs.c
new file mode 100644
index 000000000..97fd446c5
--- /dev/null
+++ b/tests/core_debugfs.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_dir.h"
+
+/**
+ * TEST: debugfs test
+ * Description: Read entries from debugfs
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: uapi
+ * Functionality: debugfs
+ * Feature: core
+ * Test category: uapi
+ *
+ * SUBTEST: read-all-entries
+ * Description: Read all entries from debugfs path validating debugfs entries
+ */
+
+IGT_TEST_DESCRIPTION("Read entries from debugfs");
+
+igt_main
+{
+	int debugfs = -1;
+	int fd = -1;
+	igt_dir_t *igt_dir = NULL;
+
+	igt_fixture {
+		fd = drm_open_driver_master(DRIVER_ANY);
+		debugfs = igt_debugfs_dir(fd);
+		igt_require(debugfs >= 0);
+
+		igt_dir = igt_dir_create(debugfs);
+		igt_require(igt_dir);
+
+		kmstest_set_vt_graphics_mode();
+	}
+
+	igt_describe("Read all entries from debugfs path.");
+	igt_subtest("read-all-entries") {
+		igt_dir_scan_dirfd(igt_dir, -1);
+		igt_dir_process_files(igt_dir, NULL, NULL);
+	}
+
+	igt_fixture {
+		igt_dir_destroy(igt_dir);
+		close(debugfs);
+		drm_close_driver(fd);
+	}
+}
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 82395e7ea..3ec1b95cf 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -3,6 +3,7 @@ igt@i915_module_load@load
 
 # Keep alphabetically sorted by default
 igt@core_auth@basic-auth
+igt@core_debugfs@read-all-entries
 igt@fbdev@eof
 igt@fbdev@info
 igt@fbdev@nullptr
diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index d9d180d87..ac3177ae9 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -7,6 +7,7 @@ igt@fbdev@nullptr
 igt@fbdev@read
 igt@fbdev@write
 
+igt@core_debugfs@read-all-entries
 igt@intel_sysfs_debugfs@xe-base
 igt@intel_sysfs_debugfs@xe-debugfs-read-all-entries
 igt@intel_sysfs_debugfs@xe-forcewake
diff --git a/tests/meson.build b/tests/meson.build
index 55bcf57ec..fa62cbeb9 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,5 +1,6 @@
 test_progs = [
 	'core_auth',
+	'core_debugfs',
 	'core_getclient',
 	'core_getstats',
 	'core_getversion',
-- 
2.43.0


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

* [PATCH v3 i-g-t 3/6] tests: Add core_debugfs_heads_power
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 2/6] tests: Add core_debugfs Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 4/6] tests: Add core_sysfs Peter Senna Tschudin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, Karthik B S, Juha-Pekka Heikkila,
	Juha-Pekka Heikkila, Swati Sharma, michal.wajdeczko,
	marcin.bernatowicz, kamil.konieczny, katarzyna.piecielska,
	zbigniew.kempczynski, ewelina.musial

Introduce core_debugfs_heads_power that is expected to work with any
GPU, not limited to i915 and Xe. The test powers off all available
heads before reading debugfs files, and then powers on all heads
before reading the files again.

Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: Juha-Pekka Heikkila <juha-pekka.heikkila@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - renamed the test
 - Removed reference to sysfs from comments  (thanks Kamil)
 - Updated description to match the display part (thanks Kamil)
 - Moved from "display" to "heads". Our CI uses "headless" to refer
   to a DUT without display and it is shorter
 - renamed subtests for shorter names (thanks Kamil)
 - fixed comments style (thanks Kamil)
 - updated CC list
 - changed the order to test first with all heads off then with all heads on
   to prevent the need from powering on the heads at the end of the test
   (thanks Kamil)
 - removed snprintf from test names (thanks Kamil)
 - removed subtest group (thanks Kamil)
 - deleted kms_tests() and moved the code to igt_main (thanks Kamil)

v2:
 - changed style of comparison to NULL
 - moved to a separate patch

 tests/core_debugfs_heads_power.c | 156 +++++++++++++++++++++++++++++++
 tests/meson.build                |   1 +
 2 files changed, 157 insertions(+)
 create mode 100644 tests/core_debugfs_heads_power.c

diff --git a/tests/core_debugfs_heads_power.c b/tests/core_debugfs_heads_power.c
new file mode 100644
index 000000000..1813986d8
--- /dev/null
+++ b/tests/core_debugfs_heads_power.c
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_dir.h"
+
+/**
+ * TEST: debugfs heads power test
+ * Description: Read entries from debugfs with all heads on and with all heads
+ *		off.
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: uapi
+ * Functionality: debugfs
+ * Feature: core
+ * Test category: uapi
+ *
+ * SUBTEST: off-read-all
+ * Description: Read all debugfs entries with heads off.
+ *
+ * SUBTEST: on-read-all
+ * Description: Read all debugfs entries with heads on.
+ */
+
+/**
+ * bool igt_kms_all_displays_on: Try to turn on all heads
+ * @display: pointer to the igt_display structure
+ *
+ * Returns: void
+ */
+static void igt_display_all_on(igt_display_t *display)
+{
+	struct igt_fb fb[IGT_MAX_PIPES];
+	enum pipe pipe;
+	int ret;
+
+	/* try to light all pipes */
+retry:
+	for_each_pipe(display, pipe) {
+		igt_output_t *output;
+
+		for_each_valid_output_on_pipe(display, pipe, output) {
+			igt_plane_t *primary;
+			drmModeModeInfo *mode;
+
+			if (output->pending_pipe != PIPE_NONE)
+				continue;
+
+			igt_output_set_pipe(output, pipe);
+			primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+			mode = igt_output_get_mode(output);
+			igt_create_pattern_fb(display->drm_fd,
+						mode->hdisplay, mode->vdisplay,
+						DRM_FORMAT_XRGB8888,
+						DRM_FORMAT_MOD_LINEAR, &fb[pipe]);
+
+			/* Set a valid fb as some debugfs like to
+			 * inspect it on a active pipe
+			 */
+			igt_plane_set_fb(primary, &fb[pipe]);
+			break;
+		}
+	}
+
+	if (display->is_atomic)
+		ret = igt_display_try_commit_atomic(display,
+				DRM_MODE_ATOMIC_TEST_ONLY |
+				DRM_MODE_ATOMIC_ALLOW_MODESET,
+				NULL);
+	else
+		ret = igt_display_try_commit2(display, COMMIT_LEGACY);
+
+	if (ret) {
+		igt_output_t *output;
+		bool found = igt_override_all_active_output_modes_to_fit_bw(display);
+
+		igt_require_f(found, "No valid mode combo found.\n");
+
+		for_each_connected_output(display, output)
+			igt_output_set_pipe(output, PIPE_NONE);
+
+		goto retry;
+	}
+
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+}
+
+/**
+ * bool igt_kms_all_displays_off: Try to turn off all heads
+ * @display: pointer to the igt_display structure
+ *
+ * Returns: void
+ */
+static void igt_display_all_off(igt_display_t *display)
+{
+	enum pipe pipe;
+	igt_output_t *output;
+	igt_plane_t *plane;
+
+	for_each_connected_output(display, output)
+		igt_output_set_pipe(output, PIPE_NONE);
+
+	for_each_pipe(display, pipe)
+		for_each_plane_on_pipe(display, pipe, plane)
+			igt_plane_set_fb(plane, NULL);
+
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+}
+
+IGT_TEST_DESCRIPTION("Read entries from debugfs with display on/off.");
+
+igt_main
+{
+	int debugfs = -1;
+	igt_display_t *display;
+	int fd = -1;
+	igt_dir_t *igt_dir = NULL;
+
+	igt_fixture {
+		fd = drm_open_driver_master(DRIVER_ANY);
+		debugfs = igt_debugfs_dir(fd);
+		igt_require(debugfs >= 0);
+
+		igt_dir = igt_dir_create(debugfs);
+		igt_require(igt_dir);
+
+		kmstest_set_vt_graphics_mode();
+
+		display = calloc(1, sizeof(*display));
+		igt_display_require(display, fd);
+	}
+
+	igt_subtest("off-read-all") {
+		igt_display_all_off(display);
+
+		igt_dir_scan_dirfd(igt_dir, -1);
+		igt_dir_process_files(igt_dir, NULL, NULL);
+	}
+
+	igt_subtest("on-read-all") {
+		/* try to light all pipes */
+		igt_display_all_on(display);
+
+		igt_dir_scan_dirfd(igt_dir, -1);
+		igt_dir_process_files(igt_dir, NULL, NULL);
+	}
+
+	igt_fixture {
+		igt_display_fini(display);
+		close(debugfs);
+		drm_close_driver(fd);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index fa62cbeb9..99dbd4feb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,7 @@
 test_progs = [
 	'core_auth',
 	'core_debugfs',
+	'core_debugfs_heads_power',
 	'core_getclient',
 	'core_getstats',
 	'core_getversion',
-- 
2.43.0


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

* [PATCH v3 i-g-t 4/6] tests: Add core_sysfs
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
                   ` (2 preceding siblings ...)
  2025-06-15 17:14 ` [PATCH v3 i-g-t 3/6] tests: Add core_debugfs_heads_power Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 5/6] tests: Add xe_debugfs Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs Peter Senna Tschudin
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

core_sysfs is GPU-agnostic test designed to work with any GPU, not
limited to i915 and Xe. The test scans the sysfs directory associated
with the GPU, reads all files, and discards the content.

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - removed "sysfs" from the name of subtest (Thanks Michal Wajdeczko)
v2:
 - changed style of comparison to NULL

 tests/core_sysfs.c                       | 58 ++++++++++++++++++++++++
 tests/intel-ci/fast-feedback.testlist    |  1 +
 tests/intel-ci/xe-fast-feedback.testlist |  1 +
 tests/meson.build                        |  1 +
 4 files changed, 61 insertions(+)
 create mode 100644 tests/core_sysfs.c

diff --git a/tests/core_sysfs.c b/tests/core_sysfs.c
new file mode 100644
index 000000000..db70e940b
--- /dev/null
+++ b/tests/core_sysfs.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_dir.h"
+#include "igt_sysfs.h"
+
+struct {
+	bool warn_on_not_hit;
+} opt = { 0 };
+
+/**
+ * TEST: sysfs test
+ * Description: Read entries from sysfs path.
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: uapi
+ * Functionality: sysfs
+ * Feature: core
+ * Test category: uapi
+ *
+ * SUBTEST: read-all-entries
+ * Description: Read all entries from sysfs path
+ *
+ */
+
+IGT_TEST_DESCRIPTION("Read entries from sysfs paths.");
+
+igt_main
+{
+	int fd = -1;
+	int sysfs = -1;
+	igt_dir_t *igt_dir = NULL;
+
+	igt_fixture {
+		fd = drm_open_driver_master(DRIVER_ANY);
+		sysfs = igt_sysfs_open(fd);
+		igt_require(sysfs >= 0);
+
+		igt_dir = igt_dir_create(sysfs);
+		igt_require(igt_dir);
+
+		kmstest_set_vt_graphics_mode();
+	}
+
+	igt_describe("Read all entries from sysfs path.");
+	igt_subtest("read-all-entries") {
+		igt_dir_scan_dirfd(igt_dir, -1);
+		igt_dir_process_files(igt_dir, NULL, NULL);
+	}
+
+	igt_fixture {
+		close(sysfs);
+		drm_close_driver(fd);
+	}
+}
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 3ec1b95cf..5d4d101ef 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -4,6 +4,7 @@ igt@i915_module_load@load
 # Keep alphabetically sorted by default
 igt@core_auth@basic-auth
 igt@core_debugfs@read-all-entries
+igt@core_sysfs@read-all-entries
 igt@fbdev@eof
 igt@fbdev@info
 igt@fbdev@nullptr
diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index ac3177ae9..a5f799f6b 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -8,6 +8,7 @@ igt@fbdev@read
 igt@fbdev@write
 
 igt@core_debugfs@read-all-entries
+igt@core_sysfs@read-all-entries
 igt@intel_sysfs_debugfs@xe-base
 igt@intel_sysfs_debugfs@xe-debugfs-read-all-entries
 igt@intel_sysfs_debugfs@xe-forcewake
diff --git a/tests/meson.build b/tests/meson.build
index 99dbd4feb..a06172d2e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -8,6 +8,7 @@ test_progs = [
 	'core_hotunplug',
 	'core_setmaster',
 	'core_setmaster_vs_auth',
+	'core_sysfs',
 	'dmabuf',
 	'dmabuf_sync_file',
 	'device_reset',
-- 
2.43.0


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

* [PATCH v3 i-g-t 5/6] tests: Add xe_debugfs
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
                   ` (3 preceding siblings ...)
  2025-06-15 17:14 ` [PATCH v3 i-g-t 4/6] tests: Add core_sysfs Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  2025-06-15 17:14 ` [PATCH v3 i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs Peter Senna Tschudin
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

xe_debugfs is a test specific to Xe GPUs. It is intended to complement
the existing generic debugfs tests core_debugfs and
core_debugfs_display_on_off.

Additionally, this test has been updated to use the igt_dir
infrastructure, resulting in simpler code.

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - unchanged from v2
v2:
 - changed style of comparison to NULL

 tests/intel-ci/xe-fast-feedback.testlist |   2 +
 tests/intel/xe_debugfs.c                 | 208 +++++++++++++++++++++++
 tests/meson.build                        |   1 +
 3 files changed, 211 insertions(+)
 create mode 100644 tests/intel/xe_debugfs.c

diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index a5f799f6b..c52f08953 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -78,6 +78,8 @@ igt@xe_create@create-execqueues-noleak
 igt@xe_create@create-execqueues-leak
 igt@xe_create@create-invalid-mbz
 igt@xe_create@create-massive-size
+igt@xe_debugfs@xe-base
+igt@xe_debugfs@xe-forcewake
 igt@xe_dma_buf_sync@export-dma-buf-once-write-sync
 igt@xe_dma_buf_sync@export-dma-buf-once-read-sync
 igt@xe_dma_buf_sync@export-dma-buf-once-read-write-sync
diff --git a/tests/intel/xe_debugfs.c b/tests/intel/xe_debugfs.c
new file mode 100644
index 000000000..66a5fa0f6
--- /dev/null
+++ b/tests/intel/xe_debugfs.c
@@ -0,0 +1,208 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include <dirent.h>
+#include <fcntl.h>
+
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_dir.h"
+#include "igt_sysfs.h"
+#include "xe/xe_query.h"
+
+
+struct {
+	bool warn_on_not_hit;
+} opt = { 0 };
+
+/**
+ * TEST: Xe debugfs test
+ * Description: Xe-specific debugfs tests. These are complementary to the
+ * core_debugfs and core_debugfs_display_on_off tests.
+ *
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: uapi
+ * Functionality: debugfs
+ * Feature: core
+ * Test category: uapi
+ *
+ */
+
+IGT_TEST_DESCRIPTION("Read entries from debugfs, and sysfs paths.");
+
+static int xe_validate_entries(igt_dir_t *igt_dir,
+			       const char * const str_val[], int str_cnt)
+{
+	igt_dir_file_list_t *file_list_entry;
+
+	if (!igt_dir)
+		return -1;
+
+	igt_dir_scan_dirfd(igt_dir, -1);
+
+	for (int i = 0; i < str_cnt; i++) {
+		int hit = 0;
+
+		igt_list_for_each_entry(file_list_entry,
+					&igt_dir->file_list_head, link) {
+			if (strcmp(file_list_entry->relative_path,
+				   str_val[i]) == 0) {
+				hit = 1;
+				break;
+			}
+		}
+
+		if (!hit && opt.warn_on_not_hit)
+			igt_warn("no test for: %s\n", str_val[i]);
+	}
+
+	return 0;
+}
+
+/**
+ * SUBTEST: xe-base
+ * Description: Check if various debugfs devnodes exist and test reading them
+ */
+static void
+xe_test_base(int fd, struct drm_xe_query_config *config, igt_dir_t *igt_dir)
+{
+	uint16_t devid = intel_get_drm_devid(fd);
+	static const char * const expected_files[] = {
+		"gt0",
+		"gt1",
+		"stolen_mm",
+		"gtt_mm",
+		"vram0_mm",
+		"forcewake_all",
+		"info",
+		"gem_names",
+		"clients",
+		"name"
+	};
+	char reference[4096];
+	int val = 0;
+
+	igt_assert(config);
+	sprintf(reference, "devid 0x%llx",
+			config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff);
+	igt_assert(igt_debugfs_search(fd, "info", reference));
+
+	sprintf(reference, "revid %lld",
+			config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16);
+	igt_assert(igt_debugfs_search(fd, "info", reference));
+
+	sprintf(reference, "is_dgfx %s", config->info[DRM_XE_QUERY_CONFIG_FLAGS] &
+		DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM ? "yes" : "no");
+
+	igt_assert(igt_debugfs_search(fd, "info", reference));
+
+	if (intel_gen(devid) < 20) {
+		switch (config->info[DRM_XE_QUERY_CONFIG_VA_BITS]) {
+		case 48:
+			val = 3;
+			break;
+		case 57:
+			val = 4;
+			break;
+		}
+
+		sprintf(reference, "vm_max_level %d", val);
+		igt_assert(igt_debugfs_search(fd, "info", reference));
+	}
+
+	snprintf(reference, sizeof(reference), "tile_count %d", xe_sysfs_get_num_tiles(fd));
+	igt_assert(igt_debugfs_search(fd, "info", reference));
+
+	igt_assert(igt_debugfs_exists(fd, "gt0", O_RDONLY));
+
+	igt_assert(igt_debugfs_exists(fd, "gtt_mm", O_RDONLY));
+	igt_debugfs_dump(fd, "gtt_mm");
+
+	if (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM) {
+		igt_assert(igt_debugfs_exists(fd, "vram0_mm", O_RDONLY));
+		igt_debugfs_dump(fd, "vram0_mm");
+	}
+
+	if (igt_debugfs_exists(fd, "stolen_mm", O_RDONLY))
+		igt_debugfs_dump(fd, "stolen_mm");
+
+	igt_assert(igt_debugfs_exists(fd, "clients", O_RDONLY));
+	igt_debugfs_dump(fd, "clients");
+
+	igt_assert(igt_debugfs_exists(fd, "gem_names", O_RDONLY));
+	igt_debugfs_dump(fd, "gem_names");
+
+	xe_validate_entries(igt_dir, expected_files,
+			    ARRAY_SIZE(expected_files));
+}
+
+/**
+ * SUBTEST: xe-forcewake
+ * Description: Check forcewake debugfs devnode
+ */
+static void
+xe_test_forcewake(int fd)
+{
+	int handle = igt_debugfs_open(fd, "forcewake_all", O_WRONLY);
+
+	igt_assert_neq(handle, -1);
+	close(handle);
+}
+
+const char *help_str =
+	"  -w\t--warn-not-hit Produce warnings if it founds a devfs node without tests";
+
+struct option long_options[] = {
+	{ "--warn-not-hit", no_argument, NULL, 'w'},
+	{ 0, 0, 0, 0 }
+};
+
+static int opt_handler(int option, int option_index, void *input)
+{
+	switch (option) {
+	case 'w':
+		opt.warn_on_not_hit = true;
+		break;
+	default:
+		return IGT_OPT_HANDLER_ERROR;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+igt_main_args("", long_options, help_str, opt_handler, NULL)
+{
+	int debugfs = -1;
+	int fd = -1;
+	igt_dir_t *igt_dir = NULL;
+
+	igt_fixture {
+		fd = drm_open_driver_master(DRIVER_XE);
+		__igt_debugfs_dump(fd, "info", IGT_LOG_INFO);
+		debugfs = igt_debugfs_dir(fd);
+
+		igt_dir = igt_dir_create(debugfs);
+		igt_require(igt_dir);
+
+		kmstest_set_vt_graphics_mode();
+	}
+
+	igt_describe("Check if various debugfs devnodes exist and test reading them.");
+	igt_subtest("xe-base") {
+		xe_test_base(fd, xe_config(fd), igt_dir);
+	}
+
+	igt_describe("Check forcewake debugfs devnode");
+	igt_subtest("xe-forcewake") {
+		xe_test_forcewake(fd);
+	}
+
+	igt_fixture {
+		igt_dir_destroy(igt_dir);
+		close(debugfs);
+		drm_close_driver(fd);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index a06172d2e..847598255 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -283,6 +283,7 @@ intel_xe_progs = [
 	'xe_compute_preempt',
 	'xe_copy_basic',
 	'xe_configfs',
+	'xe_debugfs',
 	'xe_dma_buf_sync',
 	'xe_drm_fdinfo',
 	'xe_eu_stall',
-- 
2.43.0


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

* [PATCH v3 i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs
  2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
                   ` (4 preceding siblings ...)
  2025-06-15 17:14 ` [PATCH v3 i-g-t 5/6] tests: Add xe_debugfs Peter Senna Tschudin
@ 2025-06-15 17:14 ` Peter Senna Tschudin
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-06-15 17:14 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, michal.wajdeczko, marcin.bernatowicz,
	kamil.konieczny, katarzyna.piecielska, zbigniew.kempczynski,
	ewelina.musial

The intel_sysfs_debugfs test was originally introduced to unify testing
for both i915 and Xe drivers, aiming to prevent gaps in test coverage.
However, the implementation fell short in addressing scenarios where
both i915 and Xe were present in the system.

To address these limitations, it was replaced by:
 - tests/core_debugfs (gpu agnostic)
 - tests/core_sysfs (gpu agnostic)
 - tests/intel/xe_debugfs (complementary to core_debugfs)

Cc: michal.wajdeczko@intel.com
Cc: marcin.bernatowicz@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: ewelina.musial@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v3:
 - unchanged from v2
v2:
 - changed style of comparison to NULL

 tests/intel-ci/fast-feedback.testlist    |   2 -
 tests/intel-ci/xe-fast-feedback.testlist |   4 -
 tests/intel/intel_sysfs_debugfs.c        | 430 -----------------------
 tests/intel/xe_test_config.json          |   2 +-
 tests/meson.build                        |   1 -
 5 files changed, 1 insertion(+), 438 deletions(-)
 delete mode 100644 tests/intel/intel_sysfs_debugfs.c

diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 5d4d101ef..2799bbaa5 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -55,8 +55,6 @@ igt@i915_getparams_basic@basic-subslice-total
 igt@i915_hangman@error-state-basic
 igt@i915_pciid
 igt@intel_hwmon
-igt@intel_sysfs_debugfs@i915-debugfs-read-all-entries
-igt@intel_sysfs_debugfs@i915-sysfs-read-all-entries
 igt@kms_addfb_basic@addfb25-4-tiled
 igt@kms_addfb_basic@addfb25-bad-modifier
 igt@kms_addfb_basic@addfb25-framebuffer-vs-set-tiling
diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index c52f08953..017e3ba2a 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -9,10 +9,6 @@ igt@fbdev@write
 
 igt@core_debugfs@read-all-entries
 igt@core_sysfs@read-all-entries
-igt@intel_sysfs_debugfs@xe-base
-igt@intel_sysfs_debugfs@xe-debugfs-read-all-entries
-igt@intel_sysfs_debugfs@xe-forcewake
-igt@intel_sysfs_debugfs@xe-sysfs-read-all-entries
 igt@kms_addfb_basic@addfb25-4-tiled
 igt@kms_addfb_basic@addfb25-bad-modifier
 igt@kms_addfb_basic@addfb25-modifier-no-flag
diff --git a/tests/intel/intel_sysfs_debugfs.c b/tests/intel/intel_sysfs_debugfs.c
deleted file mode 100644
index dfd8d52d8..000000000
--- a/tests/intel/intel_sysfs_debugfs.c
+++ /dev/null
@@ -1,430 +0,0 @@
-// SPDX-License-Identifier: MIT
-/*
- * Copyright © 2025 Intel Corporation
- */
-
-#include <dirent.h>
-#include <fcntl.h>
-
-#include "i915/gem.h"
-#include "igt.h"
-#include "igt_sysfs.h"
-#include "xe/xe_query.h"
-
-struct {
-	bool warn_on_not_hit;
-} opt = { 0 };
-
-/**
- * TEST: debugfs test
- * Description: Read entries from debugfs, and sysfs paths.
- * Category: Core
- * Mega feature: General Core features
- * Sub-category: uapi
- * Functionality: debugfs
- * Feature: core
- * Test category: uapi
- *
- * SUBTEST: i915-debugfs-read-all-entries
- * Description: Read all entries from debugfs path validating debugfs entries
- *
- * SUBTEST: i915-debugfs-read-all-entries-display-off
- * Description: Read all debugfs entries with display off.
- *
- * SUBTEST: i915-debugfs-read-all-entries-display-on
- * Description: Read all debugfs entries with display on.
- *
- * SUBTEST: i915-sysfs-read-all-entries
- * Description: Read all entries from sysfs path validating debugfs entries
- *
- * SUBTEST: xe-debugfs-read-all-entries
- * Description: Read all entries from debugfs path validating debugfs entries
- *
- * SUBTEST: xe-debugfs-read-all-entries-display-off
- * Description: Read all debugfs entries with display off.
- *
- * SUBTEST: xe-debugfs-read-all-entries-display-on
- * Description: Read all debugfs entries with display on.
- *
- * SUBTEST: xe-sysfs-read-all-entries
- * Description: Read all entries from sysfs path validating debugfs entries
- *
- */
-
-IGT_TEST_DESCRIPTION("Read entries from debugfs, and sysfs paths.");
-
-static void read_and_discard_sysfs_entries(int path_fd, int indent)
-{
-	struct dirent *dirent;
-	DIR *dir;
-	char tabs[8];
-	int i;
-
-	igt_assert(indent < sizeof(tabs) - 1);
-
-	for (i = 0; i < indent; i++)
-		tabs[i] = '\t';
-	tabs[i] = '\0';
-
-	dir = fdopendir(path_fd);
-	if (!dir)
-		return;
-
-	while ((dirent = readdir(dir))) {
-		if (!strcmp(dirent->d_name, ".") ||
-		    !strcmp(dirent->d_name, ".."))
-			continue;
-
-		if (dirent->d_type == DT_DIR) {
-			int sub_fd;
-
-			sub_fd = openat(path_fd, dirent->d_name,
-					O_RDONLY | O_DIRECTORY);
-			if (sub_fd < 0)
-				continue;
-
-			igt_debug("%sEntering subdir %s\n", tabs, dirent->d_name);
-			read_and_discard_sysfs_entries(sub_fd, indent + 1);
-			close(sub_fd);
-		} else if (dirent->d_type == DT_REG) {
-			char buf[512];
-			int sub_fd;
-			ssize_t ret;
-
-			igt_kmsg(KMSG_DEBUG "Reading file \"%s\"\n", dirent->d_name);
-			igt_debug("%sReading file \"%s\"\n", tabs, dirent->d_name);
-
-			sub_fd = openat(path_fd, dirent->d_name, O_RDONLY | O_NONBLOCK);
-			if (sub_fd == -1) {
-				igt_debug("%sCould not open file \"%s\" with error: %m\n",
-					  tabs, dirent->d_name);
-				continue;
-			}
-
-			do {
-				ret = read(sub_fd, buf, sizeof(buf));
-			} while (ret == sizeof(buf));
-
-			if (ret == -1)
-				igt_debug("%sCould not read file \"%s\" with error: %m\n",
-					  tabs, dirent->d_name);
-
-			close(sub_fd);
-		}
-	}
-	closedir(dir);
-}
-
-static void kms_tests(int fd, int debugfs, const char *card_name)
-{
-	igt_display_t display;
-	struct igt_fb fb[IGT_MAX_PIPES];
-	enum pipe pipe;
-	int ret;
-	char test_name[64];
-
-	igt_fixture
-		igt_display_require(&display, fd);
-
-	snprintf(test_name, sizeof(test_name),
-		 "%s-debugfs-read-all-entries-display-on", card_name);
-
-	igt_subtest(test_name) {
-		/* try to light all pipes */
-retry:
-		for_each_pipe(&display, pipe) {
-			igt_output_t *output;
-
-			for_each_valid_output_on_pipe(&display, pipe, output) {
-				igt_plane_t *primary;
-				drmModeModeInfo *mode;
-
-				if (output->pending_pipe != PIPE_NONE)
-					continue;
-
-				igt_output_set_pipe(output, pipe);
-				primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
-				mode = igt_output_get_mode(output);
-				igt_create_pattern_fb(display.drm_fd,
-						      mode->hdisplay, mode->vdisplay,
-						      DRM_FORMAT_XRGB8888,
-						      DRM_FORMAT_MOD_LINEAR, &fb[pipe]);
-
-				/* Set a valid fb as some debugfs like to
-				 * inspect it on a active pipe
-				 */
-				igt_plane_set_fb(primary, &fb[pipe]);
-				break;
-			}
-		}
-
-		if (display.is_atomic)
-			ret = igt_display_try_commit_atomic(&display,
-					DRM_MODE_ATOMIC_TEST_ONLY |
-					DRM_MODE_ATOMIC_ALLOW_MODESET,
-					NULL);
-		else
-			ret = igt_display_try_commit2(&display, COMMIT_LEGACY);
-
-		if (ret) {
-			igt_output_t *output;
-			bool found = igt_override_all_active_output_modes_to_fit_bw(&display);
-
-			igt_require_f(found, "No valid mode combo found.\n");
-
-			for_each_connected_output(&display, output)
-				igt_output_set_pipe(output, PIPE_NONE);
-
-			goto retry;
-		}
-
-		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
-
-		read_and_discard_sysfs_entries(debugfs, 0);
-	}
-
-	snprintf(test_name, sizeof(test_name),
-		 "%s-debugfs-read-all-entries-display-off", card_name);
-
-	igt_subtest(test_name) {
-		igt_output_t *output;
-		igt_plane_t *plane;
-
-		for_each_connected_output(&display, output)
-			igt_output_set_pipe(output, PIPE_NONE);
-
-		for_each_pipe(&display, pipe)
-			for_each_plane_on_pipe(&display, pipe, plane)
-				igt_plane_set_fb(plane, NULL);
-
-		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
-
-		read_and_discard_sysfs_entries(debugfs, 0);
-	}
-
-	igt_fixture
-		igt_display_fini(&display);
-}
-
-static int xe_validate_entries(int fd, const char *add_path,
-			       const char * const str_val[], int str_cnt)
-{
-	int i;
-	int hit;
-	int found = 0;
-	int not_found = 0;
-	DIR *dir;
-	struct dirent *de;
-	char path[PATH_MAX];
-
-	if (!igt_debugfs_path(fd, path, sizeof(path)))
-		return -1;
-
-	strcat(path, add_path);
-	dir = opendir(path);
-	if (!dir)
-		return -1;
-
-	while ((de = readdir(dir))) {
-		if (de->d_name[0] == '.')
-			continue;
-		hit = 0;
-		for (i = 0; i < str_cnt; i++) {
-			if (!strcmp(str_val[i], de->d_name)) {
-				hit = 1;
-				break;
-			}
-		}
-		if (hit) {
-			found++;
-		} else if (opt.warn_on_not_hit) {
-			not_found++;
-			igt_warn("no test for: %s/%s\n", path, de->d_name);
-		}
-	}
-	closedir(dir);
-	return 0;
-}
-
-/**
- * SUBTEST: xe-base
- * Description: Check if various debugfs devnodes exist and test reading them
- */
-static void
-xe_test_base(int fd, struct drm_xe_query_config *config)
-{
-	uint16_t devid = intel_get_drm_devid(fd);
-	static const char * const expected_files[] = {
-		"gt0",
-		"gt1",
-		"stolen_mm",
-		"gtt_mm",
-		"vram0_mm",
-		"forcewake_all",
-		"info",
-		"gem_names",
-		"clients",
-		"name"
-	};
-	char reference[4096];
-	int val = 0;
-
-	igt_assert(config);
-	sprintf(reference, "devid 0x%llx",
-			config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff);
-	igt_assert(igt_debugfs_search(fd, "info", reference));
-
-	sprintf(reference, "revid %lld",
-			config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16);
-	igt_assert(igt_debugfs_search(fd, "info", reference));
-
-	sprintf(reference, "is_dgfx %s", config->info[DRM_XE_QUERY_CONFIG_FLAGS] &
-		DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM ? "yes" : "no");
-
-	igt_assert(igt_debugfs_search(fd, "info", reference));
-
-	if (intel_gen(devid) < 20) {
-		switch (config->info[DRM_XE_QUERY_CONFIG_VA_BITS]) {
-		case 48:
-			val = 3;
-			break;
-		case 57:
-			val = 4;
-			break;
-		}
-
-		sprintf(reference, "vm_max_level %d", val);
-		igt_assert(igt_debugfs_search(fd, "info", reference));
-	}
-
-	snprintf(reference, sizeof(reference), "tile_count %d", xe_sysfs_get_num_tiles(fd));
-	igt_assert(igt_debugfs_search(fd, "info", reference));
-
-	igt_assert(igt_debugfs_exists(fd, "gt0", O_RDONLY));
-
-	igt_assert(igt_debugfs_exists(fd, "gtt_mm", O_RDONLY));
-	igt_debugfs_dump(fd, "gtt_mm");
-
-	if (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM) {
-		igt_assert(igt_debugfs_exists(fd, "vram0_mm", O_RDONLY));
-		igt_debugfs_dump(fd, "vram0_mm");
-	}
-
-	if (igt_debugfs_exists(fd, "stolen_mm", O_RDONLY))
-		igt_debugfs_dump(fd, "stolen_mm");
-
-	igt_assert(igt_debugfs_exists(fd, "clients", O_RDONLY));
-	igt_debugfs_dump(fd, "clients");
-
-	igt_assert(igt_debugfs_exists(fd, "gem_names", O_RDONLY));
-	igt_debugfs_dump(fd, "gem_names");
-
-	xe_validate_entries(fd, "", expected_files, ARRAY_SIZE(expected_files));
-}
-
-/**
- * SUBTEST: xe-forcewake
- * Description: Check forcewake debugfs devnode
- */
-static void
-xe_test_forcewake(int fd)
-{
-	int handle = igt_debugfs_open(fd, "forcewake_all", O_WRONLY);
-
-	igt_assert_neq(handle, -1);
-	close(handle);
-}
-
-const char *help_str =
-	"  -w\t--warn-not-hit Produce warnings if it founds a devfs node without tests";
-
-struct option long_options[] = {
-	{ "--warn-not-hit", no_argument, NULL, 'w'},
-	{ 0, 0, 0, 0 }
-};
-
-static int opt_handler(int option, int option_index, void *input)
-{
-	switch (option) {
-	case 'w':
-		opt.warn_on_not_hit = true;
-		break;
-	default:
-		return IGT_OPT_HANDLER_ERROR;
-	}
-
-	return IGT_OPT_HANDLER_SUCCESS;
-}
-
-igt_main_args("", long_options, help_str, opt_handler, NULL)
-{
-	int debugfs = -1;
-	int fd = -1;
-	int sysfs = -1;
-
-	igt_subtest_group {
-		igt_fixture {
-			fd = drm_open_driver_master(DRIVER_INTEL);
-			igt_require_gem(fd);
-			debugfs = igt_debugfs_dir(fd);
-			sysfs = igt_sysfs_open(fd);
-
-			kmstest_set_vt_graphics_mode();
-		}
-
-		igt_describe("Read all entries from sysfs path.");
-		igt_subtest("i915-sysfs-read-all-entries")
-			read_and_discard_sysfs_entries(sysfs, 0);
-		igt_describe("Read all entries from debugfs path.");
-		igt_subtest("i915-debugfs-read-all-entries")
-			read_and_discard_sysfs_entries(debugfs, 0);
-
-		igt_describe("Read all debugfs entries with display on/off.");
-		igt_subtest_group
-			kms_tests(fd, debugfs, "i915");
-
-		igt_fixture {
-			close(sysfs);
-			close(debugfs);
-			drm_close_driver(fd);
-		}
-	}
-
-	igt_subtest_group {
-		igt_fixture {
-			fd = drm_open_driver_master(DRIVER_XE);
-			__igt_debugfs_dump(fd, "info", IGT_LOG_INFO);
-			debugfs = igt_debugfs_dir(fd);
-			sysfs = igt_sysfs_open(fd);
-
-			kmstest_set_vt_graphics_mode();
-		}
-
-		igt_describe("Read all entries from sysfs path.");
-		igt_subtest("xe-sysfs-read-all-entries")
-			read_and_discard_sysfs_entries(sysfs, 0);
-		igt_describe("Read all entries from debugfs path.");
-		igt_subtest("xe-debugfs-read-all-entries")
-			read_and_discard_sysfs_entries(debugfs, 0);
-
-		igt_describe("Read all debugfs entries with display on/off.");
-		igt_subtest_group
-			kms_tests(fd, debugfs, "xe");
-
-		igt_describe("Check if various debugfs devnodes exist and test reading them.");
-		igt_subtest("xe-base") {
-			xe_test_base(fd, xe_config(fd));
-		}
-
-		igt_describe("Check forcewake debugfs devnode");
-		igt_subtest("xe-forcewake") {
-			xe_test_forcewake(fd);
-		}
-
-		igt_fixture {
-			close(sysfs);
-			close(debugfs);
-			drm_close_driver(fd);
-		}
-	}
-}
diff --git a/tests/intel/xe_test_config.json b/tests/intel/xe_test_config.json
index edca243f1..27de0efaa 100644
--- a/tests/intel/xe_test_config.json
+++ b/tests/intel/xe_test_config.json
@@ -2,7 +2,7 @@
     "description": "JSON file to be used to parse Xe documentation",
     "name": "Tests for Xe Driver",
     "drivers": [ "xe" ],
-    "files": [ "xe_*.c", "../core_*.c", "../device_*.c", "../sriov_basic.c", "intel_hwmon.c", "intel_sysfs_debugfs.c" ],
+    "files": [ "xe_*.c", "../core_*.c", "../device_*.c", "../sriov_basic.c", "intel_hwmon.c" ],
     "fields": {
         "Run type": {
             "_properties_": {
diff --git a/tests/meson.build b/tests/meson.build
index 847598255..c8f586982 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -86,7 +86,6 @@ test_progs = [
 intel_i915_xe_progs = [
 	'api_intel_allocator',
 	'intel_hwmon',
-	'intel_sysfs_debugfs',
 ]
 
 intel_i915_progs = [
-- 
2.43.0


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

end of thread, other threads:[~2025-06-15 17:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-15 17:14 [PATCH v3 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 2/6] tests: Add core_debugfs Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 3/6] tests: Add core_debugfs_heads_power Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 4/6] tests: Add core_sysfs Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 5/6] tests: Add xe_debugfs Peter Senna Tschudin
2025-06-15 17:14 ` [PATCH v3 i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs Peter Senna Tschudin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox