freedreno: fence should hold a ref to pipe
authorRob Clark <robdclark@gmail.com>
Wed, 9 May 2018 11:52:53 +0000 (07:52 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 15 May 2018 12:46:46 +0000 (08:46 -0400)
Since the fence can outlive the context, and all it really needs to wait
on a fence is the pipe, use the new fd_pipe reference counting to hold a
ref to the pipe and drop the ctx pointer.

This fixes a crash seen with (for example) glmark2:

  #0  fd_pipe_wait_timeout (pipe=0xbf48678b3cd7b32b, timestamp=0, timeout=18446744073709551615) at freedreno_pipe.c:101
  #1  0x0000ffffbdf75914 in fd_fence_finish (pscreen=0x561110, ctx=0x0, fence=0xc55c10, timeout=18446744073709551615) at ../src/gallium/drivers/freedreno/freedreno_fence.c:96
  #2  0x0000ffffbde154e4 in dri_flush (cPriv=0xb1ff80, dPriv=0x556660, flags=3, reason=__DRI2_THROTTLE_SWAPBUFFER) at ../src/gallium/state_trackers/dri/dri_drawable.c:569
  #3  0x0000ffffbecd8b44 in loader_dri3_flush (draw=0x558a28, flags=3, throttle_reason=__DRI2_THROTTLE_SWAPBUFFER) at ../src/loader/loader_dri3_helper.c:656
  #4  0x0000ffffbecbc36c in glx_dri3_flush_drawable (draw=0x558a28, flags=3) at ../src/glx/dri3_glx.c:132
  #5  0x0000ffffbecd91e8 in loader_dri3_swap_buffers_msc (draw=0x558a28, target_msc=0, divisor=0, remainder=0, flush_flags=3, force_copy=false) at ../src/loader/loader_dri3_helper.c:827
  #6  0x0000ffffbecbcfc4 in dri3_swap_buffers (pdraw=0x5589f0, target_msc=0, divisor=0, remainder=0, flush=1) at ../src/glx/dri3_glx.c:587
  #7  0x0000ffffbec98218 in glXSwapBuffers (dpy=0x502bb0, drawable=2097154) at ../src/glx/glxcmds.c:840
  #8  0x000000000040994c in CanvasGeneric::update (this=0xfffffffff400) at ../src/canvas-generic.cpp:114
  #9  0x0000000000411594 in MainLoop::step (this=this@entry=0x5728f0) at ../src/main-loop.cpp:108
  #10 0x0000000000409498 in do_benchmark (canvas=...) at ../src/main.cpp:117
  #11 0x00000000004071b0 in main (argc=<optimized out>, argv=<optimized out>) at ../src/main.cpp:210

Signed-off-by: Rob Clark <robdclark@gmail.com>
configure.ac
meson.build
src/gallium/drivers/freedreno/freedreno_fence.c

index a9babec9a4bc6e60c9ff903ca3938a79e577b8ea..5f5e76040dcfa28b5eb4349aa7d27c6170a74736 100644 (file)
@@ -78,7 +78,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.91
 LIBDRM_INTEL_REQUIRED=2.4.75
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
-LIBDRM_FREEDRENO_REQUIRED=2.4.91
+LIBDRM_FREEDRENO_REQUIRED=2.4.92
 LIBDRM_ETNAVIV_REQUIRED=2.4.89
 
 dnl Versions for external dependencies
index e52b4a51093247bef95a7aad0863081d845b4393..9a538e99511e6cd9096261c34562f149cae82ba9 100644 (file)
@@ -1041,7 +1041,7 @@ _drm_amdgpu_ver = '2.4.91'
 _drm_radeon_ver = '2.4.71'
 _drm_nouveau_ver = '2.4.66'
 _drm_etnaviv_ver = '2.4.89'
-_drm_freedreno_ver = '2.4.91'
+_drm_freedreno_ver = '2.4.92'
 _drm_intel_ver = '2.4.75'
 _drm_ver = '2.4.75'
 
index 1925f726a25c97a3c91fa643289220bc03c2331f..c4e20226b58d648dbe05d48cb5609b6de5235164 100644 (file)
@@ -41,7 +41,7 @@ struct pipe_fence_handle {
         * fence_fd become valid and the week reference is dropped.
         */
        struct fd_batch *batch;
-       struct fd_context *ctx;
+       struct fd_pipe *pipe;
        struct fd_screen *screen;
        int fence_fd;
        uint32_t timestamp;
@@ -68,6 +68,7 @@ static void fd_fence_destroy(struct pipe_fence_handle *fence)
 {
        if (fence->fence_fd != -1)
                close(fence->fence_fd);
+       fd_pipe_del(fence->pipe);
        FREE(fence);
 }
 
@@ -93,7 +94,7 @@ boolean fd_fence_finish(struct pipe_screen *pscreen,
                return ret == 0;
        }
 
-       if (fd_pipe_wait_timeout(fence->ctx->pipe, fence->timestamp, timeout))
+       if (fd_pipe_wait_timeout(fence->pipe, fence->timestamp, timeout))
                return false;
 
        return true;
@@ -111,7 +112,7 @@ static struct pipe_fence_handle * fence_create(struct fd_context *ctx,
        pipe_reference_init(&fence->reference, 1);
 
        fence->batch = batch;
-       fence->ctx = ctx;
+       fence->pipe = fd_pipe_ref(ctx->pipe);
        fence->screen = ctx->screen;
        fence->timestamp = timestamp;
        fence->fence_fd = fence_fd;