From e99ab86f77730a7f90a9eccfc51565b6027e5f95 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 25 May 2023 08:45:40 +0200 Subject: [PATCH] broadcom/compiler: flag use of control barriers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have been relying on NIR's gather info pass for this but it is not safe unless we are certain we are always calling it after any other pass that may emit a control barrier. As it stands, nir_zero_initialize_shared_memory can emit a control barrier and we don't call the gather info pass after it, which is problematic. The only reason this is not really a problem right now is because for non-scoped barriers (which is what we currently use) it doesn't emit a scoped barrier, just a regular memory barrier (which is probably a bug in the pass!), but as soon as we move to scoped barriers, this is going to be a problem, since we need to know when we emit a control barrier to ensure supergroup calculations prevent deadlocks at the barrier op. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/compiler/nir_to_vir.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index ea18d87dee3..04535ec2501 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -3526,6 +3526,13 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) */ ntq_flush_tmu(c); + /* Ensure we flag the use of the control barrier. NIR's + * gather info pass usually takes care of this, but that + * requires that we call that pass after any other pass + * may emit a control barrier, so this is safer. + */ + c->s->info.uses_control_barrier = true; + if (c->devinfo->ver >= 42) { vir_BARRIERID_dest(c, vir_reg(QFILE_MAGIC, V3D_QPU_WADDR_SYNCB));