Blame SOURCES/0001-modesetting-check-the-kms-state-on-EnterVT.patch

733295
From 41f85557a939d8037dc5e509e39316bf624fd186 Mon Sep 17 00:00:00 2001
733295
From: Martin Peres <martin.peres@linux.intel.com>
733295
Date: Fri, 24 Apr 2020 18:06:16 +0300
733295
Subject: [PATCH xserver 1/2] modesetting: check the kms state on EnterVT
733295
MIME-Version: 1.0
733295
Content-Type: text/plain; charset=UTF-8
733295
Content-Transfer-Encoding: 8bit
733295
733295
Normally, we would receive a uevent coming from Linux's DRM subsystem,
733295
which would trigger the check for disappearing/appearing resources.
733295
However, this event is not received when X is not master (another VT
733295
is selected), and so the userspace / desktop environment would not be
733295
notified about the changes that happened while X wasn't master.
733295
733295
To fix the issue, this patch forces a refresh on EnterVT by splitting
733295
the kms-checking code from the uevent handling into its own (exported)
733295
function called drmmode_update_kms_state. This function is then called
733295
from both the uevent-handling function, and on EnterVT right before
733295
restoring the modes.
733295
733295
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
733295
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
733295
Acked-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
733295
Tested-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
733295
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
733295
---
733295
 hw/xfree86/drivers/modesetting/driver.c       |  2 ++
733295
 .../drivers/modesetting/drmmode_display.c     | 34 ++++++++++++-------
733295
 .../drivers/modesetting/drmmode_display.h     |  1 +
733295
 3 files changed, 24 insertions(+), 13 deletions(-)
733295
733295
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
733295
index 2aaea5f7d..a4d486a67 100644
733295
--- a/hw/xfree86/drivers/modesetting/driver.c
733295
+++ b/hw/xfree86/drivers/modesetting/driver.c
733295
@@ -1820,6 +1820,8 @@ EnterVT(ScrnInfoPtr pScrn)
733295
 
733295
     SetMaster(pScrn);
733295
 
733295
+    drmmode_update_kms_state(&ms->drmmode);
733295
+
733295
     if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE))
733295
         return FALSE;
733295
 
733295
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
733295
index 9dd8c5573..646bacecb 100644
733295
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
733295
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
733295
@@ -3607,30 +3607,19 @@ drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
733295
     return TRUE;
733295
 }
733295
 
733295
-#ifdef CONFIG_UDEV_KMS
733295
-
733295
 #define DRM_MODE_LINK_STATUS_GOOD       0
733295
 #define DRM_MODE_LINK_STATUS_BAD        1
733295
 
733295
-static void
733295
-drmmode_handle_uevents(int fd, void *closure)
733295
+void
733295
+drmmode_update_kms_state(drmmode_ptr drmmode)
733295
 {
733295
-    drmmode_ptr drmmode = closure;
733295
     ScrnInfoPtr scrn = drmmode->scrn;
733295
-    struct udev_device *dev;
733295
     drmModeResPtr mode_res;
733295
     xf86CrtcConfigPtr  config = XF86_CRTC_CONFIG_PTR(scrn);
733295
     int i, j;
733295
     Bool found = FALSE;
733295
     Bool changed = FALSE;
733295
 
733295
-    while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) {
733295
-        udev_device_unref(dev);
733295
-        found = TRUE;
733295
-    }
733295
-    if (!found)
733295
-        return;
733295
-
733295
     /* Try to re-set the mode on all the connectors with a BAD link-state:
733295
      * This may happen if a link degrades and a new modeset is necessary, using
733295
      * different link-training parameters. If the kernel found that the current
733295
@@ -3745,6 +3734,25 @@ out:
733295
 #undef DRM_MODE_LINK_STATUS_BAD
733295
 #undef DRM_MODE_LINK_STATUS_GOOD
733295
 
733295
+#ifdef CONFIG_UDEV_KMS
733295
+
733295
+static void
733295
+drmmode_handle_uevents(int fd, void *closure)
733295
+{
733295
+    drmmode_ptr drmmode = closure;
733295
+    struct udev_device *dev;
733295
+    Bool found = FALSE;
733295
+
733295
+    while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) {
733295
+        udev_device_unref(dev);
733295
+        found = TRUE;
733295
+    }
733295
+    if (!found)
733295
+        return;
733295
+
733295
+    drmmode_update_kms_state(drmmode);
733295
+}
733295
+
733295
 #endif
733295
 
733295
 void
733295
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
733295
index 4142607fb..6ef8ab9e4 100644
733295
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
733295
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
733295
@@ -281,6 +281,7 @@ void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
733295
 extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw);
733295
 extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
733295
 
733295
+extern void drmmode_update_kms_state(drmmode_ptr drmmode);
733295
 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
733295
 extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
733295
 
733295
-- 
733295
2.28.0
733295