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 <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31941>
This commit is contained in:
Boris Brezillon 2024-11-07 09:29:38 +01:00 committed by Lars-Ivar Hesselberg Simonsen
parent 1acc5e1433
commit a502841fec
3 changed files with 19 additions and 7 deletions

View file

@ -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);

View file

@ -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 {

View file

@ -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. */