From 8a862b102c2d059ed498eeab5e4c7abb94bc5f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 21 May 2024 10:23:51 +0200 Subject: [PATCH] kms/impl-device: Inhibit real-time scheduling when querying KMS state On some setups, the kernel may keep the KMS thread busy for significant amounts of time while querying KMS state, which could result in mutter getting killed by the kernel, e.g. after hot-plugging displays. Issue: https://gitlab.gnome.org/GNOME/mutter/-/issues/3479 Part-of: --- src/backends/native/meta-kms-impl-device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 980487482..6758982a6 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -966,6 +966,9 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device, { MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); + MetaKmsImpl *kms_impl = meta_kms_impl_device_get_impl (impl_device); + MetaThreadImpl *thread_impl = META_THREAD_IMPL (kms_impl); + MetaThread *thread = meta_thread_impl_get_thread (thread_impl); g_autoptr (GError) error = NULL; int fd; drmModeRes *drm_resources; @@ -985,11 +988,13 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device, ensure_latched_fd_hold (impl_device); fd = meta_device_file_get_fd (priv->device_file); + meta_thread_inhibit_realtime_in_impl (thread); drm_resources = drmModeGetResources (fd); if (!drm_resources) { meta_topic (META_DEBUG_KMS, "Device '%s' didn't return any resources", priv->path); + meta_thread_uninhibit_realtime_in_impl (thread); goto err; } @@ -1006,6 +1011,8 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device, changes |= meta_kms_crtc_update_state_in_impl (crtc); } + meta_thread_uninhibit_realtime_in_impl (thread); + drmModeFreeResources (drm_resources); return changes;