Blame SOURCES/0031-Fix-another-buggy-fake-acpi-pci-root-driver.patch

5e6fc3
From da30e9f2eee235ce11d47bb2e32f976b8c187e5d Mon Sep 17 00:00:00 2001
5e6fc3
From: Peter Jones <pjones@redhat.com>
5e6fc3
Date: Mon, 10 Sep 2018 15:00:03 -0400
5e6fc3
Subject: [PATCH 31/39] Fix another buggy fake acpi pci root driver
5e6fc3
5e6fc3
In this case, the platform driver that creates the PCI(e) root device
5e6fc3
doesn't fill in its driver link, so we can't look up what driver is in
5e6fc3
use - but since it's the root, it *really* doesn't matter.  And in
5e6fc3
general, we only really care if it's the last node in our path, because
5e6fc3
that'll be the controller for the boot device anyway.
5e6fc3
5e6fc3
Signed-off-by: Peter Jones <pjones@redhat.com>
5e6fc3
---
5e6fc3
 src/linux-pci.c | 24 +++++++++++++++++-------
5e6fc3
 1 file changed, 17 insertions(+), 7 deletions(-)
5e6fc3
5e6fc3
diff --git a/src/linux-pci.c b/src/linux-pci.c
5e6fc3
index e7c864b2d33..f63f5914d9f 100644
5e6fc3
--- a/src/linux-pci.c
5e6fc3
+++ b/src/linux-pci.c
5e6fc3
@@ -67,7 +67,9 @@ parse_pci(struct device *dev, const char *current, const char *root)
5e6fc3
                 uint8_t bus, device, function;
5e6fc3
                 struct pci_dev_info *pci_dev;
5e6fc3
                 unsigned int i = dev->n_pci_devs;
5e6fc3
+                struct stat statbuf;
5e6fc3
 
5e6fc3
+                debug("devpart is \"%s\"", devpart);
5e6fc3
                 pos = 0;
5e6fc3
                 debug("searching for 0000:00:00.0/");
5e6fc3
                 rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
5e6fc3
@@ -100,15 +102,23 @@ parse_pci(struct device *dev, const char *current, const char *root)
5e6fc3
                         return -1;
5e6fc3
                 }
5e6fc3
                 tmp[devpart - root] = '\0';
5e6fc3
-                rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
5e6fc3
-                if (rc < 0 || !linkbuf) {
5e6fc3
-                        efi_error("Could not find driver for pci device %s", tmp);
5e6fc3
-                        free(tmp);
5e6fc3
-                        return -1;
5e6fc3
+                rc = sysfs_stat(&statbuf, "class/block/%s/driver", tmp);
5e6fc3
+                if (rc < 0 && errno == ENOENT) {
5e6fc3
+                        debug("No driver link for /sys/class/block/%s", tmp);
5e6fc3
+                        debug("Assuming this is just a buggy platform core driver");
5e6fc3
+                        dev->pci_dev[i].driverlink = NULL;
5e6fc3
+                } else {
5e6fc3
+                        rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
5e6fc3
+                        if (rc < 0 || !linkbuf) {
5e6fc3
+                                efi_error("Could not find driver for pci device %s", tmp);
5e6fc3
+                                free(tmp);
5e6fc3
+                                return -1;
5e6fc3
+                        } else {
5e6fc3
+                                dev->pci_dev[i].driverlink = strdup(linkbuf);
5e6fc3
+                                debug("driver:%s\n", linkbuf);
5e6fc3
+                        }
5e6fc3
                 }
5e6fc3
                 free(tmp);
5e6fc3
-                dev->pci_dev[i].driverlink = strdup(linkbuf);
5e6fc3
-                debug("driver:%s\n", linkbuf);
5e6fc3
                 dev->n_pci_devs += 1;
5e6fc3
         }
5e6fc3
 
5e6fc3
-- 
5e6fc3
2.17.1
5e6fc3