summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gnome-base/gdm/files/gdm-CanGraphical-wait.patch')
-rw-r--r--gnome-base/gdm/files/gdm-CanGraphical-wait.patch189
1 files changed, 189 insertions, 0 deletions
diff --git a/gnome-base/gdm/files/gdm-CanGraphical-wait.patch b/gnome-base/gdm/files/gdm-CanGraphical-wait.patch
new file mode 100644
index 00000000000..206219d8e05
--- /dev/null
+++ b/gnome-base/gdm/files/gdm-CanGraphical-wait.patch
@@ -0,0 +1,189 @@
+From 198d6392ff595f330430d92d5c380cd993be73d7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
+Date: Tue, 16 Oct 2018 20:59:23 +0200
+Subject: [PATCH] gdm3.service: wait for drm device before trying to start it
+
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gdm3/+bug/1794280
+Forwarded: not-needed
+---
+ configure.ac | 1 +
+ data/Makefile.am | 1 +
+ data/gdm.service.in | 1 +
+ utils/Makefile.am | 9 ++++
+ utils/gdm-wait-for-drm.c | 101 +++++++++++++++++++++++++++++++++++++++
+ 5 files changed, 113 insertions(+)
+ create mode 100644 utils/gdm-wait-for-drm.c
+
+diff --git a/configure.ac b/configure.ac
+index a8dcfbef..2755c100 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -76,6 +76,7 @@ PKG_CHECK_MODULES(COMMON,
+ gobject-2.0 >= $GLIB_REQUIRED_VERSION
+ gio-2.0 >= $GLIB_REQUIRED_VERSION
+ gio-unix-2.0 >= $GLIB_REQUIRED_VERSION
++ gudev-1.0
+ )
+ AC_SUBST(COMMON_CFLAGS)
+ AC_SUBST(COMMON_LIBS)
+diff --git a/data/Makefile.am b/data/Makefile.am
+index 162074f1..5f426fea 100644
+--- a/data/Makefile.am
++++ b/data/Makefile.am
+@@ -204,6 +204,7 @@ systemdsystemunit =
+ gdm.service: $(srcdir)/gdm.service.in
+ $(AM_V_GEN)sed \
+ -e 's,[@]sbindir[@],$(sbindir),g' \
++ -e 's,[@]libexecdir[@],$(libexecdir),g' \
+ -e 's,[@]GDM_INITIAL_VT[@],$(GDM_INITIAL_VT),g' \
+ -e 's,[@]LANG_CONFIG_FILE[@],$(LANG_CONFIG_FILE),g' \
+ -e 's,[@]PLYMOUTH_QUIT_SERVICE[@],$(PLYMOUTH_QUIT_SERVICE),g' \
+diff --git a/data/gdm.service.in b/data/gdm.service.in
+index 57d60ada..f7630ec4 100644
+--- a/data/gdm.service.in
++++ b/data/gdm.service.in
+@@ -30,6 +30,7 @@ StandardError=inherit
+ EnvironmentFile=-@LANG_CONFIG_FILE@
+ ExecReload=/bin/kill -SIGHUP $MAINPID
+ KeyringMode=shared
++ExecStartPre=@libexecdir@/gdm-wait-for-drm
+
+ [Install]
+ Alias=display-manager.service
+diff --git a/utils/Makefile.am b/utils/Makefile.am
+index babe890b..3eb43c30 100644
+--- a/utils/Makefile.am
++++ b/utils/Makefile.am
+@@ -35,6 +35,7 @@ bin_PROGRAMS = \
+
+ libexec_PROGRAMS = \
+ gdm-disable-wayland \
++ gdm-wait-for-drm \
+ $(NULL)
+
+ gdmflexiserver_LDADD = \
+@@ -63,6 +64,14 @@ gdm_disable_wayland_SOURCES = \
+ gdm-disable-wayland.c \
+ $(NULL)
+
++gdm_wait_for_drm_LDADD = \
++ $(COMMON_LIBS) \
++ $(NULL)
++
++gdm_wait_for_drm_SOURCES = \
++ gdm-wait-for-drm.c \
++ $(NULL)
++
+ CLEANFILES = \
+ $(NULL)
+
+diff --git a/utils/gdm-wait-for-drm.c b/utils/gdm-wait-for-drm.c
+new file mode 100644
+index 00000000..aeffb3c0
+--- /dev/null
++++ b/utils/gdm-wait-for-drm.c
+@@ -0,0 +1,101 @@
++#include <glib.h>
++#include <gudev/gudev.h>
++
++/*
++ * Workaround for LP: #1794280.
++ *
++ * That bug is because the DRM device isn't ready by the time GDM tries to
++ * start wayland/X.
++ * This is a script to add to ExecStartPre of gdm.service. It does the
++ * following:
++ *
++ * 1. Enumerate drm devices from udev, looking for a DRM master. If found,
++ * exit.
++ * 2. Connect to the 'uevent' signal of gudev, watching for the same to be
++ * added. Again exit if any are found.
++ * 3. If, after 10 seconds, we haven't seen anything, try to proceed anyway as
++ * a failsafe.
++ */
++
++static gboolean
++handle_device (GUdevDevice *device)
++{
++ const gchar * const * tags;
++ tags = g_udev_device_get_tags (device);
++ g_debug ("%s\n", g_udev_device_get_name (device));
++ if (g_strv_contains (tags, "master-of-seat"))
++ {
++ g_debug (" is seat master\n");
++ return TRUE;
++ }
++
++ return FALSE;
++}
++
++static void
++uevent_cb (GUdevClient *client G_GNUC_UNUSED,
++ gchar *action,
++ GUdevDevice *device,
++ gpointer user_data)
++{
++ GMainLoop *loop;
++
++ g_debug ("uevent action: %s\n", action);
++
++ loop = (GMainLoop *) user_data;
++
++ if (g_strcmp0 (action, "add") == 0)
++ {
++ if (handle_device (device))
++ {
++ g_debug (" this is good\n");
++ g_main_loop_quit (loop);
++ }
++ else
++ {
++ g_debug (" this is bad\n");
++ }
++ }
++}
++
++int
++main()
++{
++ const gchar * const subsystems[] = { "drm", NULL };
++
++ g_autoptr(GList) devices = NULL;
++ g_autoptr(GMainLoop) loop = NULL;
++ g_autoptr(GUdevClient) udev_client = NULL;
++ g_autoptr(GUdevEnumerator) enumerator = NULL;
++
++ loop = g_main_loop_new (NULL, FALSE);
++
++ udev_client = g_udev_client_new (subsystems);
++ enumerator = g_udev_enumerator_new (udev_client);
++ g_udev_enumerator_add_match_is_initialized (enumerator);
++ g_udev_enumerator_add_match_subsystem (enumerator, "drm");
++
++ devices = g_udev_enumerator_execute (enumerator);
++
++ g_debug ("enumerating devices...\n");
++
++ for (GList *l = devices; l != NULL; l = l->next)
++ {
++ g_autoptr(GUdevDevice) device = G_UDEV_DEVICE (l->data);
++
++ if (handle_device (device))
++ {
++ g_debug (" good enough for gdm\n");
++ return EXIT_SUCCESS;
++ }
++ }
++
++ g_signal_connect (udev_client, "uevent", G_CALLBACK (uevent_cb), loop);
++
++ /* after 10 seconds we try anyway */
++ g_timeout_add_seconds (10, (GSourceFunc) g_main_loop_quit, loop);
++
++ g_main_loop_run (loop);
++
++ return EXIT_SUCCESS;
++}
+--
+2.17.0
+