diff options
author | Liav A <liavalb@gmail.com> | 2021-10-22 20:43:33 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-23 19:17:44 +0200 |
commit | 8e55c4bfaf9cfbe9ff8ef18cadd0312ea6395f1e (patch) | |
tree | 06db162e3bf7c882ff6d410fd5404e8b7e900fba /Kernel/Bus | |
parent | 72e831e9e9cf8ccfa194ffb5d65199bdc8670830 (diff) | |
download | serenity-8e55c4bfaf9cfbe9ff8ef18cadd0312ea6395f1e.zip |
Kernel/PCI: Remove InterruptDisabler usage
Instead, just ensure we pick the m_access_lock and then m_scan_lock when
doing a scan/re-scan of the PCI configuration space so we know nobody
can actually access the PCI configuration space during the scan.
The m_scan_lock is now a Spinlock, to ensure we cannot yield to other
process while we do the PCI configuration space scanning.
Diffstat (limited to 'Kernel/Bus')
-rw-r--r-- | Kernel/Bus/PCI/Access.cpp | 10 | ||||
-rw-r--r-- | Kernel/Bus/PCI/Access.h | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index 964afd7e24..ad1f8c9106 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -8,7 +8,6 @@ #include <AK/HashTable.h> #include <Kernel/API/KResult.h> #include <Kernel/Arch/x86/IO.h> -#include <Kernel/Arch/x86/InterruptDisabler.h> #include <Kernel/Bus/PCI/Access.h> #include <Kernel/Debug.h> #include <Kernel/Firmware/ACPI/Definitions.h> @@ -40,7 +39,6 @@ UNMAP_AFTER_INIT bool Access::initialize_for_memory_access(PhysicalAddress mcfg_ if (Access::is_initialized()) return false; - InterruptDisabler disabler; auto* access = new Access(Access::AccessType::Memory); if (!access->search_pci_domains_from_acpi_mcfg_table(mcfg_table)) return false; @@ -307,7 +305,8 @@ u32 Access::read32_field(Address address, u32 field) UNMAP_AFTER_INIT void Access::rescan_hardware_with_memory_addressing() { - MutexLocker locker(m_scan_lock); + MutexLocker locker(m_access_lock); + SpinlockLocker scan_locker(m_scan_lock); VERIFY(m_device_identifiers.is_empty()); VERIFY(!m_domains.is_empty()); VERIFY(m_access_type == AccessType::Memory); @@ -330,7 +329,8 @@ UNMAP_AFTER_INIT void Access::rescan_hardware_with_memory_addressing() UNMAP_AFTER_INIT void Access::rescan_hardware_with_io_addressing() { - MutexLocker locker(m_scan_lock); + MutexLocker locker(m_access_lock); + SpinlockLocker scan_locker(m_scan_lock); VERIFY(m_device_identifiers.is_empty()); VERIFY(m_access_type == AccessType::IO); dbgln_if(PCI_DEBUG, "PCI: IO enumerating hardware"); @@ -456,7 +456,7 @@ UNMAP_AFTER_INIT void Access::enumerate_bus(int type, u8 bus, bool recursive) void Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& callback) const { - MutexLocker locker(m_scan_lock); + MutexLocker locker(m_access_lock); VERIFY(!m_device_identifiers.is_empty()); for (auto& device_identifier : m_device_identifiers) { callback(device_identifier); diff --git a/Kernel/Bus/PCI/Access.h b/Kernel/Bus/PCI/Access.h index f8fc3c1955..55762fec57 100644 --- a/Kernel/Bus/PCI/Access.h +++ b/Kernel/Bus/PCI/Access.h @@ -11,6 +11,7 @@ #include <AK/Vector.h> #include <Kernel/Bus/PCI/Definitions.h> #include <Kernel/FileSystem/SysFS.h> +#include <Kernel/Locking/Spinlock.h> namespace Kernel::PCI { @@ -82,7 +83,7 @@ private: // General Data-members mutable Mutex m_access_lock; - mutable Mutex m_scan_lock; + mutable Spinlock m_scan_lock; Bitmap m_enumerated_buses; AccessType m_access_type; Vector<DeviceIdentifier> m_device_identifiers; |