1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3763>
This commit is contained in:
Michel Dänzer 2024-05-21 10:23:51 +02:00 committed by Marge Bot
parent be4bf8da9c
commit 8a862b102c

View file

@ -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;