Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mohammed Thasleem <mohammed.thasleem@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t, v5 1/1] tests/intel/xe_pm: Fix d3cold subtests
Date: Thu, 21 Apr 2022 18:37:04 +0530	[thread overview]
Message-ID: <20220421130704.934-2-mohammed.thasleem@intel.com> (raw)
In-Reply-To: <20220421130704.934-1-mohammed.thasleem@intel.com>

xe_pm d3 test requires to turn off all display in order to
enter to d3 state therefore, adding the support to triggering
"DRM_MODE_DPMS_OFF" in setup_d3() and "DRM_MODE_DPMS_ON" in
cleanup_d3().

v2: Use IGT_CRTC_ACTIVE for displays On/Off.
v3: -Update commit message and helper names.
    -Update display on and off helpers.
v4: Remove redundant code. (Bhanu)
v5: Move helper calls to test file.
v6: -Update function name as dpms_on_off. (Anshuman)
    -Update subject and commit message. (Kamil)

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Signed-off-by: Mohammed Thasleem <mohammed.thasleem@intel.com>
---
 tests/intel/xe_pm.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index 9423984cc..42e00abb3 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -16,6 +16,7 @@
 
 #include "igt.h"
 #include "lib/igt_device.h"
+#include "lib/igt_kms.h"
 #include "lib/igt_pm.h"
 #include "lib/igt_sysfs.h"
 #include "lib/igt_syncobj.h"
@@ -36,10 +37,31 @@ typedef struct {
 	struct pci_device *pci_xe;
 	struct pci_device *pci_root;
 	char pci_slot_name[NAME_MAX];
+	drmModeResPtr res;
 } device_t;
 
 uint64_t orig_threshold;
 
+static void dpms_on_off(device_t device, int mode)
+{
+	int i;
+
+	for (i = 0; i < device.res->count_connectors; i++) {
+		drmModeConnector *connector = drmModeGetConnectorCurrent(device.fd_xe,
+					      device.res->connectors[i]);
+
+		if (!connector)
+			continue;
+
+		if (connector->connection != DRM_MODE_CONNECTED)
+			continue;
+
+		kmstest_set_connector_dpms(device.fd_xe, connector, mode);
+
+		drmModeFreeConnector(connector);
+	}
+}
+
 /* runtime_usage is only available if kernel build CONFIG_PM_ADVANCED_DEBUG */
 static bool runtime_usage_available(struct pci_device *pci)
 {
@@ -94,6 +116,9 @@ static void vram_d3cold_threshold_restore(int sig)
 
 static bool setup_d3(device_t device, enum igt_acpi_d_state state)
 {
+	if (device.res)
+		dpms_on_off(device, DRM_MODE_DPMS_OFF);
+
 	switch (state) {
 	case IGT_ACPI_D3Cold:
 		igt_require(igt_pm_acpi_d3cold_supported(device.pci_root));
@@ -110,6 +135,14 @@ static bool setup_d3(device_t device, enum igt_acpi_d_state state)
 	return false;
 }
 
+static void cleanup_d3(device_t device)
+{
+	if (device.res) {
+		dpms_on_off(device, DRM_MODE_DPMS_ON);
+		drmModeFreeResources(device.res);
+	}
+}
+
 static bool in_d3(device_t device, enum igt_acpi_d_state state)
 {
 	uint16_t val;
@@ -476,6 +509,7 @@ igt_main
 		igt_pm_get_d3cold_allowed(device.pci_slot_name, &d3cold_allowed);
 		igt_assert(igt_setup_runtime_pm(device.fd_xe));
 		sysfs_fd = igt_sysfs_open(device.fd_xe);
+		device.res = drmModeGetResources(device.fd_xe);
 	}
 
 	for (const struct s_state *s = s_states; s->name; s++) {
@@ -510,6 +544,7 @@ igt_main
 				xe_for_each_hw_engine(device.fd_xe, hwe)
 					test_exec(device, hwe, 1, 2, s->state,
 						  NO_RPM);
+				cleanup_d3(device);
 			}
 		}
 	}
@@ -518,6 +553,7 @@ igt_main
 		igt_subtest_f("%s-basic", d->name) {
 			igt_assert(setup_d3(device, d->state));
 			igt_assert(in_d3(device, d->state));
+			cleanup_d3(device);
 		}
 
 		igt_subtest_f("%s-basic-exec", d->name) {
@@ -525,6 +561,7 @@ igt_main
 			xe_for_each_hw_engine(device.fd_xe, hwe)
 				test_exec(device, hwe, 1, 1,
 					  NO_SUSPEND, d->state);
+			cleanup_d3(device);
 		}
 
 		igt_subtest_f("%s-multiple-execs", d->name) {
@@ -532,6 +569,7 @@ igt_main
 			xe_for_each_hw_engine(device.fd_xe, hwe)
 				test_exec(device, hwe, 16, 32,
 					  NO_SUSPEND, d->state);
+			cleanup_d3(device);
 		}
 	}
 
-- 
2.25.1

  reply	other threads:[~2023-12-03 18:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 13:07 [igt-dev] [PATCH i-g-t,v5 0/1] vram d3cold threshold test Mohammed Thasleem
2022-04-21 13:07 ` Mohammed Thasleem [this message]
2023-12-04  5:25   ` [igt-dev] [PATCH i-g-t, v5 1/1] tests/intel/xe_pm: Fix d3cold subtests Gupta, Anshuman
2023-12-09 19:44   ` [PATCH i-g-t v7] tests/intel/xe_pm: Fix d3 subtest Mohammed Thasleem
2023-12-11  4:57     ` Modem, Bhanuprakash
2023-12-11  8:49   ` [PATCH i-g-t v8] " Mohammed Thasleem
2023-12-12 12:24     ` Juha-Pekka Heikkila
2023-12-12 17:46       ` Thasleem, Mohammed
2023-12-12 18:35         ` Juha-Pekka Heikkila
2023-12-14 10:16     ` Gupta, Anshuman
2023-12-26 12:07     ` [PATCH i-g-t v9] " Mohammed Thasleem
2023-12-03 19:40 ` [igt-dev] ✓ CI.xeBAT: success for vram d3cold threshold test (rev10) Patchwork
2023-12-03 19:42 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2023-12-03 21:15 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-12-09 20:57 ` ✓ CI.xeBAT: success for vram d3cold threshold test (rev11) Patchwork
2023-12-09 20:58 ` ✓ Fi.CI.BAT: " Patchwork
2023-12-09 22:10 ` ✗ Fi.CI.IGT: failure " Patchwork
2023-12-11 13:13 ` ✓ CI.xeBAT: success for vram d3cold threshold test (rev12) Patchwork
2023-12-11 13:21 ` ✗ Fi.CI.BAT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-12-01 19:21 [igt-dev] [PATCH i-g-t,v5 0/1] vram d3cold threshold test Mohammed Thasleem
2023-12-01 19:21 ` [igt-dev] [PATCH i-g-t, v5 1/1] tests/intel/xe_pm: Fix d3cold subtests Mohammed Thasleem
2023-12-04  8:16   ` Modem, Bhanuprakash
2023-12-04  9:32   ` Kamil Konieczny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421130704.934-2-mohammed.thasleem@intel.com \
    --to=mohammed.thasleem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox