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

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