public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests
  2019-06-13 10:47 [igt-dev] [PATCH i-g-t 0/6] " Anshuman Gupta
@ 2019-06-13 10:47 ` Anshuman Gupta
  0 siblings, 0 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-13 10:47 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

This patch does the following chnegs to lib/igt_pm.c

-dmc_loaded() will be used by new test i915_pm_dc.c which will validate
 Display C States. So moving the same to igt_pm library.

-Introduced igt_disable_runtime_pm() in order to disable runtime suspend
 for the function which support dc9.

-Changed the igt_pm_enable_sata_link_power_management() and
 igt_pm_restore_sata_link_power_management() in order to save
 and restore the sata link power policy by an exit handler.

v2: Simplify the comment section.
v3: Remove . from the subject line.
v4: Rebased, resolve conflicts in pm_rpm.c
    Included patch set version change log.
v5: Listing actual change in patch set changelog to make review easier.
v6: igt's lib added support for disabling runtime suspend,
    change in commit log. rebased due to test name pm_rpm changed
    to i915_pm_rpm.
v7: Addressed review comment by saving POWER_DIR values in
    igt_disable_runtime_pm(). [Imre]
v8: Addressed the review comment, igt_pm_enable_sata_link_power_management
    function to restore the original SATA link power policy if things fail
    by using an exit handler. [Imre]
v9: IGT failure fixture in i915_pm_backlight and i915_pm_rpm.

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 lib/igt_pm.c                   | 190 ++++++++++++++++++++++++++-------
 lib/igt_pm.h                   |   6 +-
 tests/i915/i915_pm_backlight.c |   6 +-
 tests/i915/i915_pm_rpm.c       |  24 +----
 4 files changed, 159 insertions(+), 67 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index fd22273a..9b83fbb5 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -38,6 +38,7 @@
 #include "drmtest.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
+#include "igt_sysfs.h"
 
 /**
  * SECTION:igt_pm
@@ -63,11 +64,15 @@ enum {
 #define MIN_POWER_STR		"min_power\n"
 /* Remember to fix this if adding longer strings */
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
+int8_t *__sata_link_pm_policies;
 
 static char __igt_pm_audio_runtime_power_save[64];
 static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
+static void __igt_pm_sata_link_pm_exit_handler(int sig);
+static void __igt_pm_restore_sata_link_power_management(void);
+
 static int __igt_pm_audio_restore_runtime_pm(void)
 {
 	int fd;
@@ -280,28 +285,12 @@ void igt_pm_enable_audio_runtime_pm(void)
 		igt_debug("Failed to enable audio runtime PM! (%d)\n", -err);
 }
 
-/**
- * igt_pm_enable_sata_link_power_management:
- *
- * Enable the min_power policy for SATA link power management.
- * Without this we cannot reach deep runtime power states.
- *
- * We don't have any assertions on open since the system might not have
- * a SATA host.
- *
- * Returns:
- * An opaque pointer to the data needed to restore the default values
- * after the test has terminated, or NULL if SATA link power management
- * is not supported. This pointer should be freed when no longer used
- * (typically after having called restore_sata_link_power_management()).
- */
-int8_t *igt_pm_enable_sata_link_power_management(void)
+static void __igt_pm_enable_sata_link_power_management(void)
 {
 	int fd, i;
 	ssize_t len;
 	char *buf;
 	char *file_name;
-	int8_t *link_pm_policies = NULL;
 
 	file_name = malloc(PATH_MAX);
 	buf = malloc(MAX_POLICY_STRLEN + 1);
@@ -313,6 +302,9 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
 			 i);
 
+		/* We don't have any assertions on open since the system
+		 * might not have a SATA host.
+		 */
 		fd = open(file_name, O_RDWR);
 		if (fd < 0)
 			break;
@@ -333,11 +325,13 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 			policy = POLICY_UNKNOWN;
 
 		if (!(i % 256))
-			link_pm_policies = realloc(link_pm_policies,
-						   (i / 256 + 1) * 256 + 1);
+			__sata_link_pm_policies =
+			realloc(__sata_link_pm_policies,
+				(i / 256 + 1) * 256 + 1);
 
-		link_pm_policies[i] = policy;
-		link_pm_policies[i + 1] = 0;
+		__sata_link_pm_policies[i] = policy;
+		__sata_link_pm_policies[i + 1] = 0;
+		igt_install_exit_handler(__igt_pm_sata_link_pm_exit_handler);
 
 		/* If the policy is something we don't know about,
 		 * don't touch it, since we might potentially break things.
@@ -355,39 +349,27 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 	}
 	free(buf);
 	free(file_name);
-
-	return link_pm_policies;
 }
 
-/**
- * igt_pm_restore_sata_link_power_management:
- * @pm_data: An opaque pointer with saved link PM policies;
- *           If NULL is passed we force enable the "max_performance" policy.
- *
- * Restore the link power management policies to the values
- * prior to enabling min_power.
- *
- * Caveat: If the system supports hotplugging and hotplugging takes
- *         place during our testing so that the hosts change numbers
- *         we might restore the settings to the wrong hosts.
- */
-void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
-
+static void __igt_pm_restore_sata_link_power_management(void)
 {
 	int fd, i;
 	char *file_name;
 
+	if (!__sata_link_pm_policies)
+		return;
+
 	/* Disk runtime PM policies. */
 	file_name = malloc(PATH_MAX);
 	for (i = 0; ; i++) {
 		int8_t policy;
 
-		if (!pm_data)
+		if (!__sata_link_pm_policies)
 			policy = POLICY_MAX_PERFORMANCE;
-		else if (pm_data[i] == POLICY_UNKNOWN)
+		else if (__sata_link_pm_policies[i] == POLICY_UNKNOWN)
 			continue;
 		else
-			policy = pm_data[i];
+			policy = __sata_link_pm_policies[i];
 
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
@@ -421,7 +403,53 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
 		close(fd);
 	}
 	free(file_name);
+	free(__sata_link_pm_policies);
+	__sata_link_pm_policies = NULL;
+}
+
+/**
+ * igt_pm_enable_sata_link_power_management:
+ *
+ * Enable the min_power policy for SATA link power management.
+ * Without this we cannot reach deep runtime power states.
+ * Returns: Void
+ */
+void igt_pm_enable_sata_link_power_management(void)
+{
+	int err;
+
+	/* Check if has been already saved. */
+	if (__sata_link_pm_policies)
+		return;
+
+	 __igt_pm_enable_sata_link_power_management();
+}
+
+/**
+ * igt_pm_restore_sata_link_power_management:
+ *
+ * Restore the link power management policies to the values
+ * prior to enabling min_power.
+ *
+ * Caveat: If the system supports hotplugging and hotplugging takes
+ *         place during our testing so that the hosts change numbers
+ *         we might restore the settings to the wrong hosts.
+ */
+void igt_pm_restore_sata_link_power_management(void)
+{
+	int err;
+
+	if (!__sata_link_pm_policies)
+		return;
+
+	 __igt_pm_restore_sata_link_power_management();
 }
+
+static void __igt_pm_sata_link_pm_exit_handler(int sig)
+{
+	__igt_pm_restore_sata_link_power_management();
+}
+
 #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power"
 /* We just leak this on exit ... */
 int pm_status_fd = -1;
@@ -585,6 +613,61 @@ bool igt_setup_runtime_pm(void)
 	return true;
 }
 
+bool igt_disable_runtime_pm(void)
+{
+	int fd;
+	ssize_t size;
+	char buf[6];
+
+	if (pm_status_fd < 0) {
+		fd = open(POWER_DIR "/autosuspend_delay_ms", O_RDWR);
+		if (fd < 0)
+			return false;
+
+		size = read(fd, __igt_pm_runtime_autosuspend,
+			    sizeof(__igt_pm_runtime_autosuspend));
+
+		if (size <= 0) {
+			close(fd);
+			return false;
+		}
+
+		strchomp(__igt_pm_runtime_autosuspend);
+		igt_install_exit_handler(__igt_pm_runtime_exit_handler);
+		close(fd);
+	}
+
+	/* We know we support runtime PM, let's try to disable it now. */
+	fd = open(POWER_DIR "/control", O_RDWR);
+	igt_assert_f(fd >= 0, "Can't open " POWER_DIR "/control\n");
+
+	if (pm_status_fd < 0) {
+		igt_assert(read(fd, __igt_pm_runtime_control,
+				sizeof(__igt_pm_runtime_control)) > 0);
+		strchomp(__igt_pm_runtime_control);
+
+		igt_debug("Saved runtime power management as '%s' and '%s'\n",
+			  __igt_pm_runtime_autosuspend,
+			  __igt_pm_runtime_control);
+	}
+
+	size = write(fd, "on\n", 3);
+	igt_assert(size == 3);
+	lseek(fd, 0, SEEK_SET);
+	size = read(fd, buf, ARRAY_SIZE(buf));
+	igt_assert(size == 3);
+	igt_assert(strncmp(buf, "on\n", 3) == 0);
+	close(fd);
+
+	if (pm_status_fd < 0) {
+		pm_status_fd = open(POWER_DIR "/runtime_status", O_RDONLY);
+		igt_assert_f(pm_status_fd >= 0,
+			     "Can't open " POWER_DIR "/runtime_status\n");
+	}
+
+	return true;
+}
+
 /**
  * igt_get_runtime_pm_status:
  *
@@ -628,3 +711,30 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status)
 {
 	return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100);
 }
+
+/**
+ * dmc_loaded:
+ * @debugfs: fd to the debugfs dir.
+
+ * Check whether DMC FW is loaded or not. DMC FW is require for few Display C
+ * states like DC5 and DC6. FW does the Context Save and Restore during Display
+ * C States entry and exit.
+ *
+ * Returns:
+ * True if DMC FW is loaded otherwise false.
+ */
+bool igt_pm_dmc_loaded(int debugfs)
+{
+	igt_require(debugfs != -1);
+	char buf[15];
+	int len;
+
+	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
+	if (len < 0)
+		return true; /* no CSR support, no DMC requirement */
+
+	buf[len] = '\0';
+
+	igt_info("DMC: %s\n", buf);
+	return strstr(buf, "fw loaded: yes");
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index 10cc6794..979b3463 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -25,8 +25,8 @@
 #define IGT_PM_H
 
 void igt_pm_enable_audio_runtime_pm(void);
-int8_t *igt_pm_enable_sata_link_power_management(void);
-void igt_pm_restore_sata_link_power_management(int8_t *pm_data);
+void igt_pm_enable_sata_link_power_management(void);
+void igt_pm_restore_sata_link_power_management(void);
 
 /**
  * igt_runtime_pm_status:
@@ -47,8 +47,10 @@ enum igt_runtime_pm_status {
 };
 
 bool igt_setup_runtime_pm(void);
+bool igt_disable_runtime_pm(void);
 void igt_restore_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_pm_dmc_loaded(int debugfs);
 
 #endif /* IGT_PM_H */
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index 4c1bff5b..9a5f4c37 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -47,7 +47,6 @@ struct context {
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
-static int8_t *pm_data = NULL;
 
 static int backlight_read(int *result, const char *fname)
 {
@@ -235,7 +234,7 @@ igt_main
 		igt_plane_set_fb(primary, &fb);
 
 		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
-		pm_data = igt_pm_enable_sata_link_power_management();
+		igt_pm_enable_sata_link_power_management();
 	}
 
 	igt_subtest("basic-brightness")
@@ -255,8 +254,7 @@ igt_main
 
 		igt_display_fini(&display);
 		igt_remove_fb(display.drm_fd, &fb);
-		igt_pm_restore_sata_link_power_management(pm_data);
-		free(pm_data);
+		igt_pm_restore_sata_link_power_management();
 		close(display.drm_fd);
 	}
 }
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index a2c9d0ed..2d2f77be 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -122,8 +122,6 @@ struct modeset_params lpsp_mode_params;
 struct modeset_params non_lpsp_mode_params;
 struct modeset_params *default_mode_params;
 
-static int8_t *pm_data = NULL;
-
 static int modprobe(const char *driver)
 {
 	return igt_kmod_load(driver, NULL);
@@ -710,21 +708,6 @@ static void setup_pc8(void)
 	has_pc8 = true;
 }
 
-static bool dmc_loaded(void)
-{
-	char buf[15];
-	int len;
-
-	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
-	if (len < 0)
-	    return true; /* no CSR support, no DMC requirement */
-
-	buf[len] = '\0';
-
-	igt_info("DMC: %s\n", buf);
-	return strstr(buf, "fw loaded: yes");
-}
-
 static void dump_file(int dir, const char *filename)
 {
 	char *contents;
@@ -751,7 +734,7 @@ static bool setup_environment(void)
 
 	init_mode_set_data(&ms_data);
 
-	pm_data = igt_pm_enable_sata_link_power_management();
+	igt_pm_enable_sata_link_power_management();
 
 	has_runtime_pm = igt_setup_runtime_pm();
 	setup_pc8();
@@ -759,7 +742,7 @@ static bool setup_environment(void)
 	igt_info("Runtime PM support: %d\n", has_runtime_pm);
 	igt_info("PC8 residency support: %d\n", has_pc8);
 	igt_require(has_runtime_pm);
-	igt_require(dmc_loaded());
+	igt_require(igt_pm_dmc_loaded(debugfs));
 
 out:
 	disable_all_screens(&ms_data);
@@ -776,8 +759,7 @@ static void teardown_environment(void)
 
 	igt_restore_runtime_pm();
 
-	igt_pm_restore_sata_link_power_management(pm_data);
-	free(pm_data);
+	igt_pm_restore_sata_link_power_management();
 
 	fini_mode_set_data(&ms_data);
 
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series
@ 2019-06-18 17:56 Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

This is a resubmission of series https://patchwork.freedesktop.org/series/56713/
to collect DC6 igt test failure report from CI Bat test.
This series skip the DC6 test if in case PC8+ residencies limited
by BIOS.

This series adds DC state IGT test to CI Fast feedback list.

Anshuman Gupta (1):
  DO_NOT_MERGE: Debug patch to cover DC IGT test.

Jyoti Yadav (5):
  lib/igt_pm: igt lib helper routines to support DC5/6 tests
  tests/i915/i915_pm_dc: Added new test to verify Display C States
  tests/i915/i915_pm_dc: Added test for DC6 during PSR
  tests/i915/i915_pm_dc: Added test for DC5 during DPMS
  tests/i915/i915_pm_dc: Added test for DC6 during DPMS

 lib/igt_pm.c                          | 190 ++++++++++---
 lib/igt_pm.h                          |   6 +-
 tests/Makefile.sources                |   3 +
 tests/i915/i915_pm_backlight.c        |   6 +-
 tests/i915/i915_pm_dc.c               | 387 ++++++++++++++++++++++++++
 tests/i915/i915_pm_rpm.c              |  24 +-
 tests/intel-ci/fast-feedback.testlist |   4 +
 tests/meson.build                     |   1 +
 8 files changed, 554 insertions(+), 67 deletions(-)
 create mode 100644 tests/i915/i915_pm_dc.c

-- 
2.21.0

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-08-12 12:04   ` Imre Deak
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 2/6] tests/i915/i915_pm_dc: Added new test to verify Display C States Anshuman Gupta
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

This patch does the following chnegs to lib/igt_pm.c

-dmc_loaded() will be used by new test i915_pm_dc.c which will validate
 Display C States. So moving the same to igt_pm library.

-Introduced igt_disable_runtime_pm() in order to disable runtime suspend
 for the function which support dc9.

-Changed the igt_pm_enable_sata_link_power_management() and
 igt_pm_restore_sata_link_power_management() in order to save
 and restore the sata link power policy by an exit handler.

v2: Simplify the comment section.
v3: Remove . from the subject line.
v4: Rebased, resolve conflicts in pm_rpm.c
    Included patch set version change log.
v5: Listing actual change in patch set changelog to make review easier.
v6: igt's lib added support for disabling runtime suspend,
    change in commit log. rebased due to test name pm_rpm changed
    to i915_pm_rpm.
v7: Addressed review comment by saving POWER_DIR values in
    igt_disable_runtime_pm(). [Imre]
v8: Addressed the review comment, igt_pm_enable_sata_link_power_management
    function to restore the original SATA link power policy if things fail
    by using an exit handler. [Imre]
v9: IGT failure fixture in i915_pm_backlight and i915_pm_rpm.

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 lib/igt_pm.c                   | 190 ++++++++++++++++++++++++++-------
 lib/igt_pm.h                   |   6 +-
 tests/i915/i915_pm_backlight.c |   6 +-
 tests/i915/i915_pm_rpm.c       |  24 +----
 4 files changed, 159 insertions(+), 67 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index fd22273a..9b83fbb5 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -38,6 +38,7 @@
 #include "drmtest.h"
 #include "igt_pm.h"
 #include "igt_aux.h"
+#include "igt_sysfs.h"
 
 /**
  * SECTION:igt_pm
@@ -63,11 +64,15 @@ enum {
 #define MIN_POWER_STR		"min_power\n"
 /* Remember to fix this if adding longer strings */
 #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
+int8_t *__sata_link_pm_policies;
 
 static char __igt_pm_audio_runtime_power_save[64];
 static char * __igt_pm_audio_runtime_control_path;
 static char __igt_pm_audio_runtime_control[64];
 
+static void __igt_pm_sata_link_pm_exit_handler(int sig);
+static void __igt_pm_restore_sata_link_power_management(void);
+
 static int __igt_pm_audio_restore_runtime_pm(void)
 {
 	int fd;
@@ -280,28 +285,12 @@ void igt_pm_enable_audio_runtime_pm(void)
 		igt_debug("Failed to enable audio runtime PM! (%d)\n", -err);
 }
 
-/**
- * igt_pm_enable_sata_link_power_management:
- *
- * Enable the min_power policy for SATA link power management.
- * Without this we cannot reach deep runtime power states.
- *
- * We don't have any assertions on open since the system might not have
- * a SATA host.
- *
- * Returns:
- * An opaque pointer to the data needed to restore the default values
- * after the test has terminated, or NULL if SATA link power management
- * is not supported. This pointer should be freed when no longer used
- * (typically after having called restore_sata_link_power_management()).
- */
-int8_t *igt_pm_enable_sata_link_power_management(void)
+static void __igt_pm_enable_sata_link_power_management(void)
 {
 	int fd, i;
 	ssize_t len;
 	char *buf;
 	char *file_name;
-	int8_t *link_pm_policies = NULL;
 
 	file_name = malloc(PATH_MAX);
 	buf = malloc(MAX_POLICY_STRLEN + 1);
@@ -313,6 +302,9 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
 			 i);
 
+		/* We don't have any assertions on open since the system
+		 * might not have a SATA host.
+		 */
 		fd = open(file_name, O_RDWR);
 		if (fd < 0)
 			break;
@@ -333,11 +325,13 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 			policy = POLICY_UNKNOWN;
 
 		if (!(i % 256))
-			link_pm_policies = realloc(link_pm_policies,
-						   (i / 256 + 1) * 256 + 1);
+			__sata_link_pm_policies =
+			realloc(__sata_link_pm_policies,
+				(i / 256 + 1) * 256 + 1);
 
-		link_pm_policies[i] = policy;
-		link_pm_policies[i + 1] = 0;
+		__sata_link_pm_policies[i] = policy;
+		__sata_link_pm_policies[i + 1] = 0;
+		igt_install_exit_handler(__igt_pm_sata_link_pm_exit_handler);
 
 		/* If the policy is something we don't know about,
 		 * don't touch it, since we might potentially break things.
@@ -355,39 +349,27 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 	}
 	free(buf);
 	free(file_name);
-
-	return link_pm_policies;
 }
 
-/**
- * igt_pm_restore_sata_link_power_management:
- * @pm_data: An opaque pointer with saved link PM policies;
- *           If NULL is passed we force enable the "max_performance" policy.
- *
- * Restore the link power management policies to the values
- * prior to enabling min_power.
- *
- * Caveat: If the system supports hotplugging and hotplugging takes
- *         place during our testing so that the hosts change numbers
- *         we might restore the settings to the wrong hosts.
- */
-void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
-
+static void __igt_pm_restore_sata_link_power_management(void)
 {
 	int fd, i;
 	char *file_name;
 
+	if (!__sata_link_pm_policies)
+		return;
+
 	/* Disk runtime PM policies. */
 	file_name = malloc(PATH_MAX);
 	for (i = 0; ; i++) {
 		int8_t policy;
 
-		if (!pm_data)
+		if (!__sata_link_pm_policies)
 			policy = POLICY_MAX_PERFORMANCE;
-		else if (pm_data[i] == POLICY_UNKNOWN)
+		else if (__sata_link_pm_policies[i] == POLICY_UNKNOWN)
 			continue;
 		else
-			policy = pm_data[i];
+			policy = __sata_link_pm_policies[i];
 
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
@@ -421,7 +403,53 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
 		close(fd);
 	}
 	free(file_name);
+	free(__sata_link_pm_policies);
+	__sata_link_pm_policies = NULL;
+}
+
+/**
+ * igt_pm_enable_sata_link_power_management:
+ *
+ * Enable the min_power policy for SATA link power management.
+ * Without this we cannot reach deep runtime power states.
+ * Returns: Void
+ */
+void igt_pm_enable_sata_link_power_management(void)
+{
+	int err;
+
+	/* Check if has been already saved. */
+	if (__sata_link_pm_policies)
+		return;
+
+	 __igt_pm_enable_sata_link_power_management();
+}
+
+/**
+ * igt_pm_restore_sata_link_power_management:
+ *
+ * Restore the link power management policies to the values
+ * prior to enabling min_power.
+ *
+ * Caveat: If the system supports hotplugging and hotplugging takes
+ *         place during our testing so that the hosts change numbers
+ *         we might restore the settings to the wrong hosts.
+ */
+void igt_pm_restore_sata_link_power_management(void)
+{
+	int err;
+
+	if (!__sata_link_pm_policies)
+		return;
+
+	 __igt_pm_restore_sata_link_power_management();
 }
+
+static void __igt_pm_sata_link_pm_exit_handler(int sig)
+{
+	__igt_pm_restore_sata_link_power_management();
+}
+
 #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power"
 /* We just leak this on exit ... */
 int pm_status_fd = -1;
@@ -585,6 +613,61 @@ bool igt_setup_runtime_pm(void)
 	return true;
 }
 
+bool igt_disable_runtime_pm(void)
+{
+	int fd;
+	ssize_t size;
+	char buf[6];
+
+	if (pm_status_fd < 0) {
+		fd = open(POWER_DIR "/autosuspend_delay_ms", O_RDWR);
+		if (fd < 0)
+			return false;
+
+		size = read(fd, __igt_pm_runtime_autosuspend,
+			    sizeof(__igt_pm_runtime_autosuspend));
+
+		if (size <= 0) {
+			close(fd);
+			return false;
+		}
+
+		strchomp(__igt_pm_runtime_autosuspend);
+		igt_install_exit_handler(__igt_pm_runtime_exit_handler);
+		close(fd);
+	}
+
+	/* We know we support runtime PM, let's try to disable it now. */
+	fd = open(POWER_DIR "/control", O_RDWR);
+	igt_assert_f(fd >= 0, "Can't open " POWER_DIR "/control\n");
+
+	if (pm_status_fd < 0) {
+		igt_assert(read(fd, __igt_pm_runtime_control,
+				sizeof(__igt_pm_runtime_control)) > 0);
+		strchomp(__igt_pm_runtime_control);
+
+		igt_debug("Saved runtime power management as '%s' and '%s'\n",
+			  __igt_pm_runtime_autosuspend,
+			  __igt_pm_runtime_control);
+	}
+
+	size = write(fd, "on\n", 3);
+	igt_assert(size == 3);
+	lseek(fd, 0, SEEK_SET);
+	size = read(fd, buf, ARRAY_SIZE(buf));
+	igt_assert(size == 3);
+	igt_assert(strncmp(buf, "on\n", 3) == 0);
+	close(fd);
+
+	if (pm_status_fd < 0) {
+		pm_status_fd = open(POWER_DIR "/runtime_status", O_RDONLY);
+		igt_assert_f(pm_status_fd >= 0,
+			     "Can't open " POWER_DIR "/runtime_status\n");
+	}
+
+	return true;
+}
+
 /**
  * igt_get_runtime_pm_status:
  *
@@ -628,3 +711,30 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status)
 {
 	return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100);
 }
+
+/**
+ * dmc_loaded:
+ * @debugfs: fd to the debugfs dir.
+
+ * Check whether DMC FW is loaded or not. DMC FW is require for few Display C
+ * states like DC5 and DC6. FW does the Context Save and Restore during Display
+ * C States entry and exit.
+ *
+ * Returns:
+ * True if DMC FW is loaded otherwise false.
+ */
+bool igt_pm_dmc_loaded(int debugfs)
+{
+	igt_require(debugfs != -1);
+	char buf[15];
+	int len;
+
+	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
+	if (len < 0)
+		return true; /* no CSR support, no DMC requirement */
+
+	buf[len] = '\0';
+
+	igt_info("DMC: %s\n", buf);
+	return strstr(buf, "fw loaded: yes");
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index 10cc6794..979b3463 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -25,8 +25,8 @@
 #define IGT_PM_H
 
 void igt_pm_enable_audio_runtime_pm(void);
-int8_t *igt_pm_enable_sata_link_power_management(void);
-void igt_pm_restore_sata_link_power_management(int8_t *pm_data);
+void igt_pm_enable_sata_link_power_management(void);
+void igt_pm_restore_sata_link_power_management(void);
 
 /**
  * igt_runtime_pm_status:
@@ -47,8 +47,10 @@ enum igt_runtime_pm_status {
 };
 
 bool igt_setup_runtime_pm(void);
+bool igt_disable_runtime_pm(void);
 void igt_restore_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_pm_dmc_loaded(int debugfs);
 
 #endif /* IGT_PM_H */
diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
index 4c1bff5b..9a5f4c37 100644
--- a/tests/i915/i915_pm_backlight.c
+++ b/tests/i915/i915_pm_backlight.c
@@ -47,7 +47,6 @@ struct context {
 #define FADESPEED 100 /* milliseconds between steps */
 
 IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
-static int8_t *pm_data = NULL;
 
 static int backlight_read(int *result, const char *fname)
 {
@@ -235,7 +234,7 @@ igt_main
 		igt_plane_set_fb(primary, &fb);
 
 		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
-		pm_data = igt_pm_enable_sata_link_power_management();
+		igt_pm_enable_sata_link_power_management();
 	}
 
 	igt_subtest("basic-brightness")
@@ -255,8 +254,7 @@ igt_main
 
 		igt_display_fini(&display);
 		igt_remove_fb(display.drm_fd, &fb);
-		igt_pm_restore_sata_link_power_management(pm_data);
-		free(pm_data);
+		igt_pm_restore_sata_link_power_management();
 		close(display.drm_fd);
 	}
 }
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index a2c9d0ed..2d2f77be 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -122,8 +122,6 @@ struct modeset_params lpsp_mode_params;
 struct modeset_params non_lpsp_mode_params;
 struct modeset_params *default_mode_params;
 
-static int8_t *pm_data = NULL;
-
 static int modprobe(const char *driver)
 {
 	return igt_kmod_load(driver, NULL);
@@ -710,21 +708,6 @@ static void setup_pc8(void)
 	has_pc8 = true;
 }
 
-static bool dmc_loaded(void)
-{
-	char buf[15];
-	int len;
-
-	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
-	if (len < 0)
-	    return true; /* no CSR support, no DMC requirement */
-
-	buf[len] = '\0';
-
-	igt_info("DMC: %s\n", buf);
-	return strstr(buf, "fw loaded: yes");
-}
-
 static void dump_file(int dir, const char *filename)
 {
 	char *contents;
@@ -751,7 +734,7 @@ static bool setup_environment(void)
 
 	init_mode_set_data(&ms_data);
 
-	pm_data = igt_pm_enable_sata_link_power_management();
+	igt_pm_enable_sata_link_power_management();
 
 	has_runtime_pm = igt_setup_runtime_pm();
 	setup_pc8();
@@ -759,7 +742,7 @@ static bool setup_environment(void)
 	igt_info("Runtime PM support: %d\n", has_runtime_pm);
 	igt_info("PC8 residency support: %d\n", has_pc8);
 	igt_require(has_runtime_pm);
-	igt_require(dmc_loaded());
+	igt_require(igt_pm_dmc_loaded(debugfs));
 
 out:
 	disable_all_screens(&ms_data);
@@ -776,8 +759,7 @@ static void teardown_environment(void)
 
 	igt_restore_runtime_pm();
 
-	igt_pm_restore_sata_link_power_management(pm_data);
-	free(pm_data);
+	igt_pm_restore_sata_link_power_management();
 
 	fini_mode_set_data(&ms_data);
 
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 2/6] tests/i915/i915_pm_dc: Added new test to verify Display C States
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 3/6] tests/i915/i915_pm_dc: Added test for DC6 during PSR Anshuman Gupta
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

Currently this test validates DC5 upon PSR entry for supported platforms.
Added new file for compilation inside Makefile and Meson.

v2: Used the debugfs entry for DC counters instead of Registers.
    Used shorter names for variables.
    Introduced timeout to read DC counters.
v3: one second timeout is introduced to read DC counters.
    Skip the subtest if counters are not available for that platform.
v4: Rebased, to fix compilation error in psr_enable(), psr_wait_entry()
    and replaced igt_display_init() by igt_display_require() in pm_rpm.c.
    Addressed the review comment by removing unused function display_init,
    removing redundant igt commit suggested by Imre.
    Fixed typo in read_dc_counter().
v5: Addressed the review comment by removing redundant read_dc_counter(),
    clubbed cleanup() function in test_dc_state_psr() suggested by Imre.
    Rearranged  preprocessor directives at one place.
    Fixed compilation warning by adding function prototype for
    dc_state_wait_entry() and check_dc_counter().
    Listing actual change in patch set changelog to make review easier.
v6: Fixed "i915_edp_psr_status" string to "Sink support: yes".
v7: Rebased since test name changed from "pm_dc" to "i915_pm_dc",
    this will align with other PM tests.
    also changed the DC5/6 counter check timeout to 3 second.
v8: On few platform SATA i/p is blocking deeper package C states.
    used igt_pm_enable_sata_link_power_management() function in order
    to use min_power policy.
v9: Removing redundant igt_pm_remove_sata_link_power_management()
    as sata link policy vlaues will be restored by exit handler.

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 tests/Makefile.sources  |   3 +
 tests/i915/i915_pm_dc.c | 257 ++++++++++++++++++++++++++++++++++++++++
 tests/meson.build       |   1 +
 3 files changed, 261 insertions(+)
 create mode 100644 tests/i915/i915_pm_dc.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 214698da..21feb732 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -489,6 +489,9 @@ i915_pm_rc6_residency_SOURCES = i915/i915_pm_rc6_residency.c
 TESTS_progs += i915_pm_rpm
 i915_pm_rpm_SOURCES = i915/i915_pm_rpm.c
 
+TESTS_progs += i915_pm_dc
+i915_pm_dc_SOURCES = i915/i915_pm_dc.c
+
 TESTS_progs += i915_pm_rps
 i915_pm_rps_SOURCES = i915/i915_pm_rps.c
 
diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
new file mode 100644
index 00000000..5d608337
--- /dev/null
+++ b/tests/i915/i915_pm_dc.c
@@ -0,0 +1,257 @@
+/*
+ * 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.h"
+#include "igt_sysfs.h"
+#include "igt_psr.h"
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include "intel_bufmgr.h"
+#include "intel_io.h"
+#include "limits.h"
+#include "igt_kmod.h"
+
+/* DC State Flags */
+#define CHECK_DC5	1
+#define CHECK_DC6	2
+
+#define MSR_PKG_CST_CONFIG_CONTROL	0xE2
+/* HSW/BDW: */
+#define  PKG_CST_LIMIT_MASK		0xF
+#define  PKG_CST_LIMIT_C8		0x6
+
+#define MSR_PC8_RES	0x630
+#define MSR_PC9_RES	0x631
+#define MSR_PC10_RES	0x632
+
+typedef struct {
+	int drm_fd;
+	int debugfs_fd;
+	uint32_t devid;
+	igt_display_t display;
+	struct igt_fb fb_white;
+	enum psr_mode op_psr_mode;
+	drmModeModeInfo *mode;
+	igt_output_t *output;
+} data_t;
+
+int msr_fd;
+
+bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
+void check_dc_counter(int drm_fd, int dc_flag, uint32_t prev_dc_count);
+
+/* If the read fails, then the machine doesn't support PC8+ residencies. */
+static bool supports_pc8_plus_residencies(void)
+{
+	int rc;
+	uint64_t val;
+
+	rc = pread(msr_fd, &val, sizeof(uint64_t), MSR_PC8_RES);
+	if (rc != sizeof(val))
+		return false;
+	rc = pread(msr_fd, &val, sizeof(uint64_t), MSR_PC9_RES);
+	if (rc != sizeof(val))
+		return false;
+	rc = pread(msr_fd, &val, sizeof(uint64_t), MSR_PC10_RES);
+	if (rc != sizeof(val))
+		return false;
+
+	rc = pread(msr_fd, &val, sizeof(uint64_t), MSR_PKG_CST_CONFIG_CONTROL);
+	if (rc != sizeof(val))
+		return false;
+	if ((val & PKG_CST_LIMIT_MASK) < PKG_CST_LIMIT_C8) {
+		igt_info("PKG C-states limited below PC8 by the BIOS\n");
+		return false;
+	}
+
+	return true;
+}
+
+static void setup_output(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		drmModeConnectorPtr c = output->config.connector;
+
+		if (c->connector_type != DRM_MODE_CONNECTOR_eDP)
+			continue;
+
+		igt_output_set_pipe(output, pipe);
+		data->output = output;
+		data->mode = igt_output_get_mode(output);
+
+		return;
+	}
+}
+
+static void display_fini(data_t *data)
+{
+	igt_display_fini(&data->display);
+}
+
+static bool edp_psr_sink_support(data_t *data)
+{
+	char buf[512];
+
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_edp_psr_status",
+				buf, sizeof(buf));
+
+	return strstr(buf, "Sink support: yes");
+}
+
+static void cleanup(data_t *data)
+{
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &data->fb_white);
+}
+
+static void setup_primary(data_t *data)
+{
+	igt_plane_t *primary;
+
+	primary = igt_output_get_plane_type(data->output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, NULL);
+	igt_create_color_fb(data->drm_fd,
+			    data->mode->hdisplay, data->mode->vdisplay,
+			    DRM_FORMAT_XRGB8888,
+			    LOCAL_I915_FORMAT_MOD_X_TILED,
+			    1.0, 1.0, 1.0,
+			    &data->fb_white);
+	igt_plane_set_fb(primary, &data->fb_white);
+	igt_display_commit(&data->display);
+}
+
+static uint32_t get_dc_counter(char *dc_data)
+{
+	char *e;
+	long ret;
+	char *s = strchr(dc_data, ':');
+
+	assert(s);
+	s++;
+	ret = strtol(s, &e, 10);
+	assert(((ret != LONG_MIN && ret != LONG_MAX) || errno != ERANGE) &&
+	       e > s && *e == '\n' && ret >= 0);
+	return ret;
+}
+
+static uint32_t read_dc_counter(uint32_t drm_fd, int dc_flag)
+{
+	char buf[4096];
+	char *str;
+
+	igt_debugfs_read(drm_fd, "i915_dmc_info", buf);
+
+	if (dc_flag & CHECK_DC5)
+		str = strstr(buf, "DC3 -> DC5 count");
+	else if (dc_flag & CHECK_DC6)
+		str = strstr(buf, "DC5 -> DC6 count");
+
+	/* Check DC5/DC6 counter is available for the platform.
+	 * Skip the test if counter is not available.
+	 */
+	igt_skip_on_f(!str, "DC%d counter is not available\n",
+		      dc_flag & CHECK_DC5 ? 5 : 6);
+	return get_dc_counter(str);
+}
+
+bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count)
+{
+	return igt_wait(read_dc_counter(drm_fd, dc_flag) >
+			prev_dc_count, 3000, 100);
+}
+
+void check_dc_counter(int drm_fd, int dc_flag, uint32_t prev_dc_count)
+{
+	igt_assert_f(dc_state_wait_entry(drm_fd, dc_flag, prev_dc_count),
+		     "DC%d state is not achieved\n",
+		     dc_flag & CHECK_DC5 ? 5 : 6);
+}
+
+static void test_dc_state_psr(data_t *data, int dc_flag)
+{
+	uint32_t dc_counter_before_psr;
+
+	dc_counter_before_psr = read_dc_counter(data->drm_fd, dc_flag);
+	setup_output(data);
+	setup_primary(data);
+	igt_assert(psr_wait_entry(data->debugfs_fd, data->op_psr_mode));
+	check_dc_counter(data->drm_fd, dc_flag, dc_counter_before_psr);
+	cleanup(data);
+}
+
+int main(int argc, char *argv[])
+{
+	bool has_runtime_pm;
+	data_t data = {};
+
+	igt_skip_on_simulation();
+	igt_subtest_init(argc, argv);
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
+		igt_require(data.debugfs_fd != -1);
+		kmstest_set_vt_graphics_mode();
+		data.devid = intel_get_drm_devid(data.drm_fd);
+		igt_pm_enable_sata_link_power_management();
+		has_runtime_pm = igt_setup_runtime_pm();
+		igt_info("Runtime PM support: %d\n", has_runtime_pm);
+		igt_require(has_runtime_pm);
+		igt_require(igt_pm_dmc_loaded(data.debugfs_fd));
+		igt_display_require(&data.display, data.drm_fd);
+		/* Make sure our Kernel supports MSR and the module is loaded. */
+		igt_require(igt_kmod_load("msr", NULL) == 0);
+
+		msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
+		igt_assert_f(msr_fd >= 0,
+			     "Can't open /dev/cpu/0/msr.\n");
+	}
+
+	igt_subtest("dc5-psr") {
+		data.op_psr_mode = PSR_MODE_1;
+		psr_enable(data.debugfs_fd, data.op_psr_mode);
+		igt_require_f(edp_psr_sink_support(&data),
+			      "Sink does not support PSR\n");
+		test_dc_state_psr(&data, CHECK_DC5);
+	}
+
+	igt_fixture {
+		close(data.debugfs_fd);
+		display_fini(&data);
+	}
+
+	igt_exit();
+}
diff --git a/tests/meson.build b/tests/meson.build
index 5167a6cc..f307cfb2 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -220,6 +220,7 @@ i915_progs = [
 	'i915_pm_lpsp',
 	'i915_pm_rc6_residency',
 	'i915_pm_rpm',
+	'i915_pm_dc',
 	'i915_pm_rps',
 	'i915_pm_sseu',
 	'i915_query',
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 3/6] tests/i915/i915_pm_dc: Added test for DC6 during PSR
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 2/6] tests/i915/i915_pm_dc: Added new test to verify Display C States Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS Anshuman Gupta
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

This patch add subtest to check DC6 entry on PSR for the supported
platforms.

v2: Rename the subtest with more meaningful name.
v3: Rebased.
v4: Rebased, to fix compilation error in psr_enable().
    Addressed review comment by fixing typo in comment description
    of DC6 PSR subtest.
v5: Addressed the review comment by removing redundant read_dc_counter(),
    clubbed cleanup() function in test_dc_state_psr() suggested by Imre.
    Listing actual change in patch set changelog to make review easier.
v6: Rebased due to test name pm_dc changed to i915_pm_dc, aligning to
    other PM tests.

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 tests/i915/i915_pm_dc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index 5d608337..ae2247f4 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -248,6 +248,16 @@ int main(int argc, char *argv[])
 		test_dc_state_psr(&data, CHECK_DC5);
 	}
 
+	igt_subtest("dc6-psr") {
+		data.op_psr_mode = PSR_MODE_1;
+		psr_enable(data.debugfs_fd, data.op_psr_mode);
+		igt_require_f(edp_psr_sink_support(&data),
+			      "Sink does not support PSR\n");
+		igt_require_f(supports_pc8_plus_residencies(),
+			      "PC8+ residencies not supported\n");
+		test_dc_state_psr(&data, CHECK_DC6);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
                   ` (2 preceding siblings ...)
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 3/6] tests/i915/i915_pm_dc: Added test for DC6 during PSR Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-08-12 12:11   ` Imre Deak
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 5/6] tests/i915/i915_pm_dc: Added test for DC6 " Anshuman Gupta
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

Added new subtest for DC5 entry during DPMS on/off cycle.
During DPMS on/off cycle DC5 counter is incremented.

v2: Rename the subtest with meaningful name.
v3: Rebased.
v4: Addressed review comments by removing leftover code
    cleanup().
v5: Addressed the review comment by removing redundant
    read_dc_counter() suggested by Imre.
    Listing actual change in patch set changelog to make review easier.
v6: Three way patch applied, no functional change.
v7: Disabling runtime suspend for the platform which support, DC9.
    rebased due to test name pm_dc changed to i915_pm_dc, aligning to
    other PM tests.
v8: Introduced setup_dc_dpms() in order to disable runtime pm, restoring
    POWER_DIR values to its original and enabling runtime pm  for other
    followed sub-tests.
v9: Check DC5 counter value after DPMS off, broke the dpms_on_off
    function to dpms_on and dpms_off. [Imre]

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 tests/i915/i915_pm_dc.c | 62 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index ae2247f4..5300d273 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -57,6 +57,7 @@ typedef struct {
 	enum psr_mode op_psr_mode;
 	drmModeModeInfo *mode;
 	igt_output_t *output;
+	bool runtime_suspend_disabled;
 } data_t;
 
 int msr_fd;
@@ -213,6 +214,62 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
 	cleanup(data);
 }
 
+static void setup_dc_dpms(data_t *data)
+{
+	if (IS_BROXTON(data->devid) || IS_GEMINILAKE(data->devid) ||
+		IS_ICELAKE(data->devid)) {
+		data->runtime_suspend_disabled = igt_disable_runtime_pm();
+		igt_require_f(data->runtime_suspend_disabled,
+			      "unable to disable runtime pm for i915\n");
+	} else {
+		data->runtime_suspend_disabled = false;
+	}
+}
+
+static void dpms_off(data_t *data)
+{
+	for (int i = 0; i < data->display.n_outputs; i++) {
+		kmstest_set_connector_dpms(data->drm_fd,
+					   data->display.outputs[i].config.connector,
+					   DRM_MODE_DPMS_OFF);
+	}
+
+	if (!data->runtime_suspend_disabled)
+		igt_assert(igt_wait_for_pm_status
+			   (IGT_RUNTIME_PM_STATUS_SUSPENDED));
+}
+
+static void dpms_on(data_t *data)
+{
+	for (int i = 0; i < data->display.n_outputs; i++) {
+		kmstest_set_connector_dpms(data->drm_fd,
+					   data->display.outputs[i].config.connector,
+					   DRM_MODE_DPMS_ON);
+	}
+
+	if (!data->runtime_suspend_disabled)
+		igt_assert(igt_wait_for_pm_status
+			   (IGT_RUNTIME_PM_STATUS_ACTIVE));
+}
+
+static void test_dc_state_dpms(data_t *data, int dc_flag)
+{
+	uint32_t dc_counter;
+
+	dc_counter = read_dc_counter(data->drm_fd, dc_flag);
+	dpms_off(data);
+	check_dc_counter(data->drm_fd, dc_flag, dc_counter);
+	dpms_on(data);
+
+	/* if runtime PM is disabled for i915 restore it,
+	 * so any other sub-test can use runtime-PM.
+	 */
+	if (data->runtime_suspend_disabled) {
+		igt_restore_runtime_pm();
+		igt_setup_runtime_pm();
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	bool has_runtime_pm;
@@ -258,6 +315,11 @@ int main(int argc, char *argv[])
 		test_dc_state_psr(&data, CHECK_DC6);
 	}
 
+	igt_subtest("dc5-dpms") {
+		setup_dc_dpms(&data);
+		test_dc_state_dpms(&data, CHECK_DC5);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 5/6] tests/i915/i915_pm_dc: Added test for DC6 during DPMS
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
                   ` (3 preceding siblings ...)
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 6/6] DO_NOT_MERGE: Debug patch to cover DC IGT test Anshuman Gupta
  2019-06-18 18:44 ` [igt-dev] ✓ Fi.CI.BAT: success for DEBUG DC states igt tests patch series Patchwork
  6 siblings, 0 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

From: Jyoti Yadav <jyoti.r.yadav@intel.com>

Added new subtest for DC6 entry during DPMS on/off cycle.
During DPMS on/off cycle DC6 counter is incremented.

v2: Renamed the subtest name.
v3: Rebased.
v4: Addressed review comment by replacing igt_display_init() to
    igt_display_require(), changes got done in patch set 2.
v5: Addressed the review comment by removing redundant read_dc_counter()
    suggested by Imre.
    Listing actual change in patch set changelog to make review easier.
v6: Rebased due to test name pm_dc changed to i915_pm_dc, aligning to
    other PM tests.
v7: Introduced setup_dc_dpms() inorder to disable i915 runtime PM for
    the platform supports DC9.

Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 tests/i915/i915_pm_dc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index 5300d273..576e32c7 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -320,6 +320,13 @@ int main(int argc, char *argv[])
 		test_dc_state_dpms(&data, CHECK_DC5);
 	}
 
+	igt_subtest("dc6-dpms") {
+		setup_dc_dpms(&data);
+		igt_require_f(supports_pc8_plus_residencies(),
+			      "PC8+ residencies not supported\n");
+		test_dc_state_dpms(&data, CHECK_DC6);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] [PATCH i-g-t 6/6] DO_NOT_MERGE: Debug patch to cover DC IGT test.
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
                   ` (4 preceding siblings ...)
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 5/6] tests/i915/i915_pm_dc: Added test for DC6 " Anshuman Gupta
@ 2019-06-18 17:56 ` Anshuman Gupta
  2019-06-18 18:44 ` [igt-dev] ✓ Fi.CI.BAT: success for DEBUG DC states igt tests patch series Patchwork
  6 siblings, 0 replies; 13+ messages in thread
From: Anshuman Gupta @ 2019-06-18 17:56 UTC (permalink / raw)
  To: igt-dev; +Cc: jyoti.r.yadav

This patch make sure DC state IGT patches run on CI Bat test.
This patch print package c state counter also.

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 tests/i915/i915_pm_dc.c               | 51 +++++++++++++++++++++++++++
 tests/intel-ci/fast-feedback.testlist |  4 +++
 2 files changed, 55 insertions(+)

diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index 576e32c7..c672e72e 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -61,6 +61,8 @@ typedef struct {
 } data_t;
 
 int msr_fd;
+int pmc_debugfs;
+bool pmc_loaded;
 
 bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
 void check_dc_counter(int drm_fd, int dc_flag, uint32_t prev_dc_count);
@@ -92,6 +94,49 @@ static bool supports_pc8_plus_residencies(void)
 	return true;
 }
 
+static bool setup_pmc(void)
+{
+	const char *debugfs_root;
+	char path[200];
+
+	/* Make sure our intel_pmc_core module is loaded. */
+	pmc_loaded = igt_kmod_is_loaded("intel_pmc_core");
+
+	if (!pmc_loaded)
+		pmc_loaded = igt_kmod_load("intel_pmc_core", NULL) == 0;
+
+	if (!pmc_loaded) {
+		igt_info("intel_pmc_core module not loaded\n");
+		return;
+	}
+
+	debugfs_root = igt_debugfs_mount();
+	igt_assert(debugfs_root);
+	snprintf(path, sizeof(path), "%s/pmc_core", debugfs_root);
+	pmc_debugfs = open(path, O_RDONLY);
+	igt_require(pmc_debugfs != -1);
+}
+
+static void dump_file(int dir, const char *filename)
+{
+	char *contents;
+
+	contents = igt_sysfs_get(dir, filename);
+	if (!contents)
+		return;
+
+	igt_info("%s:\n%s\n", filename, contents);
+	free(contents);
+}
+
+static void pmc_dump_file(int fd, const char *file)
+{
+	if (!pmc_loaded)
+		return;
+
+	dump_file(fd, file);
+}
+
 static void setup_output(data_t *data)
 {
 	igt_display_t *display = &data->display;
@@ -295,6 +340,9 @@ int main(int argc, char *argv[])
 		msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
 		igt_assert_f(msr_fd >= 0,
 			     "Can't open /dev/cpu/0/msr.\n");
+		setup_pmc();
+		igt_info("Initial PC state residencies before test\n");
+		pmc_dump_file(pmc_debugfs, "package_cstate_show");
 	}
 
 	igt_subtest("dc5-psr") {
@@ -328,7 +376,10 @@ int main(int argc, char *argv[])
 	}
 
 	igt_fixture {
+		igt_info("PC state residencies after test\n");
+		pmc_dump_file(pmc_debugfs, "package_cstate_show");
 		close(data.debugfs_fd);
+		close(pmc_debugfs);
 		display_fini(&data);
 	}
 
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 9b711946..f28c306d 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -229,6 +229,10 @@ igt@kms_setmode@basic-clone-single-crtc
 igt@i915_pm_backlight@basic-brightness
 igt@i915_pm_rpm@basic-pci-d3-state
 igt@i915_pm_rpm@basic-rte
+igt@i915_pm_dc@dc5-psr
+igt@i915_pm_dc@dc6-psr
+igt@i915_pm_dc@dc5-dpms
+igt@i915_pm_dc@dc6-dpms
 igt@i915_pm_rps@basic-api
 igt@prime_busy@basic-after-default
 igt@prime_busy@basic-before-default
-- 
2.21.0

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for DEBUG DC states igt tests patch series
  2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
                   ` (5 preceding siblings ...)
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 6/6] DO_NOT_MERGE: Debug patch to cover DC IGT test Anshuman Gupta
@ 2019-06-18 18:44 ` Patchwork
  6 siblings, 0 replies; 13+ messages in thread
From: Patchwork @ 2019-06-18 18:44 UTC (permalink / raw)
  To: Anshuman Gupta; +Cc: igt-dev

== Series Details ==

Series: DEBUG DC states igt tests patch series
URL   : https://patchwork.freedesktop.org/series/62332/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6297 -> IGTPW_3173
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/62332/revisions/1/mbox/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_3173:

### IGT changes ###

#### Possible regressions ####

  * {igt@i915_pm_dc@dc6-dpms} (NEW):
    - fi-skl-6600u:       NOTRUN -> [FAIL][1] +1 similar issue
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-skl-6600u/igt@i915_pm_dc@dc6-dpms.html
    - fi-kbl-7567u:       NOTRUN -> [FAIL][2]
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-kbl-7567u/igt@i915_pm_dc@dc6-dpms.html
    - fi-cfl-8109u:       NOTRUN -> [FAIL][3]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-cfl-8109u/igt@i915_pm_dc@dc6-dpms.html

  * {igt@i915_pm_dc@dc6-psr} (NEW):
    - fi-icl-u2:          NOTRUN -> [FAIL][4] +1 similar issue
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-u2/igt@i915_pm_dc@dc6-psr.html

  
New tests
---------

  New tests have been introduced between CI_DRM_6297 and IGTPW_3173:

### New IGT tests (4) ###

  * igt@i915_pm_dc@dc5-dpms:
    - Statuses : 13 pass(s) 23 skip(s)
    - Exec time: [0.0, 5.26] s

  * igt@i915_pm_dc@dc5-psr:
    - Statuses : 3 pass(s) 33 skip(s)
    - Exec time: [0.0, 3.36] s

  * igt@i915_pm_dc@dc6-dpms:
    - Statuses : 4 fail(s) 2 pass(s) 30 skip(s)
    - Exec time: [0.0, 7.47] s

  * igt@i915_pm_dc@dc6-psr:
    - Statuses : 2 fail(s) 1 pass(s) 33 skip(s)
    - Exec time: [0.0, 3.72] s

  

Known issues
------------

  Here are the changes found in IGTPW_3173 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_contexts:
    - fi-bdw-gvtdvm:      [PASS][5] -> [DMESG-FAIL][6] ([fdo#110235])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html

  * igt@kms_busy@basic-flip-a:
    - fi-icl-dsi:         [PASS][7] -> [DMESG-WARN][8] ([fdo#106107]) +1 similar issue
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-dsi/igt@kms_busy@basic-flip-a.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-dsi/igt@kms_busy@basic-flip-a.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-icl-u3:          [PASS][9] -> [FAIL][10] ([fdo#103167])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-u3/igt@kms_frontbuffer_tracking@basic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-u3/igt@kms_frontbuffer_tracking@basic.html

  
#### Possible fixes ####

  * igt@debugfs_test@read_all_entries:
    - fi-icl-u3:          [DMESG-WARN][11] ([fdo#107724]) -> [PASS][12] +1 similar issue
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-u3/igt@debugfs_test@read_all_entries.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-u3/igt@debugfs_test@read_all_entries.html

  * igt@gem_ctx_switch@basic-default:
    - fi-icl-guc:         [INCOMPLETE][13] ([fdo#107713] / [fdo#108569]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-guc/igt@gem_ctx_switch@basic-default.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-guc/igt@gem_ctx_switch@basic-default.html

  * igt@gem_sync@basic-store-each:
    - fi-bdw-5557u:       [FAIL][15] -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-bdw-5557u/igt@gem_sync@basic-store-each.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-bdw-5557u/igt@gem_sync@basic-store-each.html

  * igt@i915_selftest@live_hangcheck:
    - fi-icl-dsi:         [INCOMPLETE][17] ([fdo#107713] / [fdo#108569]) -> [PASS][18]
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-dsi/igt@i915_selftest@live_hangcheck.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-dsi/igt@i915_selftest@live_hangcheck.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-icl-u2:          [FAIL][19] ([fdo#103167]) -> [PASS][20]
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6297/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235


Participating hosts (44 -> 37)
------------------------------

  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * IGT: IGT_5059 -> IGTPW_3173

  CI_DRM_6297: 8ebd162995143d1cc5c3ec699891e7fe059cea4c @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_3173: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/
  IGT_5059: 1f67ee0d09d6513f487f2be74aae9700e755258a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@i915_pm_dc@dc5-dpms
+igt@i915_pm_dc@dc5-psr
+igt@i915_pm_dc@dc6-dpms
+igt@i915_pm_dc@dc6-psr

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3173/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta
@ 2019-08-12 12:04   ` Imre Deak
  0 siblings, 0 replies; 13+ messages in thread
From: Imre Deak @ 2019-08-12 12:04 UTC (permalink / raw)
  To: Anshuman Gupta; +Cc: igt-dev, jyoti.r.yadav

On Tue, Jun 18, 2019 at 11:26:12PM +0530, Anshuman Gupta wrote:
> From: Jyoti Yadav <jyoti.r.yadav@intel.com>
> 
> This patch does the following chnegs to lib/igt_pm.c
> 
> -dmc_loaded() will be used by new test i915_pm_dc.c which will validate
>  Display C States. So moving the same to igt_pm library.
> 
> -Introduced igt_disable_runtime_pm() in order to disable runtime suspend
>  for the function which support dc9.
> 
> -Changed the igt_pm_enable_sata_link_power_management() and
>  igt_pm_restore_sata_link_power_management() in order to save
>  and restore the sata link power policy by an exit handler.
> 
> v2: Simplify the comment section.
> v3: Remove . from the subject line.
> v4: Rebased, resolve conflicts in pm_rpm.c
>     Included patch set version change log.
> v5: Listing actual change in patch set changelog to make review easier.
> v6: igt's lib added support for disabling runtime suspend,
>     change in commit log. rebased due to test name pm_rpm changed
>     to i915_pm_rpm.
> v7: Addressed review comment by saving POWER_DIR values in
>     igt_disable_runtime_pm(). [Imre]
> v8: Addressed the review comment, igt_pm_enable_sata_link_power_management
>     function to restore the original SATA link power policy if things fail
>     by using an exit handler. [Imre]
> v9: IGT failure fixture in i915_pm_backlight and i915_pm_rpm.
> 
> Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> ---
>  lib/igt_pm.c                   | 190 ++++++++++++++++++++++++++-------
>  lib/igt_pm.h                   |   6 +-
>  tests/i915/i915_pm_backlight.c |   6 +-
>  tests/i915/i915_pm_rpm.c       |  24 +----
>  4 files changed, 159 insertions(+), 67 deletions(-)
> 
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index fd22273a..9b83fbb5 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -38,6 +38,7 @@
>  #include "drmtest.h"
>  #include "igt_pm.h"
>  #include "igt_aux.h"
> +#include "igt_sysfs.h"
>  
>  /**
>   * SECTION:igt_pm
> @@ -63,11 +64,15 @@ enum {
>  #define MIN_POWER_STR		"min_power\n"
>  /* Remember to fix this if adding longer strings */
>  #define MAX_POLICY_STRLEN	strlen(MAX_PERFORMANCE_STR)
> +int8_t *__sata_link_pm_policies;
>  
>  static char __igt_pm_audio_runtime_power_save[64];
>  static char * __igt_pm_audio_runtime_control_path;
>  static char __igt_pm_audio_runtime_control[64];
>  
> +static void __igt_pm_sata_link_pm_exit_handler(int sig);
> +static void __igt_pm_restore_sata_link_power_management(void);
> +
>  static int __igt_pm_audio_restore_runtime_pm(void)
>  {
>  	int fd;
> @@ -280,28 +285,12 @@ void igt_pm_enable_audio_runtime_pm(void)
>  		igt_debug("Failed to enable audio runtime PM! (%d)\n", -err);
>  }
>  
> -/**
> - * igt_pm_enable_sata_link_power_management:
> - *
> - * Enable the min_power policy for SATA link power management.
> - * Without this we cannot reach deep runtime power states.
> - *
> - * We don't have any assertions on open since the system might not have
> - * a SATA host.
> - *
> - * Returns:
> - * An opaque pointer to the data needed to restore the default values
> - * after the test has terminated, or NULL if SATA link power management
> - * is not supported. This pointer should be freed when no longer used
> - * (typically after having called restore_sata_link_power_management()).
> - */
> -int8_t *igt_pm_enable_sata_link_power_management(void)
> +static void __igt_pm_enable_sata_link_power_management(void)
>  {
>  	int fd, i;
>  	ssize_t len;
>  	char *buf;
>  	char *file_name;
> -	int8_t *link_pm_policies = NULL;
>  
>  	file_name = malloc(PATH_MAX);
>  	buf = malloc(MAX_POLICY_STRLEN + 1);
> @@ -313,6 +302,9 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
>  			 "/sys/class/scsi_host/host%d/link_power_management_policy",
>  			 i);
>  
> +		/* We don't have any assertions on open since the system
> +		 * might not have a SATA host.
> +		 */
>  		fd = open(file_name, O_RDWR);
>  		if (fd < 0)
>  			break;
> @@ -333,11 +325,13 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
>  			policy = POLICY_UNKNOWN;
>  
>  		if (!(i % 256))
> -			link_pm_policies = realloc(link_pm_policies,
> -						   (i / 256 + 1) * 256 + 1);
> +			__sata_link_pm_policies =
> +			realloc(__sata_link_pm_policies,
> +				(i / 256 + 1) * 256 + 1);

Missing indentation.

>  
> -		link_pm_policies[i] = policy;
> -		link_pm_policies[i + 1] = 0;

Not added by this patch, but can't see the purpose of this 0
termination.

> +		__sata_link_pm_policies[i] = policy;
> +		__sata_link_pm_policies[i + 1] = 0;
> +		igt_install_exit_handler(__igt_pm_sata_link_pm_exit_handler);

This would restore uninitialized values to subsequent SATA hosts, if
some failure would happen before the loop ends. So I'd rather:

	for (sata_host_count = 0; ; sata_host_count++)
		save the link policiy

	install exit handler

	for (i = 0; i < sata_host_count; i++)
		set link policy to min power

>  
>  		/* If the policy is something we don't know about,
>  		 * don't touch it, since we might potentially break things.
> @@ -355,39 +349,27 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
>  	}
>  	free(buf);
>  	free(file_name);
> -
> -	return link_pm_policies;
>  }
>  
> -/**
> - * igt_pm_restore_sata_link_power_management:
> - * @pm_data: An opaque pointer with saved link PM policies;
> - *           If NULL is passed we force enable the "max_performance" policy.
> - *
> - * Restore the link power management policies to the values
> - * prior to enabling min_power.
> - *
> - * Caveat: If the system supports hotplugging and hotplugging takes
> - *         place during our testing so that the hosts change numbers
> - *         we might restore the settings to the wrong hosts.
> - */
> -void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
> -
> +static void __igt_pm_restore_sata_link_power_management(void)
>  {
>  	int fd, i;
>  	char *file_name;
>  
> +	if (!__sata_link_pm_policies)
> +		return;
> +
>  	/* Disk runtime PM policies. */
>  	file_name = malloc(PATH_MAX);
>  	for (i = 0; ; i++) {
>  		int8_t policy;
>  
> -		if (!pm_data)
> +		if (!__sata_link_pm_policies)

This can't happen now.

>  			policy = POLICY_MAX_PERFORMANCE;
> -		else if (pm_data[i] == POLICY_UNKNOWN)
> +		else if (__sata_link_pm_policies[i] == POLICY_UNKNOWN)
>  			continue;
>  		else
> -			policy = pm_data[i];
> +			policy = __sata_link_pm_policies[i];
>  
>  		snprintf(file_name, PATH_MAX,
>  			 "/sys/class/scsi_host/host%d/link_power_management_policy",
> @@ -421,7 +403,53 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
>  		close(fd);
>  	}
>  	free(file_name);
> +	free(__sata_link_pm_policies);
> +	__sata_link_pm_policies = NULL;
> +}
> +
> +/**
> + * igt_pm_enable_sata_link_power_management:
> + *
> + * Enable the min_power policy for SATA link power management.
> + * Without this we cannot reach deep runtime power states.
> + * Returns: Void
> + */
> +void igt_pm_enable_sata_link_power_management(void)
> +{
> +	int err;

Unused var.

> +
> +	/* Check if has been already saved. */
> +	if (__sata_link_pm_policies)
> +		return;
> +
> +	 __igt_pm_enable_sata_link_power_management();
> +}
> +
> +/**
> + * igt_pm_restore_sata_link_power_management:
> + *
> + * Restore the link power management policies to the values
> + * prior to enabling min_power.
> + *
> + * Caveat: If the system supports hotplugging and hotplugging takes
> + *         place during our testing so that the hosts change numbers
> + *         we might restore the settings to the wrong hosts.
> + */
> +void igt_pm_restore_sata_link_power_management(void)
> +{
> +	int err;

Ditto.

> +
> +	if (!__sata_link_pm_policies)
> +		return;
> +
> +	 __igt_pm_restore_sata_link_power_management();
>  }
> +
> +static void __igt_pm_sata_link_pm_exit_handler(int sig)
> +{
> +	__igt_pm_restore_sata_link_power_management();
> +}
> +
>  #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power"
>  /* We just leak this on exit ... */
>  int pm_status_fd = -1;
> @@ -585,6 +613,61 @@ bool igt_setup_runtime_pm(void)
>  	return true;
>  }
>  
> +bool igt_disable_runtime_pm(void)
> +{
> +	int fd;
> +	ssize_t size;
> +	char buf[6];
> +
> +	if (pm_status_fd < 0) {
> +		fd = open(POWER_DIR "/autosuspend_delay_ms", O_RDWR);
> +		if (fd < 0)
> +			return false;
> +
> +		size = read(fd, __igt_pm_runtime_autosuspend,
> +			    sizeof(__igt_pm_runtime_autosuspend));
> +
> +		if (size <= 0) {
> +			close(fd);
> +			return false;
> +		}
> +
> +		strchomp(__igt_pm_runtime_autosuspend);
> +		igt_install_exit_handler(__igt_pm_runtime_exit_handler);
> +		close(fd);
> +	}
> +
> +	/* We know we support runtime PM, let's try to disable it now. */
> +	fd = open(POWER_DIR "/control", O_RDWR);
> +	igt_assert_f(fd >= 0, "Can't open " POWER_DIR "/control\n");
> +
> +	if (pm_status_fd < 0) {
> +		igt_assert(read(fd, __igt_pm_runtime_control,
> +				sizeof(__igt_pm_runtime_control)) > 0);
> +		strchomp(__igt_pm_runtime_control);
> +
> +		igt_debug("Saved runtime power management as '%s' and '%s'\n",
> +			  __igt_pm_runtime_autosuspend,
> +			  __igt_pm_runtime_control);
> +	}
> +
> +	size = write(fd, "on\n", 3);
> +	igt_assert(size == 3);
> +	lseek(fd, 0, SEEK_SET);
> +	size = read(fd, buf, ARRAY_SIZE(buf));
> +	igt_assert(size == 3);
> +	igt_assert(strncmp(buf, "on\n", 3) == 0);
> +	close(fd);
> +
> +	if (pm_status_fd < 0) {
> +		pm_status_fd = open(POWER_DIR "/runtime_status", O_RDONLY);
> +		igt_assert_f(pm_status_fd >= 0,
> +			     "Can't open " POWER_DIR "/runtime_status\n");
> +	}
> +
> +	return true;
> +}
> +
>  /**
>   * igt_get_runtime_pm_status:
>   *
> @@ -628,3 +711,30 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status)
>  {
>  	return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100);
>  }
> +
> +/**
> + * dmc_loaded:
> + * @debugfs: fd to the debugfs dir.
> +
> + * Check whether DMC FW is loaded or not. DMC FW is require for few Display C
> + * states like DC5 and DC6. FW does the Context Save and Restore during Display
> + * C States entry and exit.
> + *
> + * Returns:
> + * True if DMC FW is loaded otherwise false.
> + */
> +bool igt_pm_dmc_loaded(int debugfs)
> +{
> +	igt_require(debugfs != -1);

This is misplaced and probably not needed.

> +	char buf[15];
> +	int len;
> +
> +	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
> +	if (len < 0)
> +		return true; /* no CSR support, no DMC requirement */
> +
> +	buf[len] = '\0';
> +
> +	igt_info("DMC: %s\n", buf);
> +	return strstr(buf, "fw loaded: yes");
> +}
> diff --git a/lib/igt_pm.h b/lib/igt_pm.h
> index 10cc6794..979b3463 100644
> --- a/lib/igt_pm.h
> +++ b/lib/igt_pm.h
> @@ -25,8 +25,8 @@
>  #define IGT_PM_H
>  
>  void igt_pm_enable_audio_runtime_pm(void);
> -int8_t *igt_pm_enable_sata_link_power_management(void);
> -void igt_pm_restore_sata_link_power_management(int8_t *pm_data);
> +void igt_pm_enable_sata_link_power_management(void);
> +void igt_pm_restore_sata_link_power_management(void);
>  
>  /**
>   * igt_runtime_pm_status:
> @@ -47,8 +47,10 @@ enum igt_runtime_pm_status {
>  };
>  
>  bool igt_setup_runtime_pm(void);
> +bool igt_disable_runtime_pm(void);
>  void igt_restore_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_pm_dmc_loaded(int debugfs);
>  
>  #endif /* IGT_PM_H */
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c
> index 4c1bff5b..9a5f4c37 100644
> --- a/tests/i915/i915_pm_backlight.c
> +++ b/tests/i915/i915_pm_backlight.c
> @@ -47,7 +47,6 @@ struct context {
>  #define FADESPEED 100 /* milliseconds between steps */
>  
>  IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
> -static int8_t *pm_data = NULL;
>  
>  static int backlight_read(int *result, const char *fname)
>  {
> @@ -235,7 +234,7 @@ igt_main
>  		igt_plane_set_fb(primary, &fb);
>  
>  		igt_display_commit2(&display, display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
> -		pm_data = igt_pm_enable_sata_link_power_management();
> +		igt_pm_enable_sata_link_power_management();
>  	}
>  
>  	igt_subtest("basic-brightness")
> @@ -255,8 +254,7 @@ igt_main
>  
>  		igt_display_fini(&display);
>  		igt_remove_fb(display.drm_fd, &fb);
> -		igt_pm_restore_sata_link_power_management(pm_data);
> -		free(pm_data);
> +		igt_pm_restore_sata_link_power_management();
>  		close(display.drm_fd);
>  	}
>  }
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
> index a2c9d0ed..2d2f77be 100644
> --- a/tests/i915/i915_pm_rpm.c
> +++ b/tests/i915/i915_pm_rpm.c
> @@ -122,8 +122,6 @@ struct modeset_params lpsp_mode_params;
>  struct modeset_params non_lpsp_mode_params;
>  struct modeset_params *default_mode_params;
>  
> -static int8_t *pm_data = NULL;
> -
>  static int modprobe(const char *driver)
>  {
>  	return igt_kmod_load(driver, NULL);
> @@ -710,21 +708,6 @@ static void setup_pc8(void)
>  	has_pc8 = true;
>  }
>  
> -static bool dmc_loaded(void)
> -{
> -	char buf[15];
> -	int len;
> -
> -	len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
> -	if (len < 0)
> -	    return true; /* no CSR support, no DMC requirement */
> -
> -	buf[len] = '\0';
> -
> -	igt_info("DMC: %s\n", buf);
> -	return strstr(buf, "fw loaded: yes");
> -}
> -
>  static void dump_file(int dir, const char *filename)
>  {
>  	char *contents;
> @@ -751,7 +734,7 @@ static bool setup_environment(void)
>  
>  	init_mode_set_data(&ms_data);
>  
> -	pm_data = igt_pm_enable_sata_link_power_management();
> +	igt_pm_enable_sata_link_power_management();
>  
>  	has_runtime_pm = igt_setup_runtime_pm();
>  	setup_pc8();
> @@ -759,7 +742,7 @@ static bool setup_environment(void)
>  	igt_info("Runtime PM support: %d\n", has_runtime_pm);
>  	igt_info("PC8 residency support: %d\n", has_pc8);
>  	igt_require(has_runtime_pm);
> -	igt_require(dmc_loaded());
> +	igt_require(igt_pm_dmc_loaded(debugfs));
>  
>  out:
>  	disable_all_screens(&ms_data);
> @@ -776,8 +759,7 @@ static void teardown_environment(void)
>  
>  	igt_restore_runtime_pm();
>  
> -	igt_pm_restore_sata_link_power_management(pm_data);
> -	free(pm_data);
> +	igt_pm_restore_sata_link_power_management();
>  
>  	fini_mode_set_data(&ms_data);
>  
> -- 
> 2.21.0
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS
  2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS Anshuman Gupta
@ 2019-08-12 12:11   ` Imre Deak
  2019-08-12 12:38     ` Gupta, Anshuman
  0 siblings, 1 reply; 13+ messages in thread
From: Imre Deak @ 2019-08-12 12:11 UTC (permalink / raw)
  To: Anshuman Gupta; +Cc: igt-dev, jyoti.r.yadav

On Tue, Jun 18, 2019 at 11:26:15PM +0530, Anshuman Gupta wrote:
> From: Jyoti Yadav <jyoti.r.yadav@intel.com>
> 
> Added new subtest for DC5 entry during DPMS on/off cycle.
> During DPMS on/off cycle DC5 counter is incremented.
> 
> v2: Rename the subtest with meaningful name.
> v3: Rebased.
> v4: Addressed review comments by removing leftover code
>     cleanup().
> v5: Addressed the review comment by removing redundant
>     read_dc_counter() suggested by Imre.
>     Listing actual change in patch set changelog to make review easier.
> v6: Three way patch applied, no functional change.
> v7: Disabling runtime suspend for the platform which support, DC9.
>     rebased due to test name pm_dc changed to i915_pm_dc, aligning to
>     other PM tests.
> v8: Introduced setup_dc_dpms() in order to disable runtime pm, restoring
>     POWER_DIR values to its original and enabling runtime pm  for other
>     followed sub-tests.
> v9: Check DC5 counter value after DPMS off, broke the dpms_on_off
>     function to dpms_on and dpms_off. [Imre]
> 
> Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> ---
>  tests/i915/i915_pm_dc.c | 62 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
> 
> diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
> index ae2247f4..5300d273 100644
> --- a/tests/i915/i915_pm_dc.c
> +++ b/tests/i915/i915_pm_dc.c
> @@ -57,6 +57,7 @@ typedef struct {
>  	enum psr_mode op_psr_mode;
>  	drmModeModeInfo *mode;
>  	igt_output_t *output;
> +	bool runtime_suspend_disabled;
>  } data_t;
>  
>  int msr_fd;
> @@ -213,6 +214,62 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
>  	cleanup(data);
>  }
>  
> +static void setup_dc_dpms(data_t *data)
> +{
> +	if (IS_BROXTON(data->devid) || IS_GEMINILAKE(data->devid) ||
> +		IS_ICELAKE(data->devid)) {

IS_BXT || IS_GLK || intel_gen() >= 11, so that it works correctly on
later GENs too?

> +		data->runtime_suspend_disabled = igt_disable_runtime_pm();
> +		igt_require_f(data->runtime_suspend_disabled,
> +			      "unable to disable runtime pm for i915\n");
> +	} else {
> +		data->runtime_suspend_disabled = false;
> +	}
> +}
> +
> +static void dpms_off(data_t *data)
> +{
> +	for (int i = 0; i < data->display.n_outputs; i++) {
> +		kmstest_set_connector_dpms(data->drm_fd,
> +					   data->display.outputs[i].config.connector,
> +					   DRM_MODE_DPMS_OFF);
> +	}
> +
> +	if (!data->runtime_suspend_disabled)
> +		igt_assert(igt_wait_for_pm_status
> +			   (IGT_RUNTIME_PM_STATUS_SUSPENDED));
> +}
> +
> +static void dpms_on(data_t *data)
> +{
> +	for (int i = 0; i < data->display.n_outputs; i++) {
> +		kmstest_set_connector_dpms(data->drm_fd,
> +					   data->display.outputs[i].config.connector,
> +					   DRM_MODE_DPMS_ON);
> +	}
> +
> +	if (!data->runtime_suspend_disabled)
> +		igt_assert(igt_wait_for_pm_status
> +			   (IGT_RUNTIME_PM_STATUS_ACTIVE));
> +}
> +
> +static void test_dc_state_dpms(data_t *data, int dc_flag)
> +{
> +	uint32_t dc_counter;
> +
> +	dc_counter = read_dc_counter(data->drm_fd, dc_flag);
> +	dpms_off(data);
> +	check_dc_counter(data->drm_fd, dc_flag, dc_counter);
> +	dpms_on(data);
> +
> +	/* if runtime PM is disabled for i915 restore it,
> +	 * so any other sub-test can use runtime-PM.
> +	 */
> +	if (data->runtime_suspend_disabled) {
> +		igt_restore_runtime_pm();
> +		igt_setup_runtime_pm();
> +	}
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  	bool has_runtime_pm;
> @@ -258,6 +315,11 @@ int main(int argc, char *argv[])
>  		test_dc_state_psr(&data, CHECK_DC6);
>  	}
>  
> +	igt_subtest("dc5-dpms") {
> +		setup_dc_dpms(&data);
> +		test_dc_state_dpms(&data, CHECK_DC5);
> +	}
> +
>  	igt_fixture {
>  		close(data.debugfs_fd);
>  		display_fini(&data);
> -- 
> 2.21.0
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS
  2019-08-12 12:11   ` Imre Deak
@ 2019-08-12 12:38     ` Gupta, Anshuman
  2019-08-12 12:43       ` Imre Deak
  0 siblings, 1 reply; 13+ messages in thread
From: Gupta, Anshuman @ 2019-08-12 12:38 UTC (permalink / raw)
  To: imre.deak; +Cc: igt-dev, jyoti.r.yadav

Hi Imre,

Thanks for review comments.
I have one comment below,
On 8/12/2019 5:41 PM, Imre Deak wrote:
> On Tue, Jun 18, 2019 at 11:26:15PM +0530, Anshuman Gupta wrote:
>> From: Jyoti Yadav <jyoti.r.yadav@intel.com>
>>
>> Added new subtest for DC5 entry during DPMS on/off cycle.
>> During DPMS on/off cycle DC5 counter is incremented.
>>
>> v2: Rename the subtest with meaningful name.
>> v3: Rebased.
>> v4: Addressed review comments by removing leftover code
>>      cleanup().
>> v5: Addressed the review comment by removing redundant
>>      read_dc_counter() suggested by Imre.
>>      Listing actual change in patch set changelog to make review easier.
>> v6: Three way patch applied, no functional change.
>> v7: Disabling runtime suspend for the platform which support, DC9.
>>      rebased due to test name pm_dc changed to i915_pm_dc, aligning to
>>      other PM tests.
>> v8: Introduced setup_dc_dpms() in order to disable runtime pm, restoring
>>      POWER_DIR values to its original and enabling runtime pm  for other
>>      followed sub-tests.
>> v9: Check DC5 counter value after DPMS off, broke the dpms_on_off
>>      function to dpms_on and dpms_off. [Imre]
>>
>> Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
>> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
>> ---
>>   tests/i915/i915_pm_dc.c | 62 +++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 62 insertions(+)
>>
>> diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
>> index ae2247f4..5300d273 100644
>> --- a/tests/i915/i915_pm_dc.c
>> +++ b/tests/i915/i915_pm_dc.c
>> @@ -57,6 +57,7 @@ typedef struct {
>>   	enum psr_mode op_psr_mode;
>>   	drmModeModeInfo *mode;
>>   	igt_output_t *output;
>> +	bool runtime_suspend_disabled;
>>   } data_t;
>>   
>>   int msr_fd;
>> @@ -213,6 +214,62 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
>>   	cleanup(data);
>>   }
>>   
>> +static void setup_dc_dpms(data_t *data)
>> +{
>> +	if (IS_BROXTON(data->devid) || IS_GEMINILAKE(data->devid) ||
>> +		IS_ICELAKE(data->devid)) {
> 
> IS_BXT || IS_GLK || intel_gen() >= 11, so that it works correctly on
> later GENs too?
TGL onward we have DMC_DEBUG registers, DMC_DEBUG1 for DC5 and 
DMC_DEBUG2 for DC6 BSpecs:49786, i believe they will retain there values
upon DC9, I will confirm once again with DMC folks.

Thanks ,
Anshuman.
> 
>> +		data->runtime_suspend_disabled = igt_disable_runtime_pm();
>> +		igt_require_f(data->runtime_suspend_disabled,
>> +			      "unable to disable runtime pm for i915\n");
>> +	} else {
>> +		data->runtime_suspend_disabled = false;
>> +	}
>> +}
>> +
>> +static void dpms_off(data_t *data)
>> +{
>> +	for (int i = 0; i < data->display.n_outputs; i++) {
>> +		kmstest_set_connector_dpms(data->drm_fd,
>> +					   data->display.outputs[i].config.connector,
>> +					   DRM_MODE_DPMS_OFF);
>> +	}
>> +
>> +	if (!data->runtime_suspend_disabled)
>> +		igt_assert(igt_wait_for_pm_status
>> +			   (IGT_RUNTIME_PM_STATUS_SUSPENDED));
>> +}
>> +
>> +static void dpms_on(data_t *data)
>> +{
>> +	for (int i = 0; i < data->display.n_outputs; i++) {
>> +		kmstest_set_connector_dpms(data->drm_fd,
>> +					   data->display.outputs[i].config.connector,
>> +					   DRM_MODE_DPMS_ON);
>> +	}
>> +
>> +	if (!data->runtime_suspend_disabled)
>> +		igt_assert(igt_wait_for_pm_status
>> +			   (IGT_RUNTIME_PM_STATUS_ACTIVE));
>> +}
>> +
>> +static void test_dc_state_dpms(data_t *data, int dc_flag)
>> +{
>> +	uint32_t dc_counter;
>> +
>> +	dc_counter = read_dc_counter(data->drm_fd, dc_flag);
>> +	dpms_off(data);
>> +	check_dc_counter(data->drm_fd, dc_flag, dc_counter);
>> +	dpms_on(data);
>> +
>> +	/* if runtime PM is disabled for i915 restore it,
>> +	 * so any other sub-test can use runtime-PM.
>> +	 */
>> +	if (data->runtime_suspend_disabled) {
>> +		igt_restore_runtime_pm();
>> +		igt_setup_runtime_pm();
>> +	}
>> +}
>> +
>>   int main(int argc, char *argv[])
>>   {
>>   	bool has_runtime_pm;
>> @@ -258,6 +315,11 @@ int main(int argc, char *argv[])
>>   		test_dc_state_psr(&data, CHECK_DC6);
>>   	}
>>   
>> +	igt_subtest("dc5-dpms") {
>> +		setup_dc_dpms(&data);
>> +		test_dc_state_dpms(&data, CHECK_DC5);
>> +	}
>> +
>>   	igt_fixture {
>>   		close(data.debugfs_fd);
>>   		display_fini(&data);
>> -- 
>> 2.21.0
>>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS
  2019-08-12 12:38     ` Gupta, Anshuman
@ 2019-08-12 12:43       ` Imre Deak
  0 siblings, 0 replies; 13+ messages in thread
From: Imre Deak @ 2019-08-12 12:43 UTC (permalink / raw)
  To: Gupta, Anshuman; +Cc: igt-dev, jyoti.r.yadav

On Mon, Aug 12, 2019 at 06:08:16PM +0530, Gupta, Anshuman wrote:
> Hi Imre,
> 
> Thanks for review comments.
> I have one comment below,
> On 8/12/2019 5:41 PM, Imre Deak wrote:
> > On Tue, Jun 18, 2019 at 11:26:15PM +0530, Anshuman Gupta wrote:
> > > From: Jyoti Yadav <jyoti.r.yadav@intel.com>
> > > 
> > > Added new subtest for DC5 entry during DPMS on/off cycle.
> > > During DPMS on/off cycle DC5 counter is incremented.
> > > 
> > > v2: Rename the subtest with meaningful name.
> > > v3: Rebased.
> > > v4: Addressed review comments by removing leftover code
> > >      cleanup().
> > > v5: Addressed the review comment by removing redundant
> > >      read_dc_counter() suggested by Imre.
> > >      Listing actual change in patch set changelog to make review easier.
> > > v6: Three way patch applied, no functional change.
> > > v7: Disabling runtime suspend for the platform which support, DC9.
> > >      rebased due to test name pm_dc changed to i915_pm_dc, aligning to
> > >      other PM tests.
> > > v8: Introduced setup_dc_dpms() in order to disable runtime pm, restoring
> > >      POWER_DIR values to its original and enabling runtime pm  for other
> > >      followed sub-tests.
> > > v9: Check DC5 counter value after DPMS off, broke the dpms_on_off
> > >      function to dpms_on and dpms_off. [Imre]
> > > 
> > > Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
> > > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > > ---
> > >   tests/i915/i915_pm_dc.c | 62 +++++++++++++++++++++++++++++++++++++++++
> > >   1 file changed, 62 insertions(+)
> > > 
> > > diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
> > > index ae2247f4..5300d273 100644
> > > --- a/tests/i915/i915_pm_dc.c
> > > +++ b/tests/i915/i915_pm_dc.c
> > > @@ -57,6 +57,7 @@ typedef struct {
> > >   	enum psr_mode op_psr_mode;
> > >   	drmModeModeInfo *mode;
> > >   	igt_output_t *output;
> > > +	bool runtime_suspend_disabled;
> > >   } data_t;
> > >   int msr_fd;
> > > @@ -213,6 +214,62 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
> > >   	cleanup(data);
> > >   }
> > > +static void setup_dc_dpms(data_t *data)
> > > +{
> > > +	if (IS_BROXTON(data->devid) || IS_GEMINILAKE(data->devid) ||
> > > +		IS_ICELAKE(data->devid)) {
> > 
> > IS_BXT || IS_GLK || intel_gen() >= 11, so that it works correctly on
> > later GENs too?
> TGL onward we have DMC_DEBUG registers, DMC_DEBUG1 for DC5 and DMC_DEBUG2
> for DC6 BSpecs:49786, i believe they will retain there values
> upon DC9, I will confirm once again with DMC folks.

And even if the counters retain their value is it also guaranteed that
there will be a ->DC6 transition before ->DC9 would happen?

If you clarify these it would be good to add a comment here too.

> 
> Thanks ,
> Anshuman.
> > 
> > > +		data->runtime_suspend_disabled = igt_disable_runtime_pm();
> > > +		igt_require_f(data->runtime_suspend_disabled,
> > > +			      "unable to disable runtime pm for i915\n");
> > > +	} else {
> > > +		data->runtime_suspend_disabled = false;
> > > +	}
> > > +}
> > > +
> > > +static void dpms_off(data_t *data)
> > > +{
> > > +	for (int i = 0; i < data->display.n_outputs; i++) {
> > > +		kmstest_set_connector_dpms(data->drm_fd,
> > > +					   data->display.outputs[i].config.connector,
> > > +					   DRM_MODE_DPMS_OFF);
> > > +	}
> > > +
> > > +	if (!data->runtime_suspend_disabled)
> > > +		igt_assert(igt_wait_for_pm_status
> > > +			   (IGT_RUNTIME_PM_STATUS_SUSPENDED));
> > > +}
> > > +
> > > +static void dpms_on(data_t *data)
> > > +{
> > > +	for (int i = 0; i < data->display.n_outputs; i++) {
> > > +		kmstest_set_connector_dpms(data->drm_fd,
> > > +					   data->display.outputs[i].config.connector,
> > > +					   DRM_MODE_DPMS_ON);
> > > +	}
> > > +
> > > +	if (!data->runtime_suspend_disabled)
> > > +		igt_assert(igt_wait_for_pm_status
> > > +			   (IGT_RUNTIME_PM_STATUS_ACTIVE));
> > > +}
> > > +
> > > +static void test_dc_state_dpms(data_t *data, int dc_flag)
> > > +{
> > > +	uint32_t dc_counter;
> > > +
> > > +	dc_counter = read_dc_counter(data->drm_fd, dc_flag);
> > > +	dpms_off(data);
> > > +	check_dc_counter(data->drm_fd, dc_flag, dc_counter);
> > > +	dpms_on(data);
> > > +
> > > +	/* if runtime PM is disabled for i915 restore it,
> > > +	 * so any other sub-test can use runtime-PM.
> > > +	 */
> > > +	if (data->runtime_suspend_disabled) {
> > > +		igt_restore_runtime_pm();
> > > +		igt_setup_runtime_pm();
> > > +	}
> > > +}
> > > +
> > >   int main(int argc, char *argv[])
> > >   {
> > >   	bool has_runtime_pm;
> > > @@ -258,6 +315,11 @@ int main(int argc, char *argv[])
> > >   		test_dc_state_psr(&data, CHECK_DC6);
> > >   	}
> > > +	igt_subtest("dc5-dpms") {
> > > +		setup_dc_dpms(&data);
> > > +		test_dc_state_dpms(&data, CHECK_DC5);
> > > +	}
> > > +
> > >   	igt_fixture {
> > >   		close(data.debugfs_fd);
> > >   		display_fini(&data);
> > > -- 
> > > 2.21.0
> > > 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-08-12 12:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-18 17:56 [igt-dev] [PATCH i-g-t 0/6] DEBUG DC states igt tests patch series Anshuman Gupta
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta
2019-08-12 12:04   ` Imre Deak
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 2/6] tests/i915/i915_pm_dc: Added new test to verify Display C States Anshuman Gupta
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 3/6] tests/i915/i915_pm_dc: Added test for DC6 during PSR Anshuman Gupta
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 4/6] tests/i915/i915_pm_dc: Added test for DC5 during DPMS Anshuman Gupta
2019-08-12 12:11   ` Imre Deak
2019-08-12 12:38     ` Gupta, Anshuman
2019-08-12 12:43       ` Imre Deak
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 5/6] tests/i915/i915_pm_dc: Added test for DC6 " Anshuman Gupta
2019-06-18 17:56 ` [igt-dev] [PATCH i-g-t 6/6] DO_NOT_MERGE: Debug patch to cover DC IGT test Anshuman Gupta
2019-06-18 18:44 ` [igt-dev] ✓ Fi.CI.BAT: success for DEBUG DC states igt tests patch series Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2019-06-13 10:47 [igt-dev] [PATCH i-g-t 0/6] " Anshuman Gupta
2019-06-13 10:47 ` [igt-dev] [PATCH i-g-t 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests Anshuman Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox