Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: badal.nilawar@intel.com
Subject: [igt-dev] [PATCH i-g-t v2 3/4] tests/xe: use igt_pm library functions
Date: Fri,  4 Aug 2023 16:01:10 +0530	[thread overview]
Message-ID: <20230804103111.21214-4-riana.tauro@intel.com> (raw)
In-Reply-To: <20230804103111.21214-1-riana.tauro@intel.com>

Modify xe_pm tests to use the d3cold_allowed get/set functions
from igt_pm library.

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
---
 tests/xe/xe_pm.c | 43 +++++++------------------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)

diff --git a/tests/xe/xe_pm.c b/tests/xe/xe_pm.c
index 16af38883..2126cbb38 100644
--- a/tests/xe/xe_pm.c
+++ b/tests/xe/xe_pm.c
@@ -33,6 +33,7 @@ typedef struct {
 	int fd_xe;
 	struct pci_device *pci_xe;
 	struct pci_device *pci_root;
+	char pci_slot_name[NAME_MAX];
 } device_t;
 
 /* runtime_usage is only available if kernel build CONFIG_PM_ADVANCED_DEBUG */
@@ -44,47 +45,16 @@ static bool runtime_usage_available(struct pci_device *pci)
 	return access(name, F_OK) == 0;
 }
 
-static int open_d3cold_allowed(struct pci_device *pci)
-{
-	char name[PATH_MAX];
-	int fd;
-
-	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/d3cold_allowed",
-		 pci->domain, pci->bus, pci->dev, pci->func);
-
-	fd = open(name, O_RDWR);
-	igt_assert_f(fd >= 0, "Can't open %s\n", name);
-
-	return fd;
-}
-
-static void get_d3cold_allowed(struct pci_device *pci, char *d3cold_allowed)
-{
-	int fd = open_d3cold_allowed(pci);
-
-	igt_assert(read(fd, d3cold_allowed, 2));
-	close(fd);
-}
-
-static void set_d3cold_allowed(struct pci_device *pci,
-			       const char *d3cold_allowed)
-{
-	int fd = open_d3cold_allowed(pci);
-
-	igt_assert(write(fd, d3cold_allowed, 2));
-	close(fd);
-}
-
 static bool setup_d3(device_t device, enum igt_acpi_d_state state)
 {
 	switch (state) {
 	case IGT_ACPI_D3Cold:
 		igt_require(igt_pm_acpi_d3cold_supported(device.pci_root));
 		igt_pm_enable_pci_card_runtime_pm(device.pci_root, NULL);
-		set_d3cold_allowed(device.pci_xe, "1\n");
+		igt_pm_set_d3cold_allowed(device.pci_slot_name, 1);
 		return true;
 	case IGT_ACPI_D3Hot:
-		set_d3cold_allowed(device.pci_xe, "0\n");
+		igt_pm_set_d3cold_allowed(device.pci_slot_name, 0);
 		return true;
 	default:
 		igt_debug("Invalid D3 Selection\n");
@@ -350,7 +320,7 @@ igt_main
 {
 	struct drm_xe_engine_class_instance *hwe;
 	device_t device;
-	char d3cold_allowed[2];
+	uint32_t d3cold_allowed;
 	const struct s_state {
 		const char *name;
 		enum igt_suspend_state state;
@@ -374,12 +344,13 @@ igt_main
 		device.fd_xe = drm_open_driver(DRIVER_XE);
 		device.pci_xe = igt_device_get_pci_device(device.fd_xe);
 		device.pci_root = igt_device_get_pci_root_port(device.fd_xe);
+		igt_device_get_pci_slot_name(device.fd_xe, device.pci_slot_name);
 
 		/* Always perform initial once-basic exec checking for health */
 		xe_for_each_hw_engine(device.fd_xe, hwe)
 			test_exec(device, hwe, 1, 1, NO_SUSPEND, NO_RPM);
 
-		get_d3cold_allowed(device.pci_xe, d3cold_allowed);
+		igt_pm_get_d3cold_allowed(device.pci_slot_name, &d3cold_allowed);
 		igt_assert(igt_setup_runtime_pm(device.fd_xe));
 	}
 
@@ -441,7 +412,7 @@ igt_main
 	}
 
 	igt_fixture {
-		set_d3cold_allowed(device.pci_xe, d3cold_allowed);
+		igt_pm_set_d3cold_allowed(device.pci_slot_name, d3cold_allowed);
 		igt_restore_runtime_pm();
 		drm_close_driver(device.fd_xe);
 	}
-- 
2.40.0

  parent reply	other threads:[~2023-08-04 10:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 10:31 [igt-dev] [PATCH i-g-t v2 0/4] Modify igt_pm functions and add GT C6 freeze test Riana Tauro
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/igt_device: Add a function to get the pci slot name Riana Tauro
2023-08-08  7:54   ` Gupta, Anshuman
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: change d3cold_allowed function parameters Riana Tauro
2023-08-08  8:02   ` Gupta, Anshuman
2023-08-04 10:31 ` Riana Tauro [this message]
2023-08-08  8:25   ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe: use igt_pm library functions Gupta, Anshuman
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 4/4] tests/xe: Add a test that validates residency during s2idle Riana Tauro
2023-08-08  8:35   ` Gupta, Anshuman
2023-08-09  5:16     ` Riana Tauro
2023-08-04 11:13 ` [igt-dev] ○ CI.xeBAT: info for Modify igt_pm functions and add GT C6 freeze test Patchwork
2023-08-04 11:23 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-04 16:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20230804103111.21214-4-riana.tauro@intel.com \
    --to=riana.tauro@intel.com \
    --cc=badal.nilawar@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