Wonkyu Kim has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84228?usp=email )
Change subject: src/device: Add more condition to check valid PCI device id ......................................................................
src/device: Add more condition to check valid PCI device id
Checking more conditions to check valid PCI device id to avoid device stuck issue.
Below are invalid PCI device id cases VID: 0x0 or 0xffff DID: 0x0 or 0xffff
Signed-off-by: Wonkyu Kim wonkyu.kim@intel.com Change-Id: Iffabc9037a8af1b2a4ffebdf30199c4f6eae9540 --- M src/device/pci_device.c 1 file changed, 18 insertions(+), 17 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/28/84228/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index a2ad2b3..1b76b2f 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -1220,20 +1220,20 @@ dummy.path.pci.devfn = devfn;
id = pci_read_config32(&dummy, PCI_VENDOR_ID); - /* - * Have we found something? Some broken boards return 0 if a - * slot is empty, but the expected answer is 0xffffffff. - */ - if (id == 0xffffffff) - return NULL;
- if ((id == 0x00000000) || (id == 0x0000ffff) || - (id == 0xffff0000)) { - printk(BIOS_SPEW, "%s, bad id 0x%x\n", - dev_path(&dummy), id); + /* Checking bad VID and DID */ + dummy.vendor = id & 0xffff; + dummy.device = (id >> 16) & 0xffff; + if ((dummy.vendor == 0x0000) || (dummy.vendor == 0xffff) || + (dummy.device == 0xffff) || (dummy.device == 0x0000)) { + printk(BIOS_SPEW, "device %s [0x%04x/0x%04x] is not found.\n", + dev_path(&dummy), dummy.vendor, dummy.device); return NULL; } + dev = alloc_dev(bus, &dummy.path); + dev->vendor = dummy.vendor; + dev->device = dummy.device; } else { /* * Enable/disable the device. Once we have found the device- @@ -1259,13 +1259,16 @@ * this also handles optional devices that may not always * show up. */ - /* If the chain is fully enumerated quit */ - if ((id == 0xffffffff) || (id == 0x00000000) || - (id == 0x0000ffff) || (id == 0xffff0000)) { + + /* Checking bad VID and DID */ + dev->vendor = id & 0xffff; + dev->device = (id >> 16) & 0xffff; + if ((dev->vendor == 0x0000) || (dev->vendor == 0xffff) || + (dev->device == 0xffff) || (dev->device == 0x0000)) { if (dev->enabled) { printk(BIOS_INFO, - "PCI: Static device %s not found, disabling it.\n", - dev_path(dev)); + "PCI: Static device %s [0x%04x/0x%04x] not found, disabling it.\n", + dev_path(dev), dev->vendor, dev->device); dev->enabled = 0; } return dev; @@ -1277,8 +1280,6 @@ class = pci_read_config32(dev, PCI_CLASS_REVISION);
/* Store the interesting information in the device structure. */ - dev->vendor = id & 0xffff; - dev->device = (id >> 16) & 0xffff; dev->hdr_type = hdr_type;
/* Class code, the upper 3 bytes of PCI_CLASS_REVISION. */