Skip to content

Conversation

Drakulix
Copy link
Member

Since #1778 we provide an api to explicitly lock the DrmOutputManager to apply multiple changes atomically without DrmOutputs being able to observe any inconsistent state.

However as a side-effect of this, it has become impossible to re-assign a crtc to a different connector in one atomic opertion, as the lock on the DrmOutputManager prevents the Drop-implementation of DrmOutput to free any crtcs for re-use. This is a problem in cosmic-comp currently, when trying to apply a new configuration in one go on more resource constraint systems leading to a rejection of the entire configuration.

This commit introduces a channel to defer freeing the crtc to the locked manager, if locking fails. Since this can be racy, we rely on the event-loop to free up any crtcs stuck in said channel. Synchronization with different threads for dropping the DrmOutput still needs to be handled by downstream (e.g. by joining said thread).

I'd like to get some feedback on this approach. I also tried to fix this issue without involving the event-loop by using additional CondVars and other synchronization primitives, but that grew very complex to the point where we might as well build our own RwLock for this specific purpose.

Since #1778 we provide an api to explicitly lock the `DrmOutputManager`
to apply multiple changes atomically without `DrmOutput`s being able to
observe any inconsistent state.

However as a side-effect of this, it has become impossible to re-assign
a crtc to a different connector in one atomic opertion, as the lock on
the `DrmOutputManager` prevents the `Drop`-implementation of `DrmOutput`
to free any crtcs for re-use.

This commit introduces a channel, if locking fails to deferr freeing
the crtc to the locked manager.
@Drakulix Drakulix requested review from cmeissl and ids1024 September 10, 2025 13:42
@Drakulix Drakulix changed the title drm/output: Allow DrmOutput descruction during manager-lock drm/output: Allow DrmOutput destruction during manager-lock Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant