diff options
author | Liav A <liavalb@gmail.com> | 2021-09-07 15:59:18 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-08 16:47:01 +0200 |
commit | 666c0c5a08aebb48a6f861968aeaccbadb05ced1 (patch) | |
tree | 6f6756fc42212db2c0ee010d79173dc4ccda48cd | |
parent | ac798da6420827b6ce7bbcec82cdcd17b63fc3ed (diff) | |
download | serenity-666c0c5a08aebb48a6f861968aeaccbadb05ced1.zip |
Kernel/VirtIO: Determine names without PCI access in IRQ context
This is a fix so the VirtIO code doesn't lead to assertion because we
try to determine the name based on the PCI values of the VirtIO device,
because trying to read from the PCI configuration space requires to
acquire a Mutex, which fails in an IRQ context.
To ensure we never encounter a situation when we call a pure virtual
function in an IRQ context, let's make class_name() method to be a
non-pure virtual function, so it can be still called at anytime.
-rw-r--r-- | Kernel/Bus/VirtIO/Device.cpp | 10 | ||||
-rw-r--r-- | Kernel/Bus/VirtIO/Device.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp index aef08c126d..17f0ac72aa 100644 --- a/Kernel/Bus/VirtIO/Device.cpp +++ b/Kernel/Bus/VirtIO/Device.cpp @@ -396,25 +396,25 @@ bool Device::handle_irq(const RegisterState&) { u8 isr_type = isr_status(); if ((isr_type & (QUEUE_INTERRUPT | DEVICE_CONFIG_INTERRUPT)) == 0) { - dbgln_if(VIRTIO_DEBUG, "{}: Handling interrupt with unknown type: {}", VirtIO::determine_device_class(pci_address()), isr_type); + dbgln_if(VIRTIO_DEBUG, "{}: Handling interrupt with unknown type: {}", class_name(), isr_type); return false; } if (isr_type & DEVICE_CONFIG_INTERRUPT) { - dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Device config interrupt!", VirtIO::determine_device_class(pci_address())); + dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Device config interrupt!", class_name()); if (!handle_device_config_change()) { set_status_bit(DEVICE_STATUS_FAILED); - dbgln("{}: Failed to handle device config change!", VirtIO::determine_device_class(pci_address())); + dbgln("{}: Failed to handle device config change!", class_name()); } } if (isr_type & QUEUE_INTERRUPT) { - dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Queue interrupt!", VirtIO::determine_device_class(pci_address())); + dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Queue interrupt!", class_name()); for (size_t i = 0; i < m_queues.size(); i++) { if (get_queue(i).new_data_available()) { handle_queue_update(i); return true; } } - dbgln_if(VIRTIO_DEBUG, "{}: Got queue interrupt but all queues are up to date!", VirtIO::determine_device_class(pci_address())); + dbgln_if(VIRTIO_DEBUG, "{}: Got queue interrupt but all queues are up to date!", class_name()); } return true; } diff --git a/Kernel/Bus/VirtIO/Device.h b/Kernel/Bus/VirtIO/Device.h index 6a2d6b3e0e..b162e267dc 100644 --- a/Kernel/Bus/VirtIO/Device.h +++ b/Kernel/Bus/VirtIO/Device.h @@ -93,7 +93,7 @@ public: virtual void initialize(); protected: - virtual StringView class_name() const = 0; + virtual StringView class_name() const { return "VirtIO::Device"; } explicit Device(PCI::Address); struct MappedMMIO { OwnPtr<Memory::Region> base; |