drm/output: Allow DrmOutput destruction during manager-lock
#1820
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #1778 we provide an api to explicitly lock the
DrmOutputManagerto apply multiple changes atomically withoutDrmOutputs 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
DrmOutputManagerprevents theDrop-implementation ofDrmOutputto 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
DrmOutputstill 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 ownRwLockfor this specific purpose.