From 57dfe4696d681708da4c7491e4da3b1e711c51fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 19 Jun 2019 22:15:12 +0200 Subject: [PATCH] kms-update: Seal updates when posting them This makes sure that we won't accidentally change KMS transaction updates after they have been posted. https://gitlab.gnome.org/GNOME/mutter/merge_requests/525 --- src/backends/native/meta-kms-update-private.h | 5 ++++ src/backends/native/meta-kms-update.c | 27 +++++++++++++++++++ src/backends/native/meta-kms.c | 2 ++ 3 files changed, 34 insertions(+) diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h index bf3326ac4..32bb68bb8 100644 --- a/src/backends/native/meta-kms-update-private.h +++ b/src/backends/native/meta-kms-update-private.h @@ -34,6 +34,7 @@ typedef struct _MetaKmsProperty typedef struct _MetaKmsPlaneAssignment { + MetaKmsUpdate *update; MetaKmsCrtc *crtc; MetaKmsPlane *plane; uint32_t fb_id; @@ -67,6 +68,10 @@ typedef struct _MetaKmsPageFlip gpointer custom_page_flip_user_data; } MetaKmsPageFlip; +void meta_kms_update_seal (MetaKmsUpdate *update); + +gboolean meta_kms_update_is_sealed (MetaKmsUpdate *update); + void meta_kms_update_set_connector_property (MetaKmsUpdate *update, MetaKmsConnector *connector, uint32_t prop_id, diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index 439e917ba..95b2464b6 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -27,6 +27,8 @@ struct _MetaKmsUpdate { + gboolean is_sealed; + MetaPowerSave power_save; GList *mode_sets; GList *plane_assignments; @@ -81,8 +83,11 @@ meta_kms_update_assign_plane (MetaKmsUpdate *update, { MetaKmsPlaneAssignment *plane_assignment; + g_assert (!meta_kms_update_is_sealed (update)); + plane_assignment = g_new0 (MetaKmsPlaneAssignment, 1); *plane_assignment = (MetaKmsPlaneAssignment) { + .update = update, .crtc = crtc, .plane = plane, .fb_id = fb_id, @@ -104,6 +109,8 @@ meta_kms_update_mode_set (MetaKmsUpdate *update, { MetaKmsModeSet *mode_set; + g_assert (!meta_kms_update_is_sealed (update)); + mode_set = g_new0 (MetaKmsModeSet, 1); *mode_set = (MetaKmsModeSet) { .crtc = crtc, @@ -122,6 +129,8 @@ meta_kms_update_set_connector_property (MetaKmsUpdate *update, { MetaKmsConnectorProperty *prop; + g_assert (!meta_kms_update_is_sealed (update)); + prop = g_new0 (MetaKmsConnectorProperty, 1); *prop = (MetaKmsConnectorProperty) { .connector = connector, @@ -141,6 +150,8 @@ meta_kms_update_page_flip (MetaKmsUpdate *update, { MetaKmsPageFlip *page_flip; + g_assert (!meta_kms_update_is_sealed (update)); + page_flip = g_new0 (MetaKmsPageFlip, 1); *page_flip = (MetaKmsPageFlip) { .crtc = crtc, @@ -161,6 +172,8 @@ meta_kms_update_custom_page_flip (MetaKmsUpdate *update, { MetaKmsPageFlip *page_flip; + g_assert (!meta_kms_update_is_sealed (update)); + page_flip = g_new0 (MetaKmsPageFlip, 1); *page_flip = (MetaKmsPageFlip) { .crtc = crtc, @@ -180,6 +193,8 @@ meta_kms_plane_assignment_set_plane_property (MetaKmsPlaneAssignment *plane_assi { MetaKmsProperty *plane_prop; + g_assert (!meta_kms_update_is_sealed (plane_assignment->update)); + plane_prop = meta_kms_property_new (prop_id, value); plane_assignment->plane_properties = @@ -216,6 +231,18 @@ meta_kms_update_has_mode_set (MetaKmsUpdate *update) return !!update->mode_sets; } +void +meta_kms_update_seal (MetaKmsUpdate *update) +{ + update->is_sealed = TRUE; +} + +gboolean +meta_kms_update_is_sealed (MetaKmsUpdate *update) +{ + return update->is_sealed; +} + MetaKmsUpdate * meta_kms_update_new (void) { diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c index 976eae230..641aaa198 100644 --- a/src/backends/native/meta-kms.c +++ b/src/backends/native/meta-kms.c @@ -202,6 +202,8 @@ meta_kms_post_update_sync (MetaKms *kms, MetaKmsUpdate *update, GError **error) { + meta_kms_update_seal (update); + return meta_kms_run_impl_task_sync (kms, meta_kms_update_process_in_impl, update,