summaryrefslogtreecommitdiff
path: root/lib/igt_device.c
diff options
context:
space:
mode:
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>2022-02-23 10:43:53 +0100
committerJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>2022-02-23 10:43:53 +0100
commita1842d465c83c732c3e3d67d41c0e29cbaf7682d (patch)
treead8d317be4bc4f5a55f7e0c61a34e837f0e9c78d /lib/igt_device.c
parentc220c60bb4679e2e9cdf8accbf90f888e6819456 (diff)
Revert "lib/igt_device: Add support for accessing unbound VF PCI devices"
This reverts commit c220c60bb4679e2e9cdf8accbf90f888e6819456. Incorrect version of the patch has been pushed, sorry. Signed-of-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Diffstat (limited to 'lib/igt_device.c')
-rw-r--r--lib/igt_device.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/lib/igt_device.c b/lib/igt_device.c
index 6d952047..c50bf4a1 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -149,9 +149,9 @@ struct igt_pci_addr {
unsigned int function;
};
-static int igt_device_get_pci_addr(int fd, unsigned int vf_id, struct igt_pci_addr *pci)
+static int igt_device_get_pci_addr(int fd, struct igt_pci_addr *pci)
{
- char link[20], path[IGT_DEV_PATH_LEN];
+ char path[IGT_DEV_PATH_LEN];
char *buf;
int sysfs;
int len;
@@ -159,21 +159,11 @@ static int igt_device_get_pci_addr(int fd, unsigned int vf_id, struct igt_pci_ad
if (!igt_device_is_pci(fd))
return -ENODEV;
- if (vf_id)
- len = snprintf(link, sizeof(link), "device/virtfn%u", vf_id - 1);
- else
- len = snprintf(link, sizeof(link), "device");
- if (igt_warn_on_f(len > sizeof(link) || link[len -1],
- "IGT bug: insufficient buffer space for rendering PCI device link name\n"))
- return -ENOSPC;
- else if (igt_debug_on_f(len < 0, "unexpected failure from snprintf()\n"))
- return len;
-
sysfs = igt_sysfs_open(fd);
if (sysfs == -1)
return -ENOENT;
- len = readlinkat(sysfs, link, path, sizeof(path) - 1);
+ len = readlinkat(sysfs, "device", path, sizeof(path) - 1);
close(sysfs);
if (len == -1)
return -ENOENT;
@@ -193,25 +183,12 @@ static int igt_device_get_pci_addr(int fd, unsigned int vf_id, struct igt_pci_ad
return 0;
}
-/**
- * __igt_device_get_pci_device:
- *
- * @fd: DRM device file descriptor
- * @vf_id: virtual function number (0 if native or PF)
- *
- * Looks up the graphics pci device using libpciaccess.
- * Since pci_system_init() is called, users are expected to call pci_sytem_clenup() after use
- * unless an error occurs and NULL is returned.
- *
- * Returns:
- * The pci_device, NULL on any failures.
- */
-struct pci_device *__igt_device_get_pci_device(int fd, unsigned int vf_id)
+static struct pci_device *__igt_device_get_pci_device(int fd)
{
struct igt_pci_addr pci_addr;
struct pci_device *pci_dev;
- if (igt_device_get_pci_addr(fd, vf_id, &pci_addr)) {
+ if (igt_device_get_pci_addr(fd, &pci_addr)) {
igt_warn("Unable to find device PCI address\n");
return NULL;
}
@@ -229,19 +206,15 @@ struct pci_device *__igt_device_get_pci_device(int fd, unsigned int vf_id)
igt_warn("Couldn't find PCI device %04x:%02x:%02x:%02x\n",
pci_addr.domain, pci_addr.bus,
pci_addr.device, pci_addr.function);
- goto cleanup;
+ return NULL;
}
if (pci_device_probe(pci_dev)) {
igt_warn("Couldn't probe PCI device\n");
- goto cleanup;
+ return NULL;
}
return pci_dev;
-
-cleanup:
- pci_system_cleanup();
- return NULL;
}
/**
@@ -250,7 +223,6 @@ cleanup:
* @fd: the device
*
* Looks up the main graphics pci device using libpciaccess.
- * Since pci_system_init() is called, users are expected to call pci_sytem_clenup() after use.
*
* Returns:
* The pci_device, skips the test on any failures.
@@ -259,7 +231,7 @@ struct pci_device *igt_device_get_pci_device(int fd)
{
struct pci_device *pci_dev;
- pci_dev = __igt_device_get_pci_device(fd, 0);
+ pci_dev = __igt_device_get_pci_device(fd);
igt_require(pci_dev);
return pci_dev;