Blame SOURCES/0002-monitor-manager-kms-Check-if-GPUs-can-have-outputs.patch

776610
From aa6d1614c069496bab3f6fa5d374c727fa352742 Mon Sep 17 00:00:00 2001
776610
From: Iain Lane <iainl@gnome.org>
776610
Date: Mon, 13 Aug 2018 10:22:22 +0000
776610
Subject: [PATCH 2/2] monitor-manager-kms: Check if GPUs can have outputs
776610
776610
We need a way for mutter to exit if no available GPUs are going to work.
776610
For example if gdm starts gnome-shell and we're using a DRM driver that
776610
doesn't work with KMS then we should exit so that GDM can try with Xorg,
776610
rather than operating in headless mode.
776610
776610
Related: https://gitlab.gnome.org/GNOME/mutter/issues/223
776610
776610
776610
(cherry picked from commit deb541ef5ac2cc07d0259c259bff8d1523388d47)
776610
---
776610
 src/backends/native/meta-gpu-kms.c            |  8 ++++++++
776610
 src/backends/native/meta-gpu-kms.h            |  2 ++
776610
 .../native/meta-monitor-manager-kms.c         | 20 +++++++++++++++++++
776610
 3 files changed, 30 insertions(+)
776610
776610
diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c
776610
index 7e7607c46..08c1e7dbe 100644
776610
--- a/src/backends/native/meta-gpu-kms.c
776610
+++ b/src/backends/native/meta-gpu-kms.c
776610
@@ -797,6 +797,12 @@ meta_gpu_kms_read_current (MetaGpu  *gpu,
776610
   return TRUE;
776610
 }
776610
 
776610
+gboolean
776610
+meta_gpu_kms_can_have_outputs (MetaGpuKms *gpu_kms)
776610
+{
776610
+  return gpu_kms->n_connectors > 0;
776610
+}
776610
+
776610
 MetaGpuKms *
776610
 meta_gpu_kms_new (MetaMonitorManagerKms  *monitor_manager_kms,
776610
                   const char             *kms_file_path,
776610
@@ -860,6 +866,8 @@ meta_gpu_kms_new (MetaMonitorManagerKms  *monitor_manager_kms,
776610
 
776610
   drmSetClientCap (gpu_kms->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
776610
 
776610
+  meta_gpu_kms_read_current (META_GPU (gpu_kms), NULL);
776610
+
776610
   source = g_source_new (&kms_event_funcs, sizeof (MetaKmsSource));
776610
   kms_source = (MetaKmsSource *) source;
776610
   kms_source->fd_tag = g_source_add_unix_fd (source,
776610
diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h
776610
index 3d0f5f65e..d53ed98c8 100644
776610
--- a/src/backends/native/meta-gpu-kms.h
776610
+++ b/src/backends/native/meta-gpu-kms.h
776610
@@ -59,6 +59,8 @@ gboolean meta_gpu_kms_apply_crtc_mode (MetaGpuKms *gpu_kms,
776610
                                        int         y,
776610
                                        uint32_t    fb_id);
776610
 
776610
+gboolean meta_gpu_kms_can_have_outputs (MetaGpuKms *gpu_kms);
776610
+
776610
 gboolean meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
776610
                                       MetaCrtc   *crtc);
776610
 
776610
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
776610
index d8e7b848d..438069110 100644
776610
--- a/src/backends/native/meta-monitor-manager-kms.c
776610
+++ b/src/backends/native/meta-monitor-manager-kms.c
776610
@@ -642,10 +642,12 @@ meta_monitor_manager_kms_initable_init (GInitable    *initable,
776610
                                         GError      **error)
776610
 {
776610
   MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (initable);
776610
+  MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
776610
   const char *subsystems[2] = { "drm", NULL };
776610
   GList *gpu_paths;
776610
   g_autofree char *primary_gpu_path = NULL;
776610
   GList *l;
776610
+  gboolean can_have_outputs;
776610
 
776610
   manager_kms->udev = g_udev_client_new (subsystems);
776610
 
776610
@@ -694,6 +696,24 @@ meta_monitor_manager_kms_initable_init (GInitable    *initable,
776610
     }
776610
   g_list_free_full (gpu_paths, g_free);
776610
 
776610
+  can_have_outputs = FALSE;
776610
+  for (l = meta_monitor_manager_get_gpus (manager); l; l = l->next)
776610
+    {
776610
+      MetaGpuKms *gpu_kms = l->data;
776610
+
776610
+      if (meta_gpu_kms_can_have_outputs (gpu_kms))
776610
+        {
776610
+          can_have_outputs = TRUE;
776610
+          break;
776610
+        }
776610
+    }
776610
+  if (!can_have_outputs)
776610
+    {
776610
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
776610
+                   "No GPUs with outputs found");
776610
+      return FALSE;
776610
+    }
776610
+
776610
   return TRUE;
776610
 }
776610
 
776610
-- 
776610
2.19.0
776610