[PATCH xserver 1/7] modesetting: Check for uevents on EnterVT

Daniel Martin consume.noise at gmail.com
Mon Nov 20 10:02:04 UTC 2017


We have to re-evaluate the outputs (their ids) before
drmmode_set_desired_modes() as it triggers drmmode_set_mode_major().
drmmode_set_mode_major() working with old ids is likely to fail and will
tear down the server.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 hw/xfree86/drivers/modesetting/driver.c          |  2 +-
 hw/xfree86/drivers/modesetting/drmmode_display.c | 18 ++++++++++++++++++
 hw/xfree86/drivers/modesetting/drmmode_display.h |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 380dbbe17..286d3e070 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -1760,7 +1760,7 @@ EnterVT(ScrnInfoPtr pScrn)
 
     SetMaster(pScrn);
 
-    if (!drmmode_set_desired_modes(pScrn, &ms->drmmode, TRUE))
+    if (!drmmode_enter_vt(pScrn, &ms->drmmode))
         return FALSE;
 
     return TRUE;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 5ecf20a36..537b2b2c0 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -54,6 +54,8 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height);
 static PixmapPtr drmmode_create_pixmap_header(ScreenPtr pScreen, int width, int height,
                                               int depth, int bitsPerPixel, int devKind,
                                               void *pPixData);
+static void drmmode_handle_uevents(int fd, void *closure);
+
 static Bool
 drmmode_zaphod_string_matches(ScrnInfoPtr scrn, const char *s, char *output_name)
 {
@@ -2008,6 +2010,22 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
 };
 
 Bool
+drmmode_enter_vt(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+{
+#ifdef CONFIG_UDEV_KMS
+    if (drmmode->uevent_monitor) {
+        drmmode_handle_uevents(
+                udev_monitor_get_fd(drmmode->uevent_monitor), drmmode);
+    }
+#endif
+
+    if (!drmmode_set_desired_modes(pScrn, drmmode, TRUE))
+        return FALSE;
+
+    return TRUE;
+}
+
+Bool
 drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 {
     modesettingEntPtr ms_ent = ms_ent_priv(pScrn);
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index c2a15adf7..b146e717a 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -180,6 +180,7 @@ Bool drmmode_SharedPixmapFlip(PixmapPtr frontTarget, xf86CrtcPtr crtc,
                               drmmode_ptr drmmode);
 void drmmode_DisableSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode);
 
+extern Bool drmmode_enter_vt(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
 extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw);
-- 
2.13.6



More information about the xorg-devel mailing list