diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c index 7cbe48ffdc0..92d6fbed38a 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c @@ -114,11 +114,10 @@ time_elapsed_enable(struct fd_context *ctx, * just hard coded. If we start exposing more countables than we * have counters, we will need to be more clever. */ - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); fd_wfi(batch, ring); OUT_PKT0(ring, REG_A4XX_CP_PERFCTR_CP_SEL_0, 1); OUT_RING(ring, CP_ALWAYS_COUNT); - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 1e115c7d2f7..281b1fd9967 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -887,8 +887,7 @@ fd6_clear_texture(struct pipe_context *pctx, struct pipe_resource *prsc, fd_batch_resource_write(batch, rsc); fd_screen_unlock(ctx->screen); - ASSERTED bool ret = fd_batch_lock_submit(batch); - assert(ret); + assert(!batch->flushed); /* Marking the batch as needing flush must come after the batch * dependency tracking (resource_read()/resource_write()), as that @@ -920,8 +919,6 @@ fd6_clear_texture(struct pipe_context *pctx, struct pipe_resource *prsc, fd_wfi(batch, batch->draw); fd6_cache_inv(batch, batch->draw); - fd_batch_unlock_submit(batch); - fd_batch_flush(batch); fd_batch_reference(&batch, NULL); @@ -1034,8 +1031,7 @@ handle_rgba_blit(struct fd_context *ctx, fd_screen_unlock(ctx->screen); - ASSERTED bool ret = fd_batch_lock_submit(batch); - assert(ret); + assert(!batch->flushed); /* Marking the batch as needing flush must come after the batch * dependency tracking (resource_read()/resource_write()), as that @@ -1072,8 +1068,6 @@ handle_rgba_blit(struct fd_context *ctx, fd_wfi(batch, batch->draw); fd6_cache_inv(batch, batch->draw); - fd_batch_unlock_submit(batch); - fd_batch_flush(batch); fd_batch_reference(&batch, NULL); diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index 28b7f0114ba..324208781eb 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -134,8 +134,6 @@ 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); @@ -313,8 +311,6 @@ __fd_batch_destroy_locked(struct fd_batch *batch) util_copy_framebuffer_state(&batch->framebuffer, NULL); batch_fini(batch); - simple_mtx_destroy(&batch->submit_lock); - free(batch->key); free(batch); fd_screen_lock(ctx->screen); @@ -350,7 +346,7 @@ batch_flush(struct fd_batch *batch) assert_dt { DBG("%p: needs_flush=%d", batch, batch->needs_flush); - if (!fd_batch_lock_submit(batch)) + if (batch->flushed) return; batch->needs_flush = false; @@ -388,7 +384,6 @@ batch_flush(struct fd_batch *batch) assert_dt assert(batch->reference.count > 0); cleanup_submit(batch); - fd_batch_unlock_submit(batch); } /* NOTE: could drop the last ref to batch diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index ecb4833b7aa..57e24cb3453 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -64,11 +64,6 @@ 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 @@ -333,26 +328,6 @@ fd_batch_reference(struct fd_batch **ptr, struct fd_batch *batch) *ptr = batch; } -static inline void -fd_batch_unlock_submit(struct fd_batch *batch) -{ - simple_mtx_unlock(&batch->submit_lock); -} - -/** - * Returns true if emit-lock was acquired, false if failed to acquire lock, - * ie. batch already flushed. - */ -static inline bool MUST_CHECK -fd_batch_lock_submit(struct fd_batch *batch) -{ - simple_mtx_lock(&batch->submit_lock); - bool ret = !batch->flushed; - if (!ret) - fd_batch_unlock_submit(batch); - return ret; -} - /** * Mark the batch as having something worth flushing (rendering, blit, query, * etc) diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 4bdbc88f24c..9354d73c1fc 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -229,7 +229,7 @@ fd_emit_string_marker(struct pipe_context *pctx, const char *string, if (!ctx->batch) return; - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); fd_batch_needs_flush(batch); @@ -239,7 +239,6 @@ fd_emit_string_marker(struct pipe_context *pctx, const char *string, fd_emit_string(batch->draw, string, len); } - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); } @@ -353,27 +352,6 @@ fd_context_batch(struct fd_context *ctx) return batch; } -/** - * Return a locked reference to the current batch. A batch with emit - * lock held is protected against flushing while the lock is held. - * The emit-lock should be acquired before screen-lock. The emit-lock - * should be held while emitting cmdstream. - */ -struct fd_batch * -fd_context_batch_locked(struct fd_context *ctx) -{ - struct fd_batch *batch = NULL; - - while (!batch) { - batch = fd_context_batch(ctx); - if (!fd_batch_lock_submit(batch)) { - fd_batch_reference(&batch, NULL); - } - } - - return batch; -} - /** * Return a reference to the current non-draw (compute/blit) batch. */ diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 8eb8f7b8322..67b8a6e8d17 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -353,7 +353,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, batch_draw_tracking(batch, info, indirect); - while (unlikely(!fd_batch_lock_submit(batch))) { + while (unlikely(batch->flushed)) { /* The current batch was flushed in batch_draw_tracking() * so start anew. We know this won't happen a second time * since we are dealing with a fresh batch: @@ -392,7 +392,6 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, assert(!batch->flushed); - fd_batch_unlock_submit(batch); fd_batch_check_size(batch); fd_batch_reference(&batch, NULL); @@ -480,7 +479,7 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, batch_clear_tracking(batch, buffers); - while (unlikely(!fd_batch_lock_submit(batch))) { + while (unlikely(batch->flushed)) { /* The current batch was flushed in batch_clear_tracking() * so start anew. We know this won't happen a second time * since we are dealing with a fresh batch: @@ -521,8 +520,6 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, assert(!batch->flushed); - fd_batch_unlock_submit(batch); - if (fallback) { fd_blitter_clear(pctx, buffers, color, depth, stencil); } diff --git a/src/gallium/drivers/freedreno/freedreno_query_acc.c b/src/gallium/drivers/freedreno/freedreno_query_acc.c index 181ff259fe6..e3f4c69f89f 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_acc.c +++ b/src/gallium/drivers/freedreno/freedreno_query_acc.c @@ -114,9 +114,8 @@ fd_acc_begin_query(struct fd_context *ctx, struct fd_query *q) assert_dt * need to just emit the capture at this moment. */ if (skip_begin_query(q->type)) { - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); fd_acc_query_resume(aq, batch); - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); } } @@ -134,7 +133,7 @@ fd_acc_end_query(struct fd_context *ctx, struct fd_query *q) assert_dt list_delinit(&aq->node); /* mark the result available: */ - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); struct fd_ringbuffer *ring = batch->draw; struct fd_resource *rsc = fd_resource(aq->prsc); @@ -150,7 +149,6 @@ fd_acc_end_query(struct fd_context *ctx, struct fd_query *q) assert_dt OUT_RING(ring, 0); /* high 32b */ } - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); } @@ -206,7 +204,7 @@ fd_acc_get_query_result_resource(struct fd_context *ctx, struct fd_query *q, { struct fd_acc_query *aq = fd_acc_query(q); const struct fd_acc_sample_provider *p = aq->provider; - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); assert(ctx->screen->gen >= 5); @@ -243,8 +241,6 @@ fd_acc_get_query_result_resource(struct fd_context *ctx, struct fd_query *q, p->result_resource(aq, ring, result_type, index, dst, offset); } - fd_batch_unlock_submit(batch); - /* If we are told to wait for results, then we need to flush. For an IMR * this would just be a wait on the GPU, but the expectation is that draws * following this one see the results of the query, which means we need to diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 982d803989b..d709c8f255f 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -137,7 +137,7 @@ fd_hw_destroy_query(struct fd_context *ctx, struct fd_query *q) static void fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q) assert_dt { - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); struct fd_hw_query *hq = fd_hw_query(q); DBG("%p", q); @@ -152,14 +152,13 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q) assert_dt assert(list_is_empty(&hq->list)); list_addtail(&hq->list, &ctx->hw_active_queries); - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); } static void fd_hw_end_query(struct fd_context *ctx, struct fd_query *q) assert_dt { - struct fd_batch *batch = fd_context_batch_locked(ctx); + struct fd_batch *batch = fd_context_batch(ctx); struct fd_hw_query *hq = fd_hw_query(q); DBG("%p", q); @@ -170,7 +169,6 @@ fd_hw_end_query(struct fd_context *ctx, struct fd_query *q) assert_dt /* remove from active list: */ list_delinit(&hq->list); - fd_batch_unlock_submit(batch); fd_batch_reference(&batch, NULL); }