Comments
Patch
===================================================================
@@ -243,17 +243,26 @@
pci_io_write_config32(dev, where, value);
#endif
}
+static inline __attribute__((always_inline)) int forbidden_dev_for_locate(device_t dev)
+{ // empty pci slots hang pci_locate_device
+ device_t dev_only = (dev & PCI_DEV(0,0x1F,0));
+ return ( ((dev_only >= PCI_DEV(0,2,0)) && (dev_only < PCI_DEV(0,0x8,0)))
+ || ((dev_only >= PCI_DEV(0,0x9,0)) && (dev_only < PCI_DEV(0,0x11,0)) )
+ );
+}
#define PCI_DEV_INVALID (0xffffffffU)
static inline device_t pci_io_locate_device(unsigned pci_id, device_t dev)
{
for(; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0,0,1)) {
unsigned int id;
+ if (!forbidden_dev_for_locate(dev)) {
id = pci_io_read_config32(dev, 0);
if (id == pci_id) {
return dev;
}
}
+ }
return PCI_DEV_INVALID;
}
@@ -261,28 +270,30 @@
{
for(; dev <= PCI_DEV(255|(((1<<CONFIG_PCI_BUS_SEGN_BITS)-1)<<8), 31, 7); dev += PCI_DEV(0,0,1)) {
unsigned int id;
+ if (!forbidden_dev_for_locate(dev)) {
id = pci_read_config32(dev, 0);
if (id == pci_id) {
return dev;
}
}
+ }
return PCI_DEV_INVALID;
}
static inline device_t pci_locate_device_on_bus(unsigned pci_id, unsigned bus)
{
device_t dev, last;
-
dev = PCI_DEV(bus, 0, 0);
last = PCI_DEV(bus, 31, 7);
-
for(; dev <=last; dev += PCI_DEV(0,0,1)) {
unsigned int id;
+ if (!forbidden_dev_for_locate(dev)) {
id = pci_read_config32(dev, 0);
if (id == pci_id) {
return dev;
}
}
+ }
return PCI_DEV_INVALID;
}