From a1842d465c83c732c3e3d67d41c0e29cbaf7682d Mon Sep 17 00:00:00 2001 From: Janusz Krzysztofik Date: Wed, 23 Feb 2022 10:43:53 +0100 Subject: 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 --- lib/igt_device.c | 44 ++++++++------------------------------------ lib/igt_device.h | 1 - 2 files changed, 8 insertions(+), 37 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; diff --git a/lib/igt_device.h b/lib/igt_device.h index 1aaa840e..278ba7a9 100644 --- a/lib/igt_device.h +++ b/lib/igt_device.h @@ -33,6 +33,5 @@ void igt_device_drop_master(int fd); int igt_device_get_card_index(int fd); struct pci_device *igt_device_get_pci_device(int fd); -struct pci_device *__igt_device_get_pci_device(int fd, unsigned int vf_id); #endif /* __IGT_DEVICE_H__ */ -- cgit v1.2.3