Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Piotr Piorkowski <piotr.piorkowski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH v2 2/2] tests/debugfs_test: Add subtest guc_log_relay
Date: Tue, 24 Apr 2018 09:50:04 +0200	[thread overview]
Message-ID: <20180424075004.18094-2-piotr.piorkowski@intel.com> (raw)
In-Reply-To: <20180410135227.13779-1-piotr.piorkowski@intel.com>

From: Piotr Piórkowski <piotr.piorkowski@intel.com>

We doesn't have any tests to verify functionality of i915_guc_log_relay.
I think we should test this component.

Let's add simple subtest to debugfs_test, which will test if guc
is enabled:
- opening the i915_guc_log_relay and creating a file guc_log0,
- flushing GuC log buffer,
- closing i915_guc_log_relay with removing from debugfs guc_log0.
Otherwise, the test will check if the attempt to open the guc_log_relay
returns an error ENODEV.

v2:
- guc isn't required for run the subtest (Chris)
- rewrite subtest as function (Michal Winiarski)
- add case when the guc is not enabled

Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/debugfs_test.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c
index 2e87e442..c7a953b1 100644
--- a/tests/debugfs_test.c
+++ b/tests/debugfs_test.c
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <errno.h>
 
 static void read_and_discard_sysfs_entries(int path_fd, int indent)
 {
@@ -87,6 +88,95 @@ static void read_and_discard_sysfs_entries(int path_fd, int indent)
 	closedir(dir);
 }
 
+static bool is_guc_loaded(int gfx_fd)
+{
+	bool load;
+
+	load = igt_debugfs_search(gfx_fd, "i915_guc_load_status",
+				"\tstatus: fetch SUCCESS, load SUCCESS");
+	igt_debug("GuC %s loaded\n", load ? "is" : "is not");
+
+	return load;
+}
+
+#define I915_GUC_LOG_RELAY_FILE  "i915_guc_log_relay"
+#define GUC_LOG_FILE  "guc_log0"
+
+static void check_guc_log_relay(int gfx_fd)
+{
+
+	int page_size = getpagesize();
+	int fd_relay = -1, fd_log = -1;
+	ssize_t read_size;
+	uint8_t *buffer;
+	bool guc_is_loaded;
+	int debugfs;
+
+	guc_is_loaded = is_guc_loaded(gfx_fd);
+
+	debugfs = igt_debugfs_dir(gfx_fd);
+	fd_relay = openat(debugfs, I915_GUC_LOG_RELAY_FILE, O_RDWR);
+
+	if (!guc_is_loaded) {
+		igt_debug("Case when GuC is disabled\n");
+		igt_debug("Attempt open file %s return value: %d ( %m )\n",
+			  I915_GUC_LOG_RELAY_FILE, errno);
+
+		igt_assert(errno == ENODEV);
+		return;
+	}
+
+	igt_debug("Case when GuC is enabled\n");
+
+	igt_assert(fd_relay > 0);
+	/*
+	 * The GUC_LOG_FILE should be created
+	 *	after opening the I915_GUC_LOG_RELAY_FILE file
+	 */
+	fd_log = igt_debugfs_open(gfx_fd, GUC_LOG_FILE, O_RDONLY);
+	igt_assert(fd_log > 0);
+
+	/*
+	 * We want to check flush and read from GUC_LOG_FILE.
+	 * First, we read all available bytes from buffer
+	 * (if any bytes are ready to be read).
+	 */
+	buffer = malloc(page_size);
+	do {
+		read_size = read(fd_log, buffer, page_size);
+		igt_debug("Shall attempt to read %d bytes from file %s.\n"
+			  "The number of bytes actually read: %li\n",
+			  page_size, GUC_LOG_FILE, read_size);
+	} while (read_size != 0);
+
+	/*
+	 * When buffer is empty, we trigger a flush
+	 * by sending anything to the file
+	 * I915_GUC_LOG_RELAY_FILE
+	 */
+	write(fd_relay, buffer, 1);
+
+	/* We read again and now we should get some bytes */
+	read_size = read(fd_log, buffer, page_size);
+
+	free(buffer);
+
+	igt_debug("Shall attempt to read %d bytes from file %s.\n"
+		  "The number of bytes actually read: %li\n",
+		  page_size, GUC_LOG_FILE, read_size);
+
+
+	igt_assert(read_size > 0);
+
+	/*
+	 * Now we try close the I915_GUC_LOG_RELAY_FILE file.
+	 * This should cause the GUC_LOG_FILE file to be closed
+	 * and removed from debugfs
+	 */
+	close(fd_relay);
+	igt_assert(!igt_debugfs_has_filename(gfx_fd, GUC_LOG_FILE));
+}
+
 igt_main
 {
 	int fd = -1, debugfs;
@@ -173,6 +263,9 @@ igt_main
 		igt_success();
 	}
 
+	igt_subtest("guc_log_relay")
+		check_guc_log_relay(fd);
+
 	igt_fixture {
 		igt_display_fini(&display);
 		close(debugfs);
-- 
2.14.3

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-04-24  7:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 13:52 [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: Add function to check if file exists in debugfs Piotr Piórkowski
2018-04-10 13:52 ` [igt-dev] [PATCH i-g-t 2/2] tests/debugfs_test: Add subtest guc_log_relay Piotr Piórkowski
2018-04-10 14:06   ` Chris Wilson
2018-04-10 14:02 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: Add function to check if file exists in debugfs Chris Wilson
2018-04-10 14:46 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] " Patchwork
2018-04-10 16:57 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
2018-04-24  7:50 ` [igt-dev] [PATCH v2 1/2] " Piotr Piorkowski
2018-04-24  8:27   ` Chris Wilson
2018-05-15 15:29   ` [igt-dev] [PATCH v3 " Piotr Piorkowski
2018-05-21 12:55   ` Piotr Piorkowski
2018-05-21 12:55   ` [igt-dev] [PATCH v3 2/2] tests/debugfs_test: Add subtest guc_log_relay Piotr Piorkowski
2018-04-24  7:50 ` Piotr Piorkowski [this message]
2018-04-24  8:34   ` [igt-dev] [PATCH v2 " Chris Wilson
2018-04-24 13:24     ` Piorkowski, Piotr
2018-04-24  8:52 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v2,1/2] lib/igt_debugfs: Add function to check if file exists in debugfs (rev2) Patchwork
2018-05-15 15:57 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v3,1/2] lib/igt_debugfs: Add function to check if file exists in debugfs (rev3) Patchwork
2018-05-21 15:08 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v3,2/2] tests/debugfs_test: Add subtest guc_log_relay (rev5) Patchwork

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=20180424075004.18094-2-piotr.piorkowski@intel.com \
    --to=piotr.piorkowski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox