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