diff --git a/Kernel/Arch/x86_64/PCI/Initializer.cpp b/Kernel/Arch/x86_64/PCI/Initializer.cpp index 37f9bc6c4d..f90479caea 100644 --- a/Kernel/Arch/x86_64/PCI/Initializer.cpp +++ b/Kernel/Arch/x86_64/PCI/Initializer.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -70,6 +71,16 @@ UNMAP_AFTER_INIT void initialize() PCIBusSysFSDirectory::initialize(); + // IRQ from pin-based interrupt should be set as reserved as soon as possible so that the PCI device + // that chooses to use MSI(x) based interrupt can avoid sharing the IRQ with other devices. + MUST(PCI::enumerate([&](DeviceIdentifier const& device_identifier) { + // A simple sanity check to avoid getting a panic in get_interrupt_handler() before setting the IRQ as reserved. + if (auto irq = device_identifier.interrupt_line().value(); irq < GENERIC_INTERRUPT_HANDLERS_COUNT) { + auto& handler = get_interrupt_handler(irq); + handler.set_reserved(); + } + })); + MUST(PCI::enumerate([&](DeviceIdentifier const& device_identifier) { dmesgln("{} {}", device_identifier.address(), device_identifier.hardware_id()); }));