From: Rob Clark Date: Thu, 4 Mar 2021 20:43:51 +0000 (-0800) Subject: freedreno: Add transfer_pool_unsync X-Git-Tag: upstream/21.2.3~6759 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=acc2c015b3bcd674c872e9d25678304918c06f08;p=platform%2Fupstream%2Fmesa.git freedreno: Add transfer_pool_unsync 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 Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index a074acb..93c57e4 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index d10588b..4917465 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -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: diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 649532f..ef6297d 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -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;