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 3/4] tests/xe: use igt_pm library functions
Date: Thu, 3 Aug 2023 10:36:08 +0530 [thread overview]
Message-ID: <20230803050609.2835714-4-riana.tauro@intel.com> (raw)
In-Reply-To: <20230803050609.2835714-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 559eccdeb..4b0c07098 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
next prev parent reply other threads:[~2023-08-03 5:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 5:06 [igt-dev] [PATCH i-g-t 0/4] RFC Modify igt_pm functions and add GT C6 freeze test Riana Tauro
2023-08-03 5:06 ` [igt-dev] [PATCH i-g-t 1/4] lib/igt_device: Add a function to get the pci slot name Riana Tauro
2023-08-03 6:44 ` Gupta, Anshuman
2023-08-03 5:06 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_pm: change d3cold_allowed function parameters Riana Tauro
2023-08-03 7:07 ` Gupta, Anshuman
2023-08-03 8:46 ` Riana Tauro
2023-08-03 8:48 ` Gupta, Anshuman
2023-08-03 5:06 ` Riana Tauro [this message]
2023-08-03 5:06 ` [igt-dev] [PATCH i-g-t 4/4] tests/xe: Add a test that validates residency during s2idle Riana Tauro
2023-08-03 7:47 ` Gupta, Anshuman
2023-08-03 8:48 ` Riana Tauro
2023-08-03 6:05 ` [igt-dev] ○ CI.xeBAT: info for RFC Modify igt_pm functions and add GT C6 freeze test Patchwork
2023-08-03 6:09 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-03 7:50 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20230803050609.2835714-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