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

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