Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/39842
to review the following change.
Change subject: device: Wait for PCI devices to show up ......................................................................
device: Wait for PCI devices to show up
Some PCI devices need too long to show up. If a device is explicitly mentioned as `on` in the devicetree, give it 1s.
Change-Id: Id8659bc38e0c7e3ec065beb0b1a303fe1e2665d2 Signed-off-by: Nico Huber nico.huber@secunet.com --- M src/device/pci_device.c 1 file changed, 22 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/42/39842/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index b1e88a6..5ee7b39 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -33,10 +33,10 @@ #include <device/hypertransport.h> #include <pc80/i8259.h> #include <security/vboot/vbnv.h> +#include <timer.h> #include <timestamp.h> #include <types.h>
- u8 pci_moving_config8(struct device *dev, unsigned int reg) { u8 value, ones, zeroes; @@ -1095,6 +1095,27 @@ id = pci_read_config32(dev, PCI_VENDOR_ID);
/* + * If the device is enabled in the devicetree, + * wait a little for it to show up. + */ + if (dev->enabled && id == 0xffffffff) { + static struct stopwatch pci_reset_sw; + + if (pci_reset_sw.start.microseconds == + pci_reset_sw.expires.microseconds) + stopwatch_init_msecs_expire(&pci_reset_sw, 1000); + + while (id == 0xffffffff && !stopwatch_expired(&pci_reset_sw)) { + mdelay(10); + id = pci_read_config32(dev, PCI_VENDOR_ID); + } + + if (id != 0xffffffff) + printk(BIOS_ERR, "PCI: Had to wait for device %s.\n", + dev_path(dev)); + } + + /* * If the device does not have a PCI ID disable it. Possibly * this is because we have already disabled the device. But * this also handles optional devices that may not always