freedreno: Defer freeing batch->key

We use the same key in autotune to track historical data about a given
framebuffer state, to inform the decision about using gmem vs sysmem
rendering.  Which means we need the key to stick around during the
flush, even if the batch is removed from the batch-cache before the
flush.

Fixes: 507f701d9e ("freedreno: Fix batch flush race condition")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11450>
This commit is contained in:
Rob Clark 2021-06-17 12:03:57 -07:00
parent 64cb143b92
commit 6402dc17b3
3 changed files with 3 additions and 5 deletions

View file

@ -315,6 +315,7 @@ __fd_batch_destroy(struct fd_batch *batch)
simple_mtx_destroy(&batch->submit_lock);
free(batch->key);
free(batch);
fd_screen_lock(ctx->screen);
}

View file

@ -252,7 +252,7 @@ struct fd_batch {
struct set *resources;
/** key in batch-cache (if not null): */
const struct fd_batch_key *key;
struct fd_batch_key *key;
uint32_t hash;
/** set of dependent batches.. holds refs to dependent batches: */

View file

@ -239,7 +239,7 @@ fd_bc_invalidate_batch(struct fd_batch *batch, bool remove)
return;
struct fd_batch_cache *cache = &batch->ctx->screen->batch_cache;
struct fd_batch_key *key = (struct fd_batch_key *)batch->key;
struct fd_batch_key *key = batch->key;
fd_screen_assert_locked(batch->ctx->screen);
@ -260,9 +260,6 @@ fd_bc_invalidate_batch(struct fd_batch *batch, bool remove)
struct hash_entry *entry =
_mesa_hash_table_search_pre_hashed(cache->ht, batch->hash, key);
_mesa_hash_table_remove(cache->ht, entry);
batch->key = NULL;
free(key);
}
void