Skip to contentSkip to conversation

Modify dc9 validation

PATCH Superseded Swati Sharma 1 participant 5 messages Sep 9, 2022 Library code

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Modify dc9 validation

dc9 test case is modified.
Added new constraint to check runtime_suspended_time for dc9.

Swati Sharma (4):
tests/i915/i915_pm_dc: Add test description tests/i915/i915_pm_dc: Change debugfs for reading platform info lib/pm: Add helper functions to get runtime suspended time tests/i915/i915_pm_dc: Modify dc9 test

 lib/igt_pm.c            | 32 +++++++++++++++++
 lib/igt_pm.h            |  1 +
 tests/i915/i915_pm_dc.c | 77 ++++++++++++++++++++++++++---------------
 3 files changed, 82 insertions(+), 28 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/4 tests/i915/i915_pm_dc: Add test description

---
 tests/i915/i915_pm_dc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/i915/i915_pm_dc.c +2 -1
index f664a2a2c..40811ae52 100644
@@ -44,6 +44,8 @@
 #define KMS_HELPER "/sys/module/drm_kms_helper/parameters/"
 #define KMS_POLL_DISABLE 0
 
+IGT_TEST_DESCRIPTION("Tests to validate display power DC states.");
+
 bool kms_poll_saved_state;
 
 typedef struct {
@@ -473,7 +475,6 @@ static void kms_poll_state_restore(int sig)
 	}
 }
 
-IGT_TEST_DESCRIPTION("These tests validate Display Power DC states");
 int main(int argc, char *argv[])
 {
 	data_t data = {};
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 2/4 tests/i915/i915_pm_dc: Change debugfs for reading platform info

In reply to Swati Sharma

With error capture being part of i915_gpu_info, with 4024 buffer size we will never be able to parse "is_dgfx" string. Instead use i915_capabilities which is meant for platform info only.

Also, changed func name from check_is_dgfx() to is_dgfx().

v2: -create separate patch for this change (imre)
v3: -create separate patch for igt description (imre)
-move is_dgfx() func on top (imre)

---
 tests/i915/i915_pm_dc.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tests/i915/i915_pm_dc.c +10 -10
index 40811ae52..bd4522275 100644
@@ -69,6 +69,15 @@ typedef struct {
 static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count);
 static void check_dc_counter(data_t *data, int dc_flag, uint32_t prev_dc_count);
 
+static bool is_dgfx(data_t *data)
+{
+	char buf[4096];
+
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_capabilities",
+				buf, sizeof(buf));
+	return strstr(buf, "is_dgfx: yes");
+}
+
 static void setup_output(data_t *data)
 {
 	igt_display_t *display = &data->display;
@@ -424,15 +433,6 @@ static void check_dc9(data_t *data, int dc_target, int prev_dc)
 			data->debugfs_dump = igt_sysfs_get(data->debugfs_fd, RPM_STATUS));
 }
 
-static bool check_is_dgfx(data_t *data)
-{
-	char buf[4096];
-
-	igt_debugfs_simple_read(data->debugfs_fd, "i915_gpu_info",
-				buf, sizeof(buf));
-	return strstr(buf, "is_dgfx: yes");
-}
-
 static void setup_dc9_dpms(data_t *data, int dc_target)
 {
 	int prev_dc, sysfs_fd;
@@ -542,7 +542,7 @@ int main(int argc, char *argv[])
 
 	igt_describe("This test validates display engine entry to DC9 state");
 	igt_subtest("dc9-dpms") {
-		if (!(check_is_dgfx(&data)))
+		if (!(is_dgfx(&data)))
 			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

PATCH v4 3/4 lib/pm: Add helper functions to get runtime suspended time

In reply to Swati Sharma

Added helper function to get runtime suspended time. This will be used to extend dc9 validation.

v2: -created separate helper igt_pm_get_power_attr_fd_rdonly() (imre)
-fixed igt_pm_get_runtime_suspended_time() (imre)
v3: -revert var name change (imre)
-add space (imre)
v4: -changed igt_info to igt_debug print

---
 lib/igt_pm.c | 32 ++++++++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 33 insertions(+)
lib/igt_pm.c +32 -0
index 99251b40b..d655356c3 100644
@@ -953,6 +953,20 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
 	return fd;
 }
 
+static int igt_pm_get_power_attr_fd_rdonly(struct pci_device *pci_dev, const char *attr)
+{
+	char name[PATH_MAX];
+	int fd;
+
+	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_RDONLY);
+	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)
 {
 	int size;
@@ -1219,3 +1233,21 @@ bool i915_is_slpc_enabled(int fd)
 	else
 		return strstr(buf, "SLPC state: running");
 }
+
+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_rdonly(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, false)) {
+		igt_assert(sscanf(time_str, "%d", &time) > 0);
+
+		igt_debug("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;
+	}
+
+	return -1;
+}
lib/igt_pm.h +1 -0
index cbbde12b5..a7d621366 100644
@@ -80,5 +80,6 @@ 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);
 bool i915_is_slpc_enabled(int fd);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
Signature · 1 line
2.25.1
#4 lore raw

PATCH v5 4/4 tests/i915/i915_pm_dc: Modify dc9 test

In reply to Swati Sharma

Existing dc9 test is modified. Added new condition, runtime_suspended_time value should increases when system enters dc9. This condition will be checked for both igfx and dgfx whereas existing condition where we wait for dc counter to reset is limited only to igfx.

v3: -changed test design (imre)
v4: -var name changed (imre)
-restricted counter reset condition to dg1 and dg2
platforms only (anshuman)
-swapped rpm vs dc9 wait order condition (imre)
v5: -add macro DC9_RESETS_DC_COUNTERS (imre)
-combine both polling (imre)
-moved is_dgfx() realignment into patch 2/4 (imre) -s/seconds/msecs/ (imre)

---
 tests/i915/i915_pm_dc.c | 54 ++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 17 deletions(-)
tests/i915/i915_pm_dc.c +37 -17
index bd4522275..142975e6c 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)
@@ -43,6 +46,7 @@
 #define RPM_STATUS "i915_runtime_pm_status"
 #define KMS_HELPER "/sys/module/drm_kms_helper/parameters/"
 #define KMS_POLL_DISABLE 0
+#define DC9_RESETS_DC_COUNTERS(devid) !(IS_DG1(devid) || IS_DG2(devid))
 
 IGT_TEST_DESCRIPTION("Tests to validate display power DC states.");
 
@@ -416,42 +420,58 @@ static bool support_dc6(int debugfs_fd)
 	return strstr(buf, "DC5 -> DC6 count");
 }
 
-static bool dc9_wait_entry(uint32_t debugfs_fd, int dc_target, int prev_dc, int seconds)
+static int read_runtime_suspended_time(int drm_fd)
 {
-	/*
-	 * since we do not have DC9 counter,
-	 * so we rely on dc5/dc6 counter reset to check if display engine was in DC9.
+	struct pci_device *i915;
+	int ret;
+
+	i915 = igt_device_get_pci_device(drm_fd);
+	ret = igt_pm_get_runtime_suspended_time(i915);
+	igt_assert_lte(0, ret);
+
+	return ret;
+}
+
+static bool dc9_wait_entry(data_t *data, int dc_target, int prev_dc, int prev_rpm, int msecs)
+{
+	/* runtime suspended residency should increment once DC9 is achieved;
+	 * this condition is valid for all platforms.
+	 * however, resetting of dc5/dc6 counter to check if display engine was in DC9;
+	 * this condition at present can be skipped for dg1 and dg2 platforms.
 	 */
-	return igt_wait(read_dc_counter(debugfs_fd, dc_target) <
-			prev_dc, seconds, 100);
+	return igt_wait((read_runtime_suspended_time(data->drm_fd) > prev_rpm) && (DC9_RESETS_DC_COUNTERS(data->devid) ?
+			(read_dc_counter(data->debugfs_fd, dc_target) < prev_dc) : true), msecs, 100);
 }
 
-static void check_dc9(data_t *data, int dc_target, int prev_dc)
+static void check_dc9(data_t *data, int dc_target, int prev_dc, int prev_rpm)
 {
-	igt_assert_f(dc9_wait_entry(data->debugfs_fd, dc_target, prev_dc, 3000),
+	igt_assert_f(dc9_wait_entry(data, dc_target, prev_dc, prev_rpm, 3000),
 			"DC9 state is not achieved\n%s:\n%s\n", RPM_STATUS,
 			data->debugfs_dump = igt_sysfs_get(data->debugfs_fd, RPM_STATUS));
 }
 
 static void setup_dc9_dpms(data_t *data, int dc_target)
 {
-	int prev_dc, sysfs_fd;
+	int prev_dc, prev_rpm, sysfs_fd;
 
 	igt_require((sysfs_fd = open(KMS_HELPER, O_RDONLY)) >= 0);
 	kms_poll_saved_state = igt_sysfs_get_boolean(sysfs_fd, "poll");
 	igt_sysfs_set_boolean(sysfs_fd, "poll", KMS_POLL_DISABLE);
 	close(sysfs_fd);
-	prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
-	setup_dc_dpms(data);
-	dpms_off(data);
-	igt_skip_on_f(!(igt_wait(read_dc_counter(data->debugfs_fd, dc_target) >
+	if (DC9_RESETS_DC_COUNTERS(data->devid)) {
+		prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
+		setup_dc_dpms(data);
+		dpms_off(data);
+		igt_skip_on_f(!(igt_wait(read_dc_counter(data->debugfs_fd, dc_target) >
 				prev_dc, 3000, 100)), "Unable to enters shallow DC states\n");
-	prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
-	dpms_on(data);
-	cleanup_dc_dpms(data);
+		prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
+		dpms_on(data);
+		cleanup_dc_dpms(data);
+	}
+	prev_rpm = read_runtime_suspended_time(data->drm_fd);
 	dpms_off(data);
 	sleep(1); /* wait for counters reset*/
-	check_dc9(data, dc_target, prev_dc);
+	check_dc9(data, dc_target, prev_dc, prev_rpm);
 	dpms_on(data);
 }
 
Signature · 1 line
2.25.1