From a502841fec8ba9ad01f23f211343922aa8212d45 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 7 Nov 2024 09:29:38 +0100 Subject: [PATCH] pan/cs: Add dynamic save_reg to exception handler Make the register dump address dynamic instead of passing it at handler creation time. This is needed for PanVK if we want to re-use the same handlers for different VkQueues, since the dump buffer needs to be per VkQueue. Signed-off-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/gallium/drivers/panfrost/pan_csf.c | 6 ++++-- src/gallium/drivers/panfrost/pan_csf.h | 3 +++ src/panfrost/lib/genxml/cs_builder.h | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index c4e8260f1e1..dca422a63d1 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -118,8 +118,9 @@ csf_oom_handler_init(struct panfrost_context *ctx) cs_builder_init(&b, &conf, queue); struct cs_exception_handler_ctx handler_ctx = { - .addr = reg_save_bo->ptr.gpu, - .sb_slot = 0, + .ctx_reg = cs_reg64(&b, TILER_OOM_CTX_REG), + .dump_addr_offset = offsetof(struct pan_csf_tiler_oom_ctx, dump_addr), + .ls_sb_slot = 0, }; struct cs_exception_handler handler; cs_exception_handler_start(&b, &handler, handler_ctx); @@ -1009,6 +1010,7 @@ emit_tiler_oom_context(struct cs_builder *b, struct panfrost_batch *batch) ctx->counter = 0; ctx->bbox_min = (batch->miny << 16) | batch->minx; ctx->bbox_max = ((batch->maxy - 1) << 16) | (batch->maxx - 1); + ctx->dump_addr = batch->ctx->csf.tiler_oom_handler.save_bo->ptr.gpu; for (unsigned i = 0; i < PAN_INCREMENTAL_RENDERING_PASS_COUNT; ++i) ctx->fbds[i] = alloc_fbd(batch); diff --git a/src/gallium/drivers/panfrost/pan_csf.h b/src/gallium/drivers/panfrost/pan_csf.h index 16ed6141942..b24167a8219 100644 --- a/src/gallium/drivers/panfrost/pan_csf.h +++ b/src/gallium/drivers/panfrost/pan_csf.h @@ -54,6 +54,9 @@ struct pan_csf_tiler_oom_ctx { /* Tiler descriptor address */ mali_ptr tiler_desc; + + /* Address of the region reserved for saving registers. */ + mali_ptr dump_addr; } PACKED; struct panfrost_csf_batch { diff --git a/src/panfrost/lib/genxml/cs_builder.h b/src/panfrost/lib/genxml/cs_builder.h index ba532fb6e53..13a3800d359 100644 --- a/src/panfrost/lib/genxml/cs_builder.h +++ b/src/panfrost/lib/genxml/cs_builder.h @@ -1673,8 +1673,9 @@ cs_nop(struct cs_builder *b) } struct cs_exception_handler_ctx { - uint64_t addr; - uint8_t sb_slot; + struct cs_index ctx_reg; + unsigned dump_addr_offset; + uint8_t ls_sb_slot; }; struct cs_exception_handler { @@ -1770,7 +1771,9 @@ cs_exception_handler_end(struct cs_builder *b, if (num_ranges > 0) { unsigned offset = 0; - cs_move64_to(b, addr_reg, handler->ctx.addr); + cs_load64_to(b, addr_reg, handler->ctx.ctx_reg, + handler->ctx.dump_addr_offset); + cs_wait_slot(b, handler->ctx.ls_sb_slot, false); for (unsigned i = 0; i < num_ranges; ++i) { unsigned reg_count = util_bitcount(masks[i]); @@ -1779,7 +1782,7 @@ cs_exception_handler_end(struct cs_builder *b, offset += reg_count * 4; } - cs_wait_slot(b, handler->ctx.sb_slot, false); + cs_wait_slot(b, handler->ctx.ls_sb_slot, false); } /* Now that the preamble is emitted, we can flush the instructions we have in @@ -1790,6 +1793,10 @@ cs_exception_handler_end(struct cs_builder *b, if (num_ranges > 0) { unsigned offset = 0; + cs_load64_to(b, addr_reg, handler->ctx.ctx_reg, + handler->ctx.dump_addr_offset); + cs_wait_slot(b, handler->ctx.ls_sb_slot, false); + for (unsigned i = 0; i < num_ranges; ++i) { unsigned reg_count = util_bitcount(masks[i]); @@ -1797,7 +1804,7 @@ cs_exception_handler_end(struct cs_builder *b, offset += reg_count * 4; } - cs_wait_slot(b, handler->ctx.sb_slot, false); + cs_wait_slot(b, handler->ctx.ls_sb_slot, false); } /* Fill the rest of the buffer with NOPs. */