All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [CI 3/5] tests/psr: Move PSR state test functions to lib
Date: Sat, 14 Jul 2018 15:19:13 -0700	[thread overview]
Message-ID: <20180714221915.12687-3-dhinakaran.pandiyan@intel.com> (raw)
In-Reply-To: <20180714221915.12687-1-dhinakaran.pandiyan@intel.com>

kms_frontbuffer_tracking and kms_psr test PSR in different ways, let'
fix that by creating common library functions.

Also, rename wait_psr_entry to psr_wait_entry.

v2: Include the new file in meson.build

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 lib/Makefile.sources |  2 ++
 lib/igt_psr.c        | 40 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_psr.h        | 34 ++++++++++++++++++++++++++++++++++
 lib/meson.build      |  1 +
 tests/kms_psr.c      | 38 +++++++++++---------------------------
 5 files changed, 88 insertions(+), 27 deletions(-)
 create mode 100644 lib/igt_psr.c
 create mode 100644 lib/igt_psr.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 042c1d3b..14356c94 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -103,6 +103,8 @@ lib_source_list =	 	\
 	igt_kmod.h		\
 	igt_syncobj.c		\
 	igt_syncobj.h		\
+	igt_psr.c		\
+	igt_psr.h		\
 	$(NULL)
 
 .PHONY: version.h.tmp
diff --git a/lib/igt_psr.c b/lib/igt_psr.c
new file mode 100644
index 00000000..c979b0b5
--- /dev/null
+++ b/lib/igt_psr.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#include  "igt_psr.h"
+
+bool psr_active(int fd, bool check_active)
+{
+	bool active;
+	char buf[512];
+
+	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+	active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
+		(strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
+	return check_active ? active : !active;
+}
+
+bool psr_wait_entry(int fd)
+{
+	return igt_wait(psr_active(fd, true), 500, 1);
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
new file mode 100644
index 00000000..980f85e0
--- /dev/null
+++ b/lib/igt_psr.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef IGT_PSR_H
+#define IGT_PSR_H
+
+#include "igt_debugfs.h"
+#include "igt_core.h"
+#include "igt_aux.h"
+
+bool psr_wait_entry(int fd);
+bool psr_active(int fd, bool check_active);
+
+#endif
diff --git a/lib/meson.build b/lib/meson.build
index 939167f9..74a5f61e 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -48,6 +48,7 @@ lib_sources = [
 	'uwildmat/uwildmat.c',
 	'igt_kmod.c',
 	'igt_vc4.c',
+	'igt_psr.c',
 ]
 
 lib_deps = [
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index ded8346a..1ed1f232 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -24,6 +24,7 @@
 
 #include "igt.h"
 #include "igt_sysfs.h"
+#include "igt_psr.h"
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -195,23 +196,6 @@ static bool sink_support(data_t *data)
 	return strstr(buf, "Sink_Support: yes\n");
 }
 
-static bool psr_active(int fd, bool check_active)
-{
-	bool active;
-	char buf[512];
-
-	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
-
-	active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
-		 (strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
-	return check_active ? active : !active;
-}
-
-static bool wait_psr_entry(int fd)
-{
-	return igt_wait((psr_active(fd, true)), 500, 1);
-}
-
 static inline void manual(const char *expected)
 {
 	igt_debug_manual_check("all", expected);
@@ -237,7 +221,7 @@ static void run_test(data_t *data)
 	manual("screen GREEN");
 
 	/* Confirm screen stays Green after PSR got active */
-	igt_assert(wait_psr_entry(data->drm_fd));
+	igt_assert(psr_wait_entry(data->drm_fd));
 	manual("screen GREEN");
 
 	/* Setting a secondary fb/plane */
@@ -250,7 +234,7 @@ static void run_test(data_t *data)
 	else
 		manual("GREEN background with WHITE box");
 
-	igt_assert(wait_psr_entry(data->drm_fd));
+	igt_assert(psr_wait_entry(data->drm_fd));
 	switch (data->op) {
 	case PAGE_FLIP:
 		/* Only in use when testing primary plane */
@@ -408,13 +392,13 @@ igt_main
 
 	igt_subtest("basic") {
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(data.drm_fd));
+		igt_assert(psr_wait_entry(data.drm_fd));
 		test_cleanup(&data);
 	}
 
 	igt_subtest("no_drrs") {
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(data.drm_fd));
+		igt_assert(psr_wait_entry(data.drm_fd));
 		igt_assert(drrs_disabled(&data));
 		test_cleanup(&data);
 	}
@@ -423,7 +407,7 @@ igt_main
 		igt_subtest_f("primary_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-			igt_assert(wait_psr_entry(data.drm_fd));
+			igt_assert(psr_wait_entry(data.drm_fd));
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -433,7 +417,7 @@ igt_main
 		igt_subtest_f("sprite_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_OVERLAY);
-			igt_assert(wait_psr_entry(data.drm_fd));
+			igt_assert(psr_wait_entry(data.drm_fd));
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -443,7 +427,7 @@ igt_main
 		igt_subtest_f("cursor_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
-			igt_assert(wait_psr_entry(data.drm_fd));
+			igt_assert(psr_wait_entry(data.drm_fd));
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -452,7 +436,7 @@ igt_main
 	igt_subtest_f("dpms") {
 		data.op = RENDER;
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(data.drm_fd));
+		igt_assert(psr_wait_entry(data.drm_fd));
 		dpms_off_on(&data);
 		run_test(&data);
 		test_cleanup(&data);
@@ -461,10 +445,10 @@ igt_main
 	igt_subtest_f("suspend") {
 		data.op = PLANE_ONOFF;
 		setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
-		igt_assert(wait_psr_entry(data.drm_fd));
+		igt_assert(psr_wait_entry(data.drm_fd));
 		igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
 					      SUSPEND_TEST_NONE);
-		igt_assert(wait_psr_entry(data.drm_fd));
+		igt_assert(psr_wait_entry(data.drm_fd));
 		run_test(&data);
 		test_cleanup(&data);
 	}
-- 
2.17.1

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

  parent reply	other threads:[~2018-07-14 22:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-14 22:19 [igt-dev] [CI 1/5] tests/psr: Remove option to run test with PSR disabled Dhinakaran Pandiyan
2018-07-14 22:19 ` [igt-dev] [CI 2/5] tests/psr: Prepare for moving PSR state checking functions into lib Dhinakaran Pandiyan
2018-07-16 17:35   ` Rodrigo Vivi
2018-07-14 22:19 ` Dhinakaran Pandiyan [this message]
2018-07-16 17:38   ` [igt-dev] [CI 3/5] tests/psr: Move PSR state test functions to lib Rodrigo Vivi
2018-07-14 22:19 ` [igt-dev] [CI 4/5] tests/frontbuffer_tracking: Use the library functions to test PSR Dhinakaran Pandiyan
2018-07-16 17:39   ` Rodrigo Vivi
2018-07-14 22:19 ` [igt-dev] [CI 5/5] DEBUG/psr: Test fix for fdo #105450 Dhinakaran Pandiyan
2018-07-16 17:41   ` Rodrigo Vivi
2018-07-14 22:40 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [CI,1/5] tests/psr: Remove option to run test with PSR disabled Patchwork
2018-07-14 23:37 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-07-16 17:31 ` [igt-dev] [CI 1/5] " Rodrigo Vivi
2018-07-16 17:35   ` Rodrigo Vivi
2018-07-16 21:20     ` Dhinakaran Pandiyan

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=20180714221915.12687-3-dhinakaran.pandiyan@intel.com \
    --to=dhinakaran.pandiyan@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 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.