From da3baba9806226f4fb9c080d7e986728457733ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 19 Mar 2021 12:08:21 +0100 Subject: [PATCH] backend/native: Only disable KMS modifiers for i915 The intel DRM driver is known for not being able to handle multi head setups when KMS modifiers are enabled, due to the implicitly selected modifiers, while being more suitable for single head setups, cause bandwidth issues when a certain number of monitor times resolution and refresh rate is configured. We don't yet support automatically finding a combination of modifiers that work, and have because of this disabled KMS modifiers unless the driver actually needs it. Lets flip this configuration the other way around, changing the current udev rule to decide wen to *disable* KMS modifier support, as it so that only the Intel driver has this problem, while on the other hand, there several drivers that requires modifiers to function at all. Part-of: --- data/61-mutter.rules | 2 +- src/backends/native/meta-backend-native.c | 4 ++-- src/backends/native/meta-gpu-kms.c | 4 ++-- src/backends/native/meta-gpu-kms.h | 2 +- src/backends/native/meta-kms-types.h | 2 +- src/backends/native/meta-renderer-native.c | 18 ++++++++++++++++-- src/backends/native/meta-udev.c | 4 ++-- src/backends/native/meta-udev.h | 2 +- 8 files changed, 26 insertions(+), 12 deletions(-) diff --git a/data/61-mutter.rules b/data/61-mutter.rules index 59cc00007..99a9cf513 100644 --- a/data/61-mutter.rules +++ b/data/61-mutter.rules @@ -1 +1 @@ -DRIVER=="tegra-host1x", SUBSYSTEM=="platform", TAG+="mutter-device-requires-kms-modifiers" +DRIVERS=="i915", SUBSYSTEM=="drm", TAG+="mutter-device-disable-kms-modifiers" diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index dbbedceae..f907acd96 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -423,8 +423,8 @@ create_gpu_from_udev_device (MetaBackendNative *native, if (meta_is_udev_device_boot_vga (device)) flags |= META_KMS_DEVICE_FLAG_BOOT_VGA; - if (meta_is_udev_device_requires_modifiers (device)) - flags |= META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS; + if (meta_is_udev_device_disable_modifiers (device)) + flags |= META_KMS_DEVICE_FLAG_DISABLE_MODIFIERS; if (meta_is_udev_device_preferred_primary (device)) flags |= META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY; diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c index e964b1094..e81c90a02 100644 --- a/src/backends/native/meta-gpu-kms.c +++ b/src/backends/native/meta-gpu-kms.c @@ -149,12 +149,12 @@ meta_gpu_kms_is_platform_device (MetaGpuKms *gpu_kms) } gboolean -meta_gpu_kms_requires_modifiers (MetaGpuKms *gpu_kms) +meta_gpu_kms_disable_modifiers (MetaGpuKms *gpu_kms) { MetaKmsDeviceFlag flags; flags = meta_kms_device_get_flags (gpu_kms->kms_device); - return !!(flags & META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS); + return !!(flags & META_KMS_DEVICE_FLAG_DISABLE_MODIFIERS); } static int diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h index 80957f5a0..f13a141f4 100644 --- a/src/backends/native/meta-gpu-kms.h +++ b/src/backends/native/meta-gpu-kms.h @@ -47,7 +47,7 @@ gboolean meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms, gboolean meta_gpu_kms_is_boot_vga (MetaGpuKms *gpu_kms); gboolean meta_gpu_kms_is_platform_device (MetaGpuKms *gpu_kms); -gboolean meta_gpu_kms_requires_modifiers (MetaGpuKms *gpu_kms); +gboolean meta_gpu_kms_disable_modifiers (MetaGpuKms *gpu_kms); MetaKmsDevice * meta_gpu_kms_get_kms_device (MetaGpuKms *gpu_kms); diff --git a/src/backends/native/meta-kms-types.h b/src/backends/native/meta-kms-types.h index 01db55a40..739aca780 100644 --- a/src/backends/native/meta-kms-types.h +++ b/src/backends/native/meta-kms-types.h @@ -59,7 +59,7 @@ typedef enum _MetaKmsDeviceFlag META_KMS_DEVICE_FLAG_NONE = 0, META_KMS_DEVICE_FLAG_BOOT_VGA = 1 << 0, META_KMS_DEVICE_FLAG_PLATFORM_DEVICE = 1 << 1, - META_KMS_DEVICE_FLAG_REQUIRES_MODIFIERS = 1 << 2, + META_KMS_DEVICE_FLAG_DISABLE_MODIFIERS = 1 << 2, META_KMS_DEVICE_FLAG_PREFERRED_PRIMARY = 1 << 3, META_KMS_DEVICE_FLAG_NO_MODE_SETTING = 1 << 4, } MetaKmsDeviceFlag; diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index f48db9ab8..d00128d56 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1984,6 +1984,8 @@ meta_renderer_native_initable_init (GInitable *initable, gpus = meta_backend_get_gpus (backend); if (gpus) { + const char *use_kms_modifiers_debug_env; + for (l = gpus; l; l = l->next) { MetaGpuKms *gpu_kms = META_GPU_KMS (l->data); @@ -1998,8 +2000,20 @@ meta_renderer_native_initable_init (GInitable *initable, if (!renderer_native->primary_gpu_kms) return FALSE; - if (meta_gpu_kms_requires_modifiers (renderer_native->primary_gpu_kms)) - renderer_native->use_modifiers = TRUE; + use_kms_modifiers_debug_env = g_getenv ("MUTTER_DEBUG_USE_KMS_MODIFIERS"); + if (use_kms_modifiers_debug_env) + { + renderer_native->use_modifiers = + g_strcmp0 (use_kms_modifiers_debug_env, "1") == 0; + } + else + { + renderer_native->use_modifiers = + !meta_gpu_kms_disable_modifiers (renderer_native->primary_gpu_kms); + } + + meta_topic (META_DEBUG_KMS, "Usage of KMS modifiers is %s", + renderer_native->use_modifiers ? "enabled" : "disabled"); } else { diff --git a/src/backends/native/meta-udev.c b/src/backends/native/meta-udev.c index 9a6bfe03b..5d58d6b56 100644 --- a/src/backends/native/meta-udev.c +++ b/src/backends/native/meta-udev.c @@ -75,7 +75,7 @@ meta_is_udev_device_boot_vga (GUdevDevice *device) } gboolean -meta_is_udev_device_requires_modifiers (GUdevDevice *device) +meta_is_udev_device_disable_modifiers (GUdevDevice *device) { g_autoptr (GUdevDevice) platform_device = NULL; const char * const * tags; @@ -92,7 +92,7 @@ meta_is_udev_device_requires_modifiers (GUdevDevice *device) if (!tags) return FALSE; - return g_strv_contains (tags, "mutter-device-requires-kms-modifiers"); + return g_strv_contains (tags, "mutter-device-disable-kms-modifiers"); } gboolean diff --git a/src/backends/native/meta-udev.h b/src/backends/native/meta-udev.h index 453cce9a7..360e06213 100644 --- a/src/backends/native/meta-udev.h +++ b/src/backends/native/meta-udev.h @@ -32,7 +32,7 @@ gboolean meta_is_udev_device_platform_device (GUdevDevice *device); gboolean meta_is_udev_device_boot_vga (GUdevDevice *device); -gboolean meta_is_udev_device_requires_modifiers (GUdevDevice *device); +gboolean meta_is_udev_device_disable_modifiers (GUdevDevice *device); gboolean meta_is_udev_device_preferred_primary (GUdevDevice *device);