[PATCH v1 1/1] tests/pm_slpc: Add test for GuC based SLPC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This tests whether SLPC in GuC is configured properly through shared data.
It checks whether GTPERF is running in default state, post reset and post
system suspend/resume.
This test will be extended further based on enablement of other SLPC tasks.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
---
 lib/igt_pm.c           | 63 ++++++++++++++++++++++++++++++++++
 lib/igt_pm.h           |  2 ++
 tests/Makefile.sources |  1 +
 tests/pm_slpc.c        | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 159 insertions(+)
 create mode 100644 tests/pm_slpc.c

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 5bf5b2e..e139d9a 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -37,6 +37,7 @@
 #include "drmtest.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
+#include "igt_debugfs.h"
 
 /**
  * SECTION:igt_pm
@@ -338,3 +339,65 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status)
 {
 	return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100);
 }
+
+#define DBG_BUF_SIZE 4096
+
+bool igt_slpc_active(void)
+{
+	ssize_t n_read;
+	char buf[DBG_BUF_SIZE];
+	bool guc_load_status = false, slpc_status = false;
+	int guc_load_status_fd;
+	int frequency_info_fd;
+
+	guc_load_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY);
+	igt_skip_on_f(guc_load_status_fd == -1,
+		      "debugfs entry 'i915_guc_load_status' not found\n");
+
+	frequency_info_fd = igt_debugfs_open("i915_frequency_info", O_RDONLY);
+	igt_skip_on_f(frequency_info_fd == -1,
+		      "debugfs entry 'i915_frequency_info' not found\n");
+
+	n_read = read(guc_load_status_fd, buf, ARRAY_SIZE(buf));
+	igt_assert(n_read >= 0);
+	buf[n_read] = '\0';
+
+	if (strstr(buf, "\tload: SUCCESS\n") != NULL)
+		guc_load_status = true;
+	else
+		igt_debug("GuC is not loaded\n");
+
+	n_read = read(frequency_info_fd, buf, ARRAY_SIZE(buf));
+	igt_assert(n_read >= 0);
+	buf[n_read] = '\0';
+
+	if (strstr(buf, "SLPC Active\n") != NULL)
+		slpc_status = true;
+
+	close(frequency_info_fd);
+	close(guc_load_status_fd);
+	return (guc_load_status && slpc_status);
+}
+
+void igt_gtperf_state_check(void)
+{
+	ssize_t n_read;
+	char buf[DBG_BUF_SIZE];
+	int slpc_info_fd;
+
+	igt_assert_f(igt_slpc_active(), "SLPC is not active\n");
+
+	slpc_info_fd = igt_debugfs_open("i915_slpc_info", O_RDONLY);
+	igt_skip_on_f(slpc_info_fd == -1,
+		      "debugfs entry 'i915_slpc_info' not found\n");
+
+	n_read = read(slpc_info_fd, buf, ARRAY_SIZE(buf));
+	igt_assert(n_read >= 0);
+	buf[n_read] = '\0';
+
+	igt_assert(strstr(buf, "global state: 3 (running)\n") != NULL);
+	igt_assert(strstr(buf, "\tgtperf task active: yes\n") != NULL);
+	igt_assert(strstr(buf, "\tfreq switch active: yes\n") != NULL);
+
+	close(slpc_info_fd);
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index eced39f..cc1ae2d 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -49,5 +49,7 @@ enum igt_runtime_pm_status {
 bool igt_setup_runtime_pm(void);
 enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
 bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
+bool igt_slpc_active(void);
+void igt_gtperf_state_check(void);
 
 #endif /* IGT_PM_H */
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 6d081c3..9a2e246 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -122,6 +122,7 @@ TESTS_progs_M = \
 	pm_rps \
 	pm_rc6_residency \
 	pm_sseu \
+	pm_slpc \
 	prime_busy \
 	prime_mmap \
 	prime_mmap_coherency \
diff --git a/tests/pm_slpc.c b/tests/pm_slpc.c
new file mode 100644
index 0000000..87ffdcb
--- /dev/null
+++ b/tests/pm_slpc.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2016 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:
+ *    Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
+ *
+ */
+
+#define _GNU_SOURCE
+#include "igt.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/wait.h>
+
+#include "intel_bufmgr.h"
+
+static int drm_fd;
+
+enum {
+	NONE,
+	RESET,
+	SYSTEM_SUSPEND
+};
+
+static void gtperf_test(unsigned mode)
+{
+	igt_gtperf_state_check();
+
+	switch (mode) {
+	case NONE:	break;
+	case RESET:	igt_force_gpu_reset();
+			break;
+	case SYSTEM_SUSPEND:	igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
+						      SUSPEND_TEST_NONE);
+				sleep(5);
+				break;
+	}
+
+	igt_gtperf_state_check();
+
+}
+
+static bool has_slpc_support(void)
+{
+	return intel_gen(intel_get_drm_devid(drm_fd)) >= 9;
+}
+
+igt_main
+{
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		drm_fd = drm_open_driver(DRIVER_INTEL);
+		igt_skip_on(!has_slpc_support());
+	}
+
+	igt_subtest("gtperf-status")
+		gtperf_test(NONE);
+
+	igt_subtest("reset-gtperf")
+		gtperf_test(RESET);
+
+	igt_subtest("system-suspend-gtperf")
+		gtperf_test(SYSTEM_SUSPEND);
+
+	igt_fixture
+		close(drm_fd);
+}
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux