xserver: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 30 13:21:57 UTC 2024


 hw/xwayland/xwayland-glamor-gbm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d5192ba8eb87f5a36bc77a7b95d349ae74fd5a59
Author: Erik Kurzinger <ekurzinger at nvidia.com>
Date:   Fri Apr 26 13:44:56 2024 -0700

    xwayland: use write fence in xwl_glamor_dmabuf_import_sync_file
    
    The functions xwl_glamor_dmabuf_import_sync_file and
    xwl_glamor_dmabuf_export_sync_file are used to ensure proper
    synchronization between clients using PresentPixmapSynced and
    compositors that do not support the wp_linux_drm_syncobj_v1 protocol
    when presenting by flipping. The acquire point's fence will be imported
    as the DMA-BUF's implicit fence before handing it off to the compositor,
    and then, after the DMA-BUF has been released, its new implicit fence
    will be exported and become the release point's fence which the client
    is expected to wait for before re-using the buffer.
    
    Both functions currently set the flags arguments of their respective
    ioctls to DMA_BUF_SYNC_READ. When importing a sync file, this means that
    any subsequent implicitly synchronized reads from the buffer will not
    wait for the fence, and when exporting a sync file it means that the
    returned fence may be signaled before preceeding reads from the buffer
    have completed.
    
    While this is correct for xwl_glamor_dmabuf_export_sync_file since the
    compositor will never write to the buffer, it is incorrect for
    xwl_glamor_dmabuf_import_sync_file. To avoid corruption, we need any
    reads from the buffer by the compositor to wait on the acquire point's
    fence.
    
    As a fix, instead of setting the DMA_BUF_SYNC_READ flag in
    xwl_glamor_dmabuf_import_sync_file, we set the DMA_BUF_SYNC_WRITE flag.
    This *does* provide the necessary guarantees.
    
    Signed-off-by: Erik Kurzinger <ekurzinger at nvidia.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1509>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 2a9f3c164..b30cff935 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -960,7 +960,7 @@ xwl_glamor_dmabuf_import_sync_file(PixmapPtr pixmap, int sync_file)
 #endif /* GBM_BO_FD_FOR_PLANE */
         struct dma_buf_import_sync_file import_args = { 0 };
         import_args.fd = sync_file;
-        import_args.flags = DMA_BUF_SYNC_READ;
+        import_args.flags = DMA_BUF_SYNC_WRITE;
         drmIoctl(plane_fd, DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &import_args);
         close(plane_fd);
     }


More information about the xorg-commit mailing list