mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Kernel/PCI: Don't hold spinlocks when doing fast device enumeration
Instead, hold the lock while we copy the contents to a stack-based Vector then iterate on it without any locking. Because we rely on heap allocations, we need to propagate errors back in case of OOM condition, therefore, both PCI::enumerate API function and PCI::Access::add_host_controller_and_enumerate_attached_devices use now a ErrorOr<void> return value to propagate errors. OOM Error can only occur when enumerating the m_device_identifiers vector under a spinlock and trying to expand the temporary Vector which will be used locklessly to actually iterate over the PCI::DeviceIdentifiers objects.
This commit is contained in:
@@ -15,7 +15,7 @@ static SerialDevice* s_the = nullptr;
|
||||
UNMAP_AFTER_INIT void PCISerialDevice::detect()
|
||||
{
|
||||
size_t current_device_minor = 68;
|
||||
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
||||
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
||||
for (auto& board_definition : board_definitions) {
|
||||
if (board_definition.device_id != device_identifier.hardware_id())
|
||||
continue;
|
||||
@@ -36,7 +36,7 @@ UNMAP_AFTER_INIT void PCISerialDevice::detect()
|
||||
dmesgln("PCISerialDevice: Found {} @ {}", board_definition.name, device_identifier.address());
|
||||
return;
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
SerialDevice& PCISerialDevice::the()
|
||||
|
||||
Reference in New Issue
Block a user