From c1d3b557d5c6dc7bee53388f3b2e1db82b799ed8 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 15 Jan 2022 09:15:46 +0200 Subject: [PATCH] Kernel/PCI: Don't try to enumerate 255 functions on the host bridge There can only be a limited number of functions (only 8). Also, consider the start bus of the PCI domain when trying to enumerate other host bridges on bus 0, device 0, functions 1-7 (function 0 is the main host bridge). --- Kernel/Bus/PCI/Controller/HostBridge.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Kernel/Bus/PCI/Controller/HostBridge.cpp b/Kernel/Bus/PCI/Controller/HostBridge.cpp index 0535195cc9..1803637293 100644 --- a/Kernel/Bus/PCI/Controller/HostBridge.cpp +++ b/Kernel/Bus/PCI/Controller/HostBridge.cpp @@ -109,19 +109,22 @@ UNMAP_AFTER_INIT void HostBridge::enumerate_attached_devices(Function::addition_would_overflow(m_domain.start_bus(), bus_as_function_number)) + break; + if (m_enumerated_buses.get(m_domain.start_bus() + bus_as_function_number)) continue; - enumerate_bus(callback, bus_as_function_number, false); - m_enumerated_buses.set(bus_as_function_number, true); + enumerate_bus(callback, m_domain.start_bus() + bus_as_function_number, false); + m_enumerated_buses.set(m_domain.start_bus() + bus_as_function_number, true); } } }