From 28f677e6dc929969fc65154d64cfcf43b2e789fe Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Fri, 28 Jan 2022 15:11:49 -0800 Subject: [PATCH] iris: implement inter-context busy-tracking Previously, no buffers were ever marked as EXEC_OBJECT_ASYNC so the Kernel would ensure dependency tracking for us. After we implemented explicit busy tracking in commit 89a34cb8450a, only the external objects kept relying on the Kernel's implicit tracking and Iris did inter-batch busy tracking, meaning we lost inter-screen and inter-context synchronization. This seemed fine to me since, as far as I understdood, it is the duty of the application to synchronize itself against multiple screens and contexts. The problem here is that applications were actually relying on the old behavior where the Kernel guarantees synchronization, so 89a34cb8450a can be seen as a regression. This commit addresses the inter-context synchronization case. v2: Rebase after the changes from a90a1f15a7c8. This new version is significantly different. Cc: mesa-stable (see the backport in MR !14783) References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14783 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5731 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5812 Fixes: 89a34cb8450a ("iris: switch to explicit busy tracking") References: a90a1f15a7c8 ("iris: Create an IRIS_BATCH_BLITTER for using the BLT command streamer") Tested-by: Konstantin Kharlamov (v1) Reviewed-by: Kenneth Graunke Signed-off-by: Paulo Zanoni Part-of: --- src/gallium/drivers/iris/iris_batch.c | 30 +++++++-------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 45c1cad579a..83397812d58 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -831,36 +831,22 @@ update_bo_syncobjs(struct iris_batch *batch, struct iris_bo *bo, bool write) struct iris_bo_screen_deps *bo_deps = &bo->deps[screen->id]; int batch_idx = batch->name; - /* Someday if IRIS_BATCH_COUNT increases to 4, we could do: - * - * int other_batch_idxs[IRIS_BATCH_COUNT - 1] = { - * (batch_idx + 1) & 3, - * (batch_idx + 2) & 3, - * (batch_idx + 3) & 3, - * }; - */ - STATIC_ASSERT(IRIS_BATCH_COUNT == 3); - int other_batch_idxs[IRIS_BATCH_COUNT - 1] = { - (batch_idx ^ 1) & 1, - (batch_idx ^ 2) & 2, - }; - /* Make our batch depend on additional syncobjs depending on what other * batches have been doing to this bo. + * + * We also look at the dependencies set by our own batch since those could + * have come from a different context, and apps don't like it when we don't + * do inter-context tracking. */ - for (unsigned i = 0; i < ARRAY_SIZE(other_batch_idxs); i++) { - unsigned other_batch_idx = other_batch_idxs[i]; - + for (unsigned i = 0; i < IRIS_BATCH_COUNT; i++) { /* If the bo is being written to by others, wait for them. */ - if (bo_deps->write_syncobjs[other_batch_idx]) - move_syncobj_to_batch(batch, - &bo_deps->write_syncobjs[other_batch_idx], + if (bo_deps->write_syncobjs[i]) + move_syncobj_to_batch(batch, &bo_deps->write_syncobjs[i], I915_EXEC_FENCE_WAIT); /* If we're writing to the bo, wait on the reads from other batches. */ if (write) - move_syncobj_to_batch(batch, - &bo_deps->read_syncobjs[other_batch_idx], + move_syncobj_to_batch(batch, &bo_deps->read_syncobjs[i], I915_EXEC_FENCE_WAIT); }