Mesa (main): panfrost: Take a ctx when submitting/destroying

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 24 20:37:27 UTC 2021


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Aug 17 17:22:42 2021 +0000

panfrost: Take a ctx when submitting/destroying

This reduces the number of batch->ctx shenanigans we do, and in turn
should reduce raciness.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12366>

---

 src/gallium/drivers/panfrost/pan_job.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 049ff9fb98a..72e2f0c9348 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -103,9 +103,8 @@ panfrost_batch_init(struct panfrost_context *ctx,
 }
 
 static void
-panfrost_batch_cleanup(struct panfrost_batch *batch)
+panfrost_batch_cleanup(struct panfrost_context *ctx, struct panfrost_batch *batch)
 {
-        struct panfrost_context *ctx = batch->ctx;
         struct panfrost_device *dev = pan_device(ctx->base.screen);
 
         assert(batch->seqnum);
@@ -151,7 +150,8 @@ panfrost_batch_cleanup(struct panfrost_batch *batch)
 }
 
 static void
-panfrost_batch_submit(struct panfrost_batch *batch,
+panfrost_batch_submit(struct panfrost_context *ctx,
+                      struct panfrost_batch *batch,
                       uint32_t in_sync, uint32_t out_sync);
 
 static struct panfrost_batch *
@@ -178,7 +178,7 @@ panfrost_get_batch(struct panfrost_context *ctx,
 
         /* The selected slot is used, we need to flush the batch */
         if (batch->seqnum)
-                panfrost_batch_submit(batch, 0, 0);
+                panfrost_batch_submit(ctx, batch, 0, 0);
 
         panfrost_batch_init(ctx, key, batch);
 
@@ -226,7 +226,7 @@ panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx, const char *reaso
 
         if (batch->scoreboard.first_job) {
                 perf_debug_ctx(ctx, "Flushing the current FBO due to: %s", reason);
-                panfrost_batch_submit(batch, 0, 0);
+                panfrost_batch_submit(ctx, batch, 0, 0);
                 batch = panfrost_get_batch(ctx, &ctx->pipe_framebuffer);
         }
 
@@ -266,7 +266,7 @@ panfrost_batch_update_access(struct panfrost_batch *batch,
 
                         /* Submit if it's a user */
                         if (_mesa_set_search(batch->resources, rsrc))
-                                panfrost_batch_submit(batch, 0, 0);
+                                panfrost_batch_submit(ctx, batch, 0, 0);
                 }
         }
 
@@ -773,10 +773,11 @@ panfrost_emit_tile_map(struct panfrost_batch *batch, struct pan_fb_info *fb)
 }
 
 static void
-panfrost_batch_submit(struct panfrost_batch *batch,
+panfrost_batch_submit(struct panfrost_context *ctx,
+                      struct panfrost_batch *batch,
                       uint32_t in_sync, uint32_t out_sync)
 {
-        struct pipe_screen *pscreen = batch->ctx->base.screen;
+        struct pipe_screen *pscreen = ctx->base.screen;
         struct panfrost_screen *screen = pan_screen(pscreen);
         struct panfrost_device *dev = pan_device(pscreen);
         int ret;
@@ -827,13 +828,13 @@ panfrost_batch_submit(struct panfrost_batch *batch,
                 if (!batch->key.cbufs[i])
                         continue;
 
-                panfrost_resource_set_damage_region(batch->ctx->base.screen,
+                panfrost_resource_set_damage_region(ctx->base.screen,
                                                     batch->key.cbufs[i]->texture,
                                                     0, NULL);
         }
 
 out:
-        panfrost_batch_cleanup(batch);
+        panfrost_batch_cleanup(ctx, batch);
 }
 
 /* Submit all batches, applying the out_sync to the currently bound batch */
@@ -842,14 +843,14 @@ void
 panfrost_flush_all_batches(struct panfrost_context *ctx, const char *reason)
 {
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-        panfrost_batch_submit(batch, ctx->syncobj, ctx->syncobj);
+        panfrost_batch_submit(ctx, batch, ctx->syncobj, ctx->syncobj);
 
         for (unsigned i = 0; i < PAN_MAX_BATCHES; i++) {
                 if (ctx->batches.slots[i].seqnum) {
                         if (reason)
                                 perf_debug_ctx(ctx, "Flushing everything due to: %s", reason);
 
-                        panfrost_batch_submit(&ctx->batches.slots[i],
+                        panfrost_batch_submit(ctx, &ctx->batches.slots[i],
                                               ctx->syncobj, ctx->syncobj);
                 }
         }
@@ -864,7 +865,7 @@ panfrost_flush_writer(struct panfrost_context *ctx,
 
         if (entry) {
                 perf_debug_ctx(ctx, "Flushing writer due to: %s", reason);
-                panfrost_batch_submit(entry->data, ctx->syncobj, ctx->syncobj);
+                panfrost_batch_submit(ctx, entry->data, ctx->syncobj, ctx->syncobj);
         }
 }
 
@@ -881,7 +882,7 @@ panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
                         continue;
 
                 perf_debug_ctx(ctx, "Flushing user due to: %s", reason);
-                panfrost_batch_submit(batch, ctx->syncobj, ctx->syncobj);
+                panfrost_batch_submit(ctx, batch, ctx->syncobj, ctx->syncobj);
         }
 }
 



More information about the mesa-commit mailing list