mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 09:04:30 +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:
@@ -231,14 +231,14 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
||||
else if (framebuffer_devices_use_bootloader_framebuffer())
|
||||
dbgln("Forcing use of framebuffer set up by the bootloader");
|
||||
|
||||
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
||||
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
|
||||
// Note: Each graphics controller will try to set its native screen resolution
|
||||
// upon creation. Later on, if we don't want to have framebuffer devices, a
|
||||
// framebuffer console will take the control instead.
|
||||
if (!is_vga_compatible_pci_device(device_identifier) && !is_display_controller_pci_device(device_identifier))
|
||||
return;
|
||||
determine_and_initialize_graphics_device(device_identifier);
|
||||
});
|
||||
}));
|
||||
|
||||
if (!m_console) {
|
||||
// If no graphics driver was instantiated and we had a bootloader provided
|
||||
|
||||
Reference in New Issue
Block a user