virtio-gpud: Don't process flush requests for background VT's

This ensures that the foreground VT doesn't lockup if a background VT
spams us with flush requests. In the future we may want to add a
scheduler or collapse redundant flush requests.
This commit is contained in:
bjorn3
2024-12-23 18:39:23 +01:00
parent 025086acd1
commit 0019eecadd
+11
View File
@@ -370,6 +370,11 @@ impl<'a> SchemeMut for Scheme<'a> {
fn fsync(&mut self, id: usize) -> syscall::Result<usize> {
let handle = self.handles.get(&id).ok_or(SysError::new(EINVAL))?;
if handle.vt != *handle.display.active_vt.borrow() {
// This is a protection against background VT's spamming us with flush requests. We will
// flush the resource on the next scanout anyway
return Ok(0);
}
futures::executor::block_on(handle.display.flush(handle.vt, None)).unwrap();
Ok(0)
}
@@ -395,6 +400,12 @@ impl<'a> SchemeMut for Scheme<'a> {
) -> syscall::Result<usize> {
let handle = self.handles.get(&id).ok_or(SysError::new(EINVAL))?;
if handle.vt != *handle.display.active_vt.borrow() {
// This is a protection against background VT's spamming us with flush requests. We will
// flush the resource on the next scanout anyway
return Ok(buf.len());
}
let damage = unsafe {
core::slice::from_raw_parts(
buf.as_ptr() as *const Damage,