diff mbox

[i-g-t] tests/gem_guc_loading: Adding simple GuC loading test

Message ID 1452010627-15643-1-git-send-email-lukasz.fiedorowicz@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lukasz Fiedorowicz Jan. 5, 2016, 4:17 p.m. UTC
Test check GuC debugfs file for successful loading confirmation

Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
---
 tests/Makefile.sources  |  1 +
 tests/gem_guc_loading.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 tests/gem_guc_loading.c

Comments

Chris Wilson Jan. 5, 2016, 9:10 p.m. UTC | #1
On Tue, Jan 05, 2016 at 05:17:07PM +0100, Lukasz Fiedorowicz wrote:
> +static void open_guc_status(void)
> +{
> +	guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
> +	igt_assert_f(guc_status_fd >= 0, "Can't open i915_guc_load_status\n");

igt_require(). So that the test doesn't explode if the kernel changes.

> +
> +static enum guc_status get_guc_status(void)
> +{
> +	char buf[LOAD_STATUS_BUF_SIZE];
> +
> +	FILE *fp = fdopen(guc_status_fd, "r");

If you just wanted the FILE*, use igt_debugfs_fopen.

> +	igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n");
> +
> +	while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp))
> +		if ((strstr(buf, "\tload: SUCCESS\n")))
> +			return GUC_ENABLED;

Testing FILE* leak handling?
-Chris
yu.dai@intel.com Jan. 7, 2016, 11:09 p.m. UTC | #2
This has been reviewed internally. LGTM.

Reviewed-by: Alex Dai <yu.dai@intel.com>

On 01/05/2016 08:17 AM, Lukasz Fiedorowicz wrote:
> Test check GuC debugfs file for successful loading confirmation
>
> Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
> ---
>   tests/Makefile.sources  |  1 +
>   tests/gem_guc_loading.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 90 insertions(+)
>   create mode 100644 tests/gem_guc_loading.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index d594038..331234f 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -36,6 +36,7 @@ TESTS_progs_M = \
>   	gem_flink_basic \
>   	gem_flink_race \
>   	gem_linear_blits \
> +	gem_guc_loading \
>   	gem_madvise \
>   	gem_mmap \
>   	gem_mmap_gtt \
> diff --git a/tests/gem_guc_loading.c b/tests/gem_guc_loading.c
> new file mode 100644
> index 0000000..fd53a46
> --- /dev/null
> +++ b/tests/gem_guc_loading.c
> @@ -0,0 +1,89 @@
> +/*
> + * Copyright © 2015 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.
> + *
> + * Authors:
> + *    Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
> + *
> + */
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +#include "igt.h"
> +
> +IGT_TEST_DESCRIPTION("GuC firmware loading test.");
> +
> +#define LOAD_STATUS_BUF_SIZE 96
> +
> +enum guc_status { GUC_ENABLED, GUC_DISABLED };
> +
> +int guc_status_fd;
> +
> +static void open_guc_status(void)
> +{
> +	guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
> +	igt_assert_f(guc_status_fd >= 0, "Can't open i915_guc_load_status\n");
> +}
> +
> +static enum guc_status get_guc_status(void)
> +{
> +	char buf[LOAD_STATUS_BUF_SIZE];
> +
> +	FILE *fp = fdopen(guc_status_fd, "r");
> +	igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n");
> +
> +	while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp))
> +		if ((strstr(buf, "\tload: SUCCESS\n")))
> +			return GUC_ENABLED;
> +
> +	return GUC_DISABLED;
> +}
> +
> +static void close_guc_status(void)
> +{
> +	close(guc_status_fd);
> +}
> +
> +static void test_guc_loaded()
> +{
> +	igt_assert_f(get_guc_status() == GUC_ENABLED, "GuC is disabled\n");
> +}
> +
> +igt_main
> +{
> +	int gfx_fd = 0;
> +	int gen = 0;
> +
> +	igt_fixture
> +	{
> +		gfx_fd = drm_open_driver(DRIVER_INTEL);
> +		gen = intel_gen(intel_get_drm_devid(gfx_fd));
> +		igt_require(gen >= 9);
> +		open_guc_status();
> +	}
> +
> +	igt_subtest("guc_loaded") test_guc_loaded();
> +
> +	igt_fixture close_guc_status();
> +}
Daniel Vetter Jan. 8, 2016, 7:55 a.m. UTC | #3
On Tue, Jan 05, 2016 at 05:17:07PM +0100, Lukasz Fiedorowicz wrote:
> Test check GuC debugfs file for successful loading confirmation
> 
> Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>

What's the value of this testcase? What happens on a system without guc?
Seems more like a "is your system configured correctly" testcase, and thus
far we haven't done those as separate tests, but just as a pile of
igt_require (or maybe igt_fail) in a relevant functional testcase.
-Daniel


> ---
>  tests/Makefile.sources  |  1 +
>  tests/gem_guc_loading.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
>  create mode 100644 tests/gem_guc_loading.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index d594038..331234f 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -36,6 +36,7 @@ TESTS_progs_M = \
>  	gem_flink_basic \
>  	gem_flink_race \
>  	gem_linear_blits \
> +	gem_guc_loading \
>  	gem_madvise \
>  	gem_mmap \
>  	gem_mmap_gtt \
> diff --git a/tests/gem_guc_loading.c b/tests/gem_guc_loading.c
> new file mode 100644
> index 0000000..fd53a46
> --- /dev/null
> +++ b/tests/gem_guc_loading.c
> @@ -0,0 +1,89 @@
> +/*
> + * Copyright © 2015 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.
> + *
> + * Authors:
> + *    Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
> + *
> + */
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +#include "igt.h"
> +
> +IGT_TEST_DESCRIPTION("GuC firmware loading test.");
> +
> +#define LOAD_STATUS_BUF_SIZE 96
> +
> +enum guc_status { GUC_ENABLED, GUC_DISABLED };
> +
> +int guc_status_fd;
> +
> +static void open_guc_status(void)
> +{
> +	guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
> +	igt_assert_f(guc_status_fd >= 0, "Can't open i915_guc_load_status\n");
> +}
> +
> +static enum guc_status get_guc_status(void)
> +{
> +	char buf[LOAD_STATUS_BUF_SIZE];
> +
> +	FILE *fp = fdopen(guc_status_fd, "r");
> +	igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n");
> +
> +	while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp))
> +		if ((strstr(buf, "\tload: SUCCESS\n")))
> +			return GUC_ENABLED;
> +
> +	return GUC_DISABLED;
> +}
> +
> +static void close_guc_status(void)
> +{
> +	close(guc_status_fd);
> +}
> +
> +static void test_guc_loaded()
> +{
> +	igt_assert_f(get_guc_status() == GUC_ENABLED, "GuC is disabled\n");
> +}
> +
> +igt_main
> +{
> +	int gfx_fd = 0;
> +	int gen = 0;
> +
> +	igt_fixture
> +	{
> +		gfx_fd = drm_open_driver(DRIVER_INTEL);
> +		gen = intel_gen(intel_get_drm_devid(gfx_fd));
> +		igt_require(gen >= 9);
> +		open_guc_status();
> +	}
> +
> +	igt_subtest("guc_loaded") test_guc_loaded();
> +
> +	igt_fixture close_guc_status();
> +}
> -- 
> 2.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Lukasz Fiedorowicz Jan. 14, 2016, 10:10 a.m. UTC | #4
Hi Daniel,

Some teams, in the past, experienced issues with GuC loading. In order to prevent such issues they need a simple loading tests that can be included in automation environment. As the time progress and GuC will become more widely used and this test could be extended but for now it is needed in its simple form

Thanks,
Lukasz

-----Original Message-----
From: Daniel Vetter [mailto:daniel.vetter@ffwll.ch] On Behalf Of Daniel Vetter
Sent: Friday, January 8, 2016 8:55 AM
To: Fiedorowicz, Lukasz
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_guc_loading: Adding simple GuC loading test

On Tue, Jan 05, 2016 at 05:17:07PM +0100, Lukasz Fiedorowicz wrote:
> Test check GuC debugfs file for successful loading confirmation
> 
> Signed-off-by: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>

What's the value of this testcase? What happens on a system without guc?
Seems more like a "is your system configured correctly" testcase, and thus far we haven't done those as separate tests, but just as a pile of igt_require (or maybe igt_fail) in a relevant functional testcase.
-Daniel


> ---
>  tests/Makefile.sources  |  1 +
>  tests/gem_guc_loading.c | 89 
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
>  create mode 100644 tests/gem_guc_loading.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 
> d594038..331234f 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -36,6 +36,7 @@ TESTS_progs_M = \
>  	gem_flink_basic \
>  	gem_flink_race \
>  	gem_linear_blits \
> +	gem_guc_loading \
>  	gem_madvise \
>  	gem_mmap \
>  	gem_mmap_gtt \
> diff --git a/tests/gem_guc_loading.c b/tests/gem_guc_loading.c new 
> file mode 100644 index 0000000..fd53a46
> --- /dev/null
> +++ b/tests/gem_guc_loading.c
> @@ -0,0 +1,89 @@
> +/*
> + * Copyright (c) 2015 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.
> + *
> + * Authors:
> + *    Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
> + *
> + */
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +#include "igt.h"
> +
> +IGT_TEST_DESCRIPTION("GuC firmware loading test.");
> +
> +#define LOAD_STATUS_BUF_SIZE 96
> +
> +enum guc_status { GUC_ENABLED, GUC_DISABLED };
> +
> +int guc_status_fd;
> +
> +static void open_guc_status(void)
> +{
> +	guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
> +	igt_assert_f(guc_status_fd >= 0, "Can't open 
> +i915_guc_load_status\n"); }
> +
> +static enum guc_status get_guc_status(void) {
> +	char buf[LOAD_STATUS_BUF_SIZE];
> +
> +	FILE *fp = fdopen(guc_status_fd, "r");
> +	igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n");
> +
> +	while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp))
> +		if ((strstr(buf, "\tload: SUCCESS\n")))
> +			return GUC_ENABLED;
> +
> +	return GUC_DISABLED;
> +}
> +
> +static void close_guc_status(void)
> +{
> +	close(guc_status_fd);
> +}
> +
> +static void test_guc_loaded()
> +{
> +	igt_assert_f(get_guc_status() == GUC_ENABLED, "GuC is disabled\n"); 
> +}
> +
> +igt_main
> +{
> +	int gfx_fd = 0;
> +	int gen = 0;
> +
> +	igt_fixture
> +	{
> +		gfx_fd = drm_open_driver(DRIVER_INTEL);
> +		gen = intel_gen(intel_get_drm_devid(gfx_fd));
> +		igt_require(gen >= 9);
> +		open_guc_status();
> +	}
> +
> +	igt_subtest("guc_loaded") test_guc_loaded();
> +
> +	igt_fixture close_guc_status();
> +}
> --
> 2.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
diff mbox

Patch

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index d594038..331234f 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -36,6 +36,7 @@  TESTS_progs_M = \
 	gem_flink_basic \
 	gem_flink_race \
 	gem_linear_blits \
+	gem_guc_loading \
 	gem_madvise \
 	gem_mmap \
 	gem_mmap_gtt \
diff --git a/tests/gem_guc_loading.c b/tests/gem_guc_loading.c
new file mode 100644
index 0000000..fd53a46
--- /dev/null
+++ b/tests/gem_guc_loading.c
@@ -0,0 +1,89 @@ 
+/*
+ * Copyright © 2015 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.
+ *
+ * Authors:
+ *    Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("GuC firmware loading test.");
+
+#define LOAD_STATUS_BUF_SIZE 96
+
+enum guc_status { GUC_ENABLED, GUC_DISABLED };
+
+int guc_status_fd;
+
+static void open_guc_status(void)
+{
+	guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
+	igt_assert_f(guc_status_fd >= 0, "Can't open i915_guc_load_status\n");
+}
+
+static enum guc_status get_guc_status(void)
+{
+	char buf[LOAD_STATUS_BUF_SIZE];
+
+	FILE *fp = fdopen(guc_status_fd, "r");
+	igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n");
+
+	while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp))
+		if ((strstr(buf, "\tload: SUCCESS\n")))
+			return GUC_ENABLED;
+
+	return GUC_DISABLED;
+}
+
+static void close_guc_status(void)
+{
+	close(guc_status_fd);
+}
+
+static void test_guc_loaded()
+{
+	igt_assert_f(get_guc_status() == GUC_ENABLED, "GuC is disabled\n");
+}
+
+igt_main
+{
+	int gfx_fd = 0;
+	int gen = 0;
+
+	igt_fixture
+	{
+		gfx_fd = drm_open_driver(DRIVER_INTEL);
+		gen = intel_gen(intel_get_drm_devid(gfx_fd));
+		igt_require(gen >= 9);
+		open_guc_status();
+	}
+
+	igt_subtest("guc_loaded") test_guc_loaded();
+
+	igt_fixture close_guc_status();
+}