Skip to contentSkip to conversation

tests/i915/i915_pm_dc: Add new dc9 test

PATCH Superseded Swati Sharma 5 participants 10 messages Aug 23, 2022 – Sep 5, 2022 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/i915/i915_pm_dc: Add new dc9 test

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9.
Existing test will be restricted to igfx only. Also, changed debugfs entry to check if platform is dgfx or igfx.

---
 lib/igt_pm.c            | 25 ++++++++++++++++++++++---
 lib/igt_pm.h            |  1 +
 tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c +22 -3
index 6ebbad330..6c99eaff9 100644
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
 	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
 		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+
 	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
 	return fd;
 }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool power_attr)
 {
 	int size;
 
 	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {
 		if (size < 0 && errno == EIO)
 			return false;
 	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
 		igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
 	}
 }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+	return time;
+}
lib/igt_pm.h +1 -0
index f28b6ebfd..ca1db7440 100644
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
 void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
 void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +34 -5
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
 #include "igt_kmod.h"
 #include "igt_psr.h"
 #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
 #include "limits.h"
 #include "time.h"
+#include "igt_pm.h"
 
 /* DC State Flags */
 #define CHECK_DC5	(1 << 0)
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
 {
 	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
 				buf, sizeof(buf));
 	return strstr(buf, "is_dgfx: yes");
 }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
 	dpms_on(data);
 }
 
+static void check_dc9_runtime_suspend_time(data_t *data)
+{
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}
+
 static void test_dc9_dpms(data_t *data)
 {
 	int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");
 	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-			igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");
+	igt_subtest("dc9-dpms-igfx") {
+		igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
+			      "PC8+ residencies not supported\n");
 		test_dc9_dpms(&data);
 	}
 
Signature · 1 line
2.25.1
#1 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/i915/i915_pm_dc: Add new dc9 test

== Series Details ==

== Series Details ==

Series: tests/i915/i915_pm_dc: Add new dc9 test
URL : https://patchwork.freedesktop.org/series/107629/
State : failure

== Summary ==

Applying: tests/i915/i915_pm_dc: Add new dc9 test
Using index info to reconstruct a base tree...
M lib/igt_pm.c
M lib/igt_pm.h
Falling back to patching base and 3-way merge... Auto-merging lib/igt_pm.h
CONFLICT (content): Merge conflict in lib/igt_pm.h Auto-merging lib/igt_pm.c
CONFLICT (content): Merge conflict in lib/igt_pm.c
Patch failed at 0001 tests/i915/i915_pm_dc: Add new dc9 test When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

#2 lore raw
In reply to Swati Sharma
Quoted 125 lines · Swati Sharma

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9.
Existing test will be restricted to igfx only. Also, changed debugfs entry to check if platform is dgfx or igfx.

---
 lib/igt_pm.c            | 25 ++++++++++++++++++++++---
 lib/igt_pm.h            |  1 +
 tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c +22 -3
index 6ebbad330..6c99eaff9 100644
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
 	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
 		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+
 	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
 	return fd;
 }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool power_attr)
 {
 	int size;
 
 	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {
 		if (size < 0 && errno == EIO)
 			return false;
 	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
 		igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
 	}
 }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+	return time;
+}
lib/igt_pm.h +1 -0
index f28b6ebfd..ca1db7440 100644
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
 void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
 void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +21 -1
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
 #include "igt_kmod.h"
 #include "igt_psr.h"
 #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
 #include "limits.h"
 #include "time.h"
+#include "igt_pm.h"
 
 /* DC State Flags */
 #define CHECK_DC5	(1 << 0)
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
 {
 	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
 				buf, sizeof(buf));
 	return strstr(buf, "is_dgfx: yes");
 }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
 	dpms_on(data);
 }
 
+static void check_dc9_runtime_suspend_time(data_t *data)
+{
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}
+
 static void test_dc9_dpms(data_t *data)
 {
 	int dc_target;

tests/i915/i915_pm_dc.c int main(int argc, char *argv[]) · line 563

Quoted 6 lines
tests/i915/i915_pm_dc.c +2 -1
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");

This will produce

DC9 statefor both

       ^^^^

tests/i915/i915_pm_dc.c int main(int argc, char *argv[]) · line 572

Quoted 12 lines
tests/i915/i915_pm_dc.c +8 -3
 	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-			igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");

Same here,

DC9 stateonly for

      ^^^^^
Signature · 1 line
Petri Latvala
Quoted 9 lines
tests/i915/i915_pm_dc.c +3 -0
+	igt_subtest("dc9-dpms-igfx") {
+		igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
+			      "PC8+ residencies not supported\n");
 		test_dc9_dpms(&data);
 	}
 
Signature · 1 line
2.25.1
#3 lore raw

Thanks Petri! Will fix in next rev.

Quoted 157 lines · Petri Latvala
Quoted 125 lines · Swati Sharma

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9.
Existing test will be restricted to igfx only. Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
  3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c +22 -3
index 6ebbad330..6c99eaff9 100644
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
  	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
  		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+
  	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
  	return fd;
  }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool power_attr)
  {
  	int size;
 
  	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {
  		if (size < 0 && errno == EIO)
  			return false;
  	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
  		igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
  	}
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+	return time;
+}
lib/igt_pm.h +1 -0
index f28b6ebfd..ca1db7440 100644
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +21 -1
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5	(1 << 0)
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
  	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
  				buf, sizeof(buf));
  	return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
  	dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data)
+{
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}
+
  static void test_dc9_dpms(data_t *data)
  {
  	int dc_target;

tests/i915/i915_pm_dc.c int main(int argc, char *argv[]) · line 563

Quoted 6 lines
tests/i915/i915_pm_dc.c +2 -1
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
  		test_dc_state_dpms(&data, CHECK_DC6);
  	}
 
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");

This will produce

DC9 statefor both

        ^^^^

tests/i915/i915_pm_dc.c int main(int argc, char *argv[]) · line 572

Quoted 12 lines
tests/i915/i915_pm_dc.c +8 -3
  	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-			igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");

Same here,

DC9 stateonly for

       ^^^^^
Signature · 1 line
~Swati Sharma
#4 lore raw
In reply to Swati Sharma
Quoted 19 lines · Swati Sharma

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9.
Existing test will be restricted to igfx only. Also, changed debugfs entry to check if platform is dgfx or igfx.

---
 lib/igt_pm.c            | 25 ++++++++++++++++++++++---
 lib/igt_pm.h            |  1 +
 tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c +0 -0
index 6ebbad330..6c99eaff9 100644

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 9 lines
lib/igt_pm.c +5 -1
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
 	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
 		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 4 lines
lib/igt_pm.c +0 -0
 	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
 	return fd;
 }

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +2 -2
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool power_attr)
 {
 	int size;
 
 	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 6 lines
lib/igt_pm.c +0 -0
 		if (size < 0 && errno == EIO)
 			return false;
 	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
 		igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
 	}

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 10 lines
lib/igt_pm.c +9 -0
 }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

Quoted 34 lines
lib/igt_pm.c +6 -0
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+	return time;
+}
lib/igt_pm.h +1 -0
index f28b6ebfd..ca1db7440 100644
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
 void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
 void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +3 -0
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
 #include "igt_kmod.h"
 #include "igt_psr.h"
 #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
 #include "limits.h"
 #include "time.h"
+#include "igt_pm.h"
 
 /* DC State Flags */
 #define CHECK_DC5	(1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
 {
 	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
 				buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 12 lines
tests/i915/i915_pm_dc.c +6 -0
 	return strstr(buf, "is_dgfx: yes");
 }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
 	dpms_on(data);
 }
 
+static void check_dc9_runtime_suspend_time(data_t *data)
+{
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 32 lines
tests/i915/i915_pm_dc.c +14 -4
+
 static void test_dc9_dpms(data_t *data)
 {
 	int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
 		test_dc_state_dpms(&data, CHECK_DC6);
 	}
 
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");
 	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-			igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");
+	igt_subtest("dc9-dpms-igfx") {
+		igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
+			      "PC8+ residencies not supported\n");
 		test_dc9_dpms(&data);
 	}
 
Signature · 1 line
2.25.1
#5 lore raw

Hi Imre,

Thanks for the review.
Have answered your review comments in https://patchwork.freedesktop.org/series/108079/#rev2
Please review rev#2

Quoted 175 lines · Imre Deak
Quoted 19 lines · Swati Sharma

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9.
Existing test will be restricted to igfx only. Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
  3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c +0 -0
index 6ebbad330..6c99eaff9 100644

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 9 lines
lib/igt_pm.c +5 -1
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
  	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
  		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 4 lines
lib/igt_pm.c +0 -0
  	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
  	return fd;
  }

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +2 -2
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool power_attr)
  {
  	int size;
 
  	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 6 lines
lib/igt_pm.c +0 -0
  		if (size < 0 && errno == EIO)
  			return false;
  	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
  		igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
  	}

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 10 lines
lib/igt_pm.c +9 -0
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

Quoted 34 lines
lib/igt_pm.c +6 -0
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+	return time;
+}
lib/igt_pm.h +1 -0
index f28b6ebfd..ca1db7440 100644
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +3 -0
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5	(1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
  	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
  				buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 12 lines
tests/i915/i915_pm_dc.c +6 -0
  	return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
  	dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data)
+{
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 32 lines
tests/i915/i915_pm_dc.c +14 -4
+
  static void test_dc9_dpms(data_t *data)
  {
  	int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
  		test_dc_state_dpms(&data, CHECK_DC6);
  	}
 
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");
  	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-			igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");
+	igt_subtest("dc9-dpms-igfx") {
+		igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
+			      "PC8+ residencies not supported\n");
  		test_dc9_dpms(&data);
  	}
 
Signature · 1 line
2.25.1
Signature · 1 line
~Swati Sharma
#6 lore raw
Quoted 10 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of Sharma, Swati2
Sent: Monday, September 5, 2022 12:20 AM
To: Deak, Imre <[email protected]>
Cc: [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Quoted 6 lines

Hi Imre,

Thanks for the review.
Have answered your review comments in
https://patchwork.freedesktop.org/series/108079/#rev2
Please review rev#2

Here we are testing runtime suspend time for DC9.
I have few question regarding the test mythology.
1. Is there any power differences, When all display pipes are off (i.e all connectors are dpms off) vs DC9 ?
We are already having a lot runtime pm test in i915_pm_rpm ? why do we need a test which just check the runtime suspend ? We are already checking d3hot and d3cold in i915_pm_rpm ?

Thanks,
Anshuman Gupta.

Quoted 190 lines · Imre Deak
Quoted 13 lines · Swati Sharma
Quoted 12 lines

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9. Existing test will be restricted to igfx only.
Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
  3 files changed, 57 insertions(+), 8 deletions(-)
Quoted 5 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct

Quoted 5 lines
lib/igt_pm.c index 6ebbad330..6c99eaff9 renamed from lib/igt_pm.c +0 -0

100644

lib/igt_pm.c +0 -0
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct

pci_device *pci_dev, const char *attr

Quoted 1 line

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct · line 947

Quoted 1 line
lib/igt_pm.c +0 -0
  	snprintf(name, PATH_MAX,

"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",

Quoted 33 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 9 lines
lib/igt_pm.c +5 -1
  		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func,
 attr);
 
-	fd = open(name, O_RDWR);
+	if (!strcmp(attr,"runtime_suspended_time"))
+		fd = open(name, O_RDONLY);
+	else
+		fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 6 lines
lib/igt_pm.c +0 -1
  	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
  	return fd;
  }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +3 -1
 autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool
+power_attr)
  {
  	int size;
 
  	size = read(fd, attr, len - 1);
 
-	if (autosuspend_delay) {
+	if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 5 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1206

Quoted 5 lines
lib/igt_pm.c +0 -0
  		if (size < 0 && errno == EIO)
  			return false;
  	} else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
 
	igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
Quoted 8 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void)

Quoted 8 lines
lib/igt_pm.c +6 -0
  	}
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev) {
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd(pci_dev,

"runtime_suspended_time");

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 2 lines
lib/igt_pm.c +2 -0
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+		igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1218

Quoted 2 lines
lib/igt_pm.c +2 -0
+
+	igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' =

%d\n",

Quoted 10 lines

lib/igt_pm.h void igt_pm_enable_pci_card_runtime_pm(struct

Quoted 10 lines
lib/igt_pm.c +5 -0
+		  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func,
+time);
+
+	return time;
+}
lib/igt_pm.h index f28b6ebfd..ca1db7440 renamed from lib/igt_pm.h +0 -0

100644

lib/igt_pm.h +0 -0
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct

pci_device *root,

Quoted 32 lines
Quoted 23 lines
lib/igt_pm.h +1 -0
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c index renamed from tests/i915/i915_pm_dc.c +0 -0

f664a2a2c..69afa3e6f 100644

tests/i915/i915_pm_dc.c +3 -0
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5	(1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
  	char buf[4096];
 
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
  				buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 3 lines

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int

Quoted 3 lines
tests/i915/i915_pm_dc.c +0 -0
  	return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int

dc_target)

Quoted 33 lines
Quoted 8 lines
tests/i915/i915_pm_dc.c +5 -0
  	dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data) {
+	struct pci_device *i915;
+	int before, after;
+
+	i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+	before = igt_pm_get_runtime_suspended_time(i915);
+	dpms_on(data);
+	cleanup_dc_dpms(data);
+	dpms_off(data);
+	sleep(1);
+	after = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lt(before, after);
+	dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change
dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 8 lines
tests/i915/i915_pm_dc.c +1 -0
+
  static void test_dc9_dpms(data_t *data)
  {
  	int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
  		test_dc_state_dpms(&data, CHECK_DC6);
  	}
 
Quoted 6 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 6 lines
tests/i915/i915_pm_dc.c +2 -3
-	igt_describe("This test validates display engine entry to DC9 state");
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "for both igfx and dgfx");
  	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
-

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 11 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 11 lines
tests/i915/i915_pm_dc.c +10 -1
-				      "PC8+ residencies not supported\n");
+		check_dc9_runtime_suspend_time(&data);
+	}
+
+	igt_fixture
+		igt_require(!(check_is_dgfx(&data)));
+
+	igt_describe("This test validates display engine entry to DC9 state"
+		     "only for igfx");
+	igt_subtest("dc9-dpms-igfx") {
+

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 7 lines
Quoted 7 lines
tests/i915/i915_pm_dc.c +1 -1
+			      "PC8+ residencies not supported\n");
  		test_dc9_dpms(&data);
  	}
 
--

2.25.1

--
~Swati Sharma

#7 lore raw
Quoted 16 lines · Anshuman
Quoted 10 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of Sharma, Swati2
Sent: Monday, September 5, 2022 12:20 AM
To: Deak, Imre <[email protected]>
Cc: [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Quoted 6 lines

Hi Imre,

Thanks for the review.
Have answered your review comments in
https://patchwork.freedesktop.org/series/108079/#rev2
Please review rev#2

Quoted 6 lines

Here we are testing runtime suspend time for DC9. I have few question regarding the test mythology.
1. Is there any power differences, When all display pipes are off (i.e all connectors are dpms off) vs DC9 ?
We are already having a lot runtime pm test in i915_pm_rpm ? why do we need a test which just check the runtime suspend ? We are already checking d3hot and d3cold in i915_pm_rpm ?

Being runtime suspended is a dependency for DC9 on all platforms, hence it makes sense to check for this too. Since DC9 doesn't cause display registers to reset on DG2, being runtime suspended is the only thing we can check there.

Quoted 192 lines

Thanks,
Anshuman Gupta.

Quoted 190 lines · Imre Deak
Quoted 13 lines · Swati Sharma
Quoted 12 lines

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9. Existing test will be restricted to igfx only.
Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-----
  3 files changed, 57 insertions(+), 8 deletions(-)
Quoted 5 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct

Quoted 5 lines
lib/igt_pm.c index 6ebbad330..6c99eaff9 renamed from lib/igt_pm.c +0 -0

100644

lib/igt_pm.c +0 -0
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct

pci_device *pci_dev, const char *attr

Quoted 1 line

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct · line 947

Quoted 1 line
lib/igt_pm.c +0 -0
   snprintf(name, PATH_MAX,

"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",

Quoted 33 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 9 lines
lib/igt_pm.c +5 -1
            pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func,
 attr);
 
-  fd = open(name, O_RDWR);
+  if (!strcmp(attr,"runtime_suspended_time"))
+          fd = open(name, O_RDONLY);
+  else
+          fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 6 lines
lib/igt_pm.c +0 -1
   igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
   return fd;
  }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +3 -1
 autosuspend_delay)
+static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool
+power_attr)
  {
   int size;
 
   size = read(fd, attr, len - 1);
 
-  if (autosuspend_delay) {
+  if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 5 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1206

Quoted 5 lines
lib/igt_pm.c +0 -0
           if (size < 0 && errno == EIO)
                   return false;
   } else {
@@ -1202,3 +1206,18 @@ void igt_pm_print_pci_card_runtime_status(void)
 
      igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);
Quoted 8 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void)

Quoted 8 lines
lib/igt_pm.c +6 -0
   }
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev) {
+  char time_str[64];
+  int time, time_fd;
+
+  time_fd = igt_pm_get_power_attr_fd(pci_dev,

"runtime_suspended_time");

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 2 lines
lib/igt_pm.c +2 -0
+  if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+          igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

Quoted 2 lines
lib/igt_pm.c +2 -0
+
+  igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' =

%d\n",

Quoted 10 lines

lib/igt_pm.h void igt_pm_enable_pci_card_runtime_pm(struct

Quoted 10 lines
lib/igt_pm.c +5 -0
+            pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func,
+time);
+
+  return time;
+}
lib/igt_pm.h index f28b6ebfd..ca1db7440 renamed from lib/igt_pm.h +0 -0

100644

lib/igt_pm.h +0 -0
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct

pci_device *root,

Quoted 32 lines
Quoted 23 lines
lib/igt_pm.h +1 -0
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c index renamed from tests/i915/i915_pm_dc.c +0 -0

f664a2a2c..69afa3e6f 100644

tests/i915/i915_pm_dc.c +3 -0
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5        (1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
   char buf[4096];
 
-  igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+  igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
                           buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 3 lines

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int

Quoted 3 lines
tests/i915/i915_pm_dc.c +0 -0
   return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int

dc_target)

Quoted 33 lines
Quoted 8 lines
tests/i915/i915_pm_dc.c +5 -0
   dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data) {
+  struct pci_device *i915;
+  int before, after;
+
+  i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+  before = igt_pm_get_runtime_suspended_time(i915);
+  dpms_on(data);
+  cleanup_dc_dpms(data);
+  dpms_off(data);
+  sleep(1);
+  after = igt_pm_get_runtime_suspended_time(i915);
+  igt_assert_lt(before, after);
+  dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change
dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 8 lines
tests/i915/i915_pm_dc.c +1 -0
+
  static void test_dc9_dpms(data_t *data)
  {
   int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
           test_dc_state_dpms(&data, CHECK_DC6);
   }
 
Quoted 6 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 6 lines
tests/i915/i915_pm_dc.c +2 -3
-  igt_describe("This test validates display engine entry to DC9 state");
+  igt_describe("This test validates display engine entry to DC9 state"
+               "for both igfx and dgfx");
   igt_subtest("dc9-dpms") {
-          if (!(check_is_dgfx(&data)))
-

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 11 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 11 lines
tests/i915/i915_pm_dc.c +10 -1
-                                "PC8+ residencies not supported\n");
+          check_dc9_runtime_suspend_time(&data);
+  }
+
+  igt_fixture
+          igt_require(!(check_is_dgfx(&data)));
+
+  igt_describe("This test validates display engine entry to DC9 state"
+               "only for igfx");
+  igt_subtest("dc9-dpms-igfx") {
+

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 7 lines
Quoted 7 lines
tests/i915/i915_pm_dc.c +1 -1
+                        "PC8+ residencies not supported\n");
           test_dc9_dpms(&data);
   }
 
--

2.25.1

--
~Swati Sharma

#8 lore raw
Quoted 31 lines

-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Monday, September 5, 2022 6:26 PM
To: Gupta, Anshuman <[email protected]>
Cc: Sharma, Swati2 <[email protected]>; [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Quoted 14 lines · Anshuman
Quoted 14 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of Sharma,
Swati2
Sent: Monday, September 5, 2022 12:20 AM
To: Deak, Imre <[email protected]>
Cc: [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Hi Imre,

Quoted 7 lines
Quoted 4 lines

Thanks for the review.
Have answered your review comments in
https://patchwork.freedesktop.org/series/108079/#rev2
Please review rev#2

Here we are testing runtime suspend time for DC9. I have few question regarding the test mythology.
1. Is there any power differences, When all display pipes are off (i.e all

Quoted 8 lines

connectors are dpms off) vs DC9 ?

Quoted 3 lines

We are already having a lot runtime pm test in i915_pm_rpm ? why do we need a test which just check the runtime suspend ? We are already checking d3hot and d3cold in i915_pm_rpm ?

Being runtime suspended is a dependency for DC9 on all platforms, hence it makes sense to check for this too. Since DC9 doesn't cause display registers to reset on DG2, being runtime suspended is the only thing we can check there.

IMO then this should be applicable for DG1/DG2, on DG2 due to various reasons the DGFX SOC Pkg power states limited to a shallow Pkg state which even can be achieved with display on idle use case.

Future DGFX platforms will enable the deepest Pkg state which may need to revisit this test.

Thanks,
Anshuman Gupta.

Quoted 204 lines
Quoted 16 lines

Thanks,
Anshuman Gupta.

Quoted 13 lines · Imre Deak
Quoted 11 lines · Swati Sharma
Quoted 10 lines

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9. Existing test will be restricted to igfx only.
Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-

----

Quoted 187 lines
Quoted 187 lines
Quoted 8 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct

Quoted 8 lines
  3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c index renamed from lib/igt_pm.c +0 -0

6ebbad330..6c99eaff9
100644

lib/igt_pm.c +0 -0
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct

pci_device *pci_dev, const char *attr

Quoted 1 line

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct · line 947

Quoted 1 line
lib/igt_pm.c +0 -0
   snprintf(name, PATH_MAX,

"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",

Quoted 34 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 8 lines
lib/igt_pm.c +4 -1
            pci_dev->domain, pci_dev->bus, pci_dev->dev,
 pci_dev->func, attr);
 
-  fd = open(name, O_RDWR);
+  if (!strcmp(attr,"runtime_suspended_time"))
+          fd = open(name, O_RDONLY);  else
+          fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 8 lines
lib/igt_pm.c +0 -1
   igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
   return fd;
  }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len,

bool
autosuspend_delay)

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +4 -1
+static bool igt_pm_read_power_attr(int fd, char *attr, int len,
+bool
+power_attr)
  {
   int size;
 
   size = read(fd, attr, len - 1);
 
-  if (autosuspend_delay) {
+  if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 6 lines

lib/igt_pm.c void · line 1207

Quoted 6 lines
           if (size < 0 && errno == EIO)
                   return false;

} else {

lib/igt_pm.c +0 -0
@@ -1202,3 +1206,18 @@ void
 igt_pm_print_pci_card_runtime_status(void)
 

igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void)

Quoted 9 lines
lib/igt_pm.c +7 -0
   }
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device
+*pci_dev) {
+  char time_str[64];
+  int time, time_fd;
+
+  time_fd = igt_pm_get_power_attr_fd(pci_dev,

"runtime_suspended_time");

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 2 lines
lib/igt_pm.c +2 -0
+  if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+          igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

Quoted 2 lines
lib/igt_pm.c +2 -0
+
+  igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' =

%d\n",

Quoted 11 lines

lib/igt_pm.h void igt_pm_enable_pci_card_runtime_pm(struct

Quoted 11 lines
lib/igt_pm.c +5 -0
+            pci_dev->domain, pci_dev->bus, pci_dev->dev,
+pci_dev->func, time);
+
+  return time;
+}
lib/igt_pm.h index renamed from lib/igt_pm.h +0 -0

f28b6ebfd..ca1db7440
100644

lib/igt_pm.h +0 -0
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct

pci_device *root,

Quoted 33 lines
Quoted 24 lines
lib/igt_pm.h +2 -0
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device
+*pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +3 -0
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5        (1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
   char buf[4096];
 
-  igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+  igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
                           buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 3 lines

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int

Quoted 3 lines
tests/i915/i915_pm_dc.c +0 -0
   return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int

dc_target)

Quoted 33 lines
Quoted 8 lines
tests/i915/i915_pm_dc.c +5 -0
   dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data) {
+  struct pci_device *i915;
+  int before, after;
+
+  i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+  before = igt_pm_get_runtime_suspended_time(i915);
+  dpms_on(data);
+  cleanup_dc_dpms(data);
+  dpms_off(data);
+  sleep(1);
+  after = igt_pm_get_runtime_suspended_time(i915);
+  igt_assert_lt(before, after);
+  dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change
dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 8 lines
tests/i915/i915_pm_dc.c +1 -0
+
  static void test_dc9_dpms(data_t *data)
  {
   int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
           test_dc_state_dpms(&data, CHECK_DC6);
   }
 
Quoted 7 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 7 lines
tests/i915/i915_pm_dc.c +2 -3
-  igt_describe("This test validates display engine entry to DC9
 state");
+  igt_describe("This test validates display engine entry to DC9 state"
+               "for both igfx and dgfx");
   igt_subtest("dc9-dpms") {
-          if (!(check_is_dgfx(&data)))
-

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 11 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 11 lines
tests/i915/i915_pm_dc.c +10 -1
-                                "PC8+ residencies not supported\n");
+          check_dc9_runtime_suspend_time(&data);
+  }
+
+  igt_fixture
+          igt_require(!(check_is_dgfx(&data)));
+
+  igt_describe("This test validates display engine entry to DC9 state"
+               "only for igfx");
+  igt_subtest("dc9-dpms-igfx") {
+

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 7 lines
Quoted 7 lines
tests/i915/i915_pm_dc.c +1 -1
+                        "PC8+ residencies not supported\n");
           test_dc9_dpms(&data);
   }
 
--

2.25.1

--
~Swati Sharma

#9 lore raw
Quoted 37 lines · Anshuman
Quoted 28 lines

-----Original Message-----
From: Deak, Imre <[email protected]>
Sent: Monday, September 5, 2022 6:26 PM
To: Gupta, Anshuman <[email protected]>
Cc: Sharma, Swati2 <[email protected]>; [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Quoted 12 lines · Anshuman
Quoted 12 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of Sharma,
Swati2
Sent: Monday, September 5, 2022 12:20 AM
To: Deak, Imre <[email protected]>
Cc: [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] tests/i915/i915_pm_dc: Add new dc9 test

Hi Imre,

Quoted 7 lines
Quoted 4 lines

Thanks for the review.
Have answered your review comments in
https://patchwork.freedesktop.org/series/108079/#rev2
Please review rev#2

Here we are testing runtime suspend time for DC9. I have few question regarding the test mythology.
1. Is there any power differences, When all display pipes are off (i.e all

connectors are dpms off) vs DC9 ?

Quoted 8 lines
Quoted 3 lines

We are already having a lot runtime pm test in i915_pm_rpm ? why do we need a test which just check the runtime suspend ? We are already checking d3hot and d3cold in i915_pm_rpm ?

Being runtime suspended is a dependency for DC9 on all platforms, hence it makes sense to check for this too. Since DC9 doesn't cause display registers to reset on DG2, being runtime suspended is the only thing we can check there.

Quoted 6 lines

IMO then this should be applicable for DG1/DG2, on DG2 due to various reasons the DGFX SOC Pkg power states limited to a shallow Pkg state which even can be achieved with display on idle use case.

Future DGFX platforms will enable the deepest Pkg state which may need to revisit this test.

Ok, skipping the DC counter check only on DG1/DG2 vs. future dGFX platforms is ok from my POV.

Quoted 207 lines

Thanks,
Anshuman Gupta.

Quoted 204 lines
Quoted 16 lines

Thanks,
Anshuman Gupta.

Quoted 13 lines · Imre Deak
Quoted 11 lines · Swati Sharma
Quoted 10 lines

Added new test to validate dc9 on both igfx and dgfx. runtime_suspended_time value increases when system enters DC9. Existing test will be restricted to igfx only.
Also, changed debugfs entry to check if platform is dgfx or igfx.

---
  lib/igt_pm.c            | 25 ++++++++++++++++++++++---
  lib/igt_pm.h            |  1 +
  tests/i915/i915_pm_dc.c | 39 ++++++++++++++++++++++++++++++++++-

----

Quoted 187 lines
Quoted 187 lines
Quoted 8 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct

Quoted 8 lines
  3 files changed, 57 insertions(+), 8 deletions(-)
lib/igt_pm.c index renamed from lib/igt_pm.c +0 -0

6ebbad330..6c99eaff9
100644

lib/igt_pm.c +0 -0
@@ -947,19 +947,23 @@ static int igt_pm_get_power_attr_fd(struct

pci_device *pci_dev, const char *attr

Quoted 1 line

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct · line 947

Quoted 1 line
lib/igt_pm.c +0 -0
   snprintf(name, PATH_MAX,

"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",

Quoted 34 lines

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 954

Quoted 8 lines
lib/igt_pm.c +4 -1
            pci_dev->domain, pci_dev->bus, pci_dev->dev,
 pci_dev->func, attr);
 
-  fd = open(name, O_RDWR);
+  if (!strcmp(attr,"runtime_suspended_time"))
+          fd = open(name, O_RDONLY);  else
+          fd = open(name, O_RDWR);
+

There is a few other places opening an attribute with RDONLY, so maybe add an igt_pm_get_power_attr_fd_rdonly() helper for that?

Quoted 8 lines
lib/igt_pm.c +0 -1
   igt_assert_f(fd >= 0, "Can't open %s\n", attr);
 
   return fd;
  }
 
-static bool igt_pm_read_power_attr(int fd, char *attr, int len,

bool
autosuspend_delay)

lib/igt_pm.c static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr · line 966

Quoted 10 lines
lib/igt_pm.c +4 -1
+static bool igt_pm_read_power_attr(int fd, char *attr, int len,
+bool
+power_attr)
  {
   int size;
 
   size = read(fd, attr, len - 1);
 
-  if (autosuspend_delay) {
+  if (power_attr) {

How did this fail for runtime_suspended_time? It doesn't return -EIO as opposed to autosuspend_delay, so maybe fd was invalid?

Quoted 6 lines

lib/igt_pm.c void · line 1207

Quoted 6 lines
           if (size < 0 && errno == EIO)
                   return false;

} else {

lib/igt_pm.c +0 -0
@@ -1202,3 +1206,18 @@ void
 igt_pm_print_pci_card_runtime_status(void)
 

igt_pm_print_pci_dev_runtime_status(__pci_dev_pwrattr[i].pci_dev);

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void)

Quoted 9 lines
lib/igt_pm.c +7 -0
   }
  }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device
+*pci_dev) {
+  char time_str[64];
+  int time, time_fd;
+
+  time_fd = igt_pm_get_power_attr_fd(pci_dev,

"runtime_suspended_time");

Quoted 9 lines

lib/igt_pm.c void igt_pm_print_pci_card_runtime_status(void) · line 1217

Quoted 2 lines
lib/igt_pm.c +2 -0
+  if (igt_pm_read_power_attr(time_fd, time_str, 64, true))
+          igt_assert(sscanf(time_str, "%d", &time) > 0);

If reading the attribute failed for any reason then we'd return random data from this function. Being able to open the attribute and reading it is a requirement for the given test.

Quoted 2 lines
lib/igt_pm.c +2 -0
+
+  igt_info("runtime suspend time for PCI '%04x:%02x:%02x.%01x' =

%d\n",

Quoted 11 lines

lib/igt_pm.h void igt_pm_enable_pci_card_runtime_pm(struct

Quoted 11 lines
lib/igt_pm.c +5 -0
+            pci_dev->domain, pci_dev->bus, pci_dev->dev,
+pci_dev->func, time);
+
+  return time;
+}
lib/igt_pm.h index renamed from lib/igt_pm.h +0 -0

f28b6ebfd..ca1db7440
100644

lib/igt_pm.h +0 -0
@@ -79,5 +79,6 @@ void igt_pm_enable_pci_card_runtime_pm(struct

pci_device *root,

Quoted 33 lines
Quoted 24 lines
lib/igt_pm.h +2 -0
  void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
  void igt_pm_restore_pci_card_runtime_pm(void);
  void igt_pm_print_pci_card_runtime_status(void);
+int igt_pm_get_runtime_suspended_time(struct pci_device
+*pci_dev);
 
  #endif /* IGT_PM_H */
tests/i915/i915_pm_dc.c +3 -0
index f664a2a2c..69afa3e6f 100644
@@ -31,8 +31,11 @@
  #include "igt_kmod.h"
  #include "igt_psr.h"
  #include "igt_sysfs.h"
+#include "igt_device.h"
+#include "igt_device_scan.h"
  #include "limits.h"
  #include "time.h"
+#include "igt_pm.h"
 
  /* DC State Flags */
  #define CHECK_DC5        (1 << 0)

tests/i915/i915_pm_dc.c static bool check_is_dgfx(data_t *data) · line 433

Quoted 6 lines
tests/i915/i915_pm_dc.c +1 -1
@@ -426,7 +429,7 @@ static bool check_is_dgfx(data_t *data)
  {
   char buf[4096];
 
-  igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
+  igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
                           buf, sizeof(buf));

Should this be a separate patch explaining the rational of the change?

Quoted 3 lines

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int

Quoted 3 lines
tests/i915/i915_pm_dc.c +0 -0
   return strstr(buf, "is_dgfx: yes");
  }
@@ -453,6 +456,23 @@ static void setup_dc9_dpms(data_t *data, int

dc_target)

Quoted 33 lines
Quoted 8 lines
tests/i915/i915_pm_dc.c +5 -0
   dpms_on(data);
  }
 
+static void check_dc9_runtime_suspend_time(data_t *data) {
+  struct pci_device *i915;
+  int before, after;
+
+  i915 = igt_device_get_pci_device(data->drm_fd);

tests/i915/i915_pm_dc.c static void setup_dc9_dpms(data_t *data, int dc_target) · line 474

Quoted 10 lines
tests/i915/i915_pm_dc.c +10 -0
+
+  before = igt_pm_get_runtime_suspended_time(i915);
+  dpms_on(data);
+  cleanup_dc_dpms(data);
+  dpms_off(data);
+  sleep(1);
+  after = igt_pm_get_runtime_suspended_time(i915);
+  igt_assert_lt(before, after);
+  dpms_on(data);
+}

I think it's better to run test_dc9_dpms() on dGFX as well, only change
dc9_wait_entry() which polls for both runtime_suspend_time to increase (on both iGFX and dGFX) and for the DC5/6 counter to reset (on iGFX only).

Quoted 8 lines
tests/i915/i915_pm_dc.c +1 -0
+
  static void test_dc9_dpms(data_t *data)
  {
   int dc_target;
@@ -539,11 +559,20 @@ int main(int argc, char *argv[])
           test_dc_state_dpms(&data, CHECK_DC6);
   }
 
Quoted 7 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 7 lines
tests/i915/i915_pm_dc.c +2 -3
-  igt_describe("This test validates display engine entry to DC9
 state");
+  igt_describe("This test validates display engine entry to DC9 state"
+               "for both igfx and dgfx");
   igt_subtest("dc9-dpms") {
-          if (!(check_is_dgfx(&data)))
-

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 11 lines

tests/i915/i915_pm_dc.c int main(int argc, char *argv[])

Quoted 11 lines
tests/i915/i915_pm_dc.c +10 -1
-                                "PC8+ residencies not supported\n");
+          check_dc9_runtime_suspend_time(&data);
+  }
+
+  igt_fixture
+          igt_require(!(check_is_dgfx(&data)));
+
+  igt_describe("This test validates display engine entry to DC9 state"
+               "only for igfx");
+  igt_subtest("dc9-dpms-igfx") {
+

igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),

Quoted 7 lines
Quoted 7 lines
tests/i915/i915_pm_dc.c +1 -1
+                        "PC8+ residencies not supported\n");
           test_dc9_dpms(&data);
   }
 
--

2.25.1

--
~Swati Sharma