Mesa (main): Revert "freedreno: Remove the submit lock locking."
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 4 21:10:40 UTC 2021
Module: Mesa
Branch: main
Commit: 398a731af9fdeec0d64e50a15cbe5474ab3329c7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=398a731af9fdeec0d64e50a15cbe5474ab3329c7
Author: Rob Clark <robdclark at chromium.org>
Date: Sat Oct 2 11:16:17 2021 -0700
Revert "freedreno: Remove the submit lock locking."
This reverts commit 22486ffa5172dd0425479ce64785b0f29bf59cdf.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13159>
---
src/gallium/drivers/freedreno/freedreno_batch.c | 4 ++++
src/gallium/drivers/freedreno/freedreno_batch.h | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index f8ada703900..dc1a850dc2b 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -135,6 +135,8 @@ fd_batch_create(struct fd_context *ctx, bool nondraw)
batch->ctx = ctx;
batch->nondraw = nondraw;
+ simple_mtx_init(&batch->submit_lock, mtx_plain);
+
batch->resources =
_mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
batch->dependents =
@@ -319,6 +321,8 @@ __fd_batch_destroy(struct fd_batch *batch)
batch_fini(batch);
+ simple_mtx_destroy(&batch->submit_lock);
+
free(batch);
}
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h
index c74e5e862f2..c6edab46ef1 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch.h
@@ -65,6 +65,11 @@ struct fd_batch {
struct fd_context *ctx;
+ /* emit_lock serializes cmdstream emission and flush. Acquire before
+ * screen->lock.
+ */
+ simple_mtx_t submit_lock;
+
/* do we need to mem2gmem before rendering. We don't, if for example,
* there was a glClear() that invalidated the entire previous buffer
* contents. Keep track of which buffer(s) are cleared, or needs
@@ -302,6 +307,7 @@ fd_batch_reference(struct fd_batch **ptr, struct fd_batch *batch)
static inline void
fd_batch_unlock_submit(struct fd_batch *batch)
{
+ simple_mtx_unlock(&batch->submit_lock);
}
/**
@@ -311,7 +317,11 @@ fd_batch_unlock_submit(struct fd_batch *batch)
static inline bool MUST_CHECK
fd_batch_lock_submit(struct fd_batch *batch)
{
- return !batch->flushed;
+ simple_mtx_lock(&batch->submit_lock);
+ bool ret = !batch->flushed;
+ if (!ret)
+ fd_batch_unlock_submit(batch);
+ return ret;
}
/**
More information about the mesa-commit
mailing list