1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:47:36 +00:00

Kernel: Implement basic VirGL device

This commit flips VirtIOGPU back to using a Mutex for its operation
lock (instead of a spinlock). This is necessary for avoiding a few
system hangs when queuing actions on the driver from multiple
processes, which becomes much more of an issue when using VirGL from
multiple userspace process.

This does result in a few code paths where we inevitably have to grab
a mutex from inside a spinlock, the only way to fix both issues is to
move to issuing asynchronous virtio gpu commands.
This commit is contained in:
Sahan Fernando 2022-02-13 16:45:30 +11:00 committed by Ali Mohammad Pur
parent 966989afe8
commit fd6a536c60
7 changed files with 503 additions and 8 deletions

View file

@ -108,7 +108,7 @@ ErrorOr<void> FramebufferDevice::flush_head_buffer(size_t)
}
ErrorOr<void> FramebufferDevice::flush_rectangle(size_t buffer_index, FBRect const& rect)
{
SpinlockLocker locker(adapter()->operation_lock());
MutexLocker locker(adapter()->operation_lock());
Protocol::Rect dirty_rect {
.x = rect.x,
.y = rect.y,
@ -165,7 +165,7 @@ FramebufferDevice::~FramebufferDevice()
ErrorOr<void> FramebufferDevice::create_framebuffer()
{
SpinlockLocker locker(adapter()->operation_lock());
MutexLocker locker(adapter()->operation_lock());
// First delete any existing framebuffers to free the memory first
m_framebuffer = nullptr;
m_framebuffer_sink_vmobject = nullptr;
@ -255,7 +255,7 @@ void FramebufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect,
void FramebufferDevice::set_buffer(int buffer_index)
{
auto& buffer = buffer_index == 0 ? m_main_buffer : m_back_buffer;
SpinlockLocker locker(adapter()->operation_lock());
MutexLocker locker(adapter()->operation_lock());
if (&buffer == m_current_buffer)
return;
m_current_buffer = &buffer;