summaryrefslogtreecommitdiff
path: root/Kernel/Bus/PCI/API.h
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-02-04 19:48:13 +0200
committerAndreas Kling <kling@serenityos.org>2022-03-14 22:39:09 +0100
commit3fb289e27d3e0ca171438f178ea6750e25ce6f32 (patch)
tree627a284bebe455e85029a6f99ae03f21b1e36a01 /Kernel/Bus/PCI/API.h
parentc0ed656c94ffa11e1949ed2e4cc68469aa0d0cd0 (diff)
downloadserenity-3fb289e27d3e0ca171438f178ea6750e25ce6f32.zip
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.
Diffstat (limited to 'Kernel/Bus/PCI/API.h')
-rw-r--r--Kernel/Bus/PCI/API.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Bus/PCI/API.h b/Kernel/Bus/PCI/API.h
index 198e55e1d9..6c95db9aa8 100644
--- a/Kernel/Bus/PCI/API.h
+++ b/Kernel/Bus/PCI/API.h
@@ -6,6 +6,8 @@
#pragma once
+#include <AK/Error.h>
+#include <AK/Try.h>
#include <Kernel/Bus/PCI/Definitions.h>
namespace Kernel::PCI {
@@ -19,7 +21,7 @@ u32 read32(Address address, PCI::RegisterOffset field);
HardwareID get_hardware_id(PCI::Address);
bool is_io_space_enabled(Address);
-void enumerate(Function<void(DeviceIdentifier const&)> callback);
+ErrorOr<void> enumerate(Function<void(DeviceIdentifier const&)> callback);
void enable_interrupt_line(Address);
void disable_interrupt_line(Address);
void raw_access(Address, u32, size_t, u32);