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 89a34cb845, 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 89a34cb845
can be seen as a regression. This commit addresses the inter-context
synchronization case.

v2: Rebase after the changes from a90a1f15a7. 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: 89a34cb845 ("iris: switch to explicit busy tracking")
References: a90a1f15a7 ("iris: Create an IRIS_BATCH_BLITTER for using the BLT command streamer")
Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru> (v1)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14505>
This commit is contained in:
Paulo Zanoni 2022-01-28 15:11:49 -08:00 committed by Marge Bot
parent 06b279ccb2
commit 28f677e6dc
1 changed files with 8 additions and 22 deletions

View File

@ -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);
}