mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
Kernel: Move VirtIO code away from using a scatter gather list
Currently, when passing buffers into VirtIOQueues, we use scatter-gather lists, which contain an internal vector of buffers. This vector is allocated, filled and the destroy whenever we try to provide buffers into a virtqueue, which would happen a lot in performance cricital code (the main transport mechanism for certain paravirtualized devices). This commit moves it over to using VirtIOQueueChains and building the chain in place in the VirtIOQueue. Also included are a bunch of fixups for the VirtIO Console device, making it use an internal VM::RingBuffer instead.
This commit is contained in:
parent
13d5cdcd08
commit
ed0e7b53a5
11 changed files with 312 additions and 159 deletions
|
@ -335,13 +335,6 @@ void VirtIODevice::finish_init()
|
|||
dbgln_if(VIRTIO_DEBUG, "{}: Finished initialization", m_class_name);
|
||||
}
|
||||
|
||||
void VirtIODevice::supply_buffer_and_notify(u16 queue_index, const ScatterGatherRefList& scatter_list, BufferType buffer_type, void* token)
|
||||
{
|
||||
VERIFY(queue_index < m_queue_count);
|
||||
if (get_queue(queue_index).supply_buffer({}, scatter_list, buffer_type, token))
|
||||
notify_queue(queue_index);
|
||||
}
|
||||
|
||||
u8 VirtIODevice::isr_status()
|
||||
{
|
||||
if (!m_isr_cfg)
|
||||
|
@ -353,12 +346,14 @@ void VirtIODevice::handle_irq(const RegisterState&)
|
|||
{
|
||||
u8 isr_type = isr_status();
|
||||
if (isr_type & DEVICE_CONFIG_INTERRUPT) {
|
||||
dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Device config interrupt!", m_class_name);
|
||||
if (!handle_device_config_change()) {
|
||||
set_status_bit(DEVICE_STATUS_FAILED);
|
||||
dbgln("{}: Failed to handle device config change!", m_class_name);
|
||||
}
|
||||
}
|
||||
if (isr_type & QUEUE_INTERRUPT) {
|
||||
dbgln_if(VIRTIO_DEBUG, "{}: VirtIO Queue interrupt!", m_class_name);
|
||||
for (size_t i = 0; i < m_queues.size(); i++) {
|
||||
if (get_queue(i).new_data_available())
|
||||
return handle_queue_update(i);
|
||||
|
@ -369,4 +364,14 @@ void VirtIODevice::handle_irq(const RegisterState&)
|
|||
dbgln("{}: Handling interrupt with unknown type: {}", m_class_name, isr_type);
|
||||
}
|
||||
|
||||
void VirtIODevice::supply_chain_and_notify(u16 queue_index, VirtIOQueueChain& chain)
|
||||
{
|
||||
auto& queue = get_queue(queue_index);
|
||||
VERIFY(&chain.queue() == &queue);
|
||||
VERIFY(queue.lock().is_locked());
|
||||
chain.submit_to_queue();
|
||||
if (queue.should_notify())
|
||||
notify_queue(queue_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue