All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Senna Tschudin <peter.senna@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Peter Senna Tschudin <peter.senna@linux.intel.com>,
	lucas.demarchi@intel.com, rodrigo.vivi@intel.com,
	kamil.konieczny@linux.intel.com, katarzyna.piecielska@intel.com,
	zbigniew.kempczynski@intel.com, michal.wajdeczko@intel.com,
	karthik.b.s@intel.com
Subject: [PATCH v4 i-g-t 3/6] tests: Add kms_debugfs
Date: Mon,  7 Jul 2025 23:03:05 +0200	[thread overview]
Message-ID: <20250707210310.54861-4-peter.senna@linux.intel.com> (raw)
In-Reply-To: <20250707210310.54861-1-peter.senna@linux.intel.com>

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

Cc: lucas.demarchi@intel.com
Cc: rodrigo.vivi@intel.com
Cc: kamil.konieczny@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: michal.wajdeczko@intel.com
Cc: karthik.b.s@intel.com
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v4:
 - change test name to kms_debugfs
 - use the wrapper function igt_fit_modes_in_bw()
 - use igt_display_require_output() to ensure there is at least one display

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/kms_debugfs.c | 157 ++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build   |   1 +
 2 files changed, 158 insertions(+)
 create mode 100644 tests/kms_debugfs.c

diff --git a/tests/kms_debugfs.c b/tests/kms_debugfs.c
new file mode 100644
index 000000000..7f94d47c6
--- /dev/null
+++ b/tests/kms_debugfs.c
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_dir.h"
+
+/**
+ * TEST: kms debugfs test
+ * Description: Read entries from debugfs with all displays on and with
+ *		all displays off.
+ *
+ * Category: Core
+ * Mega feature: General Core features
+ * Sub-category: uapi
+ * Functionality: debugfs
+ * Feature: core
+ * Test category: uapi
+ *
+ * SUBTEST: display-off-read-all
+ * Description: Read all debugfs entries with display off.
+ *
+ * SUBTEST: display-on-read-all
+ * Description: Read all debugfs entries with display on.
+ */
+
+/**
+ * igt_display_all_on: Try to turn on all displays
+ * @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) {
+		bool found = igt_fit_modes_in_bw(display);
+
+		ret = found ? 0 : -1;
+		igt_require_f(found, "No valid mode combo found.\n");
+	} else
+		ret = igt_display_try_commit2(display, COMMIT_LEGACY);
+
+	if (ret) {
+		igt_output_t *output;
+
+		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);
+}
+
+/**
+ * igt_display_all_off: Try to turn off all displays
+ * @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);
+
+		/* Make sure we have at least one output connected */
+		igt_display_require_output(display);
+	}
+
+	igt_subtest("display-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("display-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 99d7d95be..1009bef2e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -29,6 +29,7 @@ test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_edge_walk',
 	'kms_cursor_legacy',
+	'kms_debugfs',
 	'kms_dither',
 	'kms_display_modes',
 	'kms_dp_aux_dev',
-- 
2.43.0


  parent reply	other threads:[~2025-07-07 21:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16  7:42 [PATCH v3 resend i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
2025-06-24 13:24   ` Sokolowski, Jan
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 2/6] tests: Add core_debugfs Peter Senna Tschudin
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 3/6] tests: Add core_debugfs_heads_power Peter Senna Tschudin
2025-07-03 20:39   ` Rodrigo Vivi
2025-07-04  8:06     ` Peter Senna Tschudin
2025-07-04 10:01       ` Karthik B S
2025-07-04 11:36         ` Kamil Konieczny
2025-07-04 10:02   ` Karthik B S
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 4/6] tests: Add core_sysfs Peter Senna Tschudin
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 5/6] tests: Add xe_debugfs Peter Senna Tschudin
2025-07-03 20:36   ` Rodrigo Vivi
2025-07-04  8:57     ` Peter Senna Tschudin
2025-07-04  9:06     ` Peter Senna Tschudin
2025-07-07 14:43       ` Rodrigo Vivi
2025-06-16  7:42 ` [PATCH v3 resend i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs Peter Senna Tschudin
2025-07-03 20:39   ` Rodrigo Vivi
2025-06-16 19:50 ` ✓ Xe.CI.BAT: success for Replace intel_sysfs_debugfs Patchwork
2025-06-17  2:49 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-17 13:01 ` ✗ i915.CI.BAT: " Patchwork
2025-07-03 21:44 ` ✓ Xe.CI.BAT: success for Replace intel_sysfs_debugfs (rev2) Patchwork
2025-07-03 21:45 ` ✓ i915.CI.BAT: " Patchwork
2025-07-04  4:29 ` ✗ i915.CI.Full: failure " Patchwork
2025-07-05 14:40 ` ✓ Xe.CI.Full: success " Patchwork
2025-07-07 21:03 ` [PATCH v4 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
2025-07-07 21:03   ` [PATCH v4 i-g-t 1/6] lib/igt_dir: Directory processing and flexible file handling Peter Senna Tschudin
2025-07-07 21:03   ` [PATCH v4 i-g-t 2/6] tests: Add core_debugfs Peter Senna Tschudin
2025-07-07 21:03   ` Peter Senna Tschudin [this message]
2025-07-07 21:03   ` [PATCH v4 i-g-t 4/6] tests: Add core_sysfs Peter Senna Tschudin
2025-07-07 21:03   ` [PATCH v4 i-g-t 5/6] tests: Add xe_debugfs Peter Senna Tschudin
2025-07-07 21:03   ` [PATCH v4 i-g-t 6/6] tests/intel: Remove intel_sysfs_debugfs Peter Senna Tschudin
  -- strict thread matches above, loose matches on Subject: below --
2025-07-07 21:07 [PATCH v4 i-g-t 0/6] Replace intel_sysfs_debugfs Peter Senna Tschudin
2025-07-07 21:07 ` [PATCH v4 i-g-t 3/6] tests: Add kms_debugfs Peter Senna Tschudin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250707210310.54861-4-peter.senna@linux.intel.com \
    --to=peter.senna@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=karthik.b.s@intel.com \
    --cc=katarzyna.piecielska@intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.