Skip to contentSkip to conversation

DC states igt tests patch series

PATCH Superseded Anshuman Gupta 3 participants 12 messages Sep 1, 2019 – Sep 3, 2019 1 message not in the archive Library code

v13 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v13 cover DC states igt tests patch series

This is v13 of patch series, after rebasing all patches. There are few minor review comment fixes for 0001 and 0004 patchset of this series.

Anshuman Gupta (1):
tests/i915/i915_pm_dc:Skip the DC6 test if BIOS has disabled PC8+

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                   | 188 +++++++++++++-----
 lib/igt_pm.h                   |   6 +-
 tests/Makefile.sources         |   3 +
 tests/i915/i915_pm_backlight.c |   6 +-
 tests/i915/i915_pm_dc.c        | 345 +++++++++++++++++++++++++++++++++
 tests/i915/i915_pm_rpm.c       |  24 +--
 tests/meson.build              |   1 +
 7 files changed, 499 insertions(+), 74 deletions(-)
 create mode 100644 tests/i915/i915_pm_dc.c
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH v13 1/6 lib/igt_pm: igt lib helper routines to support DC5/6 tests

From: Jyoti Yadav <[email protected]>

This patch does the following changes 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. v10:Review comment fixup in sata_link_power_management
lib functions. [Imre]
v11:Add igt_assert_fd(pm_status_fd) in igt_disable_runtime_pm().
[Imre & Petri]

---
 lib/igt_pm.c                   | 188 ++++++++++++++++++++++++---------
 lib/igt_pm.h                   |   6 +-
 tests/i915/i915_pm_backlight.c |   6 +-
 tests/i915/i915_pm_rpm.c       |  24 +----
 4 files changed, 150 insertions(+), 74 deletions(-)
lib/igt_pm.c +141 -47
index fd22273a..dd5022fc 100644
@@ -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,16 @@ 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_pm_policies;
+int __scsi_host_cnt;
 
 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,39 +286,26 @@ 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;
+	int8_t policy;
 
 	file_name = malloc(PATH_MAX);
 	buf = malloc(MAX_POLICY_STRLEN + 1);
 
-	for (i = 0; ; i++) {
-		int8_t policy;
-
+	for (__scsi_host_cnt = 0; ; __scsi_host_cnt++) {
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
-			 i);
+			 __scsi_host_cnt);
 
+		/*
+		 * 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;
@@ -332,12 +325,26 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 		else
 			policy = POLICY_UNKNOWN;
 
-		if (!(i % 256))
-			link_pm_policies = realloc(link_pm_policies,
-						   (i / 256 + 1) * 256 + 1);
+		if (!(__scsi_host_cnt % 256))
+			__sata_pm_policies = realloc(__sata_pm_policies,
+						     (__scsi_host_cnt / 256 + 1)
+						     * 256 + 1);
+
+		__sata_pm_policies[__scsi_host_cnt] = policy;
+		close(fd);
+	}
 
-		link_pm_policies[i] = policy;
-		link_pm_policies[i + 1] = 0;
+	igt_install_exit_handler(__igt_pm_sata_link_pm_exit_handler);
+
+	for (i = 0; i < __scsi_host_cnt; i++) {
+		snprintf(file_name, PATH_MAX,
+			 "/sys/class/scsi_host/host%d/link_power_management_policy",
+			 i);
+		fd = open(file_name, O_RDWR);
+		if (fd < 0)
+			break;
+
+		policy = __sata_pm_policies[i];
 
 		/* If the policy is something we don't know about,
 		 * don't touch it, since we might potentially break things.
@@ -355,39 +362,25 @@ 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_pm_policies)
+		return;
+
 	/* Disk runtime PM policies. */
 	file_name = malloc(PATH_MAX);
-	for (i = 0; ; i++) {
+	for (i = 0; i < __scsi_host_cnt; i++) {
 		int8_t policy;
 
-		if (!pm_data)
-			policy = POLICY_MAX_PERFORMANCE;
-		else if (pm_data[i] == POLICY_UNKNOWN)
+		if (__sata_pm_policies[i] == POLICY_UNKNOWN)
 			continue;
 		else
-			policy = pm_data[i];
+			policy = __sata_pm_policies[i];
 
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
@@ -421,7 +414,49 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
 		close(fd);
 	}
 	free(file_name);
+	free(__sata_pm_policies);
+	__sata_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)
+{
+	/* Check if has been already saved. */
+	if (__sata_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)
+{
+	if (!__sata_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 +620,39 @@ bool igt_setup_runtime_pm(void)
 	return true;
 }
 
+/**
+ * igt_disable_runtime_pm:
+ *
+ * Disable the runtime pm for i915 device.
+ * igt_disable_runtime_pm assumes that igt_setup_runtime_pm has already
+ * called to save runtime autosuspend and control attributes.
+ *
+ * Returns:
+ * True if runtime pm is disabled, false otherwise.
+ */
+bool igt_disable_runtime_pm(void)
+{
+	int fd;
+	ssize_t size;
+	char buf[6];
+
+	igt_assert_fd(pm_status_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");
+
+	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);
+
+	return true;
+}
+
 /**
  * igt_get_runtime_pm_status:
  *
@@ -628,3 +696,29 @@ 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)
+{
+	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");
+}
lib/igt_pm.h +4 -2
index 10cc6794..979b3463 100644
@@ -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 */
tests/i915/i915_pm_backlight.c +2 -4
index 4c1bff5b..9a5f4c37 100644
@@ -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);
 	}
 }
tests/i915/i915_pm_rpm.c +3 -21
index 2168ff72..6879c513 100644
@@ -123,8 +123,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);
@@ -755,21 +753,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;
@@ -796,7 +779,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();
@@ -804,7 +787,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);
@@ -821,8 +804,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);
 
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v13 1/6] lib/igt_pm: igt lib helper routines to support DC5/6 tests

Quoted 202 lines · Anshuman Gupta

From: Jyoti Yadav <[email protected]>

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

(quoted diff) +0 -3
-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. v10:Review comment fixup in sata_link_power_management
lib functions. [Imre]
v11:Add igt_assert_fd(pm_status_fd) in igt_disable_runtime_pm().
[Imre & Petri]

---
 lib/igt_pm.c                   | 188 ++++++++++++++++++++++++---------
 lib/igt_pm.h                   |   6 +-
 tests/i915/i915_pm_backlight.c |   6 +-
 tests/i915/i915_pm_rpm.c       |  24 +----
 4 files changed, 150 insertions(+), 74 deletions(-)
lib/igt_pm.c +40 -47
index fd22273a..dd5022fc 100644
@@ -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,16 @@ 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_pm_policies;
+int __scsi_host_cnt;
 
 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,39 +286,26 @@ 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;
+	int8_t policy;
 
 	file_name = malloc(PATH_MAX);
 	buf = malloc(MAX_POLICY_STRLEN + 1);
 
-	for (i = 0; ; i++) {
-		int8_t policy;
-
+	for (__scsi_host_cnt = 0; ; __scsi_host_cnt++) {
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
-			 i);
+			 __scsi_host_cnt);
 
+		/*
+		 * 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;
@@ -332,12 +325,26 @@ int8_t *igt_pm_enable_sata_link_power_management(void)
 		else
 			policy = POLICY_UNKNOWN;
 
-		if (!(i % 256))
-			link_pm_policies = realloc(link_pm_policies,
-						   (i / 256 + 1) * 256 + 1);
+		if (!(__scsi_host_cnt % 256))
+			__sata_pm_policies = realloc(__sata_pm_policies,
+						     (__scsi_host_cnt / 256 + 1)
+						     * 256 + 1);
+
+		__sata_pm_policies[__scsi_host_cnt] = policy;
+		close(fd);
+	}
 
-		link_pm_policies[i] = policy;
-		link_pm_policies[i + 1] = 0;
+	igt_install_exit_handler(__igt_pm_sata_link_pm_exit_handler);
+
+	for (i = 0; i < __scsi_host_cnt; i++) {
+		snprintf(file_name, PATH_MAX,
+			 "/sys/class/scsi_host/host%d/link_power_management_policy",
+			 i);
+		fd = open(file_name, O_RDWR);
+		if (fd < 0)
+			break;
+
+		policy = __sata_pm_policies[i];
 
 		/* If the policy is something we don't know about,
 		 * don't touch it, since we might potentially break things.
@@ -355,39 +362,25 @@ 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_pm_policies)
+		return;
+
 	/* Disk runtime PM policies. */
 	file_name = malloc(PATH_MAX);
-	for (i = 0; ; i++) {
+	for (i = 0; i < __scsi_host_cnt; i++) {
 		int8_t policy;
 
-		if (!pm_data)
-			policy = POLICY_MAX_PERFORMANCE;
-		else if (pm_data[i] == POLICY_UNKNOWN)
+		if (__sata_pm_policies[i] == POLICY_UNKNOWN)
 			continue;
 		else
-			policy = pm_data[i];
+			policy = __sata_pm_policies[i];
 
 		snprintf(file_name, PATH_MAX,
 			 "/sys/class/scsi_host/host%d/link_power_management_policy",
@@ -421,7 +414,49 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data)
 		close(fd);
 	}
 	free(file_name);

lib/igt_pm.c void igt_pm_restore_sata_link_power_management(int8_t *pm_data) · line 426

Quoted 10 lines
lib/igt_pm.c +10 -0
+	free(__sata_pm_policies);
+	__sata_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

No need to state that nothing is returned.

Quoted 39 lines
lib/igt_pm.c +32 -0
+ */
+void igt_pm_enable_sata_link_power_management(void)
+{
+	/* Check if has been already saved. */
+	if (__sata_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)
+{
+	if (!__sata_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 +620,39 @@ bool igt_setup_runtime_pm(void)
 	return true;
 }

lib/igt_pm.c bool igt_setup_runtime_pm(void) · line 631

Quoted 10 lines
lib/igt_pm.c +9 -0
 
+/**
+ * igt_disable_runtime_pm:
+ *
+ * Disable the runtime pm for i915 device.
+ * igt_disable_runtime_pm assumes that igt_setup_runtime_pm has already
+ * called to save runtime autosuspend and control attributes.
+ *
+ * Returns:
+ * True if runtime pm is disabled, false otherwise.

This became stale now, please also make it a void fn() accordingly.

Quoted 180 lines
lib/igt_pm.c +50 -0
+ */
+bool igt_disable_runtime_pm(void)
+{
+	int fd;
+	ssize_t size;
+	char buf[6];
+
+	igt_assert_fd(pm_status_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");
+
+	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);
+
+	return true;
+}
+
 /**
  * igt_get_runtime_pm_status:
  *
@@ -628,3 +696,29 @@ 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)
+{
+	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");
+}
lib/igt_pm.h +4 -2
index 10cc6794..979b3463 100644
@@ -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 */
tests/i915/i915_pm_backlight.c +2 -4
index 4c1bff5b..9a5f4c37 100644
@@ -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);
 	}
 }
tests/i915/i915_pm_rpm.c +3 -21
index 2168ff72..6879c513 100644
@@ -123,8 +123,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);
@@ -755,21 +753,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;
@@ -796,7 +779,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();
@@ -804,7 +787,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);
@@ -821,8 +804,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);
 
Signature · 1 line
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

PATCH v13 3/6 tests/i915/i915_pm_dc: Added test for DC6 during PSR

In reply to Anshuman Gupta

From: Jyoti Yadav <[email protected]>

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.

---
 tests/i915/i915_pm_dc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/i915/i915_pm_dc.c +8 -0
index 10e4efbd..033c4f0e 100644
@@ -202,6 +202,14 @@ 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");
+		test_dc_state_psr(&data, CHECK_DC6);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

PATCH v13 4/6 tests/i915/i915_pm_dc: Added test for DC5 during DPMS

In reply to Anshuman Gupta

From: Jyoti Yadav <[email protected]>

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]
v10:Added AT_LEAST_Gen11 condition instead of IS_ICELAKE in order to
disable runtime suspend. [Imre]
v11:Added a cleanup_dc_dpms() function. [Imre]

---
 tests/i915/i915_pm_dc.c | 67 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
tests/i915/i915_pm_dc.c +67 -0
index 033c4f0e..20b6cde6 100644
@@ -46,6 +46,7 @@ typedef struct {
 	enum psr_mode op_psr_mode;
 	drmModeModeInfo *mode;
 	igt_output_t *output;
+	bool runtime_suspend_disabled;
 } data_t;
 
 static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
@@ -173,6 +174,68 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
 	cleanup_dc_psr(data);
 }
 
+static void cleanup_dc_dpms(data_t *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();
+	}
+}
+
+static void setup_dc_dpms(data_t *data)
+{
+	if (IS_BROXTON(data->devid) || IS_GEMINILAKE(data->devid) ||
+	    AT_LEAST_GEN(data->devid, 11)) {
+		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;
+
+	setup_dc_dpms(data);
+	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);
+	cleanup_dc_dpms(data);
+}
+
 int main(int argc, char *argv[])
 {
 	bool has_runtime_pm;
@@ -210,6 +273,10 @@ int main(int argc, char *argv[])
 		test_dc_state_psr(&data, CHECK_DC6);
 	}
 
+	igt_subtest("dc5-dpms") {
+		test_dc_state_dpms(&data, CHECK_DC5);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#5 lore raw

PATCH v13 5/6 tests/i915/i915_pm_dc: Added test for DC6 during DPMS

In reply to Anshuman Gupta

From: Jyoti Yadav <[email protected]>

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.

---
 tests/i915/i915_pm_dc.c | 4 ++++
 1 file changed, 4 insertions(+)
tests/i915/i915_pm_dc.c +4 -0
index 20b6cde6..4c7e152a 100644
@@ -277,6 +277,10 @@ int main(int argc, char *argv[])
 		test_dc_state_dpms(&data, CHECK_DC5);
 	}
 
+	igt_subtest("dc6-dpms") {
+		test_dc_state_dpms(&data, CHECK_DC6);
+	}
+
 	igt_fixture {
 		close(data.debugfs_fd);
 		display_fini(&data);
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#6 lore raw

PATCH v13 6/6 tests/i915/i915_pm_dc:Skip the DC6 test if BIOS has disabled PC8+

In reply to Anshuman Gupta

As DC6 requires platform to enter PC8 package C state. It make sense to skip the DC6 igt-test, if BIOS configuration has disabled PC8+ package C states.

---
 tests/i915/i915_pm_dc.c | 55 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
tests/i915/i915_pm_dc.c +55 -0
index 4c7e152a..0b29599b 100644
@@ -26,19 +26,35 @@
 #include "igt_sysfs.h"
 #include "igt_psr.h"
 #include <errno.h>
+#include <fcntl.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.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
+/*
+ * Below PKG CST limit mask and PC8 bits are meant for
+ * HSW,BDW SKL,ICL and Goldmont Microarch and future platforms.
+ * Refer IA S/W developers manual vol3c part3 chapter:35
+ */
+#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 msr_fd;
 	int debugfs_fd;
 	uint32_t devid;
 	igt_display_t display;
@@ -52,6 +68,34 @@ typedef struct {
 static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
 static 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(data_t *data)
+{
+	int rc;
+	uint64_t val;
+	int msr_fd = data->msr_fd;
+
+	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;
@@ -255,6 +299,12 @@ int main(int argc, char *argv[])
 		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);
+
+		data.msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
+		igt_assert_f(data.msr_fd >= 0,
+			     "Can't open /dev/cpu/0/msr.\n");
 	}
 
 	igt_subtest("dc5-psr") {
@@ -270,6 +320,8 @@ int main(int argc, char *argv[])
 		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(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_psr(&data, CHECK_DC6);
 	}
 
@@ -278,11 +330,14 @@ int main(int argc, char *argv[])
 	}
 
 	igt_subtest("dc6-dpms") {
+		igt_require_f(supports_pc8_plus_residencies(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
 	igt_fixture {
 		close(data.debugfs_fd);
+		close(data.msr_fd);
 		display_fini(&data);
 	}
 
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#7 lore raw

Re: [igt-dev] [PATCH i-g-t v13 6/6] tests/i915/i915_pm_dc:Skip the DC6 test if BIOS has disabled PC8+

Quoted 70 lines · Anshuman Gupta

As DC6 requires platform to enter PC8 package C state. It make sense to skip the DC6 igt-test, if BIOS configuration has disabled PC8+ package C states.

---
 tests/i915/i915_pm_dc.c | 55 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
tests/i915/i915_pm_dc.c +33 -0
index 4c7e152a..0b29599b 100644
@@ -26,19 +26,35 @@
 #include "igt_sysfs.h"
 #include "igt_psr.h"
 #include <errno.h>
+#include <fcntl.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.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
+/*
+ * Below PKG CST limit mask and PC8 bits are meant for
+ * HSW,BDW SKL,ICL and Goldmont Microarch and future platforms.
+ * Refer IA S/W developers manual vol3c part3 chapter:35
+ */
+#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 msr_fd;
 	int debugfs_fd;
 	uint32_t devid;
 	igt_display_t display;
@@ -52,6 +68,34 @@ typedef struct {
 static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
 static 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(data_t *data)
+{
+	int rc;
+	uint64_t val;
+	int msr_fd = data->msr_fd;
+
+	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;
+

tests/i915/i915_pm_dc.c typedef struct { · line 97

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+	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;
+}

I missed it last time, but this is a copy/paste from i915_pm_rpm, so please factor it out instead into a lib function.

Quoted 44 lines
tests/i915/i915_pm_dc.c +12 -0
+
 static void setup_output(data_t *data)
 {
 	igt_display_t *display = &data->display;
@@ -255,6 +299,12 @@ int main(int argc, char *argv[])
 		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);
+
+		data.msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
+		igt_assert_f(data.msr_fd >= 0,
+			     "Can't open /dev/cpu/0/msr.\n");
 	}
 
 	igt_subtest("dc5-psr") {
@@ -270,6 +320,8 @@ int main(int argc, char *argv[])
 		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(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_psr(&data, CHECK_DC6);
 	}
 
@@ -278,11 +330,14 @@ int main(int argc, char *argv[])
 	}
 
 	igt_subtest("dc6-dpms") {
+		igt_require_f(supports_pc8_plus_residencies(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
 	igt_fixture {
 		close(data.debugfs_fd);
+		close(data.msr_fd);
 		display_fini(&data);
 	}
 
Signature · 1 line
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#8 lore raw

Re: [igt-dev] [PATCH i-g-t v13 6/6] tests/i915/i915_pm_dc:Skip the DC6 test if BIOS has disabled PC8+

Quoted 76 lines · Imre Deak
Quoted 75 lines · Anshuman Gupta

As DC6 requires platform to enter PC8 package C state. It make sense to skip the DC6 igt-test, if BIOS configuration has disabled PC8+ package C states.

---
 tests/i915/i915_pm_dc.c | 55 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
tests/i915/i915_pm_dc.c +38 -0
index 4c7e152a..0b29599b 100644
@@ -26,19 +26,35 @@
 #include "igt_sysfs.h"
 #include "igt_psr.h"
 #include <errno.h>
+#include <fcntl.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.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
+/*
+ * Below PKG CST limit mask and PC8 bits are meant for
+ * HSW,BDW SKL,ICL and Goldmont Microarch and future platforms.
+ * Refer IA S/W developers manual vol3c part3 chapter:35
+ */
+#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 msr_fd;
 	int debugfs_fd;
 	uint32_t devid;
 	igt_display_t display;
@@ -52,6 +68,34 @@ typedef struct {
 static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
 static 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(data_t *data)
+{
+	int rc;
+	uint64_t val;
+	int msr_fd = data->msr_fd;
+
+	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");
Quoted 8 lines

tests/i915/i915_pm_dc.c typedef struct { · line 97

Quoted 5 lines
tests/i915/i915_pm_dc.c +5 -0
+		return false;
+	}
+
+	return true;
+}

I missed it last time, but this is a copy/paste from i915_pm_rpm, so please factor it out instead into a lib function.

msr_fd is spread pretty sparse in i915_pm_rpm, passing it to a lib function doesn't sounds good, can we take it in a seperate patch, rather then this series?

Quoted 42 lines
Quoted 42 lines
tests/i915/i915_pm_dc.c +12 -0
+
 static void setup_output(data_t *data)
 {
 	igt_display_t *display = &data->display;
@@ -255,6 +299,12 @@ int main(int argc, char *argv[])
 		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);
+
+		data.msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
+		igt_assert_f(data.msr_fd >= 0,
+			     "Can't open /dev/cpu/0/msr.\n");
 	}
 
 	igt_subtest("dc5-psr") {
@@ -270,6 +320,8 @@ int main(int argc, char *argv[])
 		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(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_psr(&data, CHECK_DC6);
 	}
 
@@ -278,11 +330,14 @@ int main(int argc, char *argv[])
 	}
 
 	igt_subtest("dc6-dpms") {
+		igt_require_f(supports_pc8_plus_residencies(&data),
+			      "PC8+ residencies not supported\n");
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
 	igt_fixture {
 		close(data.debugfs_fd);
+		close(data.msr_fd);
 		display_fini(&data);
 	}
 
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#9 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for DC states igt tests patch series (rev18)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: DC states igt tests patch series (rev18)
URL : https://patchwork.freedesktop.org/series/56713/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6817 -> IGTPW_3408
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56713/revisions/18/mbox/

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

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

### IGT changes ###

#### Issues hit ####

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][1] -> [DMESG-WARN][2] ([fdo#102614])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/fi-hsw-peppy/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/fi-hsw-peppy/igt@[email protected]

#### Possible fixes ####

* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: [DMESG-WARN][3] ([fdo#106387]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/fi-ilk-650/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/fi-ilk-650/igt@[email protected]

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

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#106387]: https://bugs.freedesktop.org/show_bug.cgi?id=106387

Participating hosts (51 -> 44)
------------------------------

Additional (1): fi-apl-guc
Missing (8): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

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

* CI: CI-20190529 -> None
* IGT: IGT_5162 -> IGTPW_3408

CI-20190529: 20190529
CI_DRM_6817: 8ae00727917ce047fc0db5672769f70c6eaa314e @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3408: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/
IGT_5162: e62ea305fdba2a9cd0dadfa527b54529cb0d1438 @ 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_3408/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#10 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for DC states igt tests patch series (rev18)

In reply to Anshuman Gupta
== Series Details ==

== Series Details ==

Series: DC states igt tests patch series (rev18)
URL : https://patchwork.freedesktop.org/series/56713/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6817_full -> IGTPW_3408_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56713/revisions/18/mbox/

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

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

### IGT changes ###

#### Possible regressions ####

* {igt@i915_pm_dc@dc6-dpms} (NEW):
- shard-kbl: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-kbl4/igt@[email protected]

New tests
---------

New tests have been introduced between CI_DRM_6817_full and IGTPW_3408_full:

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

* igt@i915_pm_dc@dc5-dpms:
- Statuses : 3 pass(s) 2 skip(s)
- Exec time: [0.0, 2.28] s

* igt@i915_pm_dc@dc5-psr:
- Statuses : 1 pass(s) 5 skip(s)
- Exec time: [0.0, 3.40] s

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

* igt@i915_pm_dc@dc6-psr:
- Statuses : 1 pass(s) 5 skip(s)
- Exec time: [0.0, 3.38] s

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_bad_reloc@negative-reloc-bsd2:
- shard-iclb: [PASS][2] -> [SKIP][3] ([fdo#109276]) +16 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb2/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb5/igt@[email protected]

* igt@gem_exec_balancer@smoke:
- shard-iclb: [PASS][4] -> [SKIP][5] ([fdo#110854])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb2/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb5/igt@[email protected]

* igt@gem_exec_schedule@deep-bsd:
- shard-iclb: [PASS][6] -> [SKIP][7] ([fdo#111325]) +4 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb5/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb1/igt@[email protected]

* igt@i915_selftest@live_hangcheck:
- shard-iclb: [PASS][8] -> [INCOMPLETE][9] ([fdo#107713] / [fdo#108569])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb1/igt@i915_selftest@live_hangcheck.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb5/igt@i915_selftest@live_hangcheck.html

* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
- shard-glk: [PASS][10] -> [FAIL][11] ([fdo#105363]) +1 similar issue
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-glk5/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-glk7/igt@[email protected]

* igt@kms_flip@2x-modeset-vs-vblank-race-interruptible:
- shard-glk: [PASS][12] -> [FAIL][13] ([fdo#103060])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-glk9/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-glk3/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-suspend:
- shard-apl: [PASS][14] -> [DMESG-WARN][15] ([fdo#108566]) +3 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-apl1/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-apl7/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-pwrite:
- shard-iclb: [PASS][16] -> [FAIL][17] ([fdo#103167]) +1 similar issue
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb3/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-pwrite.html
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-pwrite.html

* igt@kms_psr@psr2_sprite_render:
- shard-iclb: [PASS][18] -> [SKIP][19] ([fdo#109441]) +1 similar issue
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb2/igt@kms_psr@psr2_sprite_render.html
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb4/igt@kms_psr@psr2_sprite_render.html

* igt@kms_setmode@basic:
- shard-apl: [PASS][20] -> [FAIL][21] ([fdo#99912])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-apl2/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-apl4/igt@[email protected]

* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-kbl: [PASS][22] -> [INCOMPLETE][23] ([fdo#103665])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-kbl1/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-kbl6/igt@[email protected]

#### Possible fixes ####

* igt@gem_exec_parallel@contexts:
- shard-iclb: [INCOMPLETE][24] ([fdo#107713]) -> [PASS][25] +1 similar issue
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb5/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb7/igt@[email protected]

* igt@gem_exec_schedule@preempt-other-bsd1:
- shard-iclb: [SKIP][26] ([fdo#109276]) -> [PASS][27] +12 similar issues
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb7/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb1/igt@[email protected]

* igt@gem_exec_schedule@preempt-other-chain-bsd:
- shard-iclb: [SKIP][28] ([fdo#111325]) -> [PASS][29] +5 similar issues
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb1/igt@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb6/igt@[email protected]

* igt@i915_pm_rpm@gem-execbuf-stress:
- shard-apl: [INCOMPLETE][30] ([fdo#103927]) -> [PASS][31]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-apl1/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-apl4/igt@[email protected]

* igt@i915_pm_rpm@system-suspend-modeset:
- shard-iclb: [INCOMPLETE][32] ([fdo#107713] / [fdo#108840]) -> [PASS][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb2/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb4/igt@[email protected]

* igt@kms_flip@flip-vs-panning-vs-hang-interruptible:
- shard-kbl: [INCOMPLETE][34] ([fdo#103665]) -> [PASS][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-kbl7/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-kbl4/igt@[email protected]

* igt@kms_flip@flip-vs-suspend:
- shard-apl: [DMESG-WARN][36] ([fdo#108566]) -> [PASS][37] +1 similar issue
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-apl7/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-apl3/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-blt:
- shard-iclb: [FAIL][38] ([fdo#103167]) -> [PASS][39] +3 similar issues
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb8/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb3/igt@[email protected]

* igt@kms_plane_lowres@pipe-a-tiling-x:
- shard-iclb: [FAIL][40] ([fdo#103166]) -> [PASS][41]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb4/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb8/igt@[email protected]

* igt@kms_psr@psr2_cursor_mmap_cpu:
- shard-iclb: [SKIP][42] ([fdo#109441]) -> [PASS][43] +1 similar issue
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb8/igt@kms_psr@psr2_cursor_mmap_cpu.html
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html

* igt@kms_setmode@basic:
- shard-hsw: [FAIL][44] ([fdo#99912]) -> [PASS][45]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-hsw4/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-hsw1/igt@[email protected]

#### Warnings ####

* igt@gem_ctx_isolation@vcs1-nonpriv:
- shard-iclb: [SKIP][46] ([fdo#109276]) -> [FAIL][47] ([fdo#111329])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb3/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb4/igt@[email protected]

* igt@gem_mocs_settings@mocs-settings-bsd2:
- shard-iclb: [FAIL][48] ([fdo#111330]) -> [SKIP][49] ([fdo#109276])
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6817/shard-iclb4/igt@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/shard-iclb5/igt@[email protected]

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

[fdo#103060]: https://bugs.freedesktop.org/show_bug.cgi?id=103060
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#110854]: https://bugs.freedesktop.org/show_bug.cgi?id=110854
[fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
[fdo#111329]: https://bugs.freedesktop.org/show_bug.cgi?id=111329
[fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (10 -> 6)
------------------------------

Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005

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

* CI: CI-20190529 -> None
* IGT: IGT_5162 -> IGTPW_3408
* Piglit: piglit_4509 -> None

CI-20190529: 20190529
CI_DRM_6817: 8ae00727917ce047fc0db5672769f70c6eaa314e @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3408: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/
IGT_5162: e62ea305fdba2a9cd0dadfa527b54529cb0d1438 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3408/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Re: [igt-dev] [PATCH i-g-t v13 2/6] tests/i915/i915_pm_dc: Added new test to verify Display C States

Quoted 84 lines · Anshuman Gupta

From: Jyoti Yadav <[email protected]>

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: Removed redundant igt_pm_remove_sata_link_power_management()
as sata link policy values will be restored by exit handler.
v10: changed cleanup() to cleanup_dc_psr() symmetric to cleanup_dc_dpms().

---
 tests/Makefile.sources  |   3 +
 tests/i915/i915_pm_dc.c | 211 ++++++++++++++++++++++++++++++++++++++++
 tests/meson.build       |   1 +
 3 files changed, 215 insertions(+)
 create mode 100644 tests/i915/i915_pm_dc.c
tests/Makefile.sources +3 -0
index c02e4d94..ebaf75f8 100644
@@ -507,6 +507,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
 
tests/i915/i915_pm_dc.c new file +23 -0
new file mode 100644
index 00000000..10e4efbd
@@ -0,0 +1,211 @@
+/*
+ * 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.
+ *
+ */

tests/i915/i915_pm_dc.c line 33

Quoted 10 lines
tests/i915/i915_pm_dc.c new file +10 -0
+
+#include "igt.h"
+#include "igt_sysfs.h"
+#include "igt_psr.h"
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include "intel_bufmgr.h"
+#include "intel_io.h"

The above 2 includes seem unnecessary. Please also group and sort them like:

#include <a.h>
#include <b.h>

#include "a.h"
#include "b.h"

Quoted 193 lines
tests/i915/i915_pm_dc.c new file +178 -0
+#include "limits.h"
+
+/* DC State Flags */
+#define CHECK_DC5	1
+#define CHECK_DC6	2
+
+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;
+
+static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
+static void check_dc_counter(int drm_fd, int dc_flag, uint32_t prev_dc_count);
+
+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_dc_psr(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);
+}
+
+static 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);
+}
+
+static 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_dc_psr(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);
+	}
+
+	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();
+}
tests/meson.build +1 -0
index a7b2b322..f85deba1 100644
@@ -230,6 +230,7 @@ i915_progs = [
 	'i915_pm_lpsp',
 	'i915_pm_rc6_residency',
 	'i915_pm_rpm',
+	'i915_pm_dc',
 	'i915_pm_rps',
 	'i915_pm_sseu',
 	'i915_query',
Signature · 1 line
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev