Mesa (main): Revert "mesa: use simple_mtx_t for TexMutex"

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 7 23:01:46 UTC 2021


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Oct  7 15:01:30 2021 -0500

Revert "mesa: use simple_mtx_t for TexMutex"

This reverts the following commit from main:

    commit f6abb3445b7f244c0243f03bd7cf1e7ad1e2f1ab
    Author: Marek Olšák <maraeo at gmail.com>
    Date:   Fri Oct 1 15:46:48 2021 -0400

        mesa: use simple_mtx_t for TexMutex

        change mtx_recursive -> mtx_plain, there's no recursive locking

        Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
        Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
        Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
        Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13152>

Contrary to the claim in the commit message, there is recursive locking.
The meta stuff used by i965 does GL operations while the texture is
locked.  If we don't allow recursive locks, it will deadlock.  No, it's
not great, but it's the current state of affairs.  Once we delete i965
in favor of crocus and any other users of meta, we can restore the above
patch.  Until then, we need mtx_recursive.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13254>

---

 src/mesa/main/glthread.c | 4 ++--
 src/mesa/main/mtypes.h   | 2 +-
 src/mesa/main/shared.c   | 4 ++--
 src/mesa/main/texobj.c   | 4 ++--
 src/mesa/main/texobj.h   | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 49c3502620e..47353d5dd28 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -55,7 +55,7 @@ glthread_unmarshal_batch(void *job, void *gdata, int thread_index)
 
    _mesa_HashLockMutex(ctx->Shared->BufferObjects);
    ctx->BufferObjectsLocked = true;
-   simple_mtx_lock(&ctx->Shared->TexMutex);
+   mtx_lock(&ctx->Shared->TexMutex);
    ctx->TexturesLocked = true;
 
    while (pos < used) {
@@ -66,7 +66,7 @@ glthread_unmarshal_batch(void *job, void *gdata, int thread_index)
    }
 
    ctx->TexturesLocked = false;
-   simple_mtx_unlock(&ctx->Shared->TexMutex);
+   mtx_unlock(&ctx->Shared->TexMutex);
    ctx->BufferObjectsLocked = false;
    _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f00f58a80f1..ca349f4bb47 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3387,7 +3387,7 @@ struct gl_shared_state
     * \todo Improve the granularity of locking.
     */
    /*@{*/
-   simple_mtx_t TexMutex;		/**< texobj thread safety */
+   mtx_t TexMutex;		/**< texobj thread safety */
    GLuint TextureStateStamp;	        /**< state notification for shared tex */
    /*@}*/
 
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 0f7256b053f..9c6d2432370 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -128,7 +128,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
    assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1);
 
    /* Mutex and timestamp for texobj state validation */
-   simple_mtx_init(&shared->TexMutex, mtx_plain);
+   mtx_init(&shared->TexMutex, mtx_recursive);
    shared->TextureStateStamp = 0;
 
    shared->FrameBuffers = _mesa_NewHashTable();
@@ -459,7 +459,7 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
    }
 
    simple_mtx_destroy(&shared->Mutex);
-   simple_mtx_destroy(&shared->TexMutex);
+   mtx_destroy(&shared->TexMutex);
 
    free(shared);
 }
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 10285086827..ff594b04790 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -2161,7 +2161,7 @@ void
 _mesa_lock_context_textures( struct gl_context *ctx )
 {
    if (!ctx->TexturesLocked)
-      simple_mtx_lock(&ctx->Shared->TexMutex);
+      mtx_lock(&ctx->Shared->TexMutex);
 
    if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) {
       ctx->NewState |= _NEW_TEXTURE_OBJECT;
@@ -2176,7 +2176,7 @@ _mesa_unlock_context_textures( struct gl_context *ctx )
 {
    assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp);
    if (!ctx->TexturesLocked)
-      simple_mtx_unlock(&ctx->Shared->TexMutex);
+      mtx_unlock(&ctx->Shared->TexMutex);
 }
 
 
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index c933390af45..22e98d9684e 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -103,7 +103,7 @@ static inline void
 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
 {
    if (!ctx->TexturesLocked)
-      simple_mtx_lock(&ctx->Shared->TexMutex);
+      mtx_lock(&ctx->Shared->TexMutex);
    ctx->Shared->TextureStateStamp++;
    (void) texObj;
 }
@@ -113,7 +113,7 @@ _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
 {
    (void) texObj;
    if (!ctx->TexturesLocked)
-      simple_mtx_unlock(&ctx->Shared->TexMutex);
+      mtx_unlock(&ctx->Shared->TexMutex);
 }
 
 



More information about the mesa-commit mailing list