From 81ef38f4843ba9d3d435af761ff576f57efce62e Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 6 Sep 2022 23:02:41 +0800 Subject: [PATCH] gallium/auxiliary: Remove the need of _MTX_INITIALIZER_NP by using simple_mtx_t/SIMPLE_MTX_INITIALIZER Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/gallium/auxiliary/driver_trace/tr_dump.c | 27 ++++++++++---------- src/gallium/auxiliary/util/u_debug_flush.c | 11 ++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/driver_trace/tr_dump.c b/src/gallium/auxiliary/driver_trace/tr_dump.c index 22630485e45..7ef9af34cb5 100644 --- a/src/gallium/auxiliary/driver_trace/tr_dump.c +++ b/src/gallium/auxiliary/driver_trace/tr_dump.c @@ -51,6 +51,7 @@ #include "pipe/p_compiler.h" #include "os/os_thread.h" #include "util/os_time.h" +#include "util/simple_mtx.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_string.h" @@ -65,7 +66,7 @@ static bool close_stream = false; static FILE *stream = NULL; -static mtx_t call_mutex = _MTX_INITIALIZER_NP; +static simple_mtx_t call_mutex = SIMPLE_MTX_INITIALIZER; static long unsigned call_no = 0; static bool dumping = false; static long nir_count = 0; @@ -85,7 +86,7 @@ trace_dump_check_trigger(void) if (!trigger_filename) return; - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); if (trigger_active) { trigger_active = false; } else { @@ -98,7 +99,7 @@ trace_dump_check_trigger(void) } } } - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); } bool @@ -304,12 +305,12 @@ bool trace_dump_trace_enabled(void) void trace_dump_call_lock(void) { - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); } void trace_dump_call_unlock(void) { - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); } /* @@ -333,24 +334,24 @@ bool trace_dumping_enabled_locked(void) void trace_dumping_start(void) { - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); trace_dumping_start_locked(); - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); } void trace_dumping_stop(void) { - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); trace_dumping_stop_locked(); - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); } bool trace_dumping_enabled(void) { bool ret; - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); ret = trace_dumping_enabled_locked(); - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); return ret; } @@ -397,14 +398,14 @@ void trace_dump_call_end_locked(void) void trace_dump_call_begin(const char *klass, const char *method) { - mtx_lock(&call_mutex); + simple_mtx_lock(&call_mutex); trace_dump_call_begin_locked(klass, method); } void trace_dump_call_end(void) { trace_dump_call_end_locked(); - mtx_unlock(&call_mutex); + simple_mtx_unlock(&call_mutex); } void trace_dump_arg_begin(const char *name) diff --git a/src/gallium/auxiliary/util/u_debug_flush.c b/src/gallium/auxiliary/util/u_debug_flush.c index 591698b50e0..55e6d7aa9b8 100644 --- a/src/gallium/auxiliary/util/u_debug_flush.c +++ b/src/gallium/auxiliary/util/u_debug_flush.c @@ -39,6 +39,7 @@ #ifdef DEBUG #include "pipe/p_compiler.h" +#include "util/simple_mtx.h" #include "util/u_debug_stack.h" #include "util/u_debug.h" #include "util/u_memory.h" @@ -86,7 +87,7 @@ struct debug_flush_ctx { struct list_head head; }; -static mtx_t list_mutex = _MTX_INITIALIZER_NP; +static simple_mtx_t list_mutex = SIMPLE_MTX_INITIALIZER; static struct list_head ctx_list = {&ctx_list, &ctx_list}; static struct debug_stack_frame * @@ -165,9 +166,9 @@ debug_flush_ctx_create(UNUSED boolean catch_reference_of_mapped, goto out_no_ref_hash; fctx->bt_depth = bt_depth; - mtx_lock(&list_mutex); + simple_mtx_lock(&list_mutex); list_addtail(&fctx->head, &ctx_list); - mtx_unlock(&list_mutex); + simple_mtx_unlock(&list_mutex); return fctx; @@ -247,7 +248,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags) if (!persistent) { struct debug_flush_ctx *fctx; - mtx_lock(&list_mutex); + simple_mtx_lock(&list_mutex); LIST_FOR_EACH_ENTRY(fctx, &ctx_list, head) { struct debug_flush_item *item = util_hash_table_get(fctx->ref_hash, fbuf); @@ -259,7 +260,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags) FALSE, FALSE, item->ref_frame); } } - mtx_unlock(&list_mutex); + simple_mtx_unlock(&list_mutex); } }