xserver: Branch 'server-1.20-branch' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 18 20:52:09 UTC 2019


 glamor/glamor_egl.c               |   19 ++++++++++++++-----
 hw/xwayland/xwayland-cursor.c     |    2 ++
 hw/xwayland/xwayland-glamor-gbm.c |   34 ++++++++++++++++++++++++++++++----
 hw/xwayland/xwayland-input.c      |    1 +
 4 files changed, 47 insertions(+), 9 deletions(-)

New commits:
commit c86222d4bd94892f3bf3c5947c19793ca18bd9e2
Author: Carlos Garnacho <carlosg at gnome.org>
Date:   Wed May 22 17:51:04 2019 +0200

    xwayland: Reset scheduled frames after hiding tablet cursor
    
    Hiding the tablet tool cursor results in it being hidden forever after.
    This is due to the stale frame callback that will neither be disposed
    or replaced. This can be reproduced in krita (X11) as the pointer
    cursor is hidden while over the canvas.
    
    Clearing the frame callback ensures the correct behavior in future
    xwl_tablet_tool_set_cursor() calls (i.e. a new cursor surface being
    displayed, and a new frame callback created), and is 1:1
    with xwl_seat_set_cursor() for pointers.
    
    Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
    (cherry picked from commit dea4a74621294391ce5901bb3339e1b8e7151efc)

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index cf8395f1d..66720bcc0 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -188,6 +188,8 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
         zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
                                       xwl_tablet_tool->proximity_in_serial,
                                       NULL, 0, 0);
+        clear_cursor_frame_callback(xwl_cursor);
+        xwl_cursor->needs_update = FALSE;
         return;
     }
 
commit 6e199e4613e149cd5d5ce69cdd6a259744b6cb44
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Apr 26 13:37:09 2019 +0200

    glamor: Make pixmap exportable from `gbm_bo_from_pixmap()`
    
    If a pixmap is not exportable, `glamor_gbm_bo_from_pixmap()` would fail
    and the modesettings driver would consequently fail to do its page flip,
    which both prevents Present from working and also fill up the logs with
    error messages such as:
    
      (EE) modeset(0): Failed to get GBM bo for flip to new front.
      (EE) modeset(0): present flip failed
    
    Refactor the code so that `glamor_gbm_bo_from_pixmap()` takes care of
    making the pixmap exportable.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Signed-off-by: Yuxuan Shui yshui at hadean.com
    See-also: https://gitlab.freedesktop.org/xorg/xserver/merge_requests/131
    Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/68
    Fixes: 86b2d8740a "glamor: Reallocate pixmap storage without modifiers
           if necessary"
    (cherry picked from commit 26fe29f4fa53cbb7d51892e2cf397c084093812f)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index d3c678d6b..9a619a133 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -355,8 +355,8 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
     return TRUE;
 }
 
-struct gbm_bo *
-glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
+static struct gbm_bo *
+glamor_gbm_bo_from_pixmap_internal(ScreenPtr screen, PixmapPtr pixmap)
 {
     struct glamor_egl_screen_private *glamor_egl =
         glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
@@ -370,6 +370,15 @@ glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
                          pixmap_priv->image, 0);
 }
 
+struct gbm_bo *
+glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
+{
+    if (!glamor_make_pixmap_exportable(pixmap, TRUE))
+        return NULL;
+
+    return glamor_gbm_bo_from_pixmap_internal(screen, pixmap);
+}
+
 int
 glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
                            uint32_t *strides, uint32_t *offsets,
@@ -385,7 +394,7 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
     if (!glamor_make_pixmap_exportable(pixmap, TRUE))
         return 0;
 
-    bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
+    bo = glamor_gbm_bo_from_pixmap_internal(screen, pixmap);
     if (!bo)
         return 0;
 
@@ -423,7 +432,7 @@ glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
     if (!glamor_make_pixmap_exportable(pixmap, FALSE))
         return -1;
 
-    bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
+    bo = glamor_gbm_bo_from_pixmap_internal(screen, pixmap);
     if (!bo)
         return -1;
 
@@ -452,7 +461,7 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
     if (!glamor_make_pixmap_exportable(pixmap, FALSE))
         goto failure;
 
-    bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
+    bo = glamor_gbm_bo_from_pixmap_internal(screen, pixmap);
     if (!bo)
         goto failure;
 
commit 34ad57e570f96dfe4bc493f14726b7a0ae6d45f9
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 15:38:03 2019 +0100

    xwayland: Check status in GBM pixmap creation
    
    The current code in `xwl_glamor_gbm_create_pixmap_for_bo()` may fail in
    several cases that are not checked for:
    
     - `eglCreateImageKHR()` may have failed to create the image,
     - `glEGLImageTargetTexture2DOES()` may fail and set an error,
     - `glamor_set_pixmap_texture()` may fail for very large pixmaps
        because the corresponding FBO could not be created.
    
    Trying to upload content to a pixmap with no texture will crash Mesa,
    glamor and Xwayland, e.g.:
    
      XXX fail to create fbo.
      (EE)
      (EE) Backtrace:
      (EE) 0: Xwayland (OsSigHandler+0x29)
      (EE) 1: libpthread.so.0 (funlockfile+0x50)
      (EE) 2: libc.so.6 (__memmove_avx_unaligned_erms+0x215)
      (EE) 3: dri/i965_dri.so (_mesa_format_convert+0xab3)
      (EE) 4: dri/i965_dri.so (_mesa_texstore+0x205)
      (EE) 5: dri/i965_dri.so (store_texsubimage+0x28c)
      (EE) 6: dri/i965_dri.so (intel_upload_tex+0x13b)
      (EE) 7: dri/i965_dri.so (texture_sub_image+0x134)
      (EE) 8: dri/i965_dri.so (texsubimage_err+0x150)
      (EE) 9: dri/i965_dri.so (_mesa_TexSubImage2D+0x48)
      (EE) 10: Xwayland (glamor_upload_boxes+0x246)
      (EE) 11: Xwayland (glamor_copy+0x4d1)
      (EE) 12: Xwayland (miCopyRegion+0x96)
      (EE) 13: Xwayland (miDoCopy+0x43c)
      (EE) 14: Xwayland (glamor_copy_area+0x24)
      (EE) 15: Xwayland (damageCopyArea+0xba)
      (EE) 16: Xwayland (compCopyWindow+0x31c)
      (EE) 17: Xwayland (damageCopyWindow+0xd3)
      (EE) 18: Xwayland (miResizeWindow+0x7b7)
      (EE) 19: Xwayland (compResizeWindow+0x3a)
      (EE) 20: Xwayland (ConfigureWindow+0xa96)
      (EE) 21: Xwayland (ProcConfigureWindow+0x7d)
      (EE) 22: Xwayland (Dispatch+0x320)
      (EE) 23: Xwayland (dix_main+0x366)
      (EE) 24: libc.so.6 (__libc_start_main+0xf3)
      (EE) 25: Xwayland (_start+0x2e)
      (EE)
      Fatal server error:
      (EE) Caught signal 11 (Segmentation fault). Server aborting
      (EE)
    
    Check for the possible cases of failure above and fallback to the
    regular glamor pixmap creation when an error is detected.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/661
    (cherry picked from commit fc6380a11be4c6202ed72f241dd9ee8c7c24671d)

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index a211e0915..80146ab6e 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -169,6 +169,8 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
                                           xwl_screen->egl_context,
                                           EGL_NATIVE_PIXMAP_KHR,
                                           xwl_pixmap->bo, NULL);
+    if (xwl_pixmap->image == EGL_NO_IMAGE_KHR)
+      goto error;
 
     glGenTextures(1, &xwl_pixmap->texture);
     glBindTexture(GL_TEXTURE_2D, xwl_pixmap->texture);
@@ -176,14 +178,31 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
     glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);
-    glBindTexture(GL_TEXTURE_2D, 0);
+    if (eglGetError() != EGL_SUCCESS)
+      goto error;
 
-    xwl_pixmap_set_private(pixmap, xwl_pixmap);
+    glBindTexture(GL_TEXTURE_2D, 0);
 
     glamor_set_pixmap_texture(pixmap, xwl_pixmap->texture);
+    /* `set_pixmap_texture()` may fail silently if the FBO creation failed,
+     * so we check again the texture to be sure it worked.
+     */
+    if (!glamor_get_pixmap_texture(pixmap))
+      goto error;
+
     glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+    xwl_pixmap_set_private(pixmap, xwl_pixmap);
 
     return pixmap;
+
+error:
+    if (xwl_pixmap->image != EGL_NO_IMAGE_KHR)
+      eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image);
+    if (pixmap)
+      glamor_destroy_pixmap(pixmap);
+    free(xwl_pixmap);
+
+    return NULL;
 }
 
 static PixmapPtr
@@ -194,6 +213,7 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
     struct gbm_bo *bo;
+    PixmapPtr pixmap = NULL;
 
     if (width > 0 && height > 0 && depth >= 15 &&
         (hint == 0 ||
@@ -219,10 +239,16 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
         }
 
         if (bo)
-            return xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth);
+            pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth);
+
+        if (!pixmap)
+            gbm_bo_destroy(bo);
     }
 
-    return glamor_create_pixmap(screen, width, height, depth, hint);
+    if (!pixmap)
+        pixmap = glamor_create_pixmap(screen, width, height, depth, hint);
+
+    return pixmap;
 }
 
 static Bool
commit 6711b5c6fdf0581c77150306fff909d7bc63b8a4
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Thu May 9 10:36:19 2019 +0200

    xwayland: Avoid a crash on pointer enter with a grab
    
    On pointer enter notification, Xwayland checks for an existing pointer
    warp with a `NULL` sprite.
    
    In turn, `xwl_pointer_warp_emulator_maybe_lock()` checks for an existing
    grab and the destination window using `XYToWindow()` which does not
    check for the actual sprite not being `NULL`.
    
    So, in some cases, when the pointer enters the surface and there is an
    existing X11 grab which is not an ownerEvents grab, Xwayland would crash
    trying to dereference the `NULL` sprite pointer:
    
      #0  __GI_raise ()
      #1  __GI_abort () at abort.c:79
      #2  OsAbort () at utils.c:1351
      #3  AbortServer () at log.c:879
      #4  FatalError () at log.c:1017
      #5  OsSigHandler () at osinit.c:156
      #6  OsSigHandler () at osinit.c:110
      #7  <signal handler called>
      #8  XYToWindow (pSprite=0x0, x=0, y=0) at events.c:2880
      #9  xwl_pointer_warp_emulator_maybe_lock () at xwayland-input.c:2673
      #10 pointer_handle_enter () at xwayland-input.c:434
    
    Avoid the crash by simply checking for the sprite being not `NULL` in
    `xwl_pointer_warp_emulator_maybe_lock()`
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Bugzilla: https://bugzilla.redhat.com/1708119
    (cherry picked from commit 0a07446318f248b65fcbc8ab8a73ead51153f09e)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index fbbcb39cc..fa46ac3e7 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -2667,6 +2667,7 @@ xwl_pointer_warp_emulator_maybe_lock(struct xwl_pointer_warp_emulator *warp_emul
      */
     if (pointer_grab &&
         !pointer_grab->ownerEvents &&
+        sprite &&
         XYToWindow(sprite, x, y) != xwl_seat->focus_window->window)
         return;
 


More information about the xorg-commit mailing list