Mesa (main): zink: add a param to check_batch_completion for toggling lock-taking
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 22 00:31:33 UTC 2021
Module: Mesa
Branch: main
Commit: 0dc77c8aa537fbea4ebfc2ceb49a4df6843901cd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0dc77c8aa537fbea4ebfc2ceb49a4df6843901cd
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Jun 9 14:12:13 2021 -0400
zink: add a param to check_batch_completion for toggling lock-taking
need this to avoid deadlocks
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11965>
---
src/gallium/drivers/zink/zink_batch.c | 2 +-
src/gallium/drivers/zink/zink_context.c | 11 +++++++----
src/gallium/drivers/zink/zink_context.h | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index 8743228d1e2..0762481e286 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -691,7 +691,7 @@ zink_batch_usage_check_completion(struct zink_context *ctx, const struct zink_ba
return true;
if (zink_batch_usage_is_unflushed(u))
return false;
- return zink_check_batch_completion(ctx, u->usage);
+ return zink_check_batch_completion(ctx, u->usage, false);
}
void
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 79318c7eb18..92163bc21ee 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2631,7 +2631,7 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
}
bool
-zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id, bool have_lock)
{
assert(ctx->batch.state);
if (!batch_id)
@@ -2649,7 +2649,8 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
}
struct zink_fence *fence;
- simple_mtx_lock(&ctx->batch_mtx);
+ if (!have_lock)
+ simple_mtx_lock(&ctx->batch_mtx);
if (ctx->last_fence && batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id)
fence = ctx->last_fence;
@@ -2657,13 +2658,15 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&ctx->batch_states, batch_id, (void*)(uintptr_t)batch_id);
/* if we can't find it, it either must have finished already or is on a different context */
if (!he) {
- simple_mtx_unlock(&ctx->batch_mtx);
+ if (!have_lock)
+ simple_mtx_unlock(&ctx->batch_mtx);
/* return compare against last_finished, since this has info from all contexts */
return zink_screen_check_last_finished(zink_screen(ctx->base.screen), batch_id);
}
fence = he->data;
}
- simple_mtx_unlock(&ctx->batch_mtx);
+ if (!have_lock)
+ simple_mtx_unlock(&ctx->batch_mtx);
assert(fence);
if (zink_screen(ctx->base.screen)->threaded &&
!util_queue_fence_is_signalled(&zink_batch_state(fence)->flush_completed))
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index d54a61b4fcf..d4e0859202a 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -328,7 +328,7 @@ void
zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id);
bool
-zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id);
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id, bool have_lock);
void
zink_flush_queue(struct zink_context *ctx);
More information about the mesa-commit
mailing list