[PATCH] tests/intel/xe_pm: include PCI domain in i2c adapter name

Sk Anirban <[email protected]>
Newsgroups org.freedesktop.lists.igt-dev
Message-ID <[email protected]>
The i2c_designware adapter name only encoded bus and device, which
fails on non-zero PCI domains. Include the full domain/bus/device and
widen the format specifier.

Also fix IGT by using the devfn in the adapter id to match the kernel.

kernel implementation:
https://patchwork.freedesktop.org/series/170812/
Signed-off-by: Sk Anirban <[email protected]>
---
 tests/intel/xe_pm.c            | 5 +++--
 tests/intel/xe_survivability.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index 6fbc13e43..840e3f0be 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -866,8 +866,9 @@ static int find_i2c_adapter(device_t device, int sysfs_fd)
 	/* Make sure the /dev/i2c-* files exist */
 	igt_require(igt_kmod_load("i2c-dev", NULL) == 0);
 
-	snprintf(adapter, sizeof(adapter), "%s.%hu", "device/i2c_designware",
-		 (device.pci_xe->bus << 8) | (device.pci_xe->dev));
+	snprintf(adapter, sizeof(adapter), "%s.%u", "device/i2c_designware",
+		 (device.pci_xe->domain << 16 | device.pci_xe->bus << 8 |
+		  (device.pci_xe->dev << 3 | device.pci_xe->func)));
 	adapter_fd = openat(sysfs_fd, adapter, O_RDONLY);
 	igt_require_fd(adapter_fd);
 
diff --git a/tests/intel/xe_survivability.c b/tests/intel/xe_survivability.c
index 74488bbea..d72884e70 100644
--- a/tests/intel/xe_survivability.c
+++ b/tests/intel/xe_survivability.c
@@ -126,8 +126,9 @@ static int find_i2c_adapter(struct pci_device *pci_xe)
 
 	igt_require(igt_kmod_load("i2c-dev", NULL) == 0);
 
-	snprintf(device_path, sizeof(device_path), "/sys/bus/pci/devices/%s/%s.%hu", bus_addr,
-		 "i2c_designware", (pci_xe->bus << 8) | (pci_xe->dev));
+	snprintf(device_path, sizeof(device_path), "/sys/bus/pci/devices/%s/%s.%u", bus_addr,
+		 "i2c_designware", (pci_xe->domain << 16 | pci_xe->bus << 8 |
+		  (pci_xe->dev << 3 | pci_xe->func)));
 	device_dir = opendir(device_path);
 
 	if (!device_dir)
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.