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

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