From 92d819aaa00aaa185b78793ccfc2151d92538a75 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Mon, 14 Feb 2022 11:42:16 +0100 Subject: [PATCH] broadcom/compiler: fix end of TMU sequence check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We may be pipelining TMU writes and reads, in which case we can see both TMUWT and LDTMU at the end of a TMU sequence, so we should not assume that a TMUWT always terminates a sequence. Also, we had a bug where we were using inst instead of scan_inst to check if we find another TMUWT after the curent instruction. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/compiler/vir_register_allocate.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/broadcom/compiler/vir_register_allocate.c b/src/broadcom/compiler/vir_register_allocate.c index 05b71e3369a..6e47ff837f6 100644 --- a/src/broadcom/compiler/vir_register_allocate.c +++ b/src/broadcom/compiler/vir_register_allocate.c @@ -44,23 +44,22 @@ static bool is_end_of_tmu_sequence(const struct v3d_device_info *devinfo, struct qinst *inst, struct qblock *block) { - if (inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && - inst->qpu.alu.add.op == V3D_QPU_A_TMUWT) { - return true; - } - - if (!inst->qpu.sig.ldtmu) + /* Only tmuwt and ldtmu can finish TMU sequences */ + bool is_tmuwt = inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && + inst->qpu.alu.add.op == V3D_QPU_A_TMUWT; + bool is_ldtmu = inst->qpu.sig.ldtmu; + if (!is_tmuwt && !is_ldtmu) return false; + /* Check if this is the last tmuwt or ldtmu in the sequence */ list_for_each_entry_from(struct qinst, scan_inst, inst->link.next, &block->instructions, link) { - if (scan_inst->qpu.sig.ldtmu) - return false; + is_tmuwt = scan_inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && + scan_inst->qpu.alu.add.op == V3D_QPU_A_TMUWT; + is_ldtmu = scan_inst->qpu.sig.ldtmu; - if (inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && - inst->qpu.alu.add.op == V3D_QPU_A_TMUWT) { - return true; - } + if (is_tmuwt || is_ldtmu) + return false; if (qinst_writes_tmu(devinfo, scan_inst)) return true;