From 25172c21c96588d8d7a875f628064e12e1efe4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 22 Jun 2022 00:23:03 +0200 Subject: [PATCH] kms/impl-device: Move fd hold to update when processing This will let us move the update ownership to the backend, allowing it to handle it with less restrictions. Part-of: --- src/backends/native/meta-kms-impl-device.c | 4 ++-- src/backends/native/meta-kms-update-private.h | 3 +++ src/backends/native/meta-kms-update.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 4ce2bdb53..c14538975 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -1018,11 +1018,11 @@ meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device, return meta_kms_feedback_new_failed (NULL, g_steal_pointer (&error)); } - meta_kms_impl_device_hold_fd (impl_device); + meta_kms_update_realize (update, impl_device); + feedback = klass->process_update (impl_device, update, flags); if (!(flags & META_KMS_UPDATE_FLAG_TEST_ONLY)) changes = meta_kms_impl_device_predict_states (impl_device, update); - meta_kms_impl_device_unhold_fd (impl_device); meta_kms_update_free (update); diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h index e7fa6f957..f39b47b9f 100644 --- a/src/backends/native/meta-kms-update-private.h +++ b/src/backends/native/meta-kms-update-private.h @@ -197,6 +197,9 @@ void meta_kms_result_listener_free (MetaKmsResultListener *listener); void meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip); +void meta_kms_update_realize (MetaKmsUpdate *update, + MetaKmsImplDevice *impl_device); + G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback, meta_kms_plane_feedback_free) diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index 27832b2c0..68564fec7 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -25,6 +25,7 @@ #include "backends/meta-display-config-shared.h" #include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-crtc.h" +#include "backends/native/meta-kms-impl-device.h" #include "backends/native/meta-kms-mode-private.h" #include "backends/native/meta-kms-plane.h" #include "backends/native/meta-kms-private.h" @@ -44,6 +45,8 @@ struct _MetaKmsUpdate GList *page_flip_listeners; GList *result_listeners; + + MetaKmsImplDevice *impl_device; }; void @@ -902,6 +905,9 @@ meta_kms_update_new (MetaKmsDevice *device) void meta_kms_update_free (MetaKmsUpdate *update) { + if (update->impl_device) + meta_kms_impl_device_unhold_fd (update->impl_device); + g_list_free_full (update->result_listeners, (GDestroyNotify) meta_kms_result_listener_free); g_list_free_full (update->plane_assignments, @@ -917,3 +923,11 @@ meta_kms_update_free (MetaKmsUpdate *update) g_free (update); } + +void +meta_kms_update_realize (MetaKmsUpdate *update, + MetaKmsImplDevice *impl_device) +{ + update->impl_device = impl_device; + meta_kms_impl_device_hold_fd (impl_device); +}