xserver: Branch 'server-21.1-branch' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 3 00:52:40 UTC 2021


 hw/xfree86/common/xf86Events.c               |   11 +++++++++++
 hw/xfree86/os-support/linux/systemd-logind.c |   24 ++++++++++++++++++++----
 include/systemd-logind.h                     |    2 ++
 3 files changed, 33 insertions(+), 4 deletions(-)

New commits:
commit 8eb1396d3ecfd2bf968105a99759ae9445bdf768
Author: Jocelyn Falempe <jfalempe at redhat.com>
Date:   Thu Nov 18 14:51:21 2021 +0100

    xf86/logind: Fix drm_drop_master before vt_reldisp
    
    When switching to VT, the ioctl DRM_DROP_MASTER must be done before
    the ioctl VT_RELDISP. Otherwise the kernel can't change the modesetting
    reliably, and this leads to the console not showing up in some cases, like
    after unplugging a docking station with a DP or HDMI monitor.
    
    Before doing the VT_RELDISP, send a dbus message to logind, to
    pause the drm device, so logind will do the ioctl DRM_DROP_MASTER.
    
    With this patch, it changes the order logind will send the resume
    event, and drm will be sent last instead of first.
    so there is a also fix to call systemd_logind_vtenter() at the right time.
    
    Signed-off-by: Jocelyn Falempe <jfalempe at redhat.com>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    (cherry picked from commit da9d012a9c760896941769d4127e3cfb1a7a9f03)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 05fa2bb90..6076efa80 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -382,6 +382,17 @@ xf86VTLeave(void)
     for (i = 0; i < xf86NumGPUScreens; i++)
         xf86GPUScreens[i]->LeaveVT(xf86GPUScreens[i]);
 
+    if (systemd_logind_controls_session()) {
+        for (i = 0; i < xf86_num_platform_devices; i++) {
+            if (xf86_platform_devices[i].flags & XF86_PDEV_SERVER_FD) {
+                int major, minor;
+                major = xf86_platform_odev_attributes(i)->major;
+                minor = xf86_platform_odev_attributes(i)->minor;
+                systemd_logind_drop_master(major, minor);
+            }
+        }
+    }
+
     if (!xf86VTSwitchAway())
         goto switch_failed;
 
diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index fce52ff93..35d5cc75b 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -303,6 +303,20 @@ cleanup:
     dbus_error_free(&error);
 }
 
+/*
+ * Send a message to logind, to pause the drm device
+ * and ensure the drm_drop_master is done before
+ * VT_RELDISP when switching VT
+ */
+void systemd_logind_drop_master(int _major, int _minor)
+{
+    struct systemd_logind_info *info = &logind_info;
+    dbus_int32_t major = _major;
+    dbus_int32_t minor = _minor;
+
+    systemd_logind_ack_pause(info, minor, major);
+}
+
 static DBusHandlerResult
 message_filter(DBusConnection * connection, DBusMessage * message, void *data)
 {
diff --git a/include/systemd-logind.h b/include/systemd-logind.h
index a4067d097..a8af2b96d 100644
--- a/include/systemd-logind.h
+++ b/include/systemd-logind.h
@@ -33,6 +33,7 @@ int systemd_logind_take_fd(int major, int minor, const char *path, Bool *paus);
 void systemd_logind_release_fd(int major, int minor, int fd);
 int systemd_logind_controls_session(void);
 void systemd_logind_vtenter(void);
+void systemd_logind_drop_master(int major, int minor);
 #else
 #define systemd_logind_init()
 #define systemd_logind_fini()
@@ -40,6 +41,7 @@ void systemd_logind_vtenter(void);
 #define systemd_logind_release_fd(major, minor, fd) close(fd)
 #define systemd_logind_controls_session() 0
 #define systemd_logind_vtenter()
+#define systemd_logind_drop_master(major, minor)
 #endif
 
 #endif
commit 6834f977a5eadbc3289f27b2bb83997132a39fdd
Author: Jocelyn Falempe <jfalempe at redhat.com>
Date:   Thu Nov 18 14:45:42 2021 +0100

    xf86/logind: fix call systemd_logind_vtenter after receiving drm device resume
    
    logind send the resume event for input devices and drm device,
    in any order. if we call vt_enter before logind resume the drm device,
    it leads to a driver error, because logind has not done the
    DRM_IOCTL_SET_MASTER on it.
    
    Keep the old workaround to make sure we call systemd_logind_vtenter at
    least once if there are no platform device
    
    Signed-off-by: Jocelyn Falempe <jfalempe at redhat.com>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    (cherry picked from commit f5bd039633fa8360a10bd2aabb0111571f6275b0)

diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index 9f916aa7b..fce52ff93 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -394,14 +394,16 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
         /* info->vt_active gets set by systemd_logind_vtenter() */
         info->active = TRUE;
 
-        if (pdev)
+        if (pdev) {
             pdev->flags &= ~XF86_PDEV_PAUSED;
-        else
+            systemd_logind_vtenter();
+        } else
             systemd_logind_set_input_fd_for_all_devs(major, minor, fd,
                                                      info->vt_active);
 
-        /* Always call vtenter(), in case there are only legacy video devs */
-        systemd_logind_vtenter();
+        /* Always call vtenter(), only if there are only legacy video devs */
+        if (!xf86_num_platform_devices)
+            systemd_logind_vtenter();
     }
     return DBUS_HANDLER_RESULT_HANDLED;
 }


More information about the xorg-commit mailing list