summaryrefslogtreecommitdiff
path: root/Kernel/Bus
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-02-03 16:25:15 +0200
committerAndreas Kling <kling@serenityos.org>2022-02-03 23:33:20 +0100
commit2dc91865a4d96430081fed928009a8f65764a72b (patch)
treeedf37ea9994d57079a60290cbddc502dc02d11bf /Kernel/Bus
parentbe4c14452485d0f824e136393c06079a06732028 (diff)
downloadserenity-2dc91865a4d96430081fed928009a8f65764a72b.zip
Kernel: Stop allocating VirtIO configuration structs on the heap
These are trivially-copyable 12-byte structs, so there's no point in allocating them on the heap.
Diffstat (limited to 'Kernel/Bus')
-rw-r--r--Kernel/Bus/VirtIO/Device.cpp22
-rw-r--r--Kernel/Bus/VirtIO/Device.h2
2 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp
index 885566b5ac..67fbd7a098 100644
--- a/Kernel/Bus/VirtIO/Device.cpp
+++ b/Kernel/Bus/VirtIO/Device.cpp
@@ -97,32 +97,32 @@ UNMAP_AFTER_INIT void Device::initialize()
for (auto& capability : capabilities) {
if (capability.id().value() == PCI::Capabilities::ID::VendorSpecific) {
// We have a virtio_pci_cap
- auto cfg = make<Configuration>();
+ Configuration config {};
auto raw_config_type = capability.read8(0x3);
if (raw_config_type < static_cast<u8>(ConfigurationType::Common) || raw_config_type > static_cast<u8>(ConfigurationType::PCI)) {
dbgln("{}: Unknown capability configuration type: {}", m_class_name, raw_config_type);
return;
}
- cfg->cfg_type = static_cast<ConfigurationType>(raw_config_type);
+ config.cfg_type = static_cast<ConfigurationType>(raw_config_type);
auto cap_length = capability.read8(0x2);
if (cap_length < 0x10) {
dbgln("{}: Unexpected capability size: {}", m_class_name, cap_length);
break;
}
- cfg->bar = capability.read8(0x4);
- if (cfg->bar > 0x5) {
- dbgln("{}: Unexpected capability bar value: {}", m_class_name, cfg->bar);
+ config.bar = capability.read8(0x4);
+ if (config.bar > 0x5) {
+ dbgln("{}: Unexpected capability bar value: {}", m_class_name, config.bar);
break;
}
- cfg->offset = capability.read32(0x8);
- cfg->length = capability.read32(0xc);
- dbgln_if(VIRTIO_DEBUG, "{}: Found configuration {}, bar: {}, offset: {}, length: {}", m_class_name, (u32)cfg->cfg_type, cfg->bar, cfg->offset, cfg->length);
- if (cfg->cfg_type == ConfigurationType::Common)
+ config.offset = capability.read32(0x8);
+ config.length = capability.read32(0xc);
+ dbgln_if(VIRTIO_DEBUG, "{}: Found configuration {}, bar: {}, offset: {}, length: {}", m_class_name, (u32)config.cfg_type, config.bar, config.offset, config.length);
+ if (config.cfg_type == ConfigurationType::Common)
m_use_mmio = true;
- else if (cfg->cfg_type == ConfigurationType::Notify)
+ else if (config.cfg_type == ConfigurationType::Notify)
m_notify_multiplier = capability.read32(0x10);
- m_configs.append(move(cfg));
+ m_configs.append(config);
}
}
diff --git a/Kernel/Bus/VirtIO/Device.h b/Kernel/Bus/VirtIO/Device.h
index 993574a1c7..e42be0bb97 100644
--- a/Kernel/Bus/VirtIO/Device.h
+++ b/Kernel/Bus/VirtIO/Device.h
@@ -227,7 +227,7 @@ private:
virtual bool handle_irq(const RegisterState&) override;
NonnullOwnPtrVector<Queue> m_queues;
- NonnullOwnPtrVector<Configuration> m_configs;
+ Vector<Configuration> m_configs;
const Configuration* m_common_cfg { nullptr }; // Cached due to high usage
const Configuration* m_notify_cfg { nullptr }; // Cached due to high usage
const Configuration* m_isr_cfg { nullptr }; // Cached due to high usage