freedreno: Add transfer_pool_unsync
authorRob Clark <robdclark@chromium.org>
Thu, 4 Mar 2021 20:43:51 +0000 (12:43 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 11 Mar 2021 04:42:16 +0000 (04:42 +0000)
With threaded_context, in the TC_TRANSFER_MAP_UNSYNC case, we are
getting called from the frontend thread, rather than driver thread.
So we need a different slab_child_pool for that.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9323>

src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_resource.c

index a074acb..93c57e4 100644 (file)
@@ -325,6 +325,7 @@ fd_context_destroy(struct pipe_context *pctx)
                util_primconvert_destroy(ctx->primconvert);
 
        slab_destroy_child(&ctx->transfer_pool);
+       slab_destroy_child(&ctx->transfer_pool_unsync);
 
        for (i = 0; i < ARRAY_SIZE(ctx->vsc_pipe_bo); i++) {
                if (!ctx->vsc_pipe_bo[i])
@@ -577,6 +578,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
        pctx->const_uploader = pctx->stream_uploader;
 
        slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
+       slab_create_child(&ctx->transfer_pool_unsync, &screen->transfer_pool);
 
        fd_draw_init(pctx);
        fd_resource_context_init(pctx);
index d10588b..4917465 100644 (file)
@@ -204,6 +204,7 @@ struct fd_context {
 
        /* slab for pipe_transfer allocations: */
        struct slab_child_pool transfer_pool dt;
+       struct slab_child_pool transfer_pool_unsync; /* for threaded_context */
 
        /**
         * query related state:
index 649532f..ef6297d 100644 (file)
@@ -667,6 +667,9 @@ fd_resource_transfer_unmap(struct pipe_context *pctx,
 
        assert(trans->b.staging == NULL); /* for threaded context only */
 
+       /* Don't use pool_transfers_unsync. We are always in the driver
+        * thread. Freeing an object into a different pool is allowed.
+        */
        slab_free(&ctx->transfer_pool, ptrans);
 }
 
@@ -928,7 +931,12 @@ fd_resource_transfer_map(struct pipe_context *pctx,
                return NULL;
        }
 
-       ptrans = slab_alloc(&ctx->transfer_pool);
+       if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC) {
+               ptrans = slab_alloc(&ctx->transfer_pool_unsync);
+       } else {
+               ptrans = slab_alloc(&ctx->transfer_pool);
+       }
+
        if (!ptrans)
                return NULL;