From 2c6643546ad85f4e19aa3728a96fa4d6ddb571d9 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 23 Jul 2020 16:52:35 +0200 Subject: [PATCH] radeonsi/tmz: add a tmz variant for sctx::eop_bug_scratch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_fence.c | 3 ++- src/gallium/drivers/radeonsi/si_pipe.c | 10 ++++++++-- src/gallium/drivers/radeonsi/si_pipe.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c index ce9230bd647..419a26d969f 100644 --- a/src/gallium/drivers/radeonsi/si_fence.c +++ b/src/gallium/drivers/radeonsi/si_fence.c @@ -87,7 +87,8 @@ void si_cp_release_mem(struct si_context *ctx, struct radeon_cmdbuf *cs, unsigne if (ctx->chip_class == GFX9 && !compute_ib && query_type != PIPE_QUERY_OCCLUSION_COUNTER && query_type != PIPE_QUERY_OCCLUSION_PREDICATE && query_type != PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE) { - struct si_resource *scratch = ctx->eop_bug_scratch; + struct si_resource *scratch = unlikely(ctx->ws->cs_is_secure(ctx->gfx_cs)) ? + ctx->eop_bug_scratch_tmz : ctx->eop_bug_scratch; assert(16 * ctx->screen->info.num_render_backends <= scratch->b.b.width0); radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0)); diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 9fa148dff9f..a8e67c32855 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -303,6 +303,7 @@ static void si_destroy_context(struct pipe_context *context) sctx->ws->fence_reference(&sctx->last_sdma_fence, NULL); sctx->ws->fence_reference(&sctx->last_ib_barrier_fence, NULL); si_resource_reference(&sctx->eop_bug_scratch, NULL); + si_resource_reference(&sctx->eop_bug_scratch_tmz, NULL); si_resource_reference(&sctx->index_ring, NULL); si_resource_reference(&sctx->barrier_buf, NULL); si_resource_reference(&sctx->last_ib_barrier_buf, NULL); @@ -458,8 +459,13 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->chip_class = sscreen->info.chip_class; if (sctx->chip_class == GFX7 || sctx->chip_class == GFX8 || sctx->chip_class == GFX9) { - sctx->eop_bug_scratch = si_resource(pipe_buffer_create( - &sscreen->b, 0, PIPE_USAGE_DEFAULT, 16 * sscreen->info.num_render_backends)); + sctx->eop_bug_scratch = si_aligned_buffer_create( + &sscreen->b, SI_RESOURCE_FLAG_DRIVER_INTERNAL, + PIPE_USAGE_DEFAULT, 16 * sscreen->info.num_render_backends, 256); + if (sctx->screen->info.has_tmz_support) + sctx->eop_bug_scratch_tmz = si_aligned_buffer_create( + &sscreen->b, PIPE_RESOURCE_FLAG_ENCRYPTED | SI_RESOURCE_FLAG_DRIVER_INTERNAL, + PIPE_USAGE_DEFAULT, 16 * sscreen->info.num_render_backends, 256); if (!sctx->eop_bug_scratch) goto fail; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index c5d87b514a0..7db1650cd0b 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -908,6 +908,7 @@ struct si_context { struct pipe_fence_handle *last_gfx_fence; struct pipe_fence_handle *last_sdma_fence; struct si_resource *eop_bug_scratch; + struct si_resource *eop_bug_scratch_tmz; struct u_upload_mgr *cached_gtt_allocator; struct threaded_context *tc; struct u_suballocator *allocator_zeroed_memory;