[Mesa-dev] [PATCH] st/dri: fix deadlock when waiting on android fences

Marek Olšák maraeo at gmail.com
Fri Nov 10 18:10:02 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

Android fences can't be deferred, because st/dri calls fence_finish
with ctx = NULL, so the driver can't flush u_threaded_context.
---
 src/gallium/include/state_tracker/st_api.h   | 3 +--
 src/gallium/state_trackers/dri/dri_helpers.c | 3 +--
 src/mesa/state_tracker/st_manager.c          | 2 --
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index 6cdaefc..a407b98 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -140,22 +140,21 @@ enum st_attachment_type {
 #define ST_ATTACHMENT_DEPTH_STENCIL_MASK  (1 << ST_ATTACHMENT_DEPTH_STENCIL)
 #define ST_ATTACHMENT_ACCUM_MASK          (1 << ST_ATTACHMENT_ACCUM)
 #define ST_ATTACHMENT_SAMPLE_MASK         (1 << ST_ATTACHMENT_SAMPLE)
 
 /**
  * Flush flags.
  */
 #define ST_FLUSH_FRONT                    (1 << 0)
 #define ST_FLUSH_END_OF_FRAME             (1 << 1)
 #define ST_FLUSH_WAIT                     (1 << 2)
-#define ST_FLUSH_DEFERRED                 (1 << 3)
-#define ST_FLUSH_FENCE_FD                 (1 << 4)
+#define ST_FLUSH_FENCE_FD                 (1 << 3)
 
 /**
  * Value to st_manager->get_param function.
  */
 enum st_manager_param {
    /**
     * The dri state tracker on old libGL's doesn't do the right thing
     * with regards to invalidating the framebuffers.
     *
     * For the mesa state tracker that means that it needs to invalidate
diff --git a/src/gallium/state_trackers/dri/dri_helpers.c b/src/gallium/state_trackers/dri/dri_helpers.c
index 4a61455..37ab2c2 100644
--- a/src/gallium/state_trackers/dri/dri_helpers.c
+++ b/src/gallium/state_trackers/dri/dri_helpers.c
@@ -109,22 +109,21 @@ dri2_create_fence(__DRIcontext *_ctx)
 
 static void *
 dri2_create_fence_fd(__DRIcontext *_ctx, int fd)
 {
    struct st_context_iface *stapi = dri_context(_ctx)->st;
    struct pipe_context *ctx = stapi->pipe;
    struct dri2_fence *fence = CALLOC_STRUCT(dri2_fence);
 
    if (fd == -1) {
       /* exporting driver created fence, flush: */
-      stapi->flush(stapi, ST_FLUSH_DEFERRED | ST_FLUSH_FENCE_FD,
-                   &fence->pipe_fence);
+      stapi->flush(stapi, ST_FLUSH_FENCE_FD, &fence->pipe_fence);
    } else {
       /* importing a foreign fence fd: */
       ctx->create_fence_fd(ctx, &fence->pipe_fence, fd);
    }
    if (!fence->pipe_fence) {
       FREE(fence);
       return NULL;
    }
 
    fence->driscreen = dri_screen(_ctx->driScreenPriv);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 43d5dfd..4a1998c 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -627,22 +627,20 @@ st_framebuffers_purge(struct st_context *st)
 
 static void
 st_context_flush(struct st_context_iface *stctxi, unsigned flags,
                  struct pipe_fence_handle **fence)
 {
    struct st_context *st = (struct st_context *) stctxi;
    unsigned pipe_flags = 0;
 
    if (flags & ST_FLUSH_END_OF_FRAME)
       pipe_flags |= PIPE_FLUSH_END_OF_FRAME;
-   if (flags & ST_FLUSH_DEFERRED)
-      pipe_flags |= PIPE_FLUSH_DEFERRED;
    if (flags & ST_FLUSH_FENCE_FD)
       pipe_flags |= PIPE_FLUSH_FENCE_FD;
 
    FLUSH_VERTICES(st->ctx, 0);
    FLUSH_CURRENT(st->ctx, 0);
    st_flush(st, fence, pipe_flags);
 
    if ((flags & ST_FLUSH_WAIT) && fence && *fence) {
       st->pipe->screen->fence_finish(st->pipe->screen, NULL, *fence,
                                      PIPE_TIMEOUT_INFINITE);
-- 
2.7.4



More information about the mesa-dev mailing list