From: Vasily Khoruzhick Date: Thu, 5 Mar 2020 06:16:30 +0000 (-0800) Subject: lima: gpir: enforce instruction limit earlier X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d5a0ae22cf9ad893ddb10fca48e85e5dbf9c80c;p=mesa.git lima: gpir: enforce instruction limit earlier Enforce instruction limit of 512 instructions earlier. This is a workaround for infinite loops in gpir compiler and allows us to pin point the tests that are affected. Reviewed-by: Andreas Baierl Signed-off-by: Vasily Khoruzhick Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/drivers/lima/ir/gp/codegen.c b/src/gallium/drivers/lima/ir/gp/codegen.c index 113a8a0c0f3..80560bd5f77 100644 --- a/src/gallium/drivers/lima/ir/gp/codegen.c +++ b/src/gallium/drivers/lima/ir/gp/codegen.c @@ -562,11 +562,9 @@ static void gpir_codegen(gpir_codegen_instr *code, gpir_instr *instr) static void gpir_codegen_print_prog(gpir_compiler *comp) { uint32_t *data = comp->prog->shader; - int size = comp->prog->shader_size; - int num_instr = size / sizeof(gpir_codegen_instr); int num_dword_per_instr = sizeof(gpir_codegen_instr) / sizeof(uint32_t); - for (int i = 0; i < num_instr; i++) { + for (int i = 0; i < comp->num_instr; i++) { printf("%03d: ", i); for (int j = 0; j < num_dword_per_instr; j++) printf("%08x ", data[i * num_dword_per_instr + j]); @@ -582,11 +580,7 @@ bool gpir_codegen_prog(gpir_compiler *comp) num_instr += list_length(&block->instr_list); } - if (num_instr > 512) { - gpir_error("shader too big (%d), GP has a 512 instruction limit.\n", - num_instr); - return false; - } + assert(num_instr <= 512); gpir_codegen_instr *code = rzalloc_array(comp->prog, gpir_codegen_instr, num_instr); if (!code) @@ -607,7 +601,6 @@ bool gpir_codegen_prog(gpir_compiler *comp) comp->prog->shader = code; comp->prog->shader_size = num_instr * sizeof(gpir_codegen_instr); - comp->num_instr = num_instr; if (lima_debug & LIMA_DEBUG_GP) { gpir_codegen_print_prog(comp); diff --git a/src/gallium/drivers/lima/ir/gp/instr.c b/src/gallium/drivers/lima/ir/gp/instr.c index 5cfb7e34a02..a9a93290154 100644 --- a/src/gallium/drivers/lima/ir/gp/instr.c +++ b/src/gallium/drivers/lima/ir/gp/instr.c @@ -34,6 +34,12 @@ gpir_instr *gpir_instr_create(gpir_block *block) if (unlikely(!instr)) return NULL; + block->comp->num_instr++; + if (block->comp->num_instr > 512) { + gpir_error("shader exceeds limit of 512 instructions\n"); + return NULL; + } + instr->index = block->sched.instr_index++; instr->alu_num_slot_free = 6; instr->alu_non_cplx_slot_free = 5;