aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2020-03-04 22:16:30 -0800
committerMarge Bot <[email protected]>2020-03-06 21:06:54 +0000
commit4d5a0ae22cf9ad893ddb10fca48e85e5dbf9c80c (patch)
tree533122882d0c6427c75044c6aab51eeaae6e4502 /src/gallium/drivers/lima
parent70349a2252a95f181de519be61ea84bd22381e4b (diff)
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 <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4055> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4055>
Diffstat (limited to 'src/gallium/drivers/lima')
-rw-r--r--src/gallium/drivers/lima/ir/gp/codegen.c11
-rw-r--r--src/gallium/drivers/lima/ir/gp/instr.c6
2 files changed, 8 insertions, 9 deletions
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;