Skip to content

Commit cd11170

Browse files
committed
kms: Don't join on DrmSurface drop
1 parent 458f5f4 commit cd11170

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/backend/kms/device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,9 @@ impl State {
494494
if let Some(mut leasing_global) = device.inner.leasing_global.take() {
495495
leasing_global.disable_global::<State>();
496496
}
497-
for surface in device.inner.surfaces.values_mut() {
497+
for (_, surface) in device.inner.surfaces.drain() {
498498
outputs_removed.push(surface.output.clone());
499+
surface.drop_and_join();
499500
}
500501
if let Some(token) = device.event_token.take() {
501502
self.common.event_loop_handle.remove(token);

src/backend/kms/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,11 +705,9 @@ impl<'a> KmsGuard<'a> {
705705
.crtcs()
706706
.iter()
707707
.filter(|crtc| {
708-
!device
709-
.inner
710-
.surfaces
711-
.get(crtc)
712-
.is_some_and(|surface| surface.output.is_enabled())
708+
!device.inner.surfaces.get(crtc).is_some()
709+
// TODO: We can't do this. See https://github.com/Smithay/smithay/pull/1820
710+
//.is_some_and(|surface| surface.output.is_enabled())
713711
})
714712
.copied()
715713
.collect::<HashSet<crtc::Handle>>();

src/backend/kms/surface/mod.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,16 +468,30 @@ impl Surface {
468468
}
469469
}
470470
}
471+
472+
pub fn drop_and_join(mut self) {
473+
let thread = self.thread.take();
474+
let _ = self;
475+
if let Some(thread) = thread {
476+
let name = thread.thread().name().unwrap().to_string();
477+
let _ = thread.join();
478+
info!("Thread {} terminated.", name)
479+
}
480+
}
471481
}
472482

473483
impl Drop for Surface {
474484
fn drop(&mut self) {
475485
let _ = self.thread_command.send(ThreadCommand::End);
476486
self.loop_handle.remove(self.thread_token);
477487
if let Some(thread) = self.thread.take() {
478-
let name = thread.thread().name().unwrap().to_string();
479-
let _ = thread.join();
480-
info!("Thread {} terminated.", name)
488+
let _ = thread;
489+
// We want to do this, but this currently deadlocks on `apply_config_for_outputs`.
490+
/*
491+
let name = thread.thread().name().unwrap().to_string();
492+
let _ = thread.join();
493+
info!("Thread {} terminated.", name)
494+
*/
481495
}
482496
}
483497
}

0 commit comments

Comments
 (0)