mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-30 15:02:56 +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:
parent
c0ed656c94
commit
3fb289e27d
Notes:
sideshowbarker
2024-07-17 17:26:03 +09:00
Author: https://github.com/supercomputer7
Commit: 3fb289e27d
Pull-request: https://github.com/SerenityOS/serenity/pull/12282
Reviewed-by: https://github.com/awesomekling
14 changed files with 69 additions and 42 deletions
|
@ -17,9 +17,9 @@ u8 read8(Address address, PCI::RegisterOffset field) { return Access::the().read
|
|||
u16 read16(Address address, PCI::RegisterOffset field) { return Access::the().read16_field(address, to_underlying(field)); }
|
||||
u32 read32(Address address, PCI::RegisterOffset field) { return Access::the().read32_field(address, to_underlying(field)); }
|
||||
|
||||
void enumerate(Function<void(DeviceIdentifier const&)> callback)
|
||||
ErrorOr<void> enumerate(Function<void(DeviceIdentifier const&)> callback)
|
||||
{
|
||||
Access::the().fast_enumerate(callback);
|
||||
return Access::the().fast_enumerate(callback);
|
||||
}
|
||||
|
||||
DeviceIdentifier get_device_identifier(Address address)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue