[PATCH i-g-t] tests/intel/xe_pm: Add a check for power management capability

Jakub Kolakowski jakub1.kolakowski at intel.com
Thu Mar 6 19:06:21 UTC 2025


Add a check for power management capability of device tested. Currently
if test is started on configuration that does not support the PM
capability it doesn't skip, instead depending on test it may fail, abort
or timeout.
With this change test will skip with a clear message why it did.

Cc: Adam Miszczak <adam.miszczak at linux.intel.com>
Cc: Lukasz Laguna <lukasz.laguna at intel.com>
Cc: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>
Signed-off-by: Jakub Kolakowski <jakub1.kolakowski at intel.com>
---
 tests/intel/xe_pm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index c2026474d..049596ebc 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -17,6 +17,7 @@
 
 #include "igt.h"
 #include "lib/igt_device.h"
+#include "lib/igt_pci.h"
 #include "lib/igt_pm.h"
 #include "lib/igt_sysfs.h"
 #include "lib/igt_syncobj.h"
@@ -38,6 +39,8 @@
 #define PREFETCH (0x1 << 1)
 #define UNBIND_ALL (0x1 << 2)
 
+#define PCI_PM_CAP_ID 0x01
+
 enum mem_op {
 	READ,
 	WRITE,
@@ -779,6 +782,7 @@ igt_main
 	device_t device;
 	uint32_t d3cold_allowed;
 	int sysfs_fd;
+	int offset;
 
 	const struct s_state {
 		const char *name;
@@ -812,6 +816,11 @@ 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);
+
+		/* Make sure power management capability is present for device being tested */
+		offset = find_pci_cap_offset(device.pci_root, PCI_PM_CAP_ID);
+		igt_require_f(offset > 0, "PCI power management capability not found\n");
+
 		igt_device_get_pci_slot_name(device.fd_xe, device.pci_slot_name);
 
 		/* Always perform initial once-basic exec checking for health */
-- 
2.34.1



More information about the igt-dev mailing list