Module: Mesa Branch: main Commit: 55e75d89e31d247e66b77829fe6148eee3a1d088 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=55e75d89e31d247e66b77829fe6148eee3a1d088
Author: Marcin Ślusarz <[email protected]> Date: Tue Jul 11 13:57:47 2023 +0200 iris: avoid duplicating validation entries If the *first* BO is not marked as "written", but the same BO is marked as "written" later, then it will be added twice, because the first instance will have index_for_handle equal to 0. Reviewed-by: José Roberto de Souza <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24108> --- src/gallium/drivers/iris/i915/iris_kmd_backend.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/i915/iris_kmd_backend.c b/src/gallium/drivers/iris/i915/iris_kmd_backend.c index b1f2c79b078..59771da55c4 100644 --- a/src/gallium/drivers/iris/i915/iris_kmd_backend.c +++ b/src/gallium/drivers/iris/i915/iris_kmd_backend.c @@ -267,8 +267,9 @@ i915_batch_submit(struct iris_batch *batch) struct drm_i915_gem_exec_object2 *validation_list = malloc(batch->exec_count * sizeof(*validation_list)); - unsigned *index_for_handle = - calloc(batch->max_gem_handle + 1, sizeof(unsigned)); + size_t sz = (batch->max_gem_handle + 1) * sizeof(int); + int *index_for_handle = malloc(sz); + memset(index_for_handle, -1, sz); unsigned validation_count = 0; for (int i = 0; i < batch->exec_count; i++) { @@ -276,8 +277,8 @@ i915_batch_submit(struct iris_batch *batch) assert(bo->gem_handle != 0); bool written = BITSET_TEST(batch->bos_written, i); - unsigned prev_index = index_for_handle[bo->gem_handle]; - if (prev_index > 0) { + int prev_index = index_for_handle[bo->gem_handle]; + if (prev_index != -1) { if (written) validation_list[prev_index].flags |= EXEC_OBJECT_WRITE; } else {
