Skip to content

Commit 677583a

Browse files
committed
uefi: Change PciRootBridgeIo::enumerate() start only at first bus nr
1 parent 32c0944 commit 677583a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

uefi/src/proto/pci/root_bridge.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,18 @@ impl PciRootBridgeIo {
101101
use crate::proto::pci::enumeration;
102102

103103
let mut devices = BTreeSet::new();
104-
for descriptor in self.configuration()? {
105-
// In the descriptors we can query for the current root bridge, Bus entries contain ranges of valid
106-
// bus addresses. These are starting points for the recursive scanning process performed in
107-
// enumeration::enum_bus
108-
if descriptor.resource_range_type == ResourceRangeType::Bus {
109-
for bus in (descriptor.address_min as u8)..=(descriptor.address_max as u8) {
110-
let addr = PciIoAddress::new(bus, 0, 0);
111-
enumeration::visit_bus(self, addr, &mut devices)?;
112-
}
113-
}
104+
// In the descriptors, the entry with range_type bus specifies the bus numbers that were
105+
// allocated to devices below this root bridge. The first bus number in this range is
106+
// the starting point. All subsequent numbers are reached via PCI bridge recursion during enumeration.
107+
if let Some(descriptor) = self
108+
.configuration()?
109+
.iter()
110+
.find(|d| d.resource_range_type == ResourceRangeType::Bus)
111+
{
112+
let addr = PciIoAddress::new(descriptor.address_min as u8, 0, 0);
113+
enumeration::visit_bus(self, addr, &mut devices)?;
114114
}
115+
115116
Ok(devices)
116117
}
117118
}

0 commit comments

Comments
 (0)