monitor-manager-kms: Disable CRTCs if there is no monitor

After last monitor gets unplugged from the system, hotplug detection may
no longer work on Intel GFX.

This is because we didn't trigger a modeset to disable CRTCs, and i915
requires it to make hotplug detection continue to work [1].

Ensure disabled CRTCs are unset and post a modeset to disable them.

[1] https://www.kernel.org/doc/html/latest/gpu/i915.html#hotplug

https://gitlab.freedesktop.org/drm/intel/-/issues/2602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1561>
This commit is contained in:
Kai-Heng Feng 2020-12-21 14:59:32 +08:00
parent 45a9c386bb
commit e5b07138f0
3 changed files with 25 additions and 0 deletions

View File

@ -281,6 +281,14 @@ meta_monitor_manager_kms_apply_monitors_config (MetaMonitorManager *manager
if (!config)
{
if (!manager->in_init)
{
MetaBackend *backend = meta_get_backend ();
MetaRenderer *renderer = meta_backend_get_renderer (backend);
meta_renderer_native_reset_modes (META_RENDERER_NATIVE (renderer));
}
manager->screen_width = META_MONITOR_MANAGER_MIN_SCREEN_WIDTH;
manager->screen_height = META_MONITOR_MANAGER_MIN_SCREEN_HEIGHT;
meta_monitor_manager_rebuild (manager, NULL);

View File

@ -3744,6 +3744,21 @@ on_power_save_mode_changed (MetaMonitorManager *monitor_manager,
meta_kms_discard_pending_page_flips (kms);
}
void
meta_renderer_native_reset_modes (MetaRendererNative *renderer_native)
{
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
MetaKmsUpdate *kms_update;
kms_update = unset_disabled_crtcs (backend, kms);
if (kms_update)
post_pending_update (kms);
}
static MetaGpuKms *
choose_primary_gpu_unchecked (MetaBackend *backend,
MetaRendererNative *renderer_native)

View File

@ -55,6 +55,8 @@ MetaGpuKms * meta_renderer_native_get_primary_gpu (MetaRendererNative *renderer_
void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native);
gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native);
gboolean meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen,