Mesa (main): freedreno: Defer freeing batch->key

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 17 21:18:59 UTC 2021


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Thu Jun 17 12:03:57 2021 -0700

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: 507f701d9e8 ("freedreno: Fix batch flush race condition")
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11450>

---

 src/gallium/drivers/freedreno/freedreno_batch.c       | 1 +
 src/gallium/drivers/freedreno/freedreno_batch.h       | 2 +-
 src/gallium/drivers/freedreno/freedreno_batch_cache.c | 5 +----
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index 82f425d96f7..e9108671161 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -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);
 }
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h
index 9a7bfcd7bfe..8f69a9d4e25 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch.h
@@ -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: */
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index 5b514e90973..16378e77067 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -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



More information about the mesa-commit mailing list