kms: Gracefully handle page flipping direct scanouts failing

When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
This commit is contained in:
Jonas Ådahl
2021-07-01 19:45:03 +02:00
committed by Marge Bot
parent 4b0fd9ab76
commit 1d7920872d
12 changed files with 84 additions and 32 deletions

View File

@ -849,7 +849,8 @@ process_power_save (MetaKmsImplDevice *impl_device,
static MetaKmsFeedback *
meta_kms_impl_device_atomic_process_update (MetaKmsImplDevice *impl_device,
MetaKmsUpdate *update)
MetaKmsUpdate *update,
MetaKmsUpdateFlag flags)
{
GError *error = NULL;
GList *failed_planes = NULL;
@ -973,14 +974,17 @@ commit:
err:
meta_topic (META_DEBUG_KMS, "[atomic] KMS update failed: %s", error->message);
process_entries (impl_device,
update,
req,
blob_ids,
meta_kms_update_get_page_flip_listeners (update),
error,
discard_page_flip_listener,
NULL);
if (!(flags & META_KMS_UPDATE_FLAG_PRESERVE_ON_ERROR))
{
process_entries (impl_device,
update,
req,
blob_ids,
meta_kms_update_get_page_flip_listeners (update),
error,
discard_page_flip_listener,
NULL);
}
release_blob_ids (impl_device, blob_ids);