Mesa (staging/21.3): crocus: find correct relocation target for the bo.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Feb 7 19:30:05 UTC 2022
Module: Mesa
Branch: staging/21.3
Commit: b7df3d09aaf1f2c0bebc8f8d84a73a00fd3e787d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7df3d09aaf1f2c0bebc8f8d84a73a00fd3e787d
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>
(cherry picked from commit 37c3be6947b43d31e454d1f4adcee8eea49a8f0a)
---
.pick_status.json | 2 +-
src/gallium/drivers/crocus/crocus_batch.c | 21 +++++++++++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 23e0640353e..ef0fa3ab4de 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -112,7 +112,7 @@
"description": "crocus: find correct relocation target for the bo.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "f3630548f1da904ec6c63b43ece7e68afdb8867e"
},
diff --git a/src/gallium/drivers/crocus/crocus_batch.c b/src/gallium/drivers/crocus/crocus_batch.c
index d029bd0e323..885d6102ac0 100644
--- a/src/gallium/drivers/crocus/crocus_batch.c
+++ b/src/gallium/drivers/crocus/crocus_batch.c
@@ -264,21 +264,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
@@ -410,7 +419,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