fix(kms): skip empty DRM cleanup commit in display_configuration

display_configuration() issued an ALLOW_MODESET atomic commit on every udev
event, even when no planes needed detaching. The empty commit is a no-op
modeset that interferes with in-flight commits on the render thread, and it
fails with EPERM whenever we don't hold DRM master (e.g. a render-only
secondary GPU), aborting device enumeration.

Track whether any property was added and skip the commit when there is nothing
to do. A commit that does have changes still propagates its error as before, so
a genuine failure to apply cleanup is not silently swallowed.

https://github.com/pop-os/cosmic-comp/issues/2375

Authored by Claude Opus 4.8
Reviewed by Timo Strunk <Timo.Strunk@gmail.com>

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Timo Strunk 2026-07-22 22:31:41 +02:00 • committed by Jacob Kauffmann
parent 53a8d0bea2
commit 24d29008f0

View file

@ -75,6 +75,7 @@ pub fn display_configuration(
// And then cleanup
if device.is_atomic() {
let mut req = AtomicModeReq::new();
let mut has_changes = false;
let plane_handles = device.plane_handles()?;
// We cannot just shortcut and use the legacy api for all cleanups because of this.
@ -95,10 +96,15 @@ pub fn display_configuration(
let fb_id = get_prop(device, plane, "FB_ID")?;
req.add_property(plane, crtc_id, property::Value::CRTC(None));
req.add_property(plane, fb_id, property::Value::Framebuffer(None));
has_changes = true;
}
}
}
device.atomic_commit(AtomicCommitFlags::ALLOW_MODESET, req)?;
// Skip an empty commit: a no-op modeset that also fails with EPERM
// without DRM master (e.g. a render-only secondary GPU).
if has_changes {
device.atomic_commit(AtomicCommitFlags::ALLOW_MODESET, req)?;
}
} else {
for crtc in res_handles.crtcs() {
#[allow(deprecated)]