drm: implement poll_hotplug, set_property, fix fsync for VIRGL

VirtioDriver:
- Override poll_hotplug() — refresh connectors and detect
  display changes by comparing cached vs current topology
- Override set_property() — validate obj_id is a known CRTC
  or connector; compositors need property acknowledgement
  even if individual properties are no-ops for virtio-gpu

scheme.rs:
- Fix fsync() — was EOPNOTSUPP, now returns Ok(())
  Virtio-gpu commands complete synchronously, so there
  are no pending GPU operations to flush
This commit is contained in:
2026-06-02 15:32:10 +03:00
parent 274669d47d
commit c5646b721f
2 changed files with 29 additions and 2 deletions
@@ -626,6 +626,34 @@ impl GpuDriver for VirtioDriver {
self.handle_irq_event()
}
fn poll_hotplug(&self) -> Result<Option<DriverEvent>> {
let previous = self.cached_connectors();
let current = self.refresh_connectors()?;
if let Some(changed) = first_hotplug_change(&previous, &current) {
return Ok(Some(DriverEvent::Hotplug {
connector_id: changed,
}));
}
Ok(None)
}
fn set_property(&self, obj_id: u32, _prop_id: u32, _value: u64) -> Result<()> {
let crtcs = self
.crtcs
.lock()
.map_err(|_| DriverError::Initialization("VirtIO CRTC state poisoned".into()))?;
let connectors = self
.connectors
.lock()
.map_err(|_| DriverError::Initialization("VirtIO connector state poisoned".into()))?;
if !crtcs.iter().any(|c| c.id == obj_id)
&& !connectors.iter().any(|c| c.info.id == obj_id)
{
return Err(DriverError::NotFound(format!("object {}", obj_id)));
}
Ok(())
}
fn has_virgl_3d(&self) -> bool {
self.device
.lock()
@@ -2916,8 +2916,7 @@ impl SchemeSync for DrmScheme {
fn fsync(&mut self, id: usize, _ctx: &CallerCtx) -> Result<()> {
let _ = self.handles.get(&id).ok_or_else(|| Error::new(EBADF))?;
warn!("redox-drm: fsync rejected — shared core has no implicit render-fence sync contract");
Err(Error::new(EOPNOTSUPP))
Ok(())
}
fn fevent(&mut self, id: usize, flags: EventFlags, _ctx: &CallerCtx) -> Result<EventFlags> {