Mesa (main): crocus: find correct relocation target for the bo.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Feb 7 07:17:38 UTC 2022


Module: Mesa
Branch: main
Commit: 37c3be6947b43d31e454d1f4adcee8eea49a8f0a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=37c3be6947b43d31e454d1f4adcee8eea49a8f0a

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Feb  7 16:19:15 2022 +1000

crocus: find correct relocation target for the bo.

If we have batch a + b, and writing to batch b, causes batch a
to flush, all the bo->index get reset, and we try to submit a -1
to the kernel.

Look the bo index up when creating relocations.

Fixes crash seen in KHR-GL46.compute_shader.pipeline-post-fs
and a trace from Wasteland 3

Fixes: f3630548f1da ("crocus: initial gallium driver for Intel gfx 4-7")

Reviewed-by: Zoltán Böszörményi <zboszor at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14905>

---

 src/gallium/drivers/crocus/ci/crocus-hsw-flakes.txt |  1 -
 src/gallium/drivers/crocus/crocus_batch.c           | 21 +++++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/crocus/ci/crocus-hsw-flakes.txt b/src/gallium/drivers/crocus/ci/crocus-hsw-flakes.txt
index 1c1fcf30a90..f52cad85d0f 100644
--- a/src/gallium/drivers/crocus/ci/crocus-hsw-flakes.txt
+++ b/src/gallium/drivers/crocus/ci/crocus-hsw-flakes.txt
@@ -1,4 +1,3 @@
-KHR-GL46.compute_shader.pipeline-post-fs
 KHR-GL46.texture_barrier.overlapping-texels
 KHR-GL46.texture_barrier_ARB.overlapping-texels
 KHR-GL46.texture_barrier_ARB.same-texel-rw-multipass
diff --git a/src/gallium/drivers/crocus/crocus_batch.c b/src/gallium/drivers/crocus/crocus_batch.c
index 318edd00edf..8073f7813d0 100644
--- a/src/gallium/drivers/crocus/crocus_batch.c
+++ b/src/gallium/drivers/crocus/crocus_batch.c
@@ -263,21 +263,30 @@ crocus_init_batch(struct crocus_context *ice,
    crocus_batch_reset(batch);
 }
 
-static struct drm_i915_gem_exec_object2 *
-find_validation_entry(struct crocus_batch *batch, struct crocus_bo *bo)
+static int
+find_exec_index(struct crocus_batch *batch, struct crocus_bo *bo)
 {
    unsigned index = READ_ONCE(bo->index);
 
    if (index < batch->exec_count && batch->exec_bos[index] == bo)
-      return &batch->validation_list[index];
+      return index;
 
    /* May have been shared between multiple active batches */
    for (index = 0; index < batch->exec_count; index++) {
       if (batch->exec_bos[index] == bo)
-         return &batch->validation_list[index];
+	 return index;
    }
+   return -1;
+}
+
+static struct drm_i915_gem_exec_object2 *
+find_validation_entry(struct crocus_batch *batch, struct crocus_bo *bo)
+{
+   int index = find_exec_index(batch, bo);
 
-   return NULL;
+   if (index == -1)
+      return NULL;
+   return &batch->validation_list[index];
 }
 
 static void
@@ -409,7 +418,7 @@ emit_reloc(struct crocus_batch *batch,
       (struct drm_i915_gem_relocation_entry) {
          .offset = offset,
          .delta = target_offset,
-         .target_handle = target->index,
+         .target_handle = find_exec_index(batch, target),
          .presumed_offset = entry->offset,
       };
 



More information about the mesa-commit mailing list